/* * MIT License * * Copyright (c) 2026 Mark Allyn * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * global_data.cpp * Author: Mark Allyn * * Definitions of all system-wide global variables. * Extern declarations live in include/data_structure_and_constants.h. */ #include "include/data_structure_and_constants.h" /* ============================================================ * RADAR MANAGEMENT * 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_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 }; // 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 * ============================================================ */ // Thread 2 -> Thread 1: target data handoff // Components: Traffic Cop (Thread 2), Thread 1 std::mutex mutex_target_data; // Thread 3 -> Thread 2: simulator to traffic cop // Components: Simulator (Thread 3), Traffic Cop (Thread 2) std::mutex mutex_simulator_to_traffic_cop; // Thread 4 -> Thread 1: physical control panel data (not yet implemented) // Components: Physical Controls (Thread 4), Thread 1 std::mutex mutex_control_data_to_shaders; // Thread 5 -> Thread 2: Raspberry Pi receiver to traffic cop (not yet implemented) // Components: Raspberry Pi Receiver (Thread 5), Traffic Cop (Thread 2) std::mutex mutex_raspberry_pi; /* ============================================================ * SHADER UNIFORM COPIES * These are set by keyboard callbacks in Thread 1 and pushed to * GLSL shader uniforms each frame render. * Initial values are sensible defaults; adjust in include/settings.h * as components are developed and tested. * ============================================================ */ // Scope intensity — keyboard 3 (lower) / 4 (higher) // GLSL uniform: float intensity // Components: all scopes float uniform_intensity = 1.0f; // Receiver sensitivity — keyboard 5 (lower) / 6 (higher) // GLSL uniform: float sensitivity // Components: all scopes float uniform_sensitivity = 1.0f; // STC sensitivity for close-in targets — keyboard q (lower) / w (higher) // GLSL uniform: float stc_sensitivity // Components: all scopes float uniform_stc_sensitivity = 0.5f; // STC effective range (normalized 0-1) — keyboard e (lower) / r (higher) // GLSL uniform: float stc_range // Components: all scopes float uniform_stc_range = 0.3f; // Rain noise filter, PPI scopes only — keyboard t (decrease) / y (increase) // GLSL uniform: float noise_filter // Components: PPI scopes (marine traffic control, on-board boat) float uniform_noise_filter = 0.0f; // Chain Home radiogoniometer bearing in degrees — keyboard u (left) / i (right) // GLSL uniform: float radiogoniometer // Components: Chain Home A-scope float uniform_radiogoniometer = 0.0f; // Maximum radar range (scope-dependent units) — keyboard o (lower) / p (higher) // GLSL uniform: float max_range // Components: Marine A-scope, PPI scopes (not Chain Home; that is fixed) float uniform_max_range = 1.0f; // Range cursor position (normalized 0-1) — keyboard a (lower) / s (higher) // GLSL uniform: float range_cursor // Components: PPI scopes (marine traffic control, on-board boat) float uniform_range_cursor = 0.5f; // Bearing cursor in degrees — keyboard d (CCW) / f (CW) // GLSL uniform: float bearing_cursor // Components: PPI scopes (marine traffic control, on-board boat) float uniform_bearing_cursor = 0.0f; // Marine A-scope antenna rotation bearing in degrees — keyboard g (CCW) / h (CW) // GLSL uniform: float marine_a_bearing // Components: Marine A-scope float uniform_marine_a_bearing = 0.0f; /* ============================================================ * TEMPORARY TEST FILE REGISTRY * Each active test stub pushes its own filename here at startup. * Thread 1 init prints these if non-empty so the presence of test * infrastructure is always visible in the console output. * Components: any temporary test stub; Thread 1 (startup logging) * ============================================================ */ std::vector test_functions; std::vector test_functions_include;