import ctypes
from .enums import CrsNormalSlaveSelector, CrsSnowploughCommand
import Grifo_E_1553lib.data_types.enum_map as em

em.ENUM_MAP.update({
    "cursor_normal_slave_selector_tellback" :CrsNormalSlaveSelector,
    "cursor_snowplough_command_tellback" :CrsSnowploughCommand
})
class CursorXDisplayCoordAndQual(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
        ("spare", ctypes.c_uint16, 3),
        ("reserved", ctypes.c_uint16, 1),
        ("cursor_snowplough_command_tellback", ctypes.c_uint16, 1),
        ("cursor_zero_tellback", ctypes.c_uint16, 1),
        ("cursor_normal_slave_selector_tellback", ctypes.c_uint16, 1),
        ("current_x_display_coord", ctypes.c_uint16, 9)
    ]
    
    
class CursorYDisplayCoord(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
        ("spare", ctypes.c_uint16, 7),
        ("current_y_display_coord", ctypes.c_uint16, 9)
    ]
    
class _CursorPositionLatitudeStr(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
        ("latitude_lsw", ctypes.c_uint16),
        ("latitude_msw", ctypes.c_int16)
    ]
    
class CursorPositionLatitude(ctypes.Union):
    _pack_ = 1
    _fields_ = [
        ("crs_latitude", ctypes.c_uint16),
        ("str", _CursorPositionLatitudeStr)
    ]
class _CursorPositionLongitudeStr(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
        ("longitude_lsw", ctypes.c_uint16),
        ("longitude_msw", ctypes.c_int16)
    ]
    
class CursorPositionLongitude(ctypes.Union):
    _pack_ = 1
    _fields_ = [
        ("crs_longitude", ctypes.c_uint16),
        ("str", _CursorPositionLongitudeStr)
    ]