# -*- coding: utf-8 -*-
from pymsc.core.message_definitions import (
    msg_a1, msg_a2, msg_a3, msg_a4, msg_a5, msg_b6, msg_b7, msg_b9, msg_b10
)
from pymsc.utils.converters import (
    SEMICIRCLE_RAD_LSB, RAD_TO_DEG, TAS_MS_LSB, MS_TO_KNOTS,
    BARO_ALT_METERS_LSB, METERS_TO_FEET, CRS_SLAVE_RNG_METERS_LSB,
    GEOPOS_RAD_LSB, SPOI_ALT_METERS_LSB, WAYPOINT_LATLON_LSB,
    TIMETAG_MICROSECONDS_LSB, VELOCITY_METERS_LSB, ACCELERATION_METERS_LSB,
    RADIO_ALT_METERS_LSB, ATTITUDE_RATE_RAD_LSB, CAS_MS_LSB
)

# --- CHECKBOXES CONFIGURATION ---
CHECKBOXES = [
    {
        "command": "stand_by", "message": msg_a2, "field": "stby", "tooltip": "A2 stby",
        "message_tb": msg_b7, "field_tb": "stby_tellback", "tooltip_tb": "B7 stby_tb",
        "label": "Stand-By", "description": "toggle Stand-By status", "param": "0"
    },
    {
        "command": "silence", "message": msg_a2, "field": "silence", "tooltip": "A2 silence",
        "message_tb": msg_b7, "field_tb": "rf_status", "tooltip_tb": "B7 rf_status",
        "label": "Silence", "description": "toggle Silence status", "param": "0"
    },
    {
        "command": "freeze", "message": msg_a2, "field": "freeze", "tooltip": "A2 freeze",
        "message_tb": msg_b7, "field_tb": "freeze_tellback", "tooltip_tb": "B7 freeze_tb",
        "label": "Freeze", "description": "toggle Freeze status", "param": "0"
    },
    {
        "command": "ibit", "message": msg_a2, "field": "IBIT", "tooltip": "A2 IBIT",
        "message_tb": msg_b7, "field_tb": "IBIT_TB", "tooltip_tb": "B7 IBIT_TB",
        "label": "IBIT", "description": "toggle IBIT status", "param": "0"
    },
    {
        "command": "sar_enabled", "message": None, "field": "SAR_ENABLED", "tooltip": "A4 SAR_ENABLED",
        "message_tb": None, "field_tb": "", "label": "SAR enabled", "description": "toggle SAR enabled [DISABLED - field not in 1553]", "param": "0"
    },
    {
        "command": "ghost_enabled", "message": None, "field": "NORM_GHOST_SELECTION", "tooltip": "A4 Ghost",
        "message_tb": None, "field_tb": "", "label": "Ghost enabled", "description": "toggle ghost enabled [DISABLED - field not in 1553]", "param": "0"
    },
    {
        "command": "dtt_enabled", "message": None, "field": "DTT_ENABLED", "tooltip": "A4 DTT",
        "message_tb": None, "field_tb": "", "label": "DTT enabled", "description": "toggle DTT enabled [DISABLED - field not in 1553]", "param": "0"
    },
    {
        "command": "ale_blanking", "message": msg_a1, "field": "ALE_BLANKING", "tooltip": "A1 ALE",
        "message_tb": None, "field_tb": "", "label": "ALE blanking", "description": "toggle ALE blanking", "param": "0"
    },
    {
        "command": "emergency", "message": None, "field": "emergency", "tooltip": "A2 emergency",
        "message_tb": None, "field_tb": "emergency_tellback", "tooltip_tb": "B7 emergency_tb",
        "label": "EMERGENCY", "description": "toggle EMERGENCY status [DISABLED - field not in 1553]", "param": "0"
    },
    {
        "command": "deg_perf", "message": None, "field": "", "message_tb": msg_b7,
        "field_tb": "DEGRADED_PERF_STATUS", "tooltip_tb": "B7 DEGRADED", "label": "Degraded perf.", "description": ""
    },
    {
        "command": "last_acquisition_fail", "message": None, "field": "", "message_tb": msg_b7,
        "field_tb": "LAST_ACQ_FAIL", "tooltip_tb": "B7 FAIL", "label": "Last acquisition fail", "description": ""
    },
    {
        "command": "transition", "message": None, "field": "", "message_tb": msg_b7,
        "field_tb": "TRANSITION", "tooltip_tb": "B7 TRANS", "label": "Transition", "description": ""
    }
]

