From b2dfac3fed639e245dafe4cc115c3ed014ebe2b4 Mon Sep 17 00:00:00 2001 From: giles knap Date: Sun, 15 Dec 2024 13:38:37 +0000 Subject: [PATCH] fix "generic" bug --- src/builder2ibek/convert.py | 10 ++--- tests/samples/bl99p-ea-ioc-05.yaml | 4 +- tests/samples/sr03c-va-ioc-01.yaml | 66 +++++++++++++++--------------- tests/test_file_conversion.py | 9 ++++ 4 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/builder2ibek/convert.py b/src/builder2ibek/convert.py index ec23370..adf41c2 100644 --- a/src/builder2ibek/convert.py +++ b/src/builder2ibek/convert.py @@ -88,11 +88,11 @@ def do_one_element(element: Element, ioc: Generic_IOC): # then dispatch to a specific handler if there is one assert isinstance(element, Element) - info = ( - module_infos[element.module] - if element.module in module_infos - else module_infos["generic"] - ) + if element.module in module_infos: + info = module_infos[element.module] + else: + info = module_infos["generic"] + info.yaml_component = element.module entity.type = f"{info.yaml_component}.{element.name}" new_xml = info.handler(entity, element.name, ioc) diff --git a/tests/samples/bl99p-ea-ioc-05.yaml b/tests/samples/bl99p-ea-ioc-05.yaml index 68f0779..77179e4 100644 --- a/tests/samples/bl99p-ea-ioc-05.yaml +++ b/tests/samples/bl99p-ea-ioc-05.yaml @@ -16,7 +16,7 @@ entities: - type: epics.EpicsCaMaxArrayBytes max_bytes: 9000000 - - type: generic.andorCCD + - type: ADAndor.andorCCD ADDR: 0 BUFFERS: 2000 INSTALLPATH: /dls_sw/prod/R3.14.12.7/support/ANAndor/etc @@ -25,7 +25,7 @@ entities: R: ':CAM:' TIMEOUT: 1 - - type: generic.NDPosPlugin + - type: ADCore.NDPosPlugin ADDR: 0 BLOCK: 0 ENABLED: 1 diff --git a/tests/samples/sr03c-va-ioc-01.yaml b/tests/samples/sr03c-va-ioc-01.yaml index 9f63153..f3db468 100644 --- a/tests/samples/sr03c-va-ioc-01.yaml +++ b/tests/samples/sr03c-va-ioc-01.yaml @@ -29,68 +29,68 @@ entities: name: EPICS_CAS_BEACON_ADDR_LIST value: 172.23.194.105 - - type: generic.AsynIP + - type: asyn.AsynIP name: GCTLR_A_01_PORT port: 192.168.3.11:7002 - - type: generic.AsynIP + - type: asyn.AsynIP name: GCTLR_S_01_PORT port: 192.168.3.11:7003 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_S_01_PORT port: 192.168.3.11:7004 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_01_PORT port: 192.168.3.11:7005 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_02_PORT port: 192.168.3.11:7006 - - type: generic.AsynIP + - type: asyn.AsynIP name: RGA_PC_01_PORT port: 192.168.3.12:7001 - - type: generic.AsynIP + - type: asyn.AsynIP name: GCTLR_A_02_PORT port: 192.168.3.12:7003 - - type: generic.AsynIP + - type: asyn.AsynIP name: GCTLR_A_03_PORT port: 192.168.3.12:7004 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_03_PORT port: 192.168.3.12:7005 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_04_PORT port: 192.168.3.12:7006 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_05_PORT port: 192.168.3.12:7007 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_06_PORT port: 192.168.3.12:7008 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_07_PORT port: 192.168.3.12:7009 - - type: generic.AsynIP + - type: asyn.AsynIP name: MPC_A_08_PORT port: 192.168.3.12:7010 - - type: generic.FINSUDPInit + - type: FINS.FINSUDPInit ip: 192.168.3.10 name: VLVCC_01_FINS simulation: None - - type: generic.EtherIPInit + - type: ether_ip.EtherIPInit device: SR03C-VA-VLVCC-01 ip: 192.168.3.10 name: VLVCC_01.INFO @@ -561,37 +561,37 @@ entities: tag: V tagidx: 4 - - type: generic.rga + - type: rga.rga channel: 1 device: SR03S-VA-RGA-01 port: RGA_PC_01_PORT - - type: generic.rga + - type: rga.rga channel: 2 device: SR03A-VA-RGA-01 port: RGA_PC_01_PORT - - type: generic.rga + - type: rga.rga channel: 3 device: SR03A-VA-RGA-02 port: RGA_PC_01_PORT - - type: generic.rga + - type: rga.rga channel: 4 device: FE03I-VA-RGA-01 port: RGA_PC_01_PORT - - type: generic.rga + - type: rga.rga channel: 5 device: BL03I-VA-RGA-01 port: RGA_PC_01_PORT - - type: generic.rga + - type: rga.rga channel: 6 device: SR03I-VA-RGA-01 port: RGA_PC_01_PORT - - type: generic.spaceTemplate + - type: vacuumSpace.spaceTemplate device: SR03S-VA-SPACE-01 gauge: SR03S-VA-GGAUG-01 img: SR03S-VA-GIMG-01 @@ -599,7 +599,7 @@ entities: pirg: SR03S-VA-GPIRG-01 valve: SR03S-VA-GVALV-01 - - type: generic.spaceTemplate + - type: vacuumSpace.spaceTemplate device: SR03A-VA-SPACE-01 gauge: SR03A-VA-GGAUG-01 img: SR03A-VA-GIMG-01 @@ -607,7 +607,7 @@ entities: pirg: SR03A-VA-GPIRG-01 valve: SR03A-VA-GVALV-01 - - type: generic.spaceTemplate + - type: vacuumSpace.spaceTemplate device: SR03C-VA-SPACE-01 gauge: SR03C-VA-GGAUG-01 img: SR03C-VA-GIMG-01 @@ -813,7 +813,7 @@ entities: valve7: SR03S-VA-GVALV-01 valve8: SR03S-VA-GVALV-01 - - type: generic.rgaGroup + - type: rga.rgaGroup device: SR03C-VA-GRGA-01 rga1: SR03S-VA-RGA-01 rga2: SR03A-VA-RGA-01 @@ -907,7 +907,7 @@ entities: port: VLVCC_01_EIP tagidx: 2 - - type: generic.bi + - type: userIO.bi DESC: Rack 01 Fan Status DTYP: Soft Channel INP: SR03C-VA-VLVCC-01:DIGITAL01:RAWBIT.B0 CP @@ -921,7 +921,7 @@ entities: archiver_rate: 3600 Monitor name: VAFAN_01 - - type: generic.bi + - type: userIO.bi DESC: Rack 02 Fan Status DTYP: Soft Channel INP: SR03C-VA-VLVCC-01:DIGITAL01:RAWBIT.B1 CP @@ -935,7 +935,7 @@ entities: archiver_rate: 3600 Monitor name: VAFAN_02 - - type: generic.bi + - type: userIO.bi DESC: Rack 03 Fan Status DTYP: Soft Channel INP: SR03C-VA-VLVCC-01:DIGITAL01:RAWBIT.B2 CP @@ -949,7 +949,7 @@ entities: archiver_rate: 3600 Monitor name: VAFAN_03 - - type: generic.bi + - type: userIO.bi DESC: Rack 01 Duplex PSU Status DTYP: Soft Channel INP: SR03C-VA-VLVCC-01:DIGITAL01:RAWBIT.B3 CP @@ -963,7 +963,7 @@ entities: archiver_rate: 3600 Monitor name: VAPSU_01 - - type: generic.bi + - type: userIO.bi DESC: Rack 02 Duplex PSU Status DTYP: Soft Channel INP: SR03C-VA-VLVCC-01:DIGITAL01:RAWBIT.B4 CP @@ -1059,14 +1059,14 @@ entities: master: FV.MASTER name: FV.G8 - - type: generic.Moxa + - type: terminalServer.Moxa HOST: 192.168.3.11 NCHANS: 16 P: SR03C-VA-TSERV-01 R: '' name: TSERV1 - - type: generic.Moxa + - type: terminalServer.Moxa HOST: 192.168.3.12 NCHANS: 16 P: SR03C-VA-TSERV-02 diff --git a/tests/test_file_conversion.py b/tests/test_file_conversion.py index f9ad527..3ed400e 100644 --- a/tests/test_file_conversion.py +++ b/tests/test_file_conversion.py @@ -18,3 +18,12 @@ def test_convert(samples: Path): convert_file(sample_xml, out_yaml, "/epics/ibek-defs/ioc.schema.json") assert out_yaml.read_text() == sample_yaml.read_text() + + +def test_debug(samples: Path): + """ + A single test to debug the conversion process + """ + in_xml = samples / "BL99P-EA-IOC-05.xml" + out_yml = samples / "BL99P-EA-IOC-05.yaml" + convert_file(in_xml, out_yml, "/epics/ibek-defs/ioc.schema.json")