# radar_data_readr/core/structures/base_structures.py

"""
Contains the truly fundamental base classes, type aliases, and constants
for all data structure definitions in the application. This module has no
dependencies on other structure modules in this package.
"""

import ctypes
from dataclasses import dataclass

# --- Ctypes Base and Type Aliases ---


class CtypesStructureBase(ctypes.Structure):
    """A base class for ctypes.Structure with compact memory layout."""
    _pack_ = 1

    


c_boolean = ctypes.c_uint32
c_radians_t = ctypes.c_float
c_metres_t = ctypes.c_float
c_metres_per_sec_t = ctypes.c_float
c_timetag_t = ctypes.c_int


# --- Base Block (Python-side Representation, not ctypes) ---


@dataclass
class BaseBlock:
    """Base class for any parsed block of data from the radar file."""

    block_name: str
    block_size_words: int


# --- Global Constants ---

BLOCK_TYPE_MAP = {
    # Legacy Blocks (marker 0x5A5A5A5A)
    1213223748: "DSPHDRIN",
    1431261764: "DSPHDROUT", # Usato come discriminatore
    5068115: "SUM",
    1380013383: "GUARD",
    5914948: "DAZ",
    4998468: "DEL",
    1181316173: "MTIFFT",
    892678468: "D1553",
    1397769283: "CDPSTS",
    1095976257: "AESA",
    1397773124: "DSPS",
    # ID primari per i blocchi di tracking. Il nome finale (STT/MTT)
    # viene deciso dal parser usando anche un discriminatore.
    1599362131: "STT",
    1599362125: "MTT",
    # Firmware Blocks (marker 0x7A7A7A7A)
    5265477: "EXP",
    17232: "PC",
    5522756: "DET",
    1413893971: "TIMER",
    1347635524: "SOFT",
    1162692948: "EXTLINK",
    1280463939: "CTRLINK",
    1280596037: "SOFTDFE",
}

LEGACY_BLOCK_MARKER = 0x5A5A5A5A
FW_BLOCK_MARKER = 0x7A7A7A7A
SIGNAL_DATA_MARKER = 1313304915