import ctypes
import math

ICD1553_SEMICIRCLE_LSB = 3.05176E-05
GC_K_PI = math.pi
ICD1553_SEMICIRCLE_RAD_LSB = ICD1553_SEMICIRCLE_LSB * GC_K_PI

class Semicircle(ctypes.Union):
    _fields_ = [("raw", ctypes.c_int16),
                ("az_scan_centre", ctypes.c_int16),
                ("el_scan_centre", ctypes.c_int16),
                ("cursor_world_pos_azimuth", ctypes.c_int16),
                ("platform_azimuth", ctypes.c_int16),
                ("roll", ctypes.c_int16),
                ("pitch", ctypes.c_int16),
                ("az_antenna_demand", ctypes.c_int16),
                ("el_antenna_demand", ctypes.c_int16),
                ("wind_direction", ctypes.c_int16),
                ("true_heading", ctypes.c_int16),
                ("magnetic_heading", ctypes.c_int16),
                ]

    def get(self):
        return self.raw #* ICD1553_SEMICIRCLE_RAD_LSB

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