import ctypes

ICD1553_TWS_VEL_MAGNITUDE_FEET_LSB = 0.0625
GC_K_METERS_TO_FEETS = 3.28084
ICD1553_TWS_VEL_MAGNITUDE_METERS_LSB = (ICD1553_TWS_VEL_MAGNITUDE_FEET_LSB / GC_K_METERS_TO_FEETS)

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

    def get(self):
        return self.raw * ICD1553_TWS_VEL_MAGNITUDE_METERS_LSB

    def set(self, value):
        self.raw = int(value / ICD1553_TWS_VEL_MAGNITUDE_METERS_LSB)