some refactoring and socket server added

This commit is contained in:
Ayzen
2026-04-08 18:43:29 +03:00
parent 202993325d
commit 1d7d0a756e
25 changed files with 3093 additions and 2527 deletions
+46
View File
@@ -48,6 +48,10 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
pre_ring_payload = _as_dict(rings_payload.get("preprocessed"), "rings.preprocessed")
pre_tap_ring_payload = _as_dict(rings_payload.get("preprocessed_tap"), "rings.preprocessed_tap")
result_ring_payload = _as_dict(rings_payload.get("results"), "rings.results")
locator_server_payload = _as_dict(
run_payload.get("locator_server", run_payload.get("locator")),
"run.locator_server",
)
model.radar.model = str(radar_payload.get("model", model.radar.model))
model.radar.serial = str(radar_payload.get("serial", model.radar.serial))
@@ -71,6 +75,39 @@ def run_config_from_dict(payload: dict[str, Any]) -> RunConfigModel:
model.runtime.processing_live_config_path = str(
run_payload.get("processing_live_config_path", model.runtime.processing_live_config_path)
)
model.runtime.locator_server.device_id = int(
locator_server_payload.get("device_id", model.runtime.locator_server.device_id)
)
model.runtime.locator_server.protocol_version = int(
locator_server_payload.get(
"protocol_version",
model.runtime.locator_server.protocol_version,
)
)
model.runtime.locator_server.host = str(
locator_server_payload.get("host", model.runtime.locator_server.host)
)
model.runtime.locator_server.port = int(
locator_server_payload.get("port", model.runtime.locator_server.port)
)
model.runtime.locator_server.max_payload_bytes = int(
locator_server_payload.get(
"max_payload_bytes",
model.runtime.locator_server.max_payload_bytes,
)
)
model.runtime.locator_server.client_queue_size = int(
locator_server_payload.get(
"client_queue_size",
model.runtime.locator_server.client_queue_size,
)
)
model.runtime.locator_server.logger_name = str(
locator_server_payload.get(
"logger_name",
model.runtime.locator_server.logger_name,
)
)
s21_preprocess_payload = _as_dict(preprocess_payload.get("s21"), "preprocess.s21")
_load_preprocess_asset(
@@ -203,6 +240,15 @@ def run_config_to_dict(model: RunConfigModel) -> dict[str, Any]:
"idle_sleep_ms": model.runtime.idle_sleep_ms,
"continuous": model.runtime.continuous,
"processing_live_config_path": model.runtime.processing_live_config_path,
"locator_server": {
"device_id": model.runtime.locator_server.device_id,
"protocol_version": model.runtime.locator_server.protocol_version,
"host": model.runtime.locator_server.host,
"port": model.runtime.locator_server.port,
"max_payload_bytes": model.runtime.locator_server.max_payload_bytes,
"client_queue_size": model.runtime.locator_server.client_queue_size,
"logger_name": model.runtime.locator_server.logger_name,
},
"combos": [{"input": combo.input, "output": combo.output} for combo in model.combos],
},
"preprocess": {
+2
View File
@@ -6,6 +6,7 @@ from python_app.models.run_config_schema import (
GprModel,
GprRxGeometryModel,
GprTxGeometryModel,
LocatorServerRuntimeModel,
PreprocessAssetModel,
PreprocessModel,
RadarModel,
@@ -30,6 +31,7 @@ __all__ = [
"GprModel",
"GprRxGeometryModel",
"GprTxGeometryModel",
"LocatorServerRuntimeModel",
"PreprocessAssetModel",
"PreprocessModel",
"RadarModel",
+14
View File
@@ -75,6 +75,19 @@ class RingsModel:
results: RingEndpointModel = field(default_factory=lambda: RingEndpointModel(name=""))
@dataclass(slots=True)
class LocatorServerRuntimeModel:
"""Embedded locator TCP server configuration stored in run config."""
device_id: int = 3
protocol_version: int = 1
host: str = "0.0.0.0"
port: int = 8888
max_payload_bytes: int = 64 * 1024
client_queue_size: int = 32
logger_name: str = "locator_runtime"
@dataclass(slots=True)
class RuntimeModel:
"""Runtime process behavior and paths."""
@@ -83,6 +96,7 @@ class RuntimeModel:
idle_sleep_ms: int = 2
continuous: bool = False
processing_live_config_path: str = ""
locator_server: LocatorServerRuntimeModel = field(default_factory=LocatorServerRuntimeModel)
@dataclass(slots=True)