Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/fastcs_odin/frame_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __parameter_in_plugin(
f"{self._api_prefix}",
self._ios,
)
self.add_sub_controller(plugin.upper(), plugin_controller)
self.add_sub_controller(plugin, plugin_controller)
await plugin_controller.initialise()


Expand All @@ -100,7 +100,7 @@ class FrameProcessorAdapterController(OdinDataAdapterController):
"fr_ready_cnxn",
"fr_release_cnxn",
]
_subcontroller_label = "FP"
_subcontroller_label = "fp"
_subcontroller_cls = FrameProcessorController

def _collect_commands(
Expand Down Expand Up @@ -187,14 +187,14 @@ def __dataset_parameter(param: OdinParameter):
dataset_parameters, self.parameters = partition(
self.parameters, __dataset_parameter
)
if dataset_parameters:
if dataset_parameters:
dataset_controller = FrameProcessorDatasetController(
self.connection,
dataset_parameters,
f"{self._api_prefix}",
self._ios,
)
self.add_sub_controller("DS", dataset_controller)
self.add_sub_controller("ds", dataset_controller)
await dataset_controller.initialise()

def _construct_command(self, command_name, plugin_name):
Expand Down
4 changes: 2 additions & 2 deletions src/fastcs_odin/frame_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __decoder_parameter(parameter: OdinParameter):
decoder_controller = FrameReceiverDecoderController(
self.connection, decoder_parameters, f"{self._api_prefix}", self._ios
)
self.add_sub_controller("DECODER", decoder_controller)
self.add_sub_controller("decoder", decoder_controller)
await decoder_controller.initialise()

for parameter in self.parameters:
Expand All @@ -36,7 +36,7 @@ def __decoder_parameter(parameter: OdinParameter):


class FrameReceiverAdapterController(OdinDataAdapterController):
_subcontroller_label = "FR"
_subcontroller_label = "fr"
_subcontroller_cls = FrameReceiverController
_unique_config = [
"rank",
Expand Down
2 changes: 1 addition & 1 deletion src/fastcs_odin/odin_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OdinDataAdapterController(ControllerVector):
"""Sub controller for the frame processor adapter in an odin control server."""

_unique_config: list[str] = []
_subcontroller_label: str = "OD"
_subcontroller_label: str = "od"
_subcontroller_cls: type[OdinSubController] = OdinSubController

def __init__(
Expand Down
38 changes: 19 additions & 19 deletions tests/test_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async def test_fp_create_plugin_sub_controllers(mocker: MockerFixture):
controllers = fpc.sub_controllers
match controllers:
case {
"HDF": FrameProcessorPluginController(
"hdf": FrameProcessorPluginController(
parameters=[
OdinParameter(
uri=["status", "hdf", "frames_written"],
Expand All @@ -268,10 +268,10 @@ async def test_fp_create_plugin_sub_controllers(mocker: MockerFixture):
]
)
}:
sub_controllers = controllers["HDF"].sub_controllers
assert "DS" in sub_controllers
assert isinstance(sub_controllers["DS"], OdinSubController)
assert sub_controllers["DS"].parameters == [
sub_controllers = controllers["hdf"].sub_controllers
assert "ds" in sub_controllers
assert isinstance(sub_controllers["ds"], OdinSubController)
assert sub_controllers["ds"].parameters == [
OdinParameter(
uri=["status", "hdf", "dataset", "compressed_size", "compression"],
_path=["compressed_size", "compression"],
Expand Down Expand Up @@ -337,25 +337,25 @@ async def test_status_summary_attribute_io():
hdf1_controller = Controller()
hdf2_controller = Controller()

controller.add_sub_controller("FP", fpa_controller)
fpa_controller.add_sub_controller("FP0", fp1_controller)
fpa_controller.add_sub_controller("FP1", fp2_controller)
fp1_controller.add_sub_controller("HDF", hdf1_controller)
fp2_controller.add_sub_controller("HDF", hdf2_controller)
controller.add_sub_controller("fp", fpa_controller)
fpa_controller.add_sub_controller("fp0", fp1_controller)
fpa_controller.add_sub_controller("fp1", fp2_controller)
fp1_controller.add_sub_controller("hdf", hdf1_controller)
fp2_controller.add_sub_controller("hdf", hdf2_controller)

io = StatusSummaryAttributeIO()

frames_written = AttrR(
Int(),
io_ref=StatusSummaryAttributeIORef(
["FP", re.compile("FP*"), "HDF"], "frames_written", partial(sum, start=0)
["fp", re.compile("fp*"), "hdf"], "frames_written", partial(sum, start=0)
),
)
controller.frames_written = frames_written
writing = AttrR(
Bool(),
io_ref=StatusSummaryAttributeIORef(
["FP", re.compile("FP*"), ("HDF",)], "writing", any
["fp", re.compile("fp*"), ("hdf",)], "writing", any
),
)
controller.writing = writing
Expand All @@ -380,14 +380,14 @@ async def test_status_summary_attribute_io():


@pytest.mark.asyncio
@pytest.mark.parametrize("mock_sub_controller", ("FP", ("FP",), re.compile("FP")))
@pytest.mark.parametrize("mock_sub_controller", ("fp", ("fp",), re.compile("fp")))
async def test_status_summary_updater_raise_exception_if_controller_not_found(
mock_sub_controller, mocker: MockerFixture
):
controller = Controller()

controller.writing = AttrR(
Bool(), StatusSummaryAttributeIORef(["OD", mock_sub_controller], "writing", any)
Bool(), StatusSummaryAttributeIORef(["od", mock_sub_controller], "writing", any)
)
with pytest.raises(ValueError, match=r"Sub controller .* not found"):
initialise_summary_attributes(controller)
Expand Down Expand Up @@ -436,9 +436,9 @@ async def test_frame_reciever_controllers():
assert isinstance(fr_controller, FrameReceiverController)
assert valid_non_decoder_parameter in fr_controller.parameters
assert len(fr_controller.parameters) == 1
assert "DECODER" in fr_controller.sub_controllers
assert "decoder" in fr_controller.sub_controllers

decoder_controller = fr_controller.sub_controllers["DECODER"]
decoder_controller = fr_controller.sub_controllers["decoder"]
assert isinstance(decoder_controller, FrameReceiverDecoderController)
assert valid_decoder_parameter in decoder_controller.parameters
assert invalid_decoder_parameter not in decoder_controller.parameters
Expand All @@ -457,7 +457,7 @@ async def test_frame_processor_start_and_stop_writing(mocker: MockerFixture):
await fpc._create_plugin_sub_controllers(["hdf"])

# Mock the commands to check calls
hdf = fpc.sub_controllers["HDF"]
hdf = fpc.sub_controllers["hdf"]
hdf.start_writing = mocker.AsyncMock() # type: ignore
hdf.stop_writing = mocker.AsyncMock() # type: ignore

Expand Down Expand Up @@ -493,10 +493,10 @@ async def test_status_summary_updater_raises_exception_if_attribute_not_found():
controller = Controller()
sub_controller = Controller()

controller.add_sub_controller("OD", sub_controller)
controller.add_sub_controller("od", sub_controller)

controller.writing = AttrR(
Bool(), StatusSummaryAttributeIORef(["OD"], "some_attribute", any)
Bool(), StatusSummaryAttributeIORef(["od"], "some_attribute", any)
)
with pytest.raises(KeyError, match=r"Sub controller .* does not have attribute"):
initialise_summary_attributes(controller)
Loading