adding globals and constants

This commit is contained in:
2026-06-15 10:42:45 -07:00
parent fe417fe743
commit d0616ac523
3 changed files with 40 additions and 33 deletions

View File

@@ -37,29 +37,28 @@
* Components: Thread 1 (startup, scope switching), Traffic Cop (Thread 2) * Components: Thread 1 (startup, scope switching), Traffic Cop (Thread 2)
* ============================================================ */ * ============================================================ */
/* radar_management[] is indexed by RADAR_* constants (1-4). /* radar_management[] is indexed by RADAR_* constants (0-4).
* Slot 0 is unused padding so current_radar works as a direct index. * Slot 0 (RADAR_NONE) is the management/system entry.
* radar_type mirrors the array index for callers that receive a single * Its testing field holds the system-wide TESTING_* mode, initialized
* struct by value. operatable is set to 1 once a radar is fully built. * from TESTING_COMPONENT in settings.h — change that define and recompile.
* available and selected are set during startup argument parsing. */ * When testing is non-zero, no other radars can be made available.
* Slots 1-4 are per-radar entries. operatable is set to 1 once a radar is
* fully built. available and selected are set during startup argument parsing.
* The testing field in slots 1-4 mirrors slot 0 for convenient access but
* slot 0 is authoritative.
* Components: Thread 1, Traffic Cop (Thread 2) */
radar_management_structure radar_management[RADAR_COUNT] = { radar_management_structure radar_management[RADAR_COUNT] = {
{ RADAR_NONE, 0, 0, 0 }, // [0] unused { RADAR_NONE, 0, 0, 0, TESTING_COMPONENT }, // [0] management — testing mode lives here
{ RADAR_CHAIN_HOME, 0, 0, 0 }, // [1] chain_home — not yet built { RADAR_CHAIN_HOME, 0, 0, 0, TESTING_NONE }, // [1] chain_home — not yet built
{ RADAR_MARINE_ASCOPE, 0, 0, 0 }, // [2] marine_ascope — not yet built { RADAR_MARINE_ASCOPE, 0, 0, 0, TESTING_NONE }, // [2] marine_ascope — not yet built
{ RADAR_MARINE_TRAFFIC, 0, 0, 0 }, // [3] marine_traffic — not yet built { RADAR_MARINE_TRAFFIC, 0, 0, 0, TESTING_NONE }, // [3] marine_traffic — not yet built
{ RADAR_POLICE_BOAT, 0, 0, 0 }, // [4] police_boat — not yet built { RADAR_POLICE_BOAT, 0, 0, 0, TESTING_NONE }, // [4] police_boat — not yet built
}; };
// No radar selected on startup; intro screen is displayed. // No radar selected on startup; intro screen is displayed.
// Components: Thread 1, Traffic Cop (Thread 2), all scope renderers // Components: Thread 1, Traffic Cop (Thread 2), all scope renderers
int current_radar = RADAR_NONE; int current_radar = RADAR_NONE;
// Component currently under development (TESTING_* constant).
// Initialized from TESTING_COMPONENT in settings.h; change that define and recompile.
// When non-zero, no other radars can be made available.
// Components: Thread 1 (startup gating), all components
int testing_component = TESTING_COMPONENT;
/* ============================================================ /* ============================================================
* THREAD MUTEXES * THREAD MUTEXES
* Components: all threads as noted per mutex * Components: all threads as noted per mutex

View File

@@ -109,17 +109,19 @@ struct target_data_to_thread_1_structure {
* ============================================================ */ * ============================================================ */
/* Index constants for radar_management[] and current_radar. /* Index constants for radar_management[] and current_radar.
* Array slot 0 (RADAR_NONE) is unused padding so current_radar * Slot 0 (RADAR_NONE) is the management/system entry; its testing field
* can be used as a direct index into radar_management[]. */ * holds the system-wide test mode. Radar entries are slots 1-4. */
constexpr int RADAR_NONE = 0; constexpr int RADAR_NONE = 0; // management/system entry
constexpr int RADAR_CHAIN_HOME = 1; constexpr int RADAR_CHAIN_HOME = 1;
constexpr int RADAR_MARINE_ASCOPE = 2; constexpr int RADAR_MARINE_ASCOPE = 2;
constexpr int RADAR_MARINE_TRAFFIC = 3; constexpr int RADAR_MARINE_TRAFFIC = 3;
constexpr int RADAR_POLICE_BOAT = 4; constexpr int RADAR_POLICE_BOAT = 4;
constexpr int RADAR_COUNT = 5; // valid indices: 1-4; 0 is unused constexpr int RADAR_COUNT = 5; // total slots: 0 (management) + 1-4 (radars)
/* Per-radar operational state. /* Per-radar operational state.
* Indexed by RADAR_* constants above; slot 0 is unused. * Indexed by RADAR_* constants above.
* Slot 0 (RADAR_NONE) is the management/system entry — its testing field
* holds the active TESTING_* mode for the entire exhibit.
* Components: Thread 1 (startup init, scope switching), * Components: Thread 1 (startup init, scope switching),
* Traffic Cop (Thread 2, range filtering) */ * Traffic Cop (Thread 2, range filtering) */
struct radar_management_structure { struct radar_management_structure {
@@ -127,11 +129,15 @@ struct radar_management_structure {
int operatable; // 1 = radar is built and fully functional, 0 = not yet built int operatable; // 1 = radar is built and fully functional, 0 = not yet built
int available; // 1 = enabled by exhibit operator at startup, 0 = disabled int available; // 1 = enabled by exhibit operator at startup, 0 = disabled
int selected; // 1 = currently active/displayed, 0 = not active int selected; // 1 = currently active/displayed, 0 = not active
int testing; // TESTING_* constant: component under development (TESTING_NONE = normal operation)
// Only radar_management[0].testing is meaningful — it is the system-wide test mode.
}; };
// Array of radar states, indexed by RADAR_* constants. /* Array of radar states, indexed by RADAR_* constants.
// radar_management[0] is unused padding. * radar_management[0] is the management/system entry; its testing field
// Components: Thread 1, Traffic Cop (Thread 2) * holds the system-wide TESTING_* mode (see below).
* Access the active testing mode via: radar_management[RADAR_NONE].testing
* Components: Thread 1, Traffic Cop (Thread 2) */
extern radar_management_structure radar_management[RADAR_COUNT]; extern radar_management_structure radar_management[RADAR_COUNT];
// Index of the currently active radar (RADAR_NONE through RADAR_POLICE_BOAT). // Index of the currently active radar (RADAR_NONE through RADAR_POLICE_BOAT).
@@ -139,8 +145,8 @@ extern radar_management_structure radar_management[RADAR_COUNT];
// Components: Thread 1, Traffic Cop (Thread 2), all scope renderers // Components: Thread 1, Traffic Cop (Thread 2), all scope renderers
extern int current_radar; extern int current_radar;
/* Component identifiers for testing_component. /* Component identifiers for radar_management[RADAR_NONE].testing.
* When testing_component is non-zero, only that component is active and * When that field is non-zero, only the named component is active and
* no other radars can be made available. * no other radars can be made available.
* Values 2-5 correspond to RADAR_* constants for the four radar types. * Values 2-5 correspond to RADAR_* constants for the four radar types.
* Components: Thread 1 (startup), all components that gate on test mode */ * Components: Thread 1 (startup), all components that gate on test mode */
@@ -154,10 +160,9 @@ constexpr int TESTING_TRAFFIC_COP = 6; // traffic cop (Thread 2)
constexpr int TESTING_SIMULATOR = 7; // simulator (Thread 3) constexpr int TESTING_SIMULATOR = 7; // simulator (Thread 3)
constexpr int TESTING_RASPBERRY_PI = 8; // raspberry pi receiver (Thread 5) constexpr int TESTING_RASPBERRY_PI = 8; // raspberry pi receiver (Thread 5)
// Active component under development; initialized from TESTING_COMPONENT in settings.h. /* radar_management[RADAR_NONE].testing is initialized from TESTING_COMPONENT in settings.h.
// Set to TESTING_NONE for normal exhibit operation. * Set TESTING_COMPONENT to TESTING_NONE for normal exhibit operation.
// Components: Thread 1 (startup gating), all components * Components: Thread 1 (startup gating), all components */
extern int testing_component;
/* ============================================================ /* ============================================================
* THREAD MUTEXES * THREAD MUTEXES

View File

@@ -42,11 +42,12 @@
/* /*
* Set to a TESTING_* constant to put the exhibit in single-component * Set to a TESTING_* constant to put the exhibit in single-component
* test mode. When non-zero, only the named component is active and * test mode. Stored in radar_management[RADAR_NONE].testing at startup.
* no other radars can be made available. * When non-zero, only the named component is active and no other radars
* can be made available.
* *
* TESTING_NONE = 0 normal exhibit operation * TESTING_NONE = 0 normal exhibit operation
* TESTING_MANAGEMENT = 1 setup and radar selection * TESTING_MANAGEMENT = 1 setup and radar selection (02_setup_and_radar_selection)
* TESTING_CHAIN_HOME = 2 chain home A-scope * TESTING_CHAIN_HOME = 2 chain home A-scope
* TESTING_MARINE_ASCOPE = 3 marine A-scope * TESTING_MARINE_ASCOPE = 3 marine A-scope
* TESTING_MARINE_TRAFFIC = 4 marine traffic control PPI * TESTING_MARINE_TRAFFIC = 4 marine traffic control PPI
@@ -54,6 +55,8 @@
* TESTING_TRAFFIC_COP = 6 traffic cop (Thread 2) * TESTING_TRAFFIC_COP = 6 traffic cop (Thread 2)
* TESTING_SIMULATOR = 7 simulator (Thread 3) * TESTING_SIMULATOR = 7 simulator (Thread 3)
* TESTING_RASPBERRY_PI = 8 raspberry pi receiver (Thread 5) * TESTING_RASPBERRY_PI = 8 raspberry pi receiver (Thread 5)
*
* Read the active mode at runtime via: radar_management[RADAR_NONE].testing
*/ */
#define TESTING_COMPONENT TESTING_NONE #define TESTING_COMPONENT TESTING_NONE