183 lines
8.6 KiB
Python
183 lines
8.6 KiB
Python
# --- START OF FILE config.py ---
|
|
|
|
# config.py
|
|
"""
|
|
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
This module defines constants and configurations for the application.
|
|
Includes settings for logging levels, debug flags, image dimensions,
|
|
UI defaults, network parameters, and operational modes.
|
|
"""
|
|
import logging # Import logging for level constants
|
|
import numpy as np
|
|
|
|
# --- Logging Configuration ---
|
|
|
|
# Set the overall minimum logging level that the application will PROCESS.
|
|
# DEBUG allows all messages, INFO hides DEBUG, WARNING hides INFO and DEBUG, etc.
|
|
# The HANDLER level below determines what actually gets OUTPUT.
|
|
# Set to logging.DEBUG to allow the filter to work effectively.
|
|
LOG_ROOT_LEVEL = logging.DEBUG
|
|
|
|
# Set the minimum level for messages to be OUTPUT by the console handler.
|
|
# Use logging.INFO for normal operation, logging.DEBUG to see all filtered messages.
|
|
LOG_HANDLER_LEVEL = logging.DEBUG # Set to DEBUG to enable filtering via flags below
|
|
|
|
# --- Specific DEBUG message flags ---
|
|
# Set these to True to enable specific categories of DEBUG messages.
|
|
# These flags are used by the DebugControlFilter in app.py.
|
|
# The corresponding prefix used in the code is shown in brackets [].
|
|
|
|
# --- App Module Debug Flags ---
|
|
DEBUG_APP_LIFECYCLE = (
|
|
False # [App Init], [App Shutdown] - Core application start/stop steps.
|
|
)
|
|
DEBUG_APP_CALLBACKS = False # [App CB ...] - Entry/exit/values for general UI callbacks (sliders, buttons, etc.).
|
|
# Excludes specific callbacks with their own flags (e.g., MFD Params).
|
|
DEBUG_APP_QUEUE_PROCESSING = False # [App QProc ...] - Logs when items are dequeued and processed by app queue handlers.
|
|
DEBUG_APP_IMG_PROCESSING = False # [App Proc ...] - Steps within central image processing (process_and_queue_...).
|
|
DEBUG_APP_TEST_MODE = False # [App Test ...], [App Mode Switch] - Test image generation, scheduling, updates, mode switching.
|
|
DEBUG_APP_GEO_CALC = False # [App GeoCalc], [App Mouse Queue Put] - Mouse geo-coordinate calculation steps and queueing.
|
|
DEBUG_APP_MFD_PARAMS = False # [App CB MFD Param ...], [MFD LUT Update] - MFD parameter UI callbacks and LUT recalculation.
|
|
DEBUG_APP_STATUS = False # [App Status Update], [App Set Status] - Status bar update logic and formatting.
|
|
DEBUG_APP_TRIGGER = False # [App Trigger ...] - Logs when internal update triggers (_trigger_mfd/sar_update) are called.
|
|
|
|
# --- Receiver Module Debug Flags ---
|
|
DEBUG_RECEIVER_LOOP = False # [Receiver Loop] - General events in the main receiver loop (start, stop, socket events).
|
|
DEBUG_RECEIVER_PACKETS = (
|
|
False # Logs every raw SFP packet header received ("Rcvd: Key=..."). High volume.
|
|
)
|
|
DEBUG_RECEIVER_REASSEMBLY = False # [Worker ...], [Receiver Reassembly], etc. - Fragment reassembly logic, buffer allocation, submission, worker task steps.
|
|
DEBUG_RECEIVER_GEO = False # [Geo extract], "GeoInfo:", etc. - Raw GeoInfo/Metadata extraction details within the receiver/worker.
|
|
DEBUG_RECEIVER_ACK = False # [Receiver ACK] - Details of sending ACK packets.
|
|
DEBUG_RECEIVER_CLEANUP = False # [Receiver Cleanup] - Transaction cleanup actions (removing buffers, fragments).
|
|
|
|
# --- Display Manager Module Debug Flags ---
|
|
DEBUG_DISPLAY_MANAGER = False # [DisplayMgr] - Display window creation, image showing, callback setup, destruction.
|
|
|
|
# --- Utility Modules Debug Flags ---
|
|
DEBUG_UTILS = False # [Utils ...] - Logs from functions within utils.py (e.g., queue helpers, DMS conversion).
|
|
DEBUG_NETWORK = False # [Network] - Logs from functions within network.py (socket creation/closing).
|
|
DEBUG_IMAGE_PROCESSING = False # [ImageProcessing] - Logs from functions within image_processing.py (normalize, resize, palette etc.).
|
|
|
|
# --- Map Debug Flag ---
|
|
DEBUG_MAP_DETAILS = False # Set to True to enable detailed map processing logs (tiles, calculations, drawing)
|
|
|
|
# --- Other General Configuration ---
|
|
|
|
# Constants for Image Dimensions
|
|
MFD_WIDTH = 484
|
|
MFD_HEIGHT = 484
|
|
SAR_WIDTH = 2048
|
|
SAR_HEIGHT = 2048
|
|
SAR_DATA_TYPE = np.uint16 # Data type of raw SAR pixels
|
|
|
|
# Initial Display Sizes (used for placeholders and potentially UI defaults)
|
|
INITIAL_SAR_WIDTH = 1024
|
|
INITIAL_SAR_HEIGHT = 1024
|
|
INITIAL_MFD_WIDTH = 484 # Should match MFD_WIDTH if no scaling initially
|
|
INITIAL_MFD_HEIGHT = 484 # Should match MFD_HEIGHT if no scaling initially
|
|
|
|
# Target Frame Rate (for MFD test mode and queue processing timing)
|
|
MFD_FPS = 25
|
|
|
|
# Tkinter Window Configuration
|
|
TKINTER_MIN_WIDTH = 484
|
|
TKINTER_MIN_HEIGHT = 484
|
|
|
|
# UI Defaults
|
|
COLOR_PALETTES = [
|
|
"GRAY",
|
|
"JET",
|
|
"HOT",
|
|
"HSV",
|
|
"COOL",
|
|
"RAINBOW",
|
|
"AUTUMN",
|
|
"BONE",
|
|
"WINTER",
|
|
"OCEAN",
|
|
"SUMMER",
|
|
"SPRING",
|
|
] # Added more common palettes
|
|
DEFAULT_SAR_CONTRAST = 1.0
|
|
DEFAULT_SAR_BRIGHTNESS = 0
|
|
DEFAULT_SAR_PALETTE = "GRAY"
|
|
SAR_SIZE_FACTORS = [
|
|
"1:1",
|
|
"1:2",
|
|
"1:3",
|
|
"1:5",
|
|
"1:10",
|
|
] # Ratios for SAR display size combobox
|
|
DEFAULT_SAR_SIZE = "1:2" # Default selection in the combobox
|
|
INITIAL_STATUS_MESSAGE = "Initializing..." # Initial message shown in status bar
|
|
|
|
# Network Configuration
|
|
DEFAULT_SER_IP = "127.0.0.1" # Default local IP to listen on
|
|
DEFAULT_SER_PORT = 55556 # Default UDP port to listen on
|
|
|
|
# Threading Configuration
|
|
MAX_WORKERS = 5 # Max number of worker threads for the ThreadPoolExecutor in receiver
|
|
|
|
# Queue Sizes (Max number of items before dropping)
|
|
DEFAULT_SAR_QUEUE = 5 # Processed SAR images (for display)
|
|
DEFAULT_MFD_QUEUE = 5 # Processed MFD images (for display)
|
|
DEFAULT_TKINTER_QUEUE = 50 # Processed mouse coords (DMS strings/None) for UI update
|
|
DEFAULT_MOUSE_QUEUE = 50 # Raw mouse coords (x,y) from OpenCV callback
|
|
|
|
# Operational Modes & Development Flags
|
|
ENABLE_TEST_MODE = False # Default state for the "Test Image" checkbox on startup
|
|
USE_LOCAL_IMAGES = False # If True, load images from local paths instead of network
|
|
SAVE_BINARY_DUMPS = False # If True, save raw incoming UDP packets to 'dumps' folder
|
|
DUMP_DIRECTORY = "dumps" # Directory to save packet dumps
|
|
ENABLE_PROFILING = False # If True, enable cProfile for the receiver thread
|
|
DISABLE_COLORMAP_OPTIMIZATION = False # If True, use slower non-vectorized applyColorMap (for debugging OpenCV issues)
|
|
|
|
# Status Update Interval
|
|
LOG_UPDATE_INTERVAL = 0.5 # seconds - Frequency for updating status bar FPS/stats
|
|
|
|
# SFP ACK Window Configuration (for ACKs sent back to sender)
|
|
ACK_WINDOW_SIZE_MFD = 32 # Window size value sent in ACKs for MFD flow
|
|
ACK_WINDOW_SIZE_SAR = 16 # Window size value sent in ACKs for SAR flow
|
|
|
|
# MFD Visualization Defaults
|
|
DEFAULT_MFD_INTENSITY = 255 # Default intensity for MFD symbol categories (0-255)
|
|
DEFAULT_MFD_RAW_MAP_INTENSITY = (
|
|
255 # Default intensity for MFD raw map pixels (32-255 range)
|
|
)
|
|
|
|
# --- Map Overlay Configuration ---
|
|
ENABLE_MAP_OVERLAY = True # <<< SET TO True TO ENABLE THE MAP WINDOW FOR TESTING
|
|
MAP_SERVICE_PROVIDER = "osm" # Name of the service to use (must match map_services.py)
|
|
# MAP_API_KEY = None # Add this if using a service that requires a key (e.g., Google)
|
|
MAP_CACHE_DIRECTORY = "map_cache" # Root directory for cached tiles
|
|
ENABLE_ONLINE_MAP_FETCHING = True # Allow downloading tiles if not in cache
|
|
DEFAULT_MAP_ZOOM_LEVEL = 14 # Initial zoom level for the test map (adjust as needed) 12 original, 13 little more big,
|
|
# Color for placeholder tiles when offline/download fails (RGB tuple)
|
|
OFFLINE_MAP_PLACEHOLDER_COLOR = (200, 200, 200) # Light grey
|
|
MAX_MAP_DISPLAY_WIDTH = 1024
|
|
MAX_MAP_DISPLAY_HEIGHT = 1024
|
|
|
|
|
|
# SAR Georeferencing Defaults (Now explicitly used for map testing if ENABLE_MAP_OVERLAY is True)
|
|
# SAR Georeferencing Defaults
|
|
# NOTE: Setting LAT/LON to 0.0 signals the MapIntegrationManager *NOT*
|
|
# to display an initial default map area on startup.
|
|
# The map will only appear after the first valid GeoInfo is received.
|
|
SAR_CENTER_LAT = 0.0 #40.7128 # Example: New York City Latitude (Degrees)
|
|
SAR_CENTER_LON = 0.0 #-74.0060 # Example: New York City Longitude (Degrees)
|
|
SAR_IMAGE_SIZE_KM = (
|
|
50.0 # Example: Width/Height of the area to show on the map in Kilometers
|
|
)
|
|
|
|
# --- KML / Google Earth Integration Configuration ---
|
|
ENABLE_KML_GENERATION = True # Imposta a True per generare file KML quando arrivano dati SAR validi
|
|
KML_OUTPUT_DIRECTORY = "kml_output" # Cartella dove salvare i file KML generati
|
|
AUTO_LAUNCH_GOOGLE_EARTH = False # Imposta a True per tentare di aprire automaticamente il KML generato con Google Earth Pro (se installato)
|
|
# Opzionale: potresti aggiungere un percorso esplicito all'eseguibile di Google Earth se non è nel PATH
|
|
# GOOGLE_EARTH_EXECUTABLE_PATH = "C:/Program Files/Google/Google Earth Pro/client/googleearth.exe" # Esempio Windows
|
|
|
|
|
|
# --- END OF FILE config.py ---
|