# --- COMBOBOXES CONFIGURATION ---
COMBOBOXES = [
    {
        "command": "range_scale", "message": msg_a2, "field": "range_scale", "tooltip": "A2 range",
        "message_tb": msg_b7, "field_tb": "range_scale_tellback", "tooltip_tb": "B7 range_scale_tb",
        "label": "Range Scale", "description": "Select range scale",
        "values": ["NM80", "NM40", "NM20", "NM10"], "values_tb": ["NM80", "NM40", "NM20", "NM10"]
    },
    {
        "command": "velocity_scale", "message": msg_a2, "field": "velocity_scale", "tooltip": "A2 velocity",
        "message_tb": msg_b7, "field_tb": "velocity_scale_tellback", "tooltip_tb": "B7 velocity_tb",
        "label": "Velocity Scale", "description": "Select velocity scale",
        "values": ["KTS2400", "KTS1200"], "values_tb": ["KTS2400", "KTS1200"]
    },
    {
        "command": "scan_width", "message": msg_a2, "field": "scan_width", "tooltip": "A2 scan",
        "message_tb": msg_b7, "field_tb": "scan_width_tellback", "tooltip_tb": "B7 scan_tb",
        "label": "Scan Width", "description": "Select scan width",
        "values": ["W60", "W30", "W25", "W15"],
        "values_tb": ["W60", "W55", "W50", "W45", "W40", "W35", "W30", "W25", "W20", "W15", "W10", "W05", "W0", "W_NV13", "W_NV14", "W_NV15"]
    },
    {
        "command": "bars", "message": msg_a2, "field": "bars", "tooltip": "A2 bars",
        "message_tb": msg_b7, "field_tb": "bars_tellback", "tooltip_tb": "B7 bars_tb",
        "label": "Bars", "description": "Select bars",
        "values": ["_1BARS", "_2BARS", "_3BARS", "_4BARS"], "values_tb": ["_1BARS", "_2BARS", "_3BARS", "_4BARS"]
    },
    {
        "command": "mode", "message": msg_a2, "field": "rdr_mode_command", "tooltip": "A2 rdr_mode",
        "message_tb": msg_b7, "field_tb": "rdr_mode_tellback", "tooltip_tb": "B7 mode_tb",
        "label": "Mode", "description": "Select radar mode",
        "values": ["RWS", "VS", "ACM", "TWS", "MODE_4", "GM", "SEA_LOW", "SEA_HIGH", "GMTI", "BCN", "AGR", "TA", "WA", "TS", "MODE_14", "RDR_DLY"],
        "values_tb": ["RWS", "VS", "ACM", "TWS", "MODE_4", "GM", "SEA_LOW", "SEA_HIGH", "GMTI", "BCN", "AGR", "TA", "WA", "TS", "MODE_14", "RDR_DLY"]
    },
    {
        "command": "rws_submode", "message": msg_a2, "field": "rws_submode_command", "tooltip": "A2 rws",
        "message_tb": msg_b7, "field_tb": "rws_submode_tellback", "tooltip_tb": "B7 rws_tb",
        "label": "RWS submode", "description": "Select RWS submode",
        "values": ["NAM", "ASM"], "values_tb": ["NAM", "ASM"]
    },
    {
        "command": "acm_submode", "message": msg_a2, "field": "acm_submode_command", "tooltip": "A2 acm",
        "message_tb": msg_b7, "field_tb": "acm_submode_tellback", "tooltip_tb": "B7 acm_tb",
        "label": "ACM submode", "description": "Select ACM submode",
        "values": ["BORESIGHT", "NARROW", "HUD", "WIDE", "VERTICAL", "SLEWABLE", "ACM_NV_6", "ACM_NV_7"],
        "values_tb": ["BORESIGHT", "NARROW", "HUD", "WIDE", "VERTICAL", "SLEWABLE", "ACM_NV_6", "ACM_NV_7"]
    },
    {
        "command": "gm_submode", "message": msg_a2, "field": "gm_submode_command", "tooltip": "A2 gm",
        "message_tb": msg_b7, "field_tb": "gm_submode_tellback", "tooltip_tb": "B7 gm_tb",
        "label": "GM submode", "description": "Select GM submode",
        "values": ["RBM", "DBS"], "values_tb": ["RBM", "DBS"]
    },
    {
        "command": "des_ctrl", "message": msg_a2, "field": "des_ctrl", "tooltip": "A2 des",
        "message_tb": msg_b7, "field_tb": "lock_sts", "tooltip_tb": "B7 lock_sts",
        "label": "Designation", "description": "Select Designation",
        "values": ["LOCK_ON", "LOCK_DTT", "HPT_BUG", "REJECT", "LOCK_STT", "TRACK_LABEL", "EXEC_SAR", "NOT_VALID"],
        "values_tb": ["STT", "DTT", "SAM", "TWS_HPT", "AGR_LOCK", "ACQ", "SAR", "NOT_VALID"]
    },
    {
        "command": "sar", "message": msg_a2, "field": "SAR_ACQUISITION", "tooltip": "A2 SAR",
        "message_tb": msg_b7, "field_tb": "SAR_ACQUISITION_TB", "tooltip_tb": "B7 SAR_TB",
        "label": "SAR", "description": "Select SAR",
        "values": ["SAR_CURSOR", "SAR_SPOI"], "values_tb": ["SAR_CURSOR", "SAR_SPOI"]
    },
    {
        "command": "expand", "message": msg_a2, "field": "EXPAND", "tooltip": "A2 EXPAND",
        "message_tb": None, "field_tb": "", "label": "Expand", "description": "Select Expand",
        "values": ["NORMAL", "EXPAND", "EXP_NV2", "EXP_NV3"]
    },
    {
        "command": "zoom", "message": msg_a2, "field": "ZOOM_COMMAND", "tooltip": "A2 ZOOM",
        "message_tb": None, "field_tb": "", "label": "Zoom", "description": "Select Zoom",
        "values": ["ZOOM_NOT_ATIVE", "ZOOM_IN", "ZOOM_OUT", "ZOOM_SPARE"]
    },
    {
        "command": "sar_map_orientation", "message": msg_a2, "field": "SAR_MAP_ORIENTATION", "tooltip": "A2 SAR MAP",
        "message_tb": None, "field_tb": "", "label": "Sar map orient.", "description": "Select Sar map orientation",
        "values": ["SAR_AC_NOSE_REFERENCE", "SAR_SLANT_CROSS_RANGE", "NOT_USED_1", "NOT_USED_2"]
    },
    {
        "command": "ground_tgt_reject", "message": msg_a1, "field": "GND_TGT_REJ_RAD_VEL", "tooltip": "A1 GND REJ",
        "message_tb": None, "field_tb": "", "label": "Ground tgt reject", "description": "Select ground target reject",
        "values": ["LOW", "HIGH"]
    },
    {
        "command": "min_det_ground_tgt", "message": msg_a1, "field": "MIN_DET_GND_TGT_RAD_VEL", "tooltip": "A1 MIN DET",
        "message_tb": None, "field_tb": "", "label": "Min det. grnd tgt", "description": "Select min detection",
        "values": ["LOW", "HIGH"]
    },
    {
        "command": "power_up_stop", "message": msg_a2, "field": "PWR_UP_STOP_FUNCT_SEL", "tooltip": "A2 PWR UP STOP",
        "message_tb": None, "field_tb": "", "label": "Power-up stop", "description": "Select Power-up stop",
        "values": ["NORMAL", "STOP"]
    },
    {
        "command": "spot", "message": msg_a2, "field": "SPOT_FUNC_SEL", "tooltip": "A2 SPOT",
        "message_tb": None, "field_tb": "", "label": "Spot", "description": "Select Spot function",
        "values": ["NORMAL", "STOP"]
    },
    {
        "command": "alt_block", "message": msg_a1, "field": "alt_block", "tooltip": "A1 alt_block",
        "message_tb": msg_b6, "field_tb": "alt_block_tellback", "tooltip_tb": "B6 alt_block_tb",
        "label": "Alt Block", "description": "Select Alt Block",
        "values": ["BOTTOM", "TOP", "NORMAL"], "values_tb": ["BOTTOM", "TOP", "NORMAL"]
    },
    {
        "command": "frequency_agility", "message": msg_a1, "field": "FREQ_AGILITY", "tooltip": "A1 FREQ AG",
        "message_tb": msg_b6, "field_tb": "FREQ_AGILITY_TB", "tooltip_tb": "B6 FREQ AG TB",
        "label": "Freq. Agility", "description": "Select Frequency Agility",
        "values": ["FIXED", "RANDOM", "ADAPTICE", "SPARE"], "values_tb": ["FIXED", "RANDOM", "ADAPTICE", "SPARE"]
    },
    {
        "command": "freq_grouping_selection", "message": msg_a1, "field": "FREQ_GROUPING_SELECTION", "tooltip": "A1 FREQ GRP",
        "message_tb": msg_b6, "field_tb": "FREQ_GROUPING_SELECTION_TB", "tooltip_tb": "B6 FREQ GRP TB",
        "label": "Group. selection", "description": "Select Frequency Grouping Selection",
        "values": ["OPT_1", "OPT_2"], "values_tb": ["OPT_1", "OPT_2"]
    },
    {
        "command": "waveform", "message": msg_a1, "field": "WAVE_INTER_SEL", "tooltip": "A1 WAVE",
        "message_tb": msg_b6, "field_tb": "WAVE_INTER_SEL_TB", "tooltip_tb": "B6 WAVE TB",
        "label": "Waveform", "description": "Select Waveform",
        "values": ["SPARE", "INTER_1", "INTER_2", "INTER_3"], "values_tb": ["SPARE", "INTER_1", "INTER_2", "INTER_3"]
    },
    {
        "command": "lprf_threshold", "message": msg_a1, "field": "LPRF_THRESHOLD", "tooltip": "A1 LPRF",
        "message_tb": msg_b6, "field_tb": "LPRF_THRESHOLD_TB", "tooltip_tb": "B6 LPRF TB",
        "label": "LPRF Threshold", "description": "Select LPRF Threshold",
        "values": ["LOW", "HIGH"], "values_tb": ["LOW", "HIGH"]
    },
    {
        "command": "prf_lookup", "message": msg_a1, "field": "PRF_LOOKUP", "tooltip": "A1 PRF",
        "message_tb": msg_b6, "field_tb": "PRF_LOOKUP_TB", "tooltip_tb": "B6 PRF TB",
        "label": "PRF Lookup", "description": "Select PRF Lookup",
        "values": ["LPRF", "MPRF"], "values_tb": ["LPRF", "MPRF"]
    }
]

