From 13884f1f3323e836f3398b63e6be6107594e306e Mon Sep 17 00:00:00 2001 From: Subin Saji Date: Wed, 3 Jan 2024 14:47:33 +0000 Subject: [PATCH 1/3] changes to make p46 GigE cameras work --- .vscode/launch.json | 25 +++++++++++++++++++++ src/builder2ibek/__main__.py | 2 +- src/builder2ibek/converters/ADAravis.py | 8 ++----- src/builder2ibek/converters/ADZMQ.py | 12 ++++++++++ src/builder2ibek/converters/epics_base.py | 5 +++++ src/builder2ibek/converters/ffmpegServer.py | 12 ++++++++++ src/builder2ibek/moduleinfos.py | 7 +++++- 7 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 src/builder2ibek/converters/ADZMQ.py create mode 100644 src/builder2ibek/converters/ffmpegServer.py diff --git a/.vscode/launch.json b/.vscode/launch.json index 6eba39c..cffcf30 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -43,6 +43,31 @@ // https://github.com/microsoft/vscode-python/issues/693 "PYTEST_ADDOPTS": "--no-cov" }, + }, + { + "name": "Builder2ibek-P46", + "type": "python", + "request": "launch", + "justMyCode": false, + "program": "/scratch/hgv27681/work/builder2ibek/src/builder2ibek/__main__.py", + "args": [ + "file", + "/scratch/wks59344/MXBridge/bl46p-builder/etc/makeIocs/BL46P-EA-IOC-01.xml", + "--yaml", + "/scratch/wks59344/MXBridge/bl46p/iocs/bl46p-ea-dcam-01/ioc.yaml", + "--schema", + "https://github.com/epics-containers/ioc-adaravis/releases/download/2023.11.4/ibek.ioc.schema.json" + ], + "purpose": [ + "debug-test" + ], + "console": "integratedTerminal", + "env": { + // The default config in setup.cfg's "[tool:pytest]" adds coverage. + // Cannot have coverage and debugging at the same time. + // https://github.com/microsoft/vscode-python/issues/693 + "PYTEST_ADDOPTS": "--no-cov" + }, } ] } \ No newline at end of file diff --git a/src/builder2ibek/__main__.py b/src/builder2ibek/__main__.py index c744e2d..076ceb5 100644 --- a/src/builder2ibek/__main__.py +++ b/src/builder2ibek/__main__.py @@ -63,7 +63,7 @@ def tidy_up(yaml): ruamel.default_flow_style = False # this attribute is for internal use, remove before serialising - setattr(ioc, "source_file", None) + delattr(ioc, "source_file") yaml_map = CommentedMap(ioc.model_dump()) # add support yaml schema diff --git a/src/builder2ibek/converters/ADAravis.py b/src/builder2ibek/converters/ADAravis.py index 04b10f0..107888f 100644 --- a/src/builder2ibek/converters/ADAravis.py +++ b/src/builder2ibek/converters/ADAravis.py @@ -1,17 +1,13 @@ from builder2ibek.types import Entity, Generic_IOC -xml_component = "aravisGigE" +xml_component = ["aravisGigE", "ADAravis"] # type in yaml differs from above field in XML yaml_component = "ADAravis" -schema = ( - "https://github.com/epics-containers/ioc-adaravis/releases/" - "download/2023.10.2b2/ibek.ioc.schema.json" -) - def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): if entity_type == "aravisCamera": + entity.remove("PV_ALIAS") if entity["CLASS"] == "AVT_Mako_1_52": entity["CLASS"] = "AVT_Mako_G125B" if entity["CLASS"] == "AVT_Mako_1_44": diff --git a/src/builder2ibek/converters/ADZMQ.py b/src/builder2ibek/converters/ADZMQ.py new file mode 100644 index 0000000..81c3ebd --- /dev/null +++ b/src/builder2ibek/converters/ADZMQ.py @@ -0,0 +1,12 @@ +from builder2ibek.types import Entity, Generic_IOC + +xml_component = "ADZMQ" + + +def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): + """ + XML to YAML specialist convertor function for the pvlogging support module + """ + + # TODO not supporting this yet - just remove it + entity.delete_me() diff --git a/src/builder2ibek/converters/epics_base.py b/src/builder2ibek/converters/epics_base.py index 3f996d2..464f681 100644 --- a/src/builder2ibek/converters/epics_base.py +++ b/src/builder2ibek/converters/epics_base.py @@ -9,6 +9,7 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): if entity["key"] == "EPICS_CA_MAX_ARRAY_BYTES": entity.rename("value", "max_bytes") entity.remove("key") + entity.remove("name") entity.type = "epics.EpicsCaMaxArrayBytes" else: entity.rename("key", "name") @@ -21,3 +22,7 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): else: entity.type = "epics.StartupCommand" entity.remove("post_init") + + elif entity_type == "dbpf": + entity.type = "epics.Dbpf" + entity.value = str({entity.value}) diff --git a/src/builder2ibek/converters/ffmpegServer.py b/src/builder2ibek/converters/ffmpegServer.py new file mode 100644 index 0000000..e21ea0c --- /dev/null +++ b/src/builder2ibek/converters/ffmpegServer.py @@ -0,0 +1,12 @@ +from builder2ibek.types import Entity, Generic_IOC + +xml_component = "ffmpegServer" + + +def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): + """ + XML to YAML specialist convertor function for the pvlogging support module + """ + + # TODO not supporting this yet - just remove it + entity.delete_me() diff --git a/src/builder2ibek/moduleinfos.py b/src/builder2ibek/moduleinfos.py index 0b06cc6..d1c2490 100644 --- a/src/builder2ibek/moduleinfos.py +++ b/src/builder2ibek/moduleinfos.py @@ -31,4 +31,9 @@ class ModuleInfo: getattr(module, "schema", ""), getattr(module, "yaml_component", xml_component), ) - module_infos[xml_component] = info + if isinstance(xml_component, str): + module_infos[xml_component] = info + + elif isinstance(xml_component, list): + for component in xml_component: + module_infos[component] = info From 8afa35f46a2e47d63dedae28ac0c4cfe6b739750 Mon Sep 17 00:00:00 2001 From: Subin Saji Date: Wed, 3 Jan 2024 14:53:39 +0000 Subject: [PATCH 2/3] fixed Gile's lintng errors --- src/builder2ibek/builder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/builder2ibek/builder.py b/src/builder2ibek/builder.py index fc03fa6..7da5565 100644 --- a/src/builder2ibek/builder.py +++ b/src/builder2ibek/builder.py @@ -4,7 +4,7 @@ from pathlib import Path from typing import List -from xml.dom.minidom import Element as DomElement +from xml.dom.minidom import Document, Element as DomElement from xml.dom.minidom import parse, parseString from builder2ibek.types import Element @@ -25,7 +25,7 @@ def load_string(self, xml_str: str): """ parse an XML string and populate this Builder object """ - self.file = "no_file" + self.file = Path("no_file") self.name = "no_name" xml = parseString(xml_str) self._parse(xml) @@ -39,7 +39,7 @@ def load(self, input_file: Path): xml = parse(str(input_file)) self._parse(xml) - def _parse(self, xml: DomElement): + def _parse(self, xml: Document): components = xml.firstChild assert isinstance(components, DomElement) assert components.tagName == "components" From 4a452d9e331fac2aa2b87aaa606761e14607f4f2 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Wed, 3 Jan 2024 15:04:32 +0000 Subject: [PATCH 3/3] fix ruff error --- src/builder2ibek/builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder2ibek/builder.py b/src/builder2ibek/builder.py index 7da5565..3c11ffc 100644 --- a/src/builder2ibek/builder.py +++ b/src/builder2ibek/builder.py @@ -4,8 +4,8 @@ from pathlib import Path from typing import List -from xml.dom.minidom import Document, Element as DomElement -from xml.dom.minidom import parse, parseString +from xml.dom.minidom import Document, parse, parseString +from xml.dom.minidom import Element as DomElement from builder2ibek.types import Element