From e69ea0d0697d3b74a205e0fd3892bcfec492dd35 Mon Sep 17 00:00:00 2001 From: VALLONGOL Date: Tue, 21 Oct 2025 13:02:52 +0200 Subject: [PATCH] sistemato l'heading nella gestione dei target --- target_simulator/core/command_builder.py | 11 +++++------ target_simulator/gui/ppi_display.py | 2 +- target_simulator/gui/sfp_debug_window.py | 12 ++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/target_simulator/core/command_builder.py b/target_simulator/core/command_builder.py index 44c141f..4bc1fa3 100644 --- a/target_simulator/core/command_builder.py +++ b/target_simulator/core/command_builder.py @@ -42,8 +42,6 @@ def build_tgtset_from_target_state(target: Target) -> str: Builds the 'tgtset' command from a target's CURRENT dynamic state. This is used for continuous updates during simulation. """ - # Note: We do not include qualifiers like /s or /t in continuous updates - # as they are typically set only at initialization. params = [ target.target_id, f"{target.current_range_nm:.2f}", @@ -52,13 +50,14 @@ def build_tgtset_from_target_state(target: Target) -> str: f"{target.current_heading_deg:.2f}", f"{target.current_altitude_ft:.2f}", ] + qualifiers = ["/s" if target.active else "/-s", "/t" if target.traceable else "/-t"] + if hasattr(target, "restart") and getattr(target, "restart", False): + qualifiers.append("/r") - command_parts = ["tgtset"] + [str(p) for p in params] + command_parts = ["tgtset"] + [str(p) for p in params] + qualifiers full_command = " ".join(command_parts) - # We lower the log level to SPAM/VERBOSE if available, or DEBUG, - # to avoid flooding the log during live simulation. - logger.debug(f"Built state update command: {full_command!r}") + logger.debug(f"Built command: {full_command!r}") return full_command diff --git a/target_simulator/gui/ppi_display.py b/target_simulator/gui/ppi_display.py index 90a6542..10e1d3e 100644 --- a/target_simulator/gui/ppi_display.py +++ b/target_simulator/gui/ppi_display.py @@ -200,7 +200,7 @@ class PPIDisplay(ttk.Frame): # ) # except Exception: # pass - #except Exception: + # except Exception: # pass for target in self.active_targets: diff --git a/target_simulator/gui/sfp_debug_window.py b/target_simulator/gui/sfp_debug_window.py index ef2ffeb..416831d 100644 --- a/target_simulator/gui/sfp_debug_window.py +++ b/target_simulator/gui/sfp_debug_window.py @@ -596,7 +596,7 @@ class SfpDebugWindow(tk.Toplevel): temp_target.current_altitude_ft = alt_ft # 3. Build the command string - command_str = command_builder.build_tgtinit(temp_target) + command_str = command_builder.build_tgtset_from_target_state(temp_target) # Ensure the command is trimmed, prefixed with '$' and terminated with a newline command_str = command_str.strip() # if not command_str.startswith("$"): @@ -1221,10 +1221,10 @@ class SfpDebugWindow(tk.Toplevel): ) # Debug: show parsed target count and sample raw values try: - #self._log_to_widget( + # self._log_to_widget( # f"PPI: parsed {len(targets)} JSON target(s); current_range={current_range}", # "DEBUG", - #) + # ) for i, tt in enumerate(targets[:6]): try: fx = tt.get("flags", None) @@ -1253,12 +1253,12 @@ class SfpDebugWindow(tk.Toplevel): rng_m = rng_nm = az_deg = elev_deg = ( None ) - #msg = ( + # msg = ( # f"PPI RAW[{i}]: flags={fx} x={tx} y={ty} z={tz} | range_m={rng_m:.1f} range_nm={rng_nm:.2f} az={az_deg:.2f}° elev={elev_deg:.2f}°" # if rng_m is not None # else f"PPI RAW[{i}]: flags={fx} x={tx} y={ty} z={tz}" - #) - #self._log_to_widget(msg, "DEBUG") + # ) + # self._log_to_widget(msg, "DEBUG") except Exception: pass except Exception: