import ctypes
from .enums import TrackPriority
import Grifo_E_1553lib.data_types.enum_map as em
em.ENUM_MAP.update({
    "track_priority_target_09" : TrackPriority,
    "track_priority_target_10" : TrackPriority,
})

class _TrackPriority0910Str(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
       
        ("spare", ctypes.c_uint16,8),
        ("track_priority_target_10", ctypes.c_uint16,4),
        ("track_priority_target_09", ctypes.c_uint16,4),
    ]
    
class TrackPriority0910(ctypes.Union):
    _fields_ = [
        ("raw", ctypes.c_uint16),
        ("str", _TrackPriority0910Str)
                ]

    def get_track_09_priority_field(self):
        return TrackPriority((self.raw >> 13) & 0x07)
    def set_track_09_priority_field(self, value):
        self.raw &= ~(0x07 << 13)
        self.raw |= (value << 13)


    def get_track_10_priority_field(self):
        return TrackPriority((self.raw >> 4) & 0x07)
    def set_track_10_priority_field(self, value):
        self.raw &= ~(0x07 << 4)
        self.raw |= (value << 4)

    def get_spare(self):
        return (self.raw >> 0) & 0x0F
    def set_spare(self, value):
        self.raw &= ~(0x0F << 0)
        self.raw |= (value << 0)