import ctypes
from Grifo_E_1553lib.data_types.enums import (RadarFailStatus, LRUFailStatus, OvertemperatureAlarm, BITReportAvailable)
import Grifo_E_1553lib.data_types.enum_map as em

em.ENUM_MAP.update({
    "radar_fail_status" :RadarFailStatus,
    "aesa_status" :LRUFailStatus,
    "rep_status" :LRUFailStatus,
    "pps_status" :LRUFailStatus,
    "lcu_status" :LRUFailStatus,
    "aesa_over_temperature_alarm" :OvertemperatureAlarm,
    "rep_over_temperature_alarm" :OvertemperatureAlarm,
    "pps_over_temperature_alarm" :OvertemperatureAlarm,
    "bit_report_available" :BITReportAvailable,
})

class _RdrHealthStatusAndBitReportStr(ctypes.LittleEndianStructure):
    _pack_ = 1
    _fields_ = [
        ("spare",ctypes.c_uint16,3),
        ("bit_report_available",ctypes.c_uint16,1),
        ("reserved4",ctypes.c_uint16,1),
        ("pps_over_temperature_alarm",ctypes.c_uint16,1),
        ("rep_over_temperature_alarm",ctypes.c_uint16,1),
        ("aesa_over_temperature_alarm",ctypes.c_uint16,1),
        ("reserved3",ctypes.c_uint16,1),
        ("reserved2",ctypes.c_uint16,1),
        ("reserved1",ctypes.c_uint16,1),
        ("lcu_status",ctypes.c_uint16,1),
        ("pps_status",ctypes.c_uint16,1),
        ("rep_status",ctypes.c_uint16,1),
        ("aesa_status",ctypes.c_uint16,1),
        ("radar_fail_status",ctypes.c_uint16,1)
    ]

class RdrHealthStatusAndBitReport(ctypes.Union):
    _fields_ = [
        ("raw", ctypes.c_uint16),
        ("str", _RdrHealthStatusAndBitReportStr)
    ]