sistemato l'heading nella gestione dei target

This commit is contained in:
VALLONGOL 2025-10-21 13:02:52 +02:00
parent 5417fc1250
commit e69ea0d069
3 changed files with 12 additions and 13 deletions

View File

@ -42,8 +42,6 @@ def build_tgtset_from_target_state(target: Target) -> str:
Builds the 'tgtset' command from a target's CURRENT dynamic state. Builds the 'tgtset' command from a target's CURRENT dynamic state.
This is used for continuous updates during simulation. 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 = [ params = [
target.target_id, target.target_id,
f"{target.current_range_nm:.2f}", 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_heading_deg:.2f}",
f"{target.current_altitude_ft:.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) full_command = " ".join(command_parts)
# We lower the log level to SPAM/VERBOSE if available, or DEBUG, logger.debug(f"Built command: {full_command!r}")
# to avoid flooding the log during live simulation.
logger.debug(f"Built state update command: {full_command!r}")
return full_command return full_command

View File

@ -200,7 +200,7 @@ class PPIDisplay(ttk.Frame):
# ) # )
# except Exception: # except Exception:
# pass # pass
#except Exception: # except Exception:
# pass # pass
for target in self.active_targets: for target in self.active_targets:

View File

@ -596,7 +596,7 @@ class SfpDebugWindow(tk.Toplevel):
temp_target.current_altitude_ft = alt_ft temp_target.current_altitude_ft = alt_ft
# 3. Build the command string # 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 # Ensure the command is trimmed, prefixed with '$' and terminated with a newline
command_str = command_str.strip() command_str = command_str.strip()
# if not command_str.startswith("$"): # if not command_str.startswith("$"):
@ -1221,10 +1221,10 @@ class SfpDebugWindow(tk.Toplevel):
) )
# Debug: show parsed target count and sample raw values # Debug: show parsed target count and sample raw values
try: try:
#self._log_to_widget( # self._log_to_widget(
# f"PPI: parsed {len(targets)} JSON target(s); current_range={current_range}", # f"PPI: parsed {len(targets)} JSON target(s); current_range={current_range}",
# "DEBUG", # "DEBUG",
#) # )
for i, tt in enumerate(targets[:6]): for i, tt in enumerate(targets[:6]):
try: try:
fx = tt.get("flags", None) fx = tt.get("flags", None)
@ -1253,12 +1253,12 @@ class SfpDebugWindow(tk.Toplevel):
rng_m = rng_nm = az_deg = elev_deg = ( rng_m = rng_nm = az_deg = elev_deg = (
None 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}°" # 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 # if rng_m is not None
# else f"PPI RAW[{i}]: flags={fx} x={tx} y={ty} z={tz}" # 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: except Exception:
pass pass
except Exception: except Exception: