Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1014 from ess-dmsc/ECDC-3265_fixing_se00_type
Browse files Browse the repository at this point in the history
ECDC-3265 fixing se00 type
  • Loading branch information
hurvan authored Dec 16, 2022
2 parents bef2b44 + fc5e593 commit b815d06
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
21 changes: 19 additions & 2 deletions nexus_constructor/model/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ class NS10Stream(StreamModule):

@attr.s
class SE00Stream(StreamModule):
type = attr.ib(type=str)
writer_module = attr.ib(type=str, default=WriterModules.SE00.value, init=False)

def as_dict(self, error_collector: List[str]):
module_dict = StreamModule.as_dict(self, error_collector)
if self.type:
module_dict[NodeType.CONFIG][CommonKeys.DATA_TYPE] = self.type
return module_dict


@attr.s
class SENVStream(StreamModule):
Expand Down Expand Up @@ -320,9 +327,7 @@ def create_fw_module_object(mod_type, configuration, parent_node):
fw_mod_class = module_class_dict[mod_type]
if mod_type in [
WriterModules.NS10.value,
WriterModules.SE00.value,
WriterModules.SENV.value,
WriterModules.SE00.value,
WriterModules.TDCTIME.value,
WriterModules.EV42.value,
WriterModules.EV44.value,
Expand All @@ -334,6 +339,18 @@ def create_fw_module_object(mod_type, configuration, parent_node):
source=configuration[SOURCE],
parent_node=parent_node,
)
elif mod_type == WriterModules.SE00.value:
se00_type = None
if CommonKeys.TYPE in configuration:
se00_type = configuration[CommonKeys.TYPE]
elif CommonKeys.DATA_TYPE in configuration:
se00_type = configuration[CommonKeys.DATA_TYPE]
fw_mod_obj = fw_mod_class(
topic=configuration[TOPIC],
source=configuration[SOURCE],
parent_node=parent_node,
type=se00_type,
)
elif mod_type in [WriterModules.F142.value, WriterModules.F144.value]:
schema_type = None
if CommonKeys.TYPE in configuration:
Expand Down
25 changes: 23 additions & 2 deletions nexus_constructor/stream_fields_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@
"string",
]

SE00_TYPES = [
"byte",
"ubyte",
"short",
"ushort",
"int",
"uint",
"long",
"ulong",
"float",
"double",
]


def check_if_advanced_options_should_be_enabled(advanced_fields) -> bool:
"""
Expand Down Expand Up @@ -477,13 +490,16 @@ def _schema_type_changed(self, schema: str):
self.show_advanced_options_button.setChecked(False)
self.value_units_label.setVisible(False)
self.value_units_edit.setVisible(False)
self.type_combo.clear()
self._show_array_size_table(False)
if schema in [WriterModules.F142.value, WriterModules.F144.value]:
self.value_units_label.setVisible(True)
self.value_units_edit.setVisible(True)
self._set_edits_visible(True, True)
self.show_advanced_options_button.setVisible(True)
self.f142_advanced_group_box.setVisible(False)
self.type_combo.addItems(F142_TYPES)
self.type_combo.setCurrentText("double")
elif schema in [WriterModules.EV42.value, WriterModules.EV44.value]:
self._set_edits_visible(True, False)
self.show_advanced_options_button.setVisible(True)
Expand All @@ -499,9 +515,12 @@ def _schema_type_changed(self, schema: str):
self.show_advanced_options_button.setVisible(True)
elif schema == WriterModules.NS10.value:
self._set_edits_visible(True, False, "nicos/<device>/<parameter>")
elif schema == WriterModules.SE00.value:
self._set_edits_visible(True, True)
self.type_combo.addItems(SE00_TYPES)
self.type_combo.setCurrentText("double")
elif schema in [
WriterModules.TDCTIME.value,
WriterModules.SE00.value,
WriterModules.SENV.value,
]:
self._set_edits_visible(True, False)
Expand Down Expand Up @@ -591,7 +610,9 @@ def get_stream_module(self, parent) -> StreamModule:
elif current_schema == WriterModules.NS10.value:
stream = NS10Stream(parent_node=parent, source=source, topic=topic)
elif current_schema == WriterModules.SE00.value:
stream = SE00Stream(parent_node=parent, source=source, topic=topic)
stream = SE00Stream(
parent_node=parent, source=source, topic=topic, type=type
)
elif current_schema == WriterModules.SENV.value:
stream = SENVStream(parent_node=parent, source=source, topic=topic)
elif current_schema == WriterModules.HS01.value:
Expand Down
15 changes: 14 additions & 1 deletion tests/model/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def test_GIVEN_dataset_with_array_value_WHEN_adding_dataset_THEN_dataset_object_
@pytest.mark.parametrize(
"stream",
[
SE00Stream(parent_node=None, source=source, topic=topic),
SENVStream(parent_node=None, source=source, topic=topic),
TDCTStream(parent_node=None, source=source, topic=topic),
NS10Stream(parent_node=None, source=source, topic=topic),
Expand All @@ -111,6 +110,20 @@ def test_streams_with_name_source_and_topic(stream):
assert stream_dict["source"] == source


def test_se00_stream_optional_settings():
type = "double"
stream = SE00Stream(
parent_node=None,
source=source,
topic=topic,
type=type,
)
stream_dict = stream.as_dict([])["config"]
assert stream_dict["topic"] == topic
assert stream_dict["source"] == source
assert stream_dict["dtype"] == type


def test_f142_stream_optional_settings():
type = "double"
value_units = "m"
Expand Down

0 comments on commit b815d06

Please sign in to comment.