# --- SPINBOXES CONFIGURATION ---
SPINBOXES = [
    {
        "command": "tgt_history", "message": msg_a1, "field": "tgt_history", "tooltip": "A1 history",
        "message_tb": msg_b6, "field_tb": "tgt_history_tellback", "tooltip_tb": "B6 history_tb",
        "label": "Tgt History", "description": "Select target history",
        "min_value": 0, "max_value": 3, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "video_intensity", "message": msg_a1, "field": "video_intensity", "tooltip": "A1 intensity",
        "message_tb": msg_b6, "field_tb": "video_intensity_tellback", "tooltip_tb": "B6 intensity_tb",
        "label": "Video Intensity", "description": "Select Video Intensity",
        "min_value": 0, "max_value": 127, "increment": 1, "number_format": "integer", "default_value": 127
    },
    {
        "command": "if_gain", "message": None, "field": "if_gain", "tooltip": "A1 if_gain",
        "message_tb": None, "field_tb": "if_gain_tellback", "tooltip_tb": "B6 if_gain_tb",
        "label": "IF Gain [DISABLED]", "description": "Set IF Gain [DISABLED - field not in 1553]",
        "min_value": 0, "max_value": 127, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "mov_tgt_gain", "message": None, "field": "moving_target_gain", "tooltip": "A1 mov_tgt",
        "message_tb": None, "field_tb": "moving_target_gain_tellback", "tooltip_tb": "B6 mov_tgt_tb",
        "label": "Mov. Tgt gain [DISABLED]", "description": "Select moving target gain [DISABLED - field not in 1553]",
        "min_value": 0, "max_value": 127, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "beacon_delay", "message": msg_a1, "field": "beacon_delay", "tooltip": "A1 beacon_delay",
        "message_tb": msg_b6, "field_tb": "beacon_delay_tellback", "tooltip_tb": "B6 beacon_delay_tb",
        "label": "BCN Delay", "description": "Select Beacon Delay",
        "min_value": 0, "max_value": 127, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "beacon_code", "message": msg_a1, "field": "beacon_code", "tooltip": "A1 beacon_code",
        "message_tb": msg_b6, "field_tb": "beacon_code_tellback", "tooltip_tb": "B6 beacon_code_tb",
        "label": "BCN Code", "description": "Select Beacon Code",
        "min_value": 0, "max_value": 127, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "channel", "message": msg_a1, "field": "channel", "tooltip": "A1 channel",
        "message_tb": msg_b6, "field_tb": "CHANNEL_TB", "tooltip_tb": "B6 CHANNEL_TB",
        "label": "Channel", "description": "Select channel",
        "min_value": 0, "max_value": 30, "increment": 1, "number_format": "integer", "default_value": 0
    },
    {
        "command": "ptaz", "message": msg_a5, "field": "A5_ptaz", "tooltip": "A5_ptaz",
        "message_tb": None, "field_tb": "", "label": "Ptaz", "description": "Set Ptaz",
        "min_value": -180.0, "max_value": 180.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": SEMICIRCLE_RAD_LSB, "scale": RAD_TO_DEG
    },
    {
        "command": "speed", "message": msg_a4, "field": "a4_tas", "tooltip": "a4_tas",
        "message_tb": None, "field_tb": "", "label": "Speed (knots)", "description": "Set Speed",
        "min_value": -4096.0, "max_value": 4096.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": TAS_MS_LSB, "scale": MS_TO_KNOTS
    },
    {
        "command": "altitude", "message": msg_a4, "field": "a4_baro_altitude", "tooltip": "a4_baro_alt",
        "message_tb": None, "field_tb": "", "label": "Altitude (feets)", "description": "Set Altitude",
        "min_value": -131072.0, "max_value": 131068.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": BARO_ALT_METERS_LSB, "scale": METERS_TO_FEET
    },
    {
        "command": "pitch", "message": msg_a5, "field": "A5_pitch", "tooltip": "A5_pitch",
        "message_tb": None, "field_tb": "", "label": "Pitch", "description": "Set Pitch",
        "min_value": -180.0, "max_value": 180.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": SEMICIRCLE_RAD_LSB, "scale": RAD_TO_DEG
    },
    {
        "command": "roll", "message": msg_a5, "field": "A5_roll", "tooltip": "A5_roll",
        "message_tb": None, "field_tb": "", "label": "Roll", "description": "Set Roll",
        "min_value": -180.0, "max_value": 180.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": SEMICIRCLE_RAD_LSB, "scale": RAD_TO_DEG
    },
    {
        "command": "crs_az", "message": msg_a4, "field": "A4_crs_az", "tooltip": "A4_crs_az",
        "message_tb": None, "field_tb": "", "label": "Cursor Azimuth", "description": "Set Cursor Azimuth",
        "min_value": -180.0, "max_value": 180.0, "increment": 1.0, "number_format": "float",
        "default_value": 0.0, "lsb": SEMICIRCLE_RAD_LSB, "scale": RAD_TO_DEG
    },
    {
        "command": "crs_rng", "message": msg_a4, "field": "A4_crs_rng", "tooltip": "A4_crs_rng",
        "message_tb": None, "field_tb": "", "label": "Cursor Range", "description": "Set Cursor Range",
        "min_value": -262144, "max_value": 262136, "increment": 1, "number_format": "integer",
        "default_value": 0, "lsb": CRS_SLAVE_RNG_METERS_LSB, "scale": METERS_TO_FEET
    }
]

