From 5e28250f4d37446644ffdd48184a93de540364eb Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 13:34:54 -0700 Subject: [PATCH 1/8] sigan monitor --- scos_actions/hardware/__init__.py | 13 ++++++++++++- scos_actions/hardware/signal_analyzer_monitor.py | 13 +++++++++++++ .../signal_analyzer_registration_handler.py | 13 +++++++++++++ scos_actions/signals.py | 3 +++ scos_actions/status/__init__.py | 1 - 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 scos_actions/hardware/signal_analyzer_monitor.py create mode 100644 scos_actions/hardware/signal_analyzer_registration_handler.py diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index 34af394d..fc1ee4eb 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -7,13 +7,21 @@ from scos_actions import utils from scos_actions.capabilities import capabilities +from scos_actions.hardware import sigan_registration_handler +from scos_actions.hardware.signal_analyzer_monitor import SignalAnalyzerMonitor +from scos_actions.hardware.signal_analyzer_registration_handler import ( + signal_analyzer_registration_handler, +) from scos_actions.settings import ( PRESELECTOR_CLASS, PRESELECTOR_CONFIG_FILE, PRESELECTOR_MODULE, SWITCH_CONFIGS_DIR, ) -from scos_actions.signals import register_component_with_status +from scos_actions.signals import ( + register_component_with_status, + register_signal_analyzer, +) from scos_actions.status.status_registration_handler import status_registration_handler logger = logging.getLogger(__name__) @@ -68,8 +76,11 @@ def load_preselector(preselector_config, module, preselector_class_name): return ps +signa_analyzer_monitor = SignalAnalyzerMonitor() +register_signal_analyzer.connect(signal_analyzer_registration_handler) register_component_with_status.connect(status_registration_handler) logger.debug("Connected status registration handler") +register_signal_analyzer.connect(sigan_registration_handler) preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE) switches = load_switches(SWITCH_CONFIGS_DIR) logger.debug(f"Loaded {(len(switches))} switches.") diff --git a/scos_actions/hardware/signal_analyzer_monitor.py b/scos_actions/hardware/signal_analyzer_monitor.py new file mode 100644 index 00000000..14c5df1f --- /dev/null +++ b/scos_actions/hardware/signal_analyzer_monitor.py @@ -0,0 +1,13 @@ +import logging + +logger = logging.getLogger(__name__) + + +class SignalAnalyzerMonitor: + def __init__(self): + logger.debug("Initializing Signal Analyzer Monitor") + self.signal_analyzer = None + + def register_signal_analyzer(self, sigan): + logger.debug(f"Setting Signal Analyzer to {sigan}") + self.signal_analyzer = sigan diff --git a/scos_actions/hardware/signal_analyzer_registration_handler.py b/scos_actions/hardware/signal_analyzer_registration_handler.py new file mode 100644 index 00000000..012e49e8 --- /dev/null +++ b/scos_actions/hardware/signal_analyzer_registration_handler.py @@ -0,0 +1,13 @@ +import logging + +from . import signa_analyzer_monitor + +logger = logging.getLogger(__name__) + + +def signal_analyzer_registration_handler(sender, **kwargs): + try: + logger.debug(f"Registering {sender} as status provider") + signa_analyzer_monitor.register_signal_analyzer(kwargs["signal_analyzer"]) + except: + logger.exception("Error registering signal analyzer") diff --git a/scos_actions/signals.py b/scos_actions/signals.py index 36baaf3b..339f1919 100644 --- a/scos_actions/signals.py +++ b/scos_actions/signals.py @@ -13,3 +13,6 @@ # Provides argument 'action' register_action = Signal() + +# Provides argument 'sigan' +register_signal_analyzer = Signal() diff --git a/scos_actions/status/__init__.py b/scos_actions/status/__init__.py index f21e1efc..bdaa1846 100644 --- a/scos_actions/status/__init__.py +++ b/scos_actions/status/__init__.py @@ -3,5 +3,4 @@ from .status_monitor import StatusMonitor status_registrar = StatusMonitor() - start_time = datetime.datetime.utcnow() From bb4299651773d5235aeac2c031c58fff12363c5e Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 13:52:10 -0700 Subject: [PATCH 2/8] Move sigan monitor to status. --- scos_actions/hardware/__init__.py | 10 +++------- scos_actions/status/__init__.py | 2 ++ .../{hardware => status}/signal_analyzer_monitor.py | 0 .../signal_analyzer_registration_handler.py | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) rename scos_actions/{hardware => status}/signal_analyzer_monitor.py (100%) rename scos_actions/{hardware => status}/signal_analyzer_registration_handler.py (85%) diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index fc1ee4eb..0f569ebc 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -7,11 +7,6 @@ from scos_actions import utils from scos_actions.capabilities import capabilities -from scos_actions.hardware import sigan_registration_handler -from scos_actions.hardware.signal_analyzer_monitor import SignalAnalyzerMonitor -from scos_actions.hardware.signal_analyzer_registration_handler import ( - signal_analyzer_registration_handler, -) from scos_actions.settings import ( PRESELECTOR_CLASS, PRESELECTOR_CONFIG_FILE, @@ -23,6 +18,9 @@ register_signal_analyzer, ) from scos_actions.status.status_registration_handler import status_registration_handler +from scos_actions.status.signal_analyzer_registration_handler import ( + signal_analyzer_registration_handler, +) logger = logging.getLogger(__name__) @@ -76,11 +74,9 @@ def load_preselector(preselector_config, module, preselector_class_name): return ps -signa_analyzer_monitor = SignalAnalyzerMonitor() register_signal_analyzer.connect(signal_analyzer_registration_handler) register_component_with_status.connect(status_registration_handler) logger.debug("Connected status registration handler") -register_signal_analyzer.connect(sigan_registration_handler) preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE) switches = load_switches(SWITCH_CONFIGS_DIR) logger.debug(f"Loaded {(len(switches))} switches.") diff --git a/scos_actions/status/__init__.py b/scos_actions/status/__init__.py index bdaa1846..2583372b 100644 --- a/scos_actions/status/__init__.py +++ b/scos_actions/status/__init__.py @@ -1,6 +1,8 @@ import datetime +from .signal_analyzer_monitor import SignalAnalyzerMonitor from .status_monitor import StatusMonitor status_registrar = StatusMonitor() +signal_analyzer_monitor = SignalAnalyzerMonitor() start_time = datetime.datetime.utcnow() diff --git a/scos_actions/hardware/signal_analyzer_monitor.py b/scos_actions/status/signal_analyzer_monitor.py similarity index 100% rename from scos_actions/hardware/signal_analyzer_monitor.py rename to scos_actions/status/signal_analyzer_monitor.py diff --git a/scos_actions/hardware/signal_analyzer_registration_handler.py b/scos_actions/status/signal_analyzer_registration_handler.py similarity index 85% rename from scos_actions/hardware/signal_analyzer_registration_handler.py rename to scos_actions/status/signal_analyzer_registration_handler.py index 012e49e8..117759b4 100644 --- a/scos_actions/hardware/signal_analyzer_registration_handler.py +++ b/scos_actions/status/signal_analyzer_registration_handler.py @@ -1,6 +1,6 @@ import logging -from . import signa_analyzer_monitor +from scos_actions.hardware import signa_analyzer_monitor logger = logging.getLogger(__name__) From 588fb6fa5ceb188c65087eac2e1adb86dc49d561 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 14:09:29 -0700 Subject: [PATCH 3/8] fix signal_analyzer_monitor. --- scos_actions/status/signal_analyzer_registration_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scos_actions/status/signal_analyzer_registration_handler.py b/scos_actions/status/signal_analyzer_registration_handler.py index 117759b4..01253a46 100644 --- a/scos_actions/status/signal_analyzer_registration_handler.py +++ b/scos_actions/status/signal_analyzer_registration_handler.py @@ -1,6 +1,6 @@ import logging -from scos_actions.hardware import signa_analyzer_monitor +from . import signal_analyzer_monitor logger = logging.getLogger(__name__) @@ -8,6 +8,6 @@ def signal_analyzer_registration_handler(sender, **kwargs): try: logger.debug(f"Registering {sender} as status provider") - signa_analyzer_monitor.register_signal_analyzer(kwargs["signal_analyzer"]) + signal_analyzer_monitor.register_signal_analyzer(kwargs["signal_analyzer"]) except: logger.exception("Error registering signal analyzer") From eba51a98fd58cc397e46753005a237ac91c226fa Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 21:08:01 -0700 Subject: [PATCH 4/8] Create core module to initialize the StatusMonitor and SiganMonitor --- scos_actions/core/__init__.py | 5 +++++ scos_actions/{status => core}/signal_analyzer_monitor.py | 4 ++++ scos_actions/{status => core}/status_monitor.py | 0 scos_actions/discover/__init__.py | 1 + scos_actions/hardware/__init__.py | 8 +++++--- .../signal_analyzer_registration_handler.py | 2 +- scos_actions/status/__init__.py | 5 +---- scos_actions/status/status_registration_handler.py | 2 +- 8 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 scos_actions/core/__init__.py rename scos_actions/{status => core}/signal_analyzer_monitor.py (81%) rename scos_actions/{status => core}/status_monitor.py (100%) rename scos_actions/{status => hardware}/signal_analyzer_registration_handler.py (86%) diff --git a/scos_actions/core/__init__.py b/scos_actions/core/__init__.py new file mode 100644 index 00000000..f717c05b --- /dev/null +++ b/scos_actions/core/__init__.py @@ -0,0 +1,5 @@ +from .signal_analyzer_monitor import SignalAnalyzerMonitor +from .status_monitor import StatusMonitor + +signal_analyzer_monitor = SignalAnalyzerMonitor() +status_registrar = StatusMonitor() diff --git a/scos_actions/status/signal_analyzer_monitor.py b/scos_actions/core/signal_analyzer_monitor.py similarity index 81% rename from scos_actions/status/signal_analyzer_monitor.py rename to scos_actions/core/signal_analyzer_monitor.py index 14c5df1f..94833b4a 100644 --- a/scos_actions/status/signal_analyzer_monitor.py +++ b/scos_actions/core/signal_analyzer_monitor.py @@ -11,3 +11,7 @@ def __init__(self): def register_signal_analyzer(self, sigan): logger.debug(f"Setting Signal Analyzer to {sigan}") self.signal_analyzer = sigan + + @property + def signal_analyzer(self): + return self.signal_analyzer diff --git a/scos_actions/status/status_monitor.py b/scos_actions/core/status_monitor.py similarity index 100% rename from scos_actions/status/status_monitor.py rename to scos_actions/core/status_monitor.py diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index f77df84d..136e03df 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -1,3 +1,4 @@ +import scos_actions.core from scos_actions.actions import action_classes from scos_actions.actions.logger import Logger from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index 0f569ebc..5f8e6252 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -7,6 +7,10 @@ from scos_actions import utils from scos_actions.capabilities import capabilities +from scos_actions.hardware.signal_analyzer_registration_handler import ( + signal_analyzer_registration_handler, +) +from scos_actions.initialization import signal_analyzer_monitor from scos_actions.settings import ( PRESELECTOR_CLASS, PRESELECTOR_CONFIG_FILE, @@ -18,9 +22,6 @@ register_signal_analyzer, ) from scos_actions.status.status_registration_handler import status_registration_handler -from scos_actions.status.signal_analyzer_registration_handler import ( - signal_analyzer_registration_handler, -) logger = logging.getLogger(__name__) @@ -74,6 +75,7 @@ def load_preselector(preselector_config, module, preselector_class_name): return ps +signal_analyzer_monitor = signal_analyzer_monitor register_signal_analyzer.connect(signal_analyzer_registration_handler) register_component_with_status.connect(status_registration_handler) logger.debug("Connected status registration handler") diff --git a/scos_actions/status/signal_analyzer_registration_handler.py b/scos_actions/hardware/signal_analyzer_registration_handler.py similarity index 86% rename from scos_actions/status/signal_analyzer_registration_handler.py rename to scos_actions/hardware/signal_analyzer_registration_handler.py index 01253a46..2555d6ba 100644 --- a/scos_actions/status/signal_analyzer_registration_handler.py +++ b/scos_actions/hardware/signal_analyzer_registration_handler.py @@ -1,6 +1,6 @@ import logging -from . import signal_analyzer_monitor +from scos_actions.core import signal_analyzer_monitor logger = logging.getLogger(__name__) diff --git a/scos_actions/status/__init__.py b/scos_actions/status/__init__.py index 2583372b..2d749073 100644 --- a/scos_actions/status/__init__.py +++ b/scos_actions/status/__init__.py @@ -1,8 +1,5 @@ import datetime -from .signal_analyzer_monitor import SignalAnalyzerMonitor -from .status_monitor import StatusMonitor +from scos_actions.core.status_monitor import StatusMonitor -status_registrar = StatusMonitor() -signal_analyzer_monitor = SignalAnalyzerMonitor() start_time = datetime.datetime.utcnow() diff --git a/scos_actions/status/status_registration_handler.py b/scos_actions/status/status_registration_handler.py index aed88be3..2cceec5e 100644 --- a/scos_actions/status/status_registration_handler.py +++ b/scos_actions/status/status_registration_handler.py @@ -1,6 +1,6 @@ import logging -from . import status_registrar +from scos_actions.core import status_registrar logger = logging.getLogger(__name__) From 8a3b2c220e31e53b0d38d39ef43fa09a2236c305 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 21:19:49 -0700 Subject: [PATCH 5/8] typo fix. --- scos_actions/core/signal_analyzer_monitor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scos_actions/core/signal_analyzer_monitor.py b/scos_actions/core/signal_analyzer_monitor.py index 94833b4a..eb68de07 100644 --- a/scos_actions/core/signal_analyzer_monitor.py +++ b/scos_actions/core/signal_analyzer_monitor.py @@ -6,12 +6,12 @@ class SignalAnalyzerMonitor: def __init__(self): logger.debug("Initializing Signal Analyzer Monitor") - self.signal_analyzer = None + self._signal_analyzer = None def register_signal_analyzer(self, sigan): logger.debug(f"Setting Signal Analyzer to {sigan}") - self.signal_analyzer = sigan + self._signal_analyzer = sigan @property def signal_analyzer(self): - return self.signal_analyzer + return self._signal_analyzer From 71da125f8f7100d1dc642c35f9de9e0f54ce32d7 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Mon, 8 Jan 2024 21:24:21 -0700 Subject: [PATCH 6/8] rename initialization import. --- scos_actions/hardware/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/hardware/__init__.py b/scos_actions/hardware/__init__.py index 5f8e6252..b8eef049 100644 --- a/scos_actions/hardware/__init__.py +++ b/scos_actions/hardware/__init__.py @@ -7,10 +7,10 @@ from scos_actions import utils from scos_actions.capabilities import capabilities +from scos_actions.core import signal_analyzer_monitor from scos_actions.hardware.signal_analyzer_registration_handler import ( signal_analyzer_registration_handler, ) -from scos_actions.initialization import signal_analyzer_monitor from scos_actions.settings import ( PRESELECTOR_CLASS, PRESELECTOR_CONFIG_FILE, From b2022e497dbf718d145ba37ae546e36fc5e3736d Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Tue, 9 Jan 2024 07:58:42 -0700 Subject: [PATCH 7/8] add test for sigan registration. --- scos_actions/discover/__init__.py | 6 +++++- scos_actions/discover/tests/test_sigan_registration.py | 10 ++++++++++ scos_actions/signals.py | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 scos_actions/discover/tests/test_sigan_registration.py diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 136e03df..661da6e2 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -7,12 +7,16 @@ from scos_actions.hardware.mocks.mock_gps import MockGPS from scos_actions.hardware.mocks.mock_sigan import MockSignalAnalyzer from scos_actions.settings import ACTION_DEFINITIONS_DIR, MOCK_SIGAN -from scos_actions.signals import register_component_with_status +from scos_actions.signals import ( + register_component_with_status, + register_signal_analyzer, +) mock_sigan = MockSignalAnalyzer(randomize_values=True) mock_gps = MockGPS() if MOCK_SIGAN: register_component_with_status.send(mock_sigan.__class__, component=mock_sigan) + register_signal_analyzer.send(__name__, signal_analzyer=mock_sigan) actions = {"logger": Logger()} test_actions = { "test_sync_gps": SyncGps( diff --git a/scos_actions/discover/tests/test_sigan_registration.py b/scos_actions/discover/tests/test_sigan_registration.py new file mode 100644 index 00000000..56ffb181 --- /dev/null +++ b/scos_actions/discover/tests/test_sigan_registration.py @@ -0,0 +1,10 @@ +import pytest +from scos_actions.core import signal_analyzer_monitor +from scos_actions.signals import register_signal_analyzer +from scos_actions.hardware.mocks.mock_sigan import MockSignalAnalyzer + + +def test_sigan_registration(): + sigan = MockSignalAnalyzer() + register_signal_analyzer.send(__name__, signal_analyzer=sigan) + assert signal_analyzer_monitor.signal_analyzer == sigan diff --git a/scos_actions/signals.py b/scos_actions/signals.py index 339f1919..1818e013 100644 --- a/scos_actions/signals.py +++ b/scos_actions/signals.py @@ -14,5 +14,5 @@ # Provides argument 'action' register_action = Signal() -# Provides argument 'sigan' +# Provides argument 'signal_analyzer' register_signal_analyzer = Signal() From 9a7309c226d60d4c961dfbf6b4ca226f06179a46 Mon Sep 17 00:00:00 2001 From: Doug Boulware Date: Tue, 9 Jan 2024 08:35:11 -0700 Subject: [PATCH 8/8] Increment version. --- scos_actions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scos_actions/__init__.py b/scos_actions/__init__.py index 54ccb5d2..73d4c8be 100644 --- a/scos_actions/__init__.py +++ b/scos_actions/__init__.py @@ -1 +1 @@ -__version__ = "7.1.0" +__version__ = "8.0.0"