Initial setup for project, preparing for first component
This commit is contained in:
178
include/data_structure_and_constants.h
Normal file
178
include/data_structure_and_constants.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* data_structure_and_constants.h
|
||||
* Author: Mark Allyn
|
||||
*
|
||||
* System-wide data structures, constants, and extern declarations.
|
||||
* Include this file in ALL CPU source code files.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
/* ============================================================
|
||||
* TARGET DATA STRUCTURES
|
||||
* Components: Traffic Cop (Thread 2), Simulator (Thread 3),
|
||||
* Thread 1 (OpenGL / shader pipeline)
|
||||
* ============================================================ */
|
||||
|
||||
/* Master target record populated from simulator or Raspberry Pi data.
|
||||
* Components: Traffic Cop (Thread 2), Simulator (Thread 3) */
|
||||
struct target_data_structure {
|
||||
double target_longitude;
|
||||
double target_latitude;
|
||||
std::string vessel_name; // empty if unavailable
|
||||
std::string registration; // empty if unavailable
|
||||
float length; // meters
|
||||
float beam; // meters
|
||||
int vessel_type; // AIS type code or aircraft type
|
||||
uint32_t mmsi; // AIS unique identifier; ICAO hex for aircraft
|
||||
float course; // degrees, true north
|
||||
float speed; // knots
|
||||
float altitude; // meters; 0 for surface vessels
|
||||
int type; // 0 = vessel, 1 = aircraft
|
||||
int police_boat; // 1 = police boat, 0 = not
|
||||
time_t timestamp;
|
||||
};
|
||||
|
||||
/* Lean SSBO payload uploaded to shaders via SSBO layout(std430).
|
||||
* String fields are stripped before upload.
|
||||
* Components: Thread 1 (shader upload), all radar scope shaders */
|
||||
struct ssbo_target_information {
|
||||
float target_x; // Cartesian offset X, meters from radar
|
||||
float target_y; // Cartesian offset Y, meters from radar
|
||||
float length; // meters
|
||||
float beam; // meters
|
||||
float course; // radians, true north
|
||||
float altitude; // meters; 0 for surface vessels
|
||||
time_t timestamp;
|
||||
float current_reflectivity; // derived from vessel_type
|
||||
float height_estimate; // derived from vessel_type
|
||||
float noiseglint; // derived from vessel_type
|
||||
int32_t police_boat; // 1 = police boat
|
||||
uint32_t mmsi;
|
||||
int type; // 0 = vessel, 1 = aircraft
|
||||
};
|
||||
|
||||
/* Intermediate payload passed from Traffic Cop to Thread 1.
|
||||
* String fields are present here but stripped before SSBO upload.
|
||||
* Components: Traffic Cop (Thread 2) -> Thread 1 */
|
||||
struct target_data_to_thread_1_structure {
|
||||
float target_x;
|
||||
float target_y;
|
||||
std::string vessel_name; // stripped before SSBO upload
|
||||
std::string registration; // stripped before SSBO upload
|
||||
float length;
|
||||
float beam;
|
||||
float course;
|
||||
float altitude;
|
||||
time_t timestamp;
|
||||
float current_reflectivity;
|
||||
float height_estimate;
|
||||
float noiseglint;
|
||||
int32_t police_boat;
|
||||
int type;
|
||||
uint32_t mmsi;
|
||||
};
|
||||
|
||||
/* ============================================================
|
||||
* THREAD MUTEXES
|
||||
* Defined in global_data.cpp; extern declared here.
|
||||
* ============================================================ */
|
||||
|
||||
// Thread 2 -> Thread 1: protects target data handoff
|
||||
extern std::mutex mutex_target_data;
|
||||
|
||||
// Thread 3 -> Thread 2: protects simulator-to-traffic-cop handoff
|
||||
extern std::mutex mutex_simulator_to_traffic_cop;
|
||||
|
||||
// Thread 4 -> Thread 1: protects physical control data (Thread 4 not yet implemented)
|
||||
extern std::mutex mutex_control_data_to_shaders;
|
||||
|
||||
// Thread 5 -> Thread 2: protects Raspberry Pi receiver data (Thread 5 not yet implemented)
|
||||
extern std::mutex mutex_raspberry_pi;
|
||||
|
||||
/* ============================================================
|
||||
* SHADER UNIFORM COPIES
|
||||
* Defined in global_data.cpp; extern declared here.
|
||||
* Components: Thread 1 (keyboard callbacks and per-frame uniform push),
|
||||
* all radar scope shaders.
|
||||
* Note: uniforms are implemented as each scope component is built.
|
||||
* ============================================================ */
|
||||
|
||||
// Scope intensity — keyboard 3 (lower) / 4 (higher)
|
||||
// GLSL uniform: float intensity
|
||||
// Components: all scopes
|
||||
extern float uniform_intensity;
|
||||
|
||||
// Receiver sensitivity — keyboard 5 (lower) / 6 (higher)
|
||||
// GLSL uniform: float sensitivity
|
||||
// Components: all scopes
|
||||
extern float uniform_sensitivity;
|
||||
|
||||
// STC sensitivity for close-in targets — keyboard q (lower) / w (higher)
|
||||
// GLSL uniform: float stc_sensitivity
|
||||
// Components: all scopes
|
||||
extern float uniform_stc_sensitivity;
|
||||
|
||||
// STC effective range — keyboard e (lower) / r (higher)
|
||||
// GLSL uniform: float stc_range
|
||||
// Components: all scopes
|
||||
extern float uniform_stc_range;
|
||||
|
||||
// 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)
|
||||
extern float uniform_noise_filter;
|
||||
|
||||
// Chain Home radiogoniometer bearing — keyboard u (left) / i (right)
|
||||
// GLSL uniform: float radiogoniometer
|
||||
// Components: Chain Home A-scope
|
||||
extern float uniform_radiogoniometer;
|
||||
|
||||
// Maximum radar range, all scopes except Chain Home — keyboard o (lower) / p (higher)
|
||||
// GLSL uniform: float max_range
|
||||
// Components: Marine A-scope, PPI scopes
|
||||
extern float uniform_max_range;
|
||||
|
||||
// Range cursor, PPI scopes only — keyboard a (lower) / s (higher)
|
||||
// GLSL uniform: float range_cursor
|
||||
// Components: PPI scopes (marine traffic control, on-board boat)
|
||||
extern float uniform_range_cursor;
|
||||
|
||||
// Bearing cursor, PPI scopes only — keyboard d (CCW) / f (CW)
|
||||
// GLSL uniform: float bearing_cursor
|
||||
// Components: PPI scopes (marine traffic control, on-board boat)
|
||||
extern float uniform_bearing_cursor;
|
||||
|
||||
// Marine A-scope antenna rotation bearing — keyboard g (CCW) / h (CW)
|
||||
// GLSL uniform: float marine_a_bearing
|
||||
// Components: Marine A-scope
|
||||
extern float uniform_marine_a_bearing;
|
||||
128
include/settings.h
Normal file
128
include/settings.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* settings.h
|
||||
* Author: Mark Allyn
|
||||
*
|
||||
* System-wide configuration and debug toggles.
|
||||
* Include this file in ALL components.
|
||||
* Change a value and recompile — no AI rewrite needed.
|
||||
*
|
||||
* Each section is labeled with the component name it governs.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/* ============================================================
|
||||
* GENERAL / OPENGL DEBUG
|
||||
* Component: Thread 1 (initialization)
|
||||
* ============================================================ */
|
||||
|
||||
// 1 = enable GL_DEBUG_OUTPUT and glDebugMessageCallback at startup
|
||||
#define ENABLE_GL_DEBUG_OUTPUT 1
|
||||
|
||||
/* ============================================================
|
||||
* THREAD 1 - OpenGL / Shader Init / Keyboard / Main Loop
|
||||
* ============================================================ */
|
||||
|
||||
// 1 = print shader compile and link status to stdout
|
||||
#define DEBUG_SHADER_COMPILE 1
|
||||
|
||||
/* ============================================================
|
||||
* THREAD 2 - Traffic Cop
|
||||
* ============================================================ */
|
||||
|
||||
// 1 = print each target record received from simulator or Raspberry Pi
|
||||
#define DEBUG_TRAFFIC_COP_INPUT 0
|
||||
|
||||
// 1 = print each target record handed off to Thread 1
|
||||
#define DEBUG_TRAFFIC_COP_OUTPUT 0
|
||||
|
||||
/* ============================================================
|
||||
* THREAD 3 - Simulator
|
||||
* ============================================================ */
|
||||
|
||||
// 1 = print simulated target positions each update cycle
|
||||
#define DEBUG_SIMULATOR_OUTPUT 0
|
||||
|
||||
/* ============================================================
|
||||
* SCOPE RENDERING - ISOLATION TOGGLES
|
||||
* Use these to isolate subsystems during development.
|
||||
* ============================================================ */
|
||||
|
||||
// 1 = disable P7 phosphor persistence layer (see raw target hits only)
|
||||
#define DISABLE_P7_PERSISTENCE 0
|
||||
|
||||
// 1 = disable land and terrain rendering (see targets without background)
|
||||
#define DISABLE_LAND_TERRAIN 0
|
||||
|
||||
// 1 = disable target rendering (see terrain/land background alone)
|
||||
#define DISABLE_TARGETS 0
|
||||
|
||||
/* ============================================================
|
||||
* CHAIN HOME A-SCOPE
|
||||
* Component: Chain Home scope (1940s, World War 2)
|
||||
* ============================================================ */
|
||||
|
||||
// Fixed maximum range in km; the max_range control has no effect for this scope
|
||||
#define CHAIN_HOME_MAX_RANGE_KM 200.0f
|
||||
|
||||
/* ============================================================
|
||||
* MARINE A-SCOPE
|
||||
* Component: 1940s marine A-scope (pre-PPI)
|
||||
* ============================================================ */
|
||||
|
||||
// Selectable maximum range steps in nautical miles (o/p keys cycle through these)
|
||||
#define MARINE_A_SCOPE_NUM_RANGES 4
|
||||
#define MARINE_A_SCOPE_RANGE_STEP_1 3.0f
|
||||
#define MARINE_A_SCOPE_RANGE_STEP_2 6.0f
|
||||
#define MARINE_A_SCOPE_RANGE_STEP_3 12.0f
|
||||
#define MARINE_A_SCOPE_RANGE_STEP_4 24.0f
|
||||
|
||||
/* ============================================================
|
||||
* PPI SCOPE - MARINE TRAFFIC CONTROL
|
||||
* Component: PPI scope, marine traffic control station
|
||||
* ============================================================ */
|
||||
|
||||
// Selectable maximum range steps in nautical miles
|
||||
#define PPI_MTC_NUM_RANGES 5
|
||||
#define PPI_MTC_RANGE_STEP_1 3.0f
|
||||
#define PPI_MTC_RANGE_STEP_2 6.0f
|
||||
#define PPI_MTC_RANGE_STEP_3 12.0f
|
||||
#define PPI_MTC_RANGE_STEP_4 24.0f
|
||||
#define PPI_MTC_RANGE_STEP_5 48.0f
|
||||
|
||||
/* ============================================================
|
||||
* PPI SCOPE - ON-BOARD BOAT
|
||||
* Component: PPI scope, on-board boat view
|
||||
* ============================================================ */
|
||||
|
||||
// Selectable maximum range steps in nautical miles
|
||||
#define PPI_BOAT_NUM_RANGES 5
|
||||
#define PPI_BOAT_RANGE_STEP_1 1.5f
|
||||
#define PPI_BOAT_RANGE_STEP_2 3.0f
|
||||
#define PPI_BOAT_RANGE_STEP_3 6.0f
|
||||
#define PPI_BOAT_RANGE_STEP_4 12.0f
|
||||
#define PPI_BOAT_RANGE_STEP_5 24.0f
|
||||
Reference in New Issue
Block a user