Data Models
Core data structures and models used throughout the application.
Configuration
Configuration data models for sensors and application settings.
This module defines dataclasses for storing sensor configuration, including default settings, serial communication parameters, calculated dependencies, and global application configuration.
calculatedConfigSensorData
dataclass
Bases: defaultConfigSensorData
Configuration for calculated/derived sensors.
Extends defaultConfigSensorData for sensors that compute values based on other sensor measurements rather than direct serial input.
Attributes:
| Name | Type | Description |
|---|---|---|
dependencies |
list[configSensorData]
|
List of source sensors required for calculations. |
Source code in src/core/models/config_data.py
44 45 46 47 48 49 50 51 52 53 54 | |
configData
dataclass
Global application configuration.
Attributes:
| Name | Type | Description |
|---|---|---|
sensors |
Dict[SensorId, defaultConfigSensorData]
|
Dictionary mapping sensor IDs to their configuration. |
emulation |
list[SensorId]
|
List of sensor IDs to run in emulation/simulation mode. |
Source code in src/core/models/config_data.py
56 57 58 59 60 61 62 63 64 65 | |
configSensorData
dataclass
Bases: defaultConfigSensorData
Sensor configuration with serial communication parameters.
Extends defaultConfigSensorData with physical serial connection details.
Attributes:
| Name | Type | Description |
|---|---|---|
baud |
int
|
Serial port baud rate (default: 115200). |
serialId |
str
|
Serial port identifier/device path. |
enabled |
bool
|
Whether this sensor is actively monitored. |
Source code in src/core/models/config_data.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
defaultConfigSensorData
dataclass
Base sensor configuration with default values.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
SensorId
|
Unique sensor identifier from SensorId enum. |
description |
str
|
Human-readable description of the sensor. |
displayName |
str
|
Name to display in user interfaces. |
max |
float
|
Maximum measurement value for the sensor. |
Source code in src/core/models/config_data.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
Sensor Models
Sensor ID enumeration for type-safe sensor references.
SensorId
Bases: Enum
Enumeration of all available sensors.
Source code in src/core/models/sensor_enum.py
5 6 7 8 9 10 11 12 13 | |
Sensor Data
Sensor data model.
SensorData
dataclass
Data class representing a single sensor reading.
Source code in src/core/models/sensor_data.py
8 9 10 11 12 13 14 15 16 17 | |
Sensor State
Test state enumeration for tracking test session status.
TestState
Bases: Enum
Enumeration of all possible test states.
Source code in src/core/models/test_state.py
5 6 7 8 9 10 | |
Utilities
Circular Buffer
CircularBuffer for efficient time-series data storage with O(1) access and insertion. Optimized for speed: precomputed indices, vectorized operations where possible. Supports reference arrays for different time windows with uniform point spacing.
CircularBuffer
Efficient circular buffer for storing (time, value) tuples. - O(1) insertion at the end - O(1) random access - Fixed capacity, overwrites oldest when full - Optimized for speed: pre-allocated buffer, direct indexing
Source code in src/core/models/circular_buffer.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
__init__(capacity)
Initialize circular buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
int
|
Maximum number of (time, value) tuples to store |
required |
Source code in src/core/models/circular_buffer.py
34 35 36 37 38 39 40 41 42 43 44 45 46 | |
append(time, value)
Add a (time, value) tuple to the buffer. O(1).
Source code in src/core/models/circular_buffer.py
48 49 50 51 52 53 54 55 56 57 | |
clear()
Clear all entries.
Source code in src/core/models/circular_buffer.py
151 152 153 154 | |
get(index)
Get item at logical index (0 = oldest, count-1 = newest). O(1) access.
Source code in src/core/models/circular_buffer.py
59 60 61 62 63 64 65 66 67 68 69 70 71 | |
get_all()
Get all valid entries in chronological order. Optimized for bulk retrieval.
Source code in src/core/models/circular_buffer.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
get_range(start_index, end_index)
Get entries from start_index to end_index (exclusive). Optimized retrieval.
Source code in src/core/models/circular_buffer.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
is_full()
Check if buffer is at capacity.
Source code in src/core/models/circular_buffer.py
143 144 145 | |
size()
Get number of valid entries.
Source code in src/core/models/circular_buffer.py
147 148 149 | |
DisplayDuration
Bases: Enum
Enum for display durations in seconds
Source code in src/core/models/circular_buffer.py
10 11 12 13 14 15 16 17 18 19 20 | |
value_seconds()
Get duration in seconds
Source code in src/core/models/circular_buffer.py
18 19 20 | |
SensorDataStorage
Stores time-series data for all sensors with circular buffers and reference arrays. Heavily optimized for speed with precomputed offsets and direct indexing.
Each sensor gets indexed by sensor_id.value for O(1) access. All reference arrays have the SAME number of points but different spacing.
Source code in src/core/models/circular_buffer.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
__init__(sensor_count, sampling_frequency)
Initialize sensor data storage with precomputed structures for speed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensor_count
|
int
|
Number of sensors (e.g., 7 for FORCE, DISP_1, DISP_2, DISP_3, DISP_4, DISP_5, ARC) |
required |
sampling_frequency
|
float
|
Sampling frequency in Hz (points per second) |
required |
Source code in src/core/models/circular_buffer.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
append(sensor_idx, time, value)
Add a data point to a sensor's buffer. O(1).
Source code in src/core/models/circular_buffer.py
241 242 243 244 245 | |
clear_all()
Clear all sensor data.
Source code in src/core/models/circular_buffer.py
321 322 323 324 | |
clear_sensor(sensor_idx)
Clear data for a specific sensor.
Source code in src/core/models/circular_buffer.py
315 316 317 318 319 | |
get_data(sensor_idx)
Get all data points for a sensor.
Source code in src/core/models/circular_buffer.py
247 248 249 250 251 | |
get_data_for_duration(sensor_idx, duration)
Get data points for a specific display duration with uniform spacing. Returns up to reference_points_count points evenly spaced across the duration.
Source code in src/core/models/circular_buffer.py
253 254 255 256 257 258 259 260 261 262 | |
get_data_for_window_seconds(sensor_idx, window_seconds)
Retrieve data for a given time window (in seconds) with uniform spacing. Optimized: uses precomputed offsets and direct indexing, no dynamic computation.
Source code in src/core/models/circular_buffer.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
get_sensor_buffer_stats(sensor_idx)
Get statistics about a sensor's buffer.
Source code in src/core/models/circular_buffer.py
326 327 328 329 330 331 332 333 334 335 336 | |
Test Data
TestMetaData
dataclass
Data class representing metadata for a test. Compatible with both dataclass operations and Pydantic validation.
Source code in src/core/models/test_data.py
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |