Go to file
2025-11-24 14:03:21 +01:00
.github aggiunto il rate dei pacchetti inviati dal server 2025-10-29 12:27:37 +01:00
.vscode salvate latenze,posizioni,e performance in file csv 2025-11-17 12:41:30 +01:00
cpp/DspRIS aggiunta la funzione di debug con messaggi SYNC al server 2025-11-17 15:42:55 +01:00
doc aggiunta funzione di esportazione per mathlab 2025-11-24 10:11:15 +01:00
target_simulator Allineati i test alla versione attuale del codice 2025-11-24 14:03:21 +01:00
tests Allineati i test alla versione attuale del codice 2025-11-24 14:03:21 +01:00
tools Allineati i test alla versione attuale del codice 2025-11-24 14:03:21 +01:00
.gitignore Chore: Stop tracking files based on .gitignore update. 2025-11-21 15:58:49 +01:00
convert.py fine ottimizzazione 2025-11-13 10:57:10 +01:00
corto_200sec_con_test_latency.pcapng allineamento assi x e y secondo convenzione server e refactoring posizionamento target 2025-11-20 16:50:50 +01:00
corto_200sec_senza_test_latency.pcapng allineamento assi x e y secondo convenzione server e refactoring posizionamento target 2025-11-20 16:50:50 +01:00
debug_brackets.py cambiata l'ascissa con il tempo della simulazione nei grafici di analisi 2025-11-17 12:49:29 +01:00
debug_targets.py cambiata l'ascissa con il tempo della simulazione nei grafici di analisi 2025-11-17 12:49:29 +01:00
GEMINI.md first commit 2025-10-01 14:17:56 +02:00
logger_prefs.json aggiunto il salvataggio dei dati del debug delle latenze nei messaggi di sync in csv 2025-11-17 16:01:11 +01:00
logger_prefs.json_old aggiunta la funzione di debug con messaggi SYNC al server 2025-11-17 15:42:55 +01:00
profile.svg modiificato sistema logging e cambiato aggiornamento tabello target 2025-11-13 10:01:24 +01:00
pyproject.toml aggiunti i test unit, fix alcuni import, aggiunto il report di coverage 2025-10-15 14:12:02 +02:00
README.md aggiunto la schermata di configurazione del logger 2025-10-28 09:43:23 +01:00
run_tests.bat raggiunta una copertura del 67 % per i test automatici 2025-10-16 15:58:41 +02:00
scenarios.json aggiunto l'invio di rcs e amplitude 2025-11-21 11:06:10 +01:00
settings.json aggiunta funzione di esportazione per mathlab 2025-11-24 10:11:15 +01:00
SUM7056227 Rev. A.pdf aggiunto l'invio del comando tgtinit con i parametri corretti. 2025-10-20 14:09:01 +02:00
tar.pcapng allineamento assi x e y secondo convenzione server e refactoring posizionamento target 2025-11-20 16:50:50 +01:00
target_simulator.bundle add 2025-11-12 13:20:55 +01:00
target_simulator.ico Chore: Stop tracking files based on .gitignore update. 2025-10-31 13:46:11 +01:00
target_types.json aggiunto l'invio di rcs e amplitude 2025-11-21 11:06:10 +01:00
test_server_packets.py aggiunta la funzione di debug con messaggi SYNC al server 2025-11-17 15:42:55 +01:00
TN-IMGSER GRIFO Video over IP Rev.A1.pdf aggiunta nella finestra di debug sfp l'interpretazione dei dati header 2025-10-16 11:49:57 +02:00
todo.md aggiunta funzione di esportazione per mathlab 2025-11-24 10:11:15 +01:00

target_simulator

A brief description of target_simulator.

Features

  • Feature 1
  • Feature 2

Getting Started

...

Contributing

...

License

...

Note: debug GUI vs simulation command behaviour

The project provides two different code paths for sending target update commands:

  • Debug GUI (SFP Packet Inspector / Simple Target Sender):

    • When you press "Send Target" from the debug window, the GUI sends a tgtset command that includes state qualifiers such as /s (active), /t (traceable) and /r (restart) if the corresponding checkboxes are set.
    • This behaviour is intentional: the debug UI is meant for manual testing and for explicitly toggling target flags.
  • Runtime Simulation:

    • The simulation engine and continuous updates use tgtset commands that contain only the positional/kinematic parameters (range, azimuth, velocity, heading, altitude) and do not include the state qualifiers. This avoids unintentionally changing target lifecycle flags during normal simulation.