# --- LABELS CONFIGURATION ---
LABELS = [
    {
        "command": "crs_x/y", "message1": msg_b6, "field1": "crs_x_tellback", "tooltip1": "Cursor x",
        "message2": msg_b6, "field2": "crs_y_tellback", "tooltip2": "Cursor y", "message3": None, "field3": "",
        "label": "x/y (pixel)", "description": "Get Cursor Position in pixel"
    },
    {
        "command": "crs_range/azimuth", "message1": msg_b6, "field1": "CRS_RANGE_tellback", "tooltip1": "Cursor range",
        "lsb1": CRS_SLAVE_RNG_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_b6, "field2": "CRS_AZIMUTH_tellback", "tooltip2": "Cursor azimuth",
        "lsb2": SEMICIRCLE_RAD_LSB, "scale2": RAD_TO_DEG, "message3": None, "field3": "",
        "label": "Range(m)/Azimuth(deg)", "description": "Get Cursor Position in range/azimuth"
    },
    {
        "command": "crs_lat/lon", "message1": msg_b6, "field1": "CRS_LAT_tellback", "tooltip1": "Cursor LAT",
        "lsb1": GEOPOS_RAD_LSB, "scale1": RAD_TO_DEG,
        "message2": msg_b6, "field2": "CRS_LON_tellback", "tooltip2": "Cursor LON",
        "lsb2": GEOPOS_RAD_LSB, "scale2": RAD_TO_DEG, "message3": None, "field3": "",
        "label": "Lat/Lon", "description": "Get Cursor Position in Lat/Lon"
    }
]

