import ctypes
from .enums import DlTargetTypeSelector

class TargetPresentationData(ctypes.Structure):
    _fields_ = [("raw", ctypes.c_uint16)]

    def get_dl_target_type_selector(self):
        return DlTargetTypeSelector((self.raw >> 13) & 0x03)

    def set_dl_target_type_selector(self, value):
        self.raw &= ~(0x03 << 13)
        self.raw |= (value << 13)

    def get_velocity_of_target(self):
        return (self.raw >> 11) & 0x03

    def set_velocity_of_target(self, value):
        self.raw &= ~(0x03 << 11)
        self.raw |= (value << 11)

    def get_altitude_of_target(self):
        return (self.raw >> 4) & 0x7F

    def set_altitude_of_target(self, value):
        self.raw &= ~(0x7F << 4)
        self.raw |= (value << 4)

    def get_intercept_zone_selector(self):
        return (self.raw >> 3) & 0x01

    def set_intercept_zone_selector(self, value):
        self.raw &= ~(0x01 << 3)
        self.raw |= (value << 3)

    def get_spare(self):
        return (self.raw >> 0) & 0x07

    def set_spare(self, value):
        self.raw &= ~(0x07 << 0)
        self.raw |= (value << 0)