-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Register signal analyzer signal/signal analyzer monitor #107
Changes from all commits
5e28250
bb42996
588fb6f
eba51a9
8a3b2c2
71da125
b2022e4
9a7309c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "7.1.0" | ||
__version__ = "8.0.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .signal_analyzer_monitor import SignalAnalyzerMonitor | ||
from .status_monitor import StatusMonitor | ||
|
||
signal_analyzer_monitor = SignalAnalyzerMonitor() | ||
status_registrar = StatusMonitor() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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 | ||
|
||
@property | ||
def signal_analyzer(self): | ||
return self._signal_analyzer |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,20 @@ | |
|
||
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.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,6 +75,8 @@ def load_preselector(preselector_config, module, preselector_class_name): | |
return ps | ||
|
||
|
||
signal_analyzer_monitor = signal_analyzer_monitor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line seems to be unnecessary |
||
register_signal_analyzer.connect(signal_analyzer_registration_handler) | ||
register_component_with_status.connect(status_registration_handler) | ||
logger.debug("Connected status registration handler") | ||
preselector = load_preselector_from_file(PRESELECTOR_CONFIG_FILE) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import logging | ||
|
||
from scos_actions.core import signal_analyzer_monitor | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def signal_analyzer_registration_handler(sender, **kwargs): | ||
try: | ||
logger.debug(f"Registering {sender} as status provider") | ||
signal_analyzer_monitor.register_signal_analyzer(kwargs["signal_analyzer"]) | ||
except: | ||
logger.exception("Error registering signal analyzer") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import datetime | ||
|
||
from .status_monitor import StatusMonitor | ||
|
||
status_registrar = StatusMonitor() | ||
from scos_actions.core.status_monitor import StatusMonitor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this import is no longer needed since the |
||
|
||
start_time = datetime.datetime.utcnow() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest including a type hint here and on the property below to indicate that these expect/return instances of
SignalAnalyzerInterface