diff --git a/global_data.cpp b/global_data.cpp index 97dbb66..3cbade7 100644 --- a/global_data.cpp +++ b/global_data.cpp @@ -37,29 +37,28 @@ * Components: Thread 1 (startup, scope switching), Traffic Cop (Thread 2) * ============================================================ */ -/* radar_management[] is indexed by RADAR_* constants (1-4). - * Slot 0 is unused padding so current_radar works as a direct index. - * radar_type mirrors the array index for callers that receive a single - * struct by value. operatable is set to 1 once a radar is fully built. - * available and selected are set during startup argument parsing. */ +/* radar_management[] is indexed by RADAR_* constants (0-4). + * Slot 0 (RADAR_NONE) is the management/system entry. + * Its testing field holds the system-wide TESTING_* mode, initialized + * from TESTING_COMPONENT in settings.h — change that define and recompile. + * 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_NONE, 0, 0, 0 }, // [0] unused - { RADAR_CHAIN_HOME, 0, 0, 0 }, // [1] chain_home — not yet built - { RADAR_MARINE_ASCOPE, 0, 0, 0 }, // [2] marine_ascope — not yet built - { RADAR_MARINE_TRAFFIC, 0, 0, 0 }, // [3] marine_traffic — not yet built - { RADAR_POLICE_BOAT, 0, 0, 0 }, // [4] police_boat — not yet built + { RADAR_NONE, 0, 0, 0, TESTING_COMPONENT }, // [0] management — testing mode lives here + { RADAR_CHAIN_HOME, 0, 0, 0, TESTING_NONE }, // [1] chain_home — not yet built + { RADAR_MARINE_ASCOPE, 0, 0, 0, TESTING_NONE }, // [2] marine_ascope — not yet built + { RADAR_MARINE_TRAFFIC, 0, 0, 0, TESTING_NONE }, // [3] marine_traffic — 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. // Components: Thread 1, Traffic Cop (Thread 2), all scope renderers 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 * Components: all threads as noted per mutex diff --git a/include/data_structure_and_constants.h b/include/data_structure_and_constants.h index a419eb9..819d4ad 100644 --- a/include/data_structure_and_constants.h +++ b/include/data_structure_and_constants.h @@ -109,17 +109,19 @@ struct target_data_to_thread_1_structure { * ============================================================ */ /* Index constants for radar_management[] and current_radar. - * Array slot 0 (RADAR_NONE) is unused padding so current_radar - * can be used as a direct index into radar_management[]. */ -constexpr int RADAR_NONE = 0; + * Slot 0 (RADAR_NONE) is the management/system entry; its testing field + * holds the system-wide test mode. Radar entries are slots 1-4. */ +constexpr int RADAR_NONE = 0; // management/system entry constexpr int RADAR_CHAIN_HOME = 1; constexpr int RADAR_MARINE_ASCOPE = 2; constexpr int RADAR_MARINE_TRAFFIC = 3; 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. - * 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), * Traffic Cop (Thread 2, range filtering) */ 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 available; // 1 = enabled by exhibit operator at startup, 0 = disabled 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. -// radar_management[0] is unused padding. -// Components: Thread 1, Traffic Cop (Thread 2) +/* Array of radar states, indexed by RADAR_* constants. + * radar_management[0] is the management/system entry; its testing field + * 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]; // 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 extern int current_radar; -/* Component identifiers for testing_component. - * When testing_component is non-zero, only that component is active and +/* Component identifiers for radar_management[RADAR_NONE].testing. + * When that field is non-zero, only the named component is active and * no other radars can be made available. * Values 2-5 correspond to RADAR_* constants for the four radar types. * 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_RASPBERRY_PI = 8; // raspberry pi receiver (Thread 5) -// Active component under development; initialized from TESTING_COMPONENT in settings.h. -// Set to TESTING_NONE for normal exhibit operation. -// Components: Thread 1 (startup gating), all components -extern int testing_component; +/* radar_management[RADAR_NONE].testing is initialized from TESTING_COMPONENT in settings.h. + * Set TESTING_COMPONENT to TESTING_NONE for normal exhibit operation. + * Components: Thread 1 (startup gating), all components */ /* ============================================================ * THREAD MUTEXES diff --git a/include/settings.h b/include/settings.h index 2b7212a..c6f53ad 100644 --- a/include/settings.h +++ b/include/settings.h @@ -42,11 +42,12 @@ /* * Set to a TESTING_* constant to put the exhibit in single-component - * test mode. When non-zero, only the named component is active and - * no other radars can be made available. + * test mode. Stored in radar_management[RADAR_NONE].testing at startup. + * When non-zero, only the named component is active and no other radars + * can be made available. * * 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_MARINE_ASCOPE = 3 marine A-scope * TESTING_MARINE_TRAFFIC = 4 marine traffic control PPI @@ -54,6 +55,8 @@ * TESTING_TRAFFIC_COP = 6 traffic cop (Thread 2) * TESTING_SIMULATOR = 7 simulator (Thread 3) * 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