From c1baee45b4340188a208162eb9b5816b43b83c6d Mon Sep 17 00:00:00 2001 From: VALLONGOL Date: Thu, 13 Nov 2025 10:01:30 +0100 Subject: [PATCH] modiificato sistema logging e cambiato aggiornamento tabello target --- target_simulator/analysis/simulation_state_hub.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/target_simulator/analysis/simulation_state_hub.py b/target_simulator/analysis/simulation_state_hub.py index b6c8935..c5c4f6f 100644 --- a/target_simulator/analysis/simulation_state_hub.py +++ b/target_simulator/analysis/simulation_state_hub.py @@ -159,19 +159,22 @@ class SimulationStateHub: ): """ Adds a new simulated state for a given target. + + LOCK-FREE: Writes directly to write_buffer without lock. + Thread: Called from SimulationEngine thread. Args: target_id: The ID of the target. timestamp: The local timestamp (e.g., from time.monotonic()) when the state was generated. state: A tuple representing the target's state (x_ft, y_ft, z_ft). """ - with self._lock: - if target_id not in self._target_data: - self._initialize_target(target_id) + # LOCK-FREE: Write directly to write buffer + if target_id not in self._write_buffer['target_data']: + self._initialize_target_in_buffer(target_id, self._write_buffer) - # Prepend the timestamp to the state tuple - full_state = (timestamp,) + state - self._target_data[target_id]["simulated"].append(full_state) + # Prepend the timestamp to the state tuple + full_state = (timestamp,) + state + self._write_buffer['target_data'][target_id]["simulated"].append(full_state) def add_real_state( self, target_id: int, timestamp: float, state: Tuple[float, ...]