Why this matters

  • Historically the code used tgtinit in some debug flows. tgtinit sets some different internal parameters (for example heading_start) and can change target motion in unintended ways. To preserve correct simulation behaviour, the debug window now sends tgtset + qualifiers while the simulation keeps sending tgtset without qualifiers.

Where to look in the code

  • Debug GUI sender: target_simulator/gui/sfp_debug_window.py (_on_send_target).
  • Command builders: target_simulator/core/command_builder.py (build_tgtset_from_target_state, build_tgtset_selective, build_tgtinit).
  • Settings: debug file names and options are in settings.json (section debug) and target_simulator/config.py contains defaults.

If you want the debug UI to exactly mimic runtime behaviour, uncheck the Active/Traceable/Restart checkboxes before sending, or use the runtime APIs to send tgtset without qualifiers.

Debug logging (attivazione localizzata)

Il progetto utilizza il modulo logging di Python con logger a livello di modulo (per esempio target_simulator.analysis.simulation_state_hub). In diversi punti del codice è stato standardizzato l'uso di logger = logging.getLogger(__name__) e aggiunto un helper temporary_log_level in target_simulator/utils/logger.py per attivare temporaneamente livelli di log più verbosi.

Di seguito alcuni esempi rapidi per attivare/disattivare il DEBUG solo per la parte del codice che ti interessa analizzare.

Attivare DEBUG per un modulo (a runtime)

Apri una shell Python o esegui lo snippet nel tuo script/main e imposta il livello del logger del modulo che vuoi investigare.

Esempio — abilitare DEBUG solo per lo state hub:

import logging
logging.getLogger('target_simulator.analysis.simulation_state_hub').setLevel(logging.DEBUG)

Per tornare a INFO (o disattivare DEBUG):

logging.getLogger('target_simulator.analysis.simulation_state_hub').setLevel(logging.INFO)

I nomi dei logger corrispondono ai path dei moduli. Esempi utili:

  • target_simulator.analysis.simulation_state_hub
  • target_simulator.gui.sfp_debug_window
  • target_simulator.gui.ppi_display
  • target_simulator.gui.payload_router
  • target_simulator.core.sfp_transport

Attivare DEBUG solo per un blocco di codice (temporaneo)

Usa il context manager temporary_log_level fornito in target_simulator.utils.logger:

from logging import getLogger
from target_simulator.utils.logger import temporary_log_level

mod_logger = getLogger('target_simulator.gui.payload_router')

with temporary_log_level(mod_logger, logging.DEBUG):
	# dentro questo blocco il logger è DEBUG
	router.process_some_payload(...)   # esempio
# All'uscita il livello viene ripristinato automaticamente

Debug ancora più granulare — child logger e filtri

Per messaggi molto verbosi puoi creare child logger o usare extra + Filter:

Child logger:

base = logging.getLogger('target_simulator.analysis.simulation_state_hub')
diag = base.getChild('diagnostics')  # 'target_simulator.analysis.simulation_state_hub.diagnostics'
diag.setLevel(logging.DEBUG)
diag.debug("dettagli diagnostici: ...")

Esempio di filtro basato su extra:

class ExtraKeyFilter(logging.Filter):
	def __init__(self, key, allowed_values):
		super().__init__()
		self.key = key
		self.allowed = set(allowed_values)
	def filter(self, record):
		return getattr(record, self.key, None) in self.allowed

handler = logging.StreamHandler()
handler.addFilter(ExtraKeyFilter('topic', ['diagnostic']))
logging.getLogger('target_simulator').addHandler(handler)

# Emetti:
logging.getLogger('target_simulator.analysis.simulation_state_hub').debug("...", extra={'topic':'diagnostic'})

Esecuzione rapida da PowerShell

Esempio per aprire REPL con PYTHONPATH corretto (Windows PowerShell):

$env:PYTHONPATH='C:\src\____GitProjects\target_simulator'
python
# dentro REPL eseguire i comandi logging mostrati sopra

Oppure eseguire un singolo comando:

$env:PYTHONPATH='C:\src\____GitProjects\target_simulator'; python -c "import logging; logging.getLogger('target_simulator.gui.payload_router').setLevel(logging.DEBUG); print('DEBUG enabled')"

Se vuoi, possiamo aggiungere un piccolo pannello nella GUI per controllare i livelli dei logger a runtime; fammi sapere se preferisci questa opzione.