# --- LIST CONTROLS CONFIGURATION ---
LIST_CONTROLS = [
    {
        "command": "antenna", "label": "Antenna slew/az/el", "description": "Set antenna param",
        "message1": msg_a4, "field1": "A4_ant_slew", "type1": "checkbox", "tooltip1": "A4_ant_slew",
        "message2": msg_a4, "field2": "A4_az_demand", "type2": "spinbox", "tooltip2": "A4_az_demand",
        "min_value2": 0.0, "max_value2": 180.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": SEMICIRCLE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_a4, "field3": "A4_el_demand", "type3": "spinbox", "tooltip3": "A4_el_demand",
        "min_value3": 0.0, "max_value3": 180.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": SEMICIRCLE_RAD_LSB, "scale3": RAD_TO_DEG
    },
    {
        "command": "cursor_rates", "label": "Cursor rates (inv.,x,y)", "description": "Set cursor rates",
        "message1": msg_a4, "field1": "A4_crs_rate_val", "type1": "checkbox", "tooltip1": "A4_crs_rate_val",
        "message2": msg_a4, "field2": "A4_crs_x", "type2": "spinbox", "tooltip2": "A4_crs_x",
        "min_value2": -32766, "max_value2": 32766, "increment2": 1, "number_format2": "integer",
        "message3": msg_a4, "field3": "A4_crs_y", "type3": "spinbox", "tooltip3": "A4_crs_y",
        "min_value3": -32766, "max_value3": 32766, "increment3": 1, "number_format3": "integer"
    },
    {
        "command": "cursor_slave", "label": "Cursor slave (inv,az,rng)", "description": "Set cursor slave",
        "message1": msg_a4, "field1": "A4_crs_slave", "type1": "checkbox", "tooltip1": "A4_crs_slave",
        "message2": msg_a4, "field2": "A4_crs_az", "type2": "spinbox", "tooltip2": "A4_crs_az",
        "min_value2": 0.0, "max_value2": 180.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": SEMICIRCLE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_a4, "field3": "A4_crs_rng", "type3": "spinbox", "tooltip3": "A4_crs_rng",
        "min_value3": 0.0, "max_value3": 180.0, "increment3": 1.0, "number_format3": "integer",
        "lsb3": CRS_SLAVE_RNG_METERS_LSB, "scale3": METERS_TO_FEET
    },
    {
        "command": "tas", "label": "TAS", "description": "Set TAS",
        "message1": msg_a4, "field1": "a4_tas", "type1": "spinbox", "tooltip1": "a4_tas",
        "min_value1": 0.125, "max_value1": 4096.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": TAS_MS_LSB, "scale1": MS_TO_KNOTS,
        "message2": msg_a4, "field2": "a4_tas_invalid", "type2": "checkbox", "label2": "invalid", "tooltip2": "a4_tas_invalid"
    },
    {
        "command": "cas", "label": "CAS", "description": "Set CAS",
        "message1": msg_a4, "field1": "a4_cas", "type1": "spinbox", "tooltip1": "a4_cas",
        "min_value1": 0.125, "max_value1": 4096.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": CAS_MS_LSB, "scale1": MS_TO_KNOTS,
        "message2": msg_a4, "field2": "a4_cas_invalid", "type2": "checkbox", "label2": "invalid", "tooltip2": "a4_cas_invalid"
    },
    {
        "command": "nav_data_invalid", "label": "Navigation data invalid", "description": "Set Nav Data Invalid",
        "message1": msg_a4, "field1": "NAVIGATION_DATA_INVALID", "type1": "checkbox", "tooltip1": "A4 NAV INV"
    },
    {
        "command": "vx/vy/vz", "label": "Vx/Vy/Vz", "description": "Set velocities",
        "message1": msg_a5, "field1": "A5_x_vel", "type1": "spinbox", "tooltip1": "A5_x_vel",
        "min_value1": -999.0, "max_value1": 999.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": VELOCITY_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a5, "field2": "A5_y_vel", "type2": "spinbox", "tooltip2": "A5_y_vel",
        "min_value2": -999.0, "max_value2": 999.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": VELOCITY_METERS_LSB, "scale2": METERS_TO_FEET,
        "message3": msg_a5, "field3": "A5_z_vel", "type3": "spinbox", "tooltip3": "A5_z_vel",
        "min_value3": -999.0, "max_value3": 999.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": VELOCITY_METERS_LSB, "scale3": METERS_TO_FEET
    },
    {
        "command": "accx/accy/accz", "label": "A/C Accelerations", "description": "Set Accelerations",
        "message1": msg_a4, "field1": "A4_x_acc", "type1": "spinbox", "tooltip1": "A4_x_acc",
        "min_value1": -1024.0, "max_value1": 1024.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": ACCELERATION_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a4, "field2": "A4_y_acc", "type2": "spinbox", "tooltip2": "A4_y_acc",
        "min_value2": -1024.0, "max_value2": 1024.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": ACCELERATION_METERS_LSB, "scale2": METERS_TO_FEET,
        "message3": msg_a4, "field3": "A4_z_acc", "type3": "spinbox", "tooltip3": "A4_z_acc",
        "min_value3": -1024.0, "max_value3": 1024.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": ACCELERATION_METERS_LSB, "scale3": METERS_TO_FEET
    },
    {
        "command": "nx/ny/nz", "label": "Acc. nx/ny/nz", "description": "Set Accel Factors",
        "message1": msg_a5, "field1": "a5_nx", "type1": "spinbox", "tooltip1": "a5_nx",
        "min_value1": 0.0, "max_value1": 312.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": ACCELERATION_METERS_LSB, "scale1": 1,
        "message2": msg_a5, "field2": "a5_ny", "type2": "spinbox", "tooltip2": "a5_ny",
        "min_value2": 0.0, "max_value2": 312.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": ACCELERATION_METERS_LSB, "scale2": 1,
        "message3": msg_a5, "field3": "a5_nz", "type3": "spinbox", "tooltip3": "a5_nz",
        "min_value3": 0.0, "max_value3": 312.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": ACCELERATION_METERS_LSB, "scale3": 1
    },
    {
        "command": "wind", "label": "Wind speed/dir", "description": "Set wind info",
        "message1": msg_a4, "field1": "A4_wind_speed", "type1": "spinbox", "tooltip1": "A4_wind_speed",
        "min_value1": -124.0, "max_value1": 125.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": VELOCITY_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a4, "field2": "A4_wind_direction", "type2": "spinbox", "tooltip2": "A4_wind_direction",
        "min_value2": 0.0, "max_value2": 180.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": SEMICIRCLE_RAD_LSB, "scale2": RAD_TO_DEG
    },
    {
        "command": "alt_corrected", "label": "Corrected", "description": "Set alt corrected",
        "message1": msg_a4, "field1": "a4_corrected_baro_altitude", "type1": "spinbox", "tooltip1": "a4_corrected",
        "min_value1": -131000.0, "max_value1": 131000.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": BARO_ALT_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a4, "field2": "a4_corrected_baro_altitude_invalid", "type2": "checkbox", "label2": "inv", "tooltip2": "inv"
    },
    {
        "command": "alt_barometric", "label": "Barometric", "description": "Set alt baro",
        "message1": msg_a4, "field1": "a4_baro_altitude", "type1": "spinbox", "tooltip1": "a4_baro",
        "min_value1": -131000.0, "max_value1": 131000.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": BARO_ALT_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a4, "field2": "a4_baro_altitude_invalid", "type2": "checkbox", "label2": "inv", "tooltip2": "inv"
    },
    {
        "command": "alt_radio", "label": "Radio Alt", "description": "Set radio altitude",
        "message1": msg_a4, "field1": "a4_radio_altimeter_altitude", "type1": "spinbox", "tooltip1": "a4_radio",
        "min_value1": -65000.0, "max_value1": 65000.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": RADIO_ALT_METERS_LSB, "scale1": METERS_TO_FEET,
        "message2": msg_a4, "field2": "a4_radio_altimeter_invalid", "type2": "checkbox", "label2": "inv", "tooltip2": "inv"
    },
    {
        "command": "attitude", "label": "Invalid", "description": "Set attitude invalid",
        "message1": msg_a4, "field1": "ATTITUDE_INVALID", "type1": "checkbox", "tooltip1": "A4 ATT INV"
    },
    {
        "command": "true_heading", "label": "True Heading", "description": "Set True Heading",
        "message1": msg_a4, "field1": "A4_true_heading", "type1": "spinbox", "tooltip1": "A4_true_heading",
        "min_value1": -180.0, "max_value1": 180.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": SEMICIRCLE_RAD_LSB, "scale1": RAD_TO_DEG
    },
    {
        "command": "magnetic_heading", "label": "Magnetic Heading", "description": "Set Mag Heading",
        "message1": msg_a4, "field1": "A4_magnetic_heading", "type1": "spinbox", "tooltip1": "A4_magnetic_heading",
        "min_value1": -180.0, "max_value1": 180.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": SEMICIRCLE_RAD_LSB, "scale1": RAD_TO_DEG
    },
    {
        "command": "platform_azimuth", "label": "Platform Azimuth", "description": "Set Plat Azimuth",
        "message1": msg_a5, "field1": "A5_ptaz", "type1": "spinbox", "tooltip1": "A5_ptaz",
        "min_value1": -180.0, "max_value1": 180.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": SEMICIRCLE_RAD_LSB, "scale1": RAD_TO_DEG
    },
    {
        "command": "yaw_snu", "label": "Yaw", "description": "Set yaw",
        "message1": msg_a5, "field1": "a5_nx", "type1": "space",
        "message2": msg_a5, "field2": "A5_rate_yaw", "type2": "spinbox", "tooltip2": "rate",
        "min_value2": -800.0, "max_value2": 800.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": ATTITUDE_RATE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_a5, "field3": "A5_angacc_yaw", "type3": "spinbox", "tooltip3": "accel",
        "min_value3": -12.0, "max_value3": 12.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": ATTITUDE_RATE_RAD_LSB, "scale3": 1
    },
    {
        "command": "pitch_snu", "label": "Pitch", "description": "Set pitch",
        "message1": msg_a5, "field1": "A5_pitch", "type1": "spinbox", "tooltip1": "pos",
        "min_value1": -180.0, "max_value1": 180.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": SEMICIRCLE_RAD_LSB, "scale1": RAD_TO_DEG,
        "message2": msg_a5, "field2": "A5_rate_pitch", "type2": "spinbox", "tooltip2": "rate",
        "min_value2": -720.0, "max_value2": 720.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": ATTITUDE_RATE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_a5, "field3": "A5_angacc_pitch", "type3": "spinbox", "tooltip3": "accel",
        "min_value3": -12.0, "max_value3": 12.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": ATTITUDE_RATE_RAD_LSB, "scale3": 1
    },
    {
        "command": "roll_snu", "label": "Roll", "description": "Set roll",
        "message1": msg_a5, "field1": "A5_roll", "type1": "spinbox", "tooltip1": "pos",
        "min_value1": -180.0, "max_value1": 180.0, "increment1": 1.0, "number_format1": "float",
        "lsb1": SEMICIRCLE_RAD_LSB, "scale1": RAD_TO_DEG,
        "message2": msg_a5, "field2": "A5_rate_roll", "type2": "spinbox", "tooltip2": "rate",
        "min_value2": -720.0, "max_value2": 720.0, "increment2": 1.0, "number_format2": "float",
        "lsb2": ATTITUDE_RATE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_a5, "field3": "A5_angacc_roll", "type3": "spinbox", "tooltip3": "accel",
        "min_value3": -12.0, "max_value3": 12.0, "increment3": 1.0, "number_format3": "float",
        "lsb3": ATTITUDE_RATE_RAD_LSB, "scale3": 1
    },
    {
        "command": "antenna_tb", "label": "Antenna az/el", "description": "Get Actual Pos",
        "message1": msg_b6, "field1": "CHANNEL_TB", "type1": "space",
        "message2": msg_b6, "field2": "az_centre_tellback", "type2": "label", "tooltip2": "az",
        "lsb2": SEMICIRCLE_RAD_LSB, "scale2": RAD_TO_DEG,
        "message3": msg_b6, "field3": "el_centre_tellback", "type3": "label", "tooltip3": "el",
        "lsb3": SEMICIRCLE_RAD_LSB, "scale3": RAD_TO_DEG
    },
    {
        "command": "a_c_lat_lon", "label": "A/C Lat/Lon", "description": "Set AC Pos",
        "message1": msg_a4, "field1": "PRESENT_POSITION_INVALID", "type1": "checkbox", "tooltip1": "inv",
        "message2": msg_a4, "field2": "A4_ppos_lat", "type2": "spinbox", "tooltip2": "lat",
        "lsb2": GEOPOS_RAD_LSB, "scale2": RAD_TO_DEG, "min_value2": -90.0, "max_value2": 90.0, "number_format2": "float",
        "message3": msg_a4, "field3": "A4_ppos_long", "type3": "spinbox", "tooltip3": "lon",
        "lsb3": GEOPOS_RAD_LSB, "scale3": RAD_TO_DEG, "min_value3": -180.0, "max_value3": 180.0, "number_format3": "float"
    },
    {
        "command": "spoi_lat_lot", "label": "SPOI Lat/Long", "description": "Set SPOI Pos",
        "message1": msg_a4, "field1": "A4_spoi_pos_invalid", "type1": "checkbox", "tooltip1": "inv",
        "message2": msg_a4, "field2": "A4_spoi_lat", "type2": "spinbox", "tooltip2": "lat",
        "lsb2": GEOPOS_RAD_LSB, "scale2": RAD_TO_DEG, "min_value2": -90.0, "max_value2": 90.0, "number_format2": "float",
        "message3": msg_a4, "field3": "A4_spoi_long", "type3": "spinbox", "tooltip3": "lon",
        "lsb3": GEOPOS_RAD_LSB, "scale3": RAD_TO_DEG, "min_value3": -180.0, "max_value3": 180.0, "number_format3": "float"
    },
    {
        "command": "spoi_altitude", "label": "SPOI Altitude", "description": "Set SPOI Alt",
        "message1": msg_a4, "field1": "A4_spoi_antitude_invalid", "type1": "checkbox", "tooltip1": "inv",
        "message2": msg_a4, "field2": "A4_spoi_baroalt", "type2": "spinbox", "tooltip2": "alt",
        "lsb2": SPOI_ALT_METERS_LSB, "scale2": METERS_TO_FEET, "min_value2": -32000, "max_value2": 32000, "number_format2": "float",
        "message3": None
    },
    {
        "command": "clearance_plane", "label": "Clearance Plane", "description": "Set Clearance Dist",
        "message1": msg_a4, "field1": "CLEARANCE_PLANE_DIST", "type1": "spinbox", "tooltip1": "dist",
        "min_value1": 0, "max_value1": 64000, "increment1": 1, "number_format1": "float"
    },
    {
        "command": "timetag_inu", "label": "INU", "description": "INU",
        "message1": msg_a5, "field1": "A5_Timetag", "type1": "label", "tooltip1": "Timetag",
        "lsb1": TIMETAG_MICROSECONDS_LSB
    },
    {
        "command": "timetag_ptaz", "label": "Pt Az", "description": "Pt Az",
        "message1": msg_a5, "field1": "A5_ptaz_timetag", "type1": "label", "tooltip1": "Timetag",
        "lsb1": TIMETAG_MICROSECONDS_LSB
    },
    {
        "command": "timetag_pitch", "label": "Pitch", "description": "Pitch",
        "message1": msg_a5, "field1": "A5_pitch_timetag", "type1": "label", "tooltip1": "Timetag",
        "lsb1": TIMETAG_MICROSECONDS_LSB
    },
    {
        "command": "timetag_roll", "label": "Roll", "description": "Roll",
        "message1": msg_a5, "field1": "A5_roll_timetag", "type1": "label", "tooltip1": "Timetag",
        "lsb1": TIMETAG_MICROSECONDS_LSB
    },
    {
        "command": "timetag_ppos", "label": "Position", "description": "Position",
        "message1": msg_a4, "field1": "A4_ppos_timetag", "type1": "label", "tooltip1": "Timetag",
        "lsb1": TIMETAG_MICROSECONDS_LSB
    },
    {
        "command": "crs_slave", "label": "Set cursor slave", "description": "toggle Cursor Slave",
        "message1": msg_a4, "field1": "A4_crs_slave", "type1": "checkbox", "tooltip1": "A4_crs_slave"
    },
    {
        "command": "crs_zero", "label": "Set cursor zero", "description": "toggle Cursor Zero",
        "message1": msg_a4, "field1": "A4_crs_zero", "type1": "checkbox", "tooltip1": "A4_crs_zero"
    },
    {
        "command": "crs_snowplough", "label": "Set cursor snowplough", "description": "toggle Cursor Snow",
        "message1": msg_a4, "field1": "A4_crs_snowplough", "type1": "checkbox", "tooltip1": "A4_crs_snowplough"
    }
]