From d88b9e8a769796e0e79878f2b918ea734f3667e8 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Fri, 21 Jun 2024 05:32:42 +0000 Subject: [PATCH] enable regex database args --- src/ibek/render_db.py | 18 +- tests/generate_samples.sh | 13 + tests/samples/iocs/dlsPLC.ibek.ioc.yaml | 18 + tests/samples/outputs/dlsPLC/index.bob | 28 + tests/samples/outputs/dlsPLC/ioc.subst | 9 + tests/samples/outputs/dlsPLC/st.cmd | 19 + .../schemas/dlsPLC.ibek.ioc.schema.json | 617 +++++++++++++++++ .../samples/support/dlsPLC.ibek.support.yaml | 643 ++++++++++++++++++ tests/test_cli.py | 12 + tests/test_support.py | 1 + 10 files changed, 1377 insertions(+), 1 deletion(-) create mode 100644 tests/samples/iocs/dlsPLC.ibek.ioc.yaml create mode 100644 tests/samples/outputs/dlsPLC/index.bob create mode 100644 tests/samples/outputs/dlsPLC/ioc.subst create mode 100644 tests/samples/outputs/dlsPLC/st.cmd create mode 100644 tests/samples/schemas/dlsPLC.ibek.ioc.schema.json create mode 100644 tests/samples/support/dlsPLC.ibek.support.yaml diff --git a/src/ibek/render_db.py b/src/ibek/render_db.py index 514953290..303cda078 100644 --- a/src/ibek/render_db.py +++ b/src/ibek/render_db.py @@ -3,6 +3,7 @@ support module yaml files. """ +import re from dataclasses import dataclass from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple @@ -74,7 +75,22 @@ def add_database(self, database: Database, entity: Entity) -> None: if str_to_bool(UTILS.render(entity, database.enabled)): database.file = database.file.strip("\n") + parameters = entity.__dict__.keys() + # take each database parameter and expand it into the set of + # entity parameters that it matches using regex + expanded_database_entries: dict[str, str] = {} for arg, value in database.args.items(): + if "*" in arg or "?" in arg: + # this is a regex - match the parameters to the regex + for parameter in parameters: + if re.match(arg, parameter): + # TODO - should we perform regex subst on the value as well? + expanded_database_entries[parameter] = value + else: + # simple db argument name + expanded_database_entries[arg] = value + + for arg, value in expanded_database_entries.items(): if value is None: if arg not in entity.__dict__ and arg not in UTILS.variables: raise ValueError( @@ -82,7 +98,7 @@ def add_database(self, database: Database, entity: Entity) -> None: f"'{database.file}' not found in context" ) - self.add_row(database.file, database.args, entity) + self.add_row(database.file, expanded_database_entries, entity) def add_extra_databases(self, databases: List[Tuple[Database, Entity]]) -> None: """Add databases that are not part of EntityModels diff --git a/tests/generate_samples.sh b/tests/generate_samples.sh index 05f07d84b..ce41ecccc 100755 --- a/tests/generate_samples.sh +++ b/tests/generate_samples.sh @@ -127,3 +127,16 @@ ibek ioc generate-schema --no-ibek-defs support/fastVacuum.ibek.support.yaml --o echo making fastVacuum ioc EPICS_ROOT=`pwd`/epics ibek runtime generate iocs/fastVacuum.ibek.ioc.yaml support/fastVacuum.ibek.support.yaml mv `pwd`/epics/{runtime,opi}/* `pwd`/outputs/fastVacuum + + + +############################################################################ +# vacValveDebounce (dlsPLC) example +############################################################################ + +echo making an ioc schema using dlsPLC support yaml +ibek ioc generate-schema --no-ibek-defs support/dlsPLC.ibek.support.yaml support/asyn.ibek.support.yaml --output schemas/dlsPLC.ibek.ioc.schema.json + +echo making fastVacuum ioc +EPICS_ROOT=`pwd`/epics ibek runtime generate iocs/dlsPLC.ibek.ioc.yaml support/dlsPLC.ibek.support.yaml support/asyn.ibek.support.yaml +mv `pwd`/epics/{runtime,opi}/* `pwd`/outputs/dlsPLC diff --git a/tests/samples/iocs/dlsPLC.ibek.ioc.yaml b/tests/samples/iocs/dlsPLC.ibek.ioc.yaml new file mode 100644 index 000000000..eb4681ded --- /dev/null +++ b/tests/samples/iocs/dlsPLC.ibek.ioc.yaml @@ -0,0 +1,18 @@ +# yaml-language-server: $schema=../schemas/dlsPLC.ibek.ioc.schema.json + +ioc_name: "{{ _global.get_env('IOC_NAME') }}" + +description: auto-generated by https://github.com/epics-containers/builder2ibek + +entities: + - type: asyn.AsynIP + name: VLVCC_01_EIP + port: DUMMY + + - type: dlsPLC.NX102_vacValveDebounce + ILKNUM: 1 + device: SR03A-VA-VALVE-01 + name: V1 + port: VLVCC_01_EIP + tag: V + tagidx: 1 diff --git a/tests/samples/outputs/dlsPLC/index.bob b/tests/samples/outputs/dlsPLC/index.bob new file mode 100644 index 000000000..e8793a481 --- /dev/null +++ b/tests/samples/outputs/dlsPLC/index.bob @@ -0,0 +1,28 @@ + + + 0 + 0 + 10 + 35 + 4 + 4 + + Title + TITLE + Title + 0 + 0 + 10 + 25 + + + + + + + + + true + 1 + + diff --git a/tests/samples/outputs/dlsPLC/ioc.subst b/tests/samples/outputs/dlsPLC/ioc.subst new file mode 100644 index 000000000..3fab9218b --- /dev/null +++ b/tests/samples/outputs/dlsPLC/ioc.subst @@ -0,0 +1,9 @@ +############################################################################# +# DB substitution file generated by http://github.com/epics-containers/ibek # +############################################################################# + +file "$(DLSPLC)/db/NX102_vacValveDebounce.template" { +pattern + { "type", "entity_enabled", "mode1", "mode2", "ilksta_sv0", "ilksta_sv1", "ilksta_sv2", "ilksta_sv3", "ilksta_sv4", "ilksta_sv5", "ilksta_label0", "ilksta_label1", "ilksta_label2", "ilksta_label3", "ilksta_label4", "ilksta_label5", "sta_sv0", "sta_sv1", "sta_sv2", "sta_sv3", "sta_sv4", "sta_sv5", "sta_sv6", "sta_label0", "sta_label1", "sta_label2", "sta_label3", "sta_label4", "sta_label5", "sta_label6", "con_label0", "con_label1", "con_label2", "con_label3", "con_label4", "con_label5", "con_label6", "whylocked", "allowpv", "tagidx", "tag", "ILKNUM", "device", "port", "con_label7", "sta_label7", "sta_sv7", "ilksta_label6", "ilksta_label7", "ilksta_sv6", "ilksta_sv7", "DIRILK1", "DIRILK2", "name", "desc" } + { "dlsPLC.NX102_vacValveDebounce", "True", "Operational", "Service", "MAJOR", "NO_ALARM", "NO_ALARM", "NO_ALARM", "NO_ALARM", "NO_ALARM", "Failed", "Run Ilks Ok", "OK", "Disarmed", "", "", "MAJOR", "NO_ALARM", "NO_ALARM", "NO_ALARM", "NO_ALARM", "NO_ALARM", "NO_ALARM", "Fault", "Open", "Opening", "Closed", "Closing", "", "", "Open", "Close", "Reset", "", "", "", "", "Open command not allowed", "", "1", "V", "1", "SR03A-VA-VALVE-01", "VLVCC_01_EIP", "", "", "NO_ALARM", "", "", "NO_ALARM", "NO_ALARM", "", "ILK2", "V1", "$(device)" } +} diff --git a/tests/samples/outputs/dlsPLC/st.cmd b/tests/samples/outputs/dlsPLC/st.cmd new file mode 100644 index 000000000..c57f22c62 --- /dev/null +++ b/tests/samples/outputs/dlsPLC/st.cmd @@ -0,0 +1,19 @@ +# EPICS IOC Startup Script generated by https://github.com/epics-containers/ibek + +cd "/epics/ioc" + +epicsEnvSet NAME_AS_ENV_VAR my name is VLVCC_01_EIP + +dbLoadDatabase dbd/ioc.dbd +ioc_registerRecordDeviceDriver pdbbase + +# Setting up Asyn Port VLVCC_01_EIP on DUMMY: +# AsynIPConfigure({{name}}, {{port}}, {{stop}}, {{parity}}, {{bits}}) +AsynIPConfigure(VLVCC_01_EIP, DUMMY, 1, none, 8) +asynSetOption(9600, 0, N, Y) +asynOctetSetInputEos("\n") +asynOctetSetOutputEos("\n") + +dbLoadRecords /epics/runtime/ioc.db +iocInit + diff --git a/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json new file mode 100644 index 000000000..919b7670f --- /dev/null +++ b/tests/samples/schemas/dlsPLC.ibek.ioc.schema.json @@ -0,0 +1,617 @@ +{ + "$defs": { + "asyn_AsynIP": { + "additionalProperties": false, + "properties": { + "type": { + "const": "asyn.AsynIP", + "description": "Asyn IP Port", + "enum": [ + "asyn.AsynIP" + ], + "title": "Type", + "type": "string" + }, + "entity_enabled": { + "default": true, + "description": "enable or disable this entity instance", + "title": "Entity Enabled", + "type": "boolean" + }, + "port": { + "description": "Serial port tty name / IP address optionally followed by protocol", + "title": "Port", + "type": "string" + }, + "name": { + "description": "Override name", + "title": "Name", + "type": "string" + }, + "input_eos": { + "default": "\"\\n\"", + "description": "Input end of string (terminator)", + "title": "Input Eos", + "type": "string" + }, + "output_eos": { + "default": "\"\\n\"", + "description": "Output end of string (terminator)", + "title": "Output Eos", + "type": "string" + }, + "priority": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Priority", + "type": "integer" + } + ], + "default": 100, + "description": "union of and jinja representation of {typ}", + "title": "Priority" + }, + "noAuto_connect": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Set to stop auto_connect", + "type": "boolean" + } + ], + "default": false, + "description": "union of and jinja representation of {typ}", + "title": "Noauto Connect" + }, + "noProcessEos": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Set to avoid processing end of string", + "type": "boolean" + } + ], + "default": false, + "description": "union of and jinja representation of {typ}", + "title": "Noprocesseos" + }, + "baud": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Baud Rate", + "type": "integer" + } + ], + "default": 9600, + "description": "union of and jinja representation of {typ}", + "title": "Baud" + }, + "parity": { + "allOf": [ + { + "$ref": "#/$defs/parity" + } + ], + "default": "none", + "description": "Parity" + }, + "crtscts": { + "allOf": [ + { + "$ref": "#/$defs/crtscts" + } + ], + "default": "N", + "description": "Set hardware flow control on" + }, + "stop": { + "allOf": [ + { + "$ref": "#/$defs/stop" + } + ], + "default": "1", + "description": "Stop Bits" + }, + "disconnectOnReadTimeout": { + "allOf": [ + { + "$ref": "#/$defs/disconnectOnReadTimeout" + } + ], + "default": "Y", + "description": "Disconnect when a read times out" + }, + "bits": { + "allOf": [ + { + "$ref": "#/$defs/bits" + } + ], + "default": "8", + "description": "Bits" + } + }, + "required": [ + "type", + "port", + "name" + ], + "title": "asyn_AsynIP", + "type": "object" + }, + "bits": { + "enum": [ + "8", + "5", + "7", + "6" + ], + "title": "bits", + "type": "string" + }, + "crtscts": { + "enum": [ + "Y", + "N" + ], + "title": "crtscts", + "type": "string" + }, + "disconnectOnReadTimeout": { + "enum": [ + "Y", + "N" + ], + "title": "disconnectOnReadTimeout", + "type": "string" + }, + "dlsPLC_NX102_vacValveDebounce": { + "additionalProperties": false, + "properties": { + "type": { + "const": "dlsPLC.NX102_vacValveDebounce", + "description": "Template database for a vacuum valve without debounce or raw air records", + "enum": [ + "dlsPLC.NX102_vacValveDebounce" + ], + "title": "Type", + "type": "string" + }, + "entity_enabled": { + "default": true, + "description": "enable or disable this entity instance", + "title": "Entity Enabled", + "type": "boolean" + }, + "mode1": { + "default": "Operational", + "description": "name of remote operational mode (:MODE)", + "title": "Mode1", + "type": "string" + }, + "mode2": { + "default": "Service", + "description": "name of local operational mode (:MODE)", + "title": "Mode2", + "type": "string" + }, + "ilksta_sv0": { + "default": "MAJOR", + "description": "Template argument", + "title": "Ilksta Sv0", + "type": "string" + }, + "ilksta_sv1": { + "default": "NO_ALARM", + "description": "Template argument", + "title": "Ilksta Sv1", + "type": "string" + }, + "ilksta_sv2": { + "default": "NO_ALARM", + "description": "Template argument", + "title": "Ilksta Sv2", + "type": "string" + }, + "ilksta_sv3": { + "default": "NO_ALARM", + "description": "Template argument", + "title": "Ilksta Sv3", + "type": "string" + }, + "ilksta_sv4": { + "default": "NO_ALARM", + "description": "Template argument", + "title": "Ilksta Sv4", + "type": "string" + }, + "ilksta_sv5": { + "default": "NO_ALARM", + "description": "Template argument", + "title": "Ilksta Sv5", + "type": "string" + }, + "ilksta_label0": { + "default": "Failed", + "description": "Template argument", + "title": "Ilksta Label0", + "type": "string" + }, + "ilksta_label1": { + "default": "Run Ilks Ok", + "description": "Template argument", + "title": "Ilksta Label1", + "type": "string" + }, + "ilksta_label2": { + "default": "OK", + "description": "Template argument", + "title": "Ilksta Label2", + "type": "string" + }, + "ilksta_label3": { + "default": "Disarmed", + "description": "Template argument", + "title": "Ilksta Label3", + "type": "string" + }, + "ilksta_label4": { + "default": "", + "description": "Template argument", + "title": "Ilksta Label4", + "type": "string" + }, + "ilksta_label5": { + "default": "", + "description": "Template argument", + "title": "Ilksta Label5", + "type": "string" + }, + "sta_sv0": { + "default": "MAJOR", + "description": "Alarm severity for status value 0.", + "title": "Sta Sv0", + "type": "string" + }, + "sta_sv1": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 1.", + "title": "Sta Sv1", + "type": "string" + }, + "sta_sv2": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 2.", + "title": "Sta Sv2", + "type": "string" + }, + "sta_sv3": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 3.", + "title": "Sta Sv3", + "type": "string" + }, + "sta_sv4": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 4.", + "title": "Sta Sv4", + "type": "string" + }, + "sta_sv5": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 5.", + "title": "Sta Sv5", + "type": "string" + }, + "sta_sv6": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 6.", + "title": "Sta Sv6", + "type": "string" + }, + "sta_label0": { + "default": "Fault", + "description": "Label string for status value 0", + "title": "Sta Label0", + "type": "string" + }, + "sta_label1": { + "default": "Open", + "description": "Label string for status value 1", + "title": "Sta Label1", + "type": "string" + }, + "sta_label2": { + "default": "Opening", + "description": "Label string for status value 2", + "title": "Sta Label2", + "type": "string" + }, + "sta_label3": { + "default": "Closed", + "description": "Label string for status value 3", + "title": "Sta Label3", + "type": "string" + }, + "sta_label4": { + "default": "Closing", + "description": "Label string for status value 4", + "title": "Sta Label4", + "type": "string" + }, + "sta_label5": { + "default": "", + "description": "Label string for status value 5", + "title": "Sta Label5", + "type": "string" + }, + "sta_label6": { + "default": "", + "description": "Label string for status value 6", + "title": "Sta Label6", + "type": "string" + }, + "con_label0": { + "default": "Open", + "description": "Label string for control value 0", + "title": "Con Label0", + "type": "string" + }, + "con_label1": { + "default": "Close", + "description": "Label string for control value 1", + "title": "Con Label1", + "type": "string" + }, + "con_label2": { + "default": "Reset", + "description": "Label string for control value 2", + "title": "Con Label2", + "type": "string" + }, + "con_label3": { + "default": "", + "description": "Label string for control value 3", + "title": "Con Label3", + "type": "string" + }, + "con_label4": { + "default": "", + "description": "Label string for control value 4", + "title": "Con Label4", + "type": "string" + }, + "con_label5": { + "default": "", + "description": "Label string for control value 5", + "title": "Con Label5", + "type": "string" + }, + "con_label6": { + "default": "", + "description": "Label string for control value 6", + "title": "Con Label6", + "type": "string" + }, + "whylocked": { + "default": "Open command not allowed", + "description": "String to output to EDM synoptic as to precisely why the device is locked and by whom", + "title": "Whylocked", + "type": "string" + }, + "allowpv": { + "default": "", + "description": "If specified, then only write an open command when this is non-zero. MUST have CP at the end of it", + "title": "Allowpv", + "type": "string" + }, + "tagidx": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Template argument", + "type": "integer" + } + ], + "description": "union of and jinja representation of {typ}", + "title": "Tagidx" + }, + "tag": { + "description": "NX PLC tag string e.g. V (from V.Control[1])", + "title": "Tag", + "type": "string" + }, + "ILKNUM": { + "anyOf": [ + { + "description": "jinja that renders to ", + "pattern": ".*\\{\\{.*\\}\\}.*", + "type": "string" + }, + { + "description": "Part of Gauge PLC tag (Gauge.PIRG[dollar(ILKNUM)])", + "type": "integer" + } + ], + "description": "union of and jinja representation of {typ}", + "title": "Ilknum" + }, + "device": { + "description": "device name", + "title": "Device", + "type": "string" + }, + "port": { + "description": "EtherIP Port Name", + "title": "Port", + "type": "string" + }, + "con_label7": { + "default": "", + "description": "Label string for control value 7 (Optional - defaults to \"\")", + "title": "Con Label7", + "type": "string" + }, + "sta_label7": { + "default": "", + "description": "Label string for status value 7 (Optional - defaults to \"\")", + "title": "Sta Label7", + "type": "string" + }, + "sta_sv7": { + "default": "NO_ALARM", + "description": "Alarm severity for status value 7 (Optional - defaults to NO_ALARM)", + "title": "Sta Sv7", + "type": "string" + }, + "ilksta_label6": { + "default": "", + "description": "Label string for status value 6 (Optional - defaults to \"\")", + "title": "Ilksta Label6", + "type": "string" + }, + "ilksta_label7": { + "default": "", + "description": "Label string for status value 7 (Optional - defaults to \"\")", + "title": "Ilksta Label7", + "type": "string" + }, + "ilksta_sv6": { + "default": "NO_ALARM", + "description": "Alarm severity for interlock status value 6 (Optional - defaults to NO_ALARM)", + "title": "Ilksta Sv6", + "type": "string" + }, + "ilksta_sv7": { + "default": "NO_ALARM", + "description": "Alarm severity for interlock status value 7 (Optional - defaults to NO_ALARM)", + "title": "Ilksta Sv7", + "type": "string" + }, + "DIRILK1": { + "default": "", + "description": "Part of ILK1 PV name (dollar(device):dollar(DIRILK1)ILK), named for \"direction\" of operation controlled by ILK1, e.g. set to OPEN for Bistable valve or leave blank for ordinary valve. (Optional - defaults to \"\")", + "title": "Dirilk1", + "type": "string" + }, + "DIRILK2": { + "default": "ILK2", + "description": "Part of ILK2 PV name (dollar(device):dollar(DIRILK2)ILK), named for \"direction\" of operation controlled by ILK2, e.g. set to CLOSE for Bistable valves (Optional - defaults to \"ILK2\")", + "title": "Dirilk2", + "type": "string" + }, + "name": { + "description": "Object name and associated gui name (Optional - defaults to \"\")", + "title": "Name", + "type": "string" + }, + "desc": { + "default": "$(device)", + "description": "Box label for gui (Optional - defaults to value of device macro)", + "title": "Desc", + "type": "string" + } + }, + "required": [ + "type", + "tagidx", + "tag", + "ILKNUM", + "device", + "port", + "name" + ], + "title": "dlsPLC_NX102_vacValveDebounce", + "type": "object" + }, + "parity": { + "enum": [ + "even", + "none", + "odd" + ], + "title": "parity", + "type": "string" + }, + "stop": { + "enum": [ + "1", + "2" + ], + "title": "stop", + "type": "string" + } + }, + "additionalProperties": false, + "properties": { + "ioc_name": { + "description": "Name of IOC instance", + "title": "Ioc Name", + "type": "string" + }, + "description": { + "description": "Description of what the IOC does", + "title": "Description", + "type": "string" + }, + "entities": { + "description": "List of entities this IOC instantiates", + "items": { + "discriminator": { + "mapping": { + "asyn.AsynIP": "#/$defs/asyn_AsynIP", + "dlsPLC.NX102_vacValveDebounce": "#/$defs/dlsPLC_NX102_vacValveDebounce" + }, + "propertyName": "type" + }, + "oneOf": [ + { + "$ref": "#/$defs/dlsPLC_NX102_vacValveDebounce" + }, + { + "$ref": "#/$defs/asyn_AsynIP" + } + ] + }, + "title": "Entities", + "type": "array" + }, + "shared": { + "default": [], + "description": "A place to create any anchors required for repeating YAML", + "items": {}, + "title": "Shared", + "type": "array" + } + }, + "required": [ + "ioc_name", + "description", + "entities" + ], + "title": "NewIOC", + "type": "object" +} \ No newline at end of file diff --git a/tests/samples/support/dlsPLC.ibek.support.yaml b/tests/samples/support/dlsPLC.ibek.support.yaml new file mode 100644 index 000000000..4413cdddb --- /dev/null +++ b/tests/samples/support/dlsPLC.ibek.support.yaml @@ -0,0 +1,643 @@ +# yaml-language-server: $schema=../schemas/ibek.support.schema.json + +# an excerpt from the dlsPLC.ibek.support.yaml file to test the following +# features: +# - anchors and aliases +# - use of <<: [*alias1, *alias2] to merge multiple aliases into a single Parameter +# - use of regex in database arguments (see .*) + +shared: + # These shared sections are used to define common parameters for the + # various Definitions described in the dlsPLC.ibek.support.yaml file. + # + # They are in the form of anchors that can be merged into each Definition + # via aliases. This allows for a more DRY approach and makes the file + # considerably smaller. + # + # e.g. + # + # params: + # <<: [*ilk, *gilk, *cilk, *con_label, *sta_label, *sta_sv, *ilksta, *ilksta_sv] + # con_label0: + # type: str + # description: |- + # Label string for control value 0 + # default: On + # + # merges all the shared sections into the params section of a Definition, but + # would still allow override of individual parameters as shown for con_label0. + + - PQ: &PQ + P: + type: str + description: |- + Device Prefix + Q: + type: str + description: |- + Device Suffix + + - tagidx: &tagidx + tagidx: + type: int + description: |- + Template argument + + - tag: &tag + tag: + type: str + description: |- + NX PLC tag string e.g. V (from V.Control[1]) + ILKNUM: + type: int + description: |- + Part of Gauge PLC tag (Gauge.PIRG[dollar(ILKNUM)]) + + - delay: &delay + delay: + type: int + description: |- + delay between opening valves + + - vlvcc: &vlvcc + vlvcc: + type: str + description: |- + device name of valve control crate (prefix of device name), NOTE: make sure there is a read100 component whose century (0 means 0-99) includes the object address + addr: + type: str + description: |- + First address in the DM variable range decade. E.g. if valve is in DM110..119 then addr=110 + + - ilk: &ilk + ilk0: + type: str + description: |- + Interlock description 0 + default: unused + ilk1: + type: str + description: |- + Interlock description 1 + default: unused + ilk2: + type: str + description: |- + Interlock description 2 + default: unused + ilk3: + type: str + description: |- + Interlock description 3 + default: unused + ilk4: + type: str + description: |- + Interlock description 4 + default: unused + ilk5: + type: str + description: |- + Interlock description 5 + default: unused + ilk6: + type: str + description: |- + Interlock description 6 + default: unused + ilk7: + type: str + description: |- + Interlock description 7 + default: unused + ilk8: + type: str + description: |- + Interlock description 8 + default: unused + ilk9: + type: str + description: |- + Interlock description 9 + default: unused + ilk10: + type: str + description: |- + Interlock description 10 + default: unused + ilk11: + type: str + description: |- + Interlock description 11 + default: unused + ilk12: + type: str + description: |- + Interlock description 12 + default: unused + ilk13: + type: str + description: |- + Interlock description 13 + default: unused + ilk14: + type: str + description: |- + Interlock description 14 + default: unused + ilk15: + type: str + description: |- + Interlock description 15 + default: unused + + - gilk: &gilk + gilk0: + type: str + description: |- + Gauge interlock description 0 + default: unused + gilk1: + type: str + description: |- + Gauge interlock description 1 + default: unused + gilk2: + type: str + description: |- + Gauge interlock description 2 + default: unused + gilk3: + type: str + description: |- + Gauge interlock description 3 + default: unused + gilk4: + type: str + description: |- + Gauge interlock description 4 + default: unused + gilk5: + type: str + description: |- + Gauge interlock description 5 + default: unused + gilk6: + type: str + description: |- + Gauge interlock description 6 + default: unused + gilk7: + type: str + description: |- + Gauge interlock description 7 + default: unused + gilk8: + type: str + description: |- + Gauge interlock description 8 + default: unused + gilk9: + type: str + description: |- + Gauge interlock description 9 + default: unused + gilk10: + type: str + description: |- + Gauge interlock description 10 + default: unused + gilk11: + type: str + description: |- + Gauge interlock description 11 + default: unused + gilk12: + type: str + description: |- + Gauge interlock description 12 + default: unused + gilk13: + type: str + description: |- + Gauge interlock description 13 + default: unused + gilk14: + type: str + description: |- + Gauge interlock description 14 + default: unused + gilk15: + type: str + description: |- + Gauge interlock description 15 + default: unused + + - cilk: &cilk + cilk0: + type: str + description: |- + Gauge interlock description 0 + default: unused + cilk1: + type: str + description: |- + Gauge interlock description 1 + default: unused + cilk2: + type: str + description: |- + Gauge interlock description 2 + default: unused + cilk3: + type: str + description: |- + Gauge interlock description 3 + default: unused + cilk4: + type: str + description: |- + Gauge interlock description 4 + default: unused + cilk5: + type: str + description: |- + Gauge interlock description 5 + default: unused + cilk6: + type: str + description: |- + Gauge interlock description 6 + default: unused + cilk7: + type: str + description: |- + Gauge interlock description 7 + default: unused + cilk8: + type: str + description: |- + Gauge interlock description 8 + default: unused + cilk9: + type: str + description: |- + Gauge interlock description 9 + default: unused + cilk10: + type: str + description: |- + Gauge interlock description 10 + default: unused + cilk11: + type: str + description: |- + Gauge interlock description 11 + default: unused + cilk12: + type: str + description: |- + Gauge interlock description 12 + default: unused + cilk13: + type: str + description: |- + Gauge interlock description 13 + default: unused + cilk14: + type: str + description: |- + Gauge interlock description 14 + default: unused + cilk15: + type: str + description: |- + Gauge interlock description 15 + default: unused + + - con_label: &con_label + con_label0: + type: str + description: |- + Label string for control value 0 + default: Open + con_label1: + type: str + description: |- + Label string for control value 1 + default: Close + con_label2: + type: str + description: |- + Label string for control value 2 + default: Reset + con_label3: + type: str + description: |- + Label string for control value 3 + default: "" + con_label4: + type: str + description: |- + Label string for control value 4 + default: "" + con_label5: + type: str + description: |- + Label string for control value 5 + default: "" + con_label6: + type: str + description: |- + Label string for control value 6 + default: "" + + - sta_label: &sta_label + sta_label0: + type: str + description: |- + Label string for status value 0 + default: Fault + sta_label1: + type: str + description: |- + Label string for status value 1 + default: Open + sta_label2: + type: str + description: |- + Label string for status value 2 + default: Opening + sta_label3: + type: str + description: |- + Label string for status value 3 + default: Closed + sta_label4: + type: str + description: |- + Label string for status value 4 + default: Closing + sta_label5: + type: str + description: |- + Label string for status value 5 + default: "" + sta_label6: + type: str + description: |- + Label string for status value 6 + default: "" + + - sta_sv: &sta_sv + sta_sv0: + type: str + description: |- + Alarm severity for status value 0. + default: MAJOR + sta_sv1: + type: str + description: |- + Alarm severity for status value 1. + default: NO_ALARM + sta_sv2: + type: str + description: |- + Alarm severity for status value 2. + default: NO_ALARM + sta_sv3: + type: str + description: |- + Alarm severity for status value 3. + default: NO_ALARM + sta_sv4: + type: str + description: |- + Alarm severity for status value 4. + default: NO_ALARM + sta_sv5: + type: str + description: |- + Alarm severity for status value 5. + default: NO_ALARM + sta_sv6: + type: str + description: |- + Alarm severity for status value 6. + default: NO_ALARM + + - ilksta_label: &ilksta_label + ilksta_label0: + type: str + description: |- + Template argument + default: Failed + ilksta_label1: + type: str + description: |- + Template argument + default: Run Ilks Ok + ilksta_label2: + type: str + description: |- + Template argument + default: OK + ilksta_label3: + type: str + description: |- + Template argument + default: Disarmed + ilksta_label4: + type: str + description: |- + Template argument + default: "" + ilksta_label5: + type: str + description: |- + Template argument + default: "" + + - ilksta_sv: &ilksta_sv + ilksta_sv0: + type: str + description: |- + Template argument + default: MAJOR + ilksta_sv1: + type: str + description: |- + Template argument + default: NO_ALARM + ilksta_sv2: + type: str + description: |- + Template argument + default: NO_ALARM + ilksta_sv3: + type: str + description: |- + Template argument + default: NO_ALARM + ilksta_sv4: + type: str + description: |- + Template argument + default: NO_ALARM + ilksta_sv5: + type: str + description: |- + Template argument + default: NO_ALARM + + - mode: &mode + mode1: + type: str + description: |- + name of remote operational mode (:MODE) + default: Operational + mode2: + type: str + description: |- + name of local operational mode (:MODE) + default: Service + + - allowpv: &allowpv + allowpv: + type: str + description: |- + If specified, then only write an open command when this is non-zero. MUST have CP at the end of it + default: "" + + - whylocked: &whylocked + whylocked: + type: str + description: |- + String to output to EDM synoptic as to precisely why the device is locked and by whom + default: Open command not allowed + + - timeout: &timeout + timeout: + type: int + description: |- + Timeout in seconds for the FINS protocol + default: 0 + + - alarm_limits: &alarm_limits + lolo: + type: str + description: |- + Lolo alarm limit + low: + type: str + description: |- + Low alarm limit + high: + type: str + description: |- + High alarm limit + hihi: + type: str + description: |- + Hihi alarm limit + hopr: + type: str + description: |- + High operating range + lopr: + type: str + description: |- + Low operating range + llsv: + type: str + description: |- + Lolo severity + default: NO_ALARM + lsv: + type: str + description: |- + Low severity + default: NO_ALARM + hyst: + type: int + description: |- + alarm deadband + default: 0 + +module: dlsPLC + +entity_models: + - name: NX102_vacValveDebounce + description: |- + Template database for a vacuum valve without debounce or raw air records + parameters: + # TODO the ordering of the subst file headings is rather mixed up by this alias and override approach + # TODO what can we do about that? - one approach is not use .* for database arguments but list explicity + <<: [*tag, *tagidx, *allowpv, *whylocked, *con_label, *sta_label, *sta_sv, *ilksta_label, *ilksta_sv, *mode] + device: + type: str + description: |- + device name + port: + type: str + description: |- + EtherIP Port Name + con_label7: + type: str + description: |- + Label string for control value 7 (Optional - defaults to "") + default: "" + sta_label7: + type: str + description: |- + Label string for status value 7 (Optional - defaults to "") + default: "" + sta_sv7: + type: str + description: |- + Alarm severity for status value 7 (Optional - defaults to NO_ALARM) + default: NO_ALARM + ilksta_label6: + type: str + description: |- + Label string for status value 6 (Optional - defaults to "") + default: "" + ilksta_label7: + type: str + description: |- + Label string for status value 7 (Optional - defaults to "") + default: "" + ilksta_sv6: + type: str + description: |- + Alarm severity for interlock status value 6 (Optional - defaults to NO_ALARM) + default: NO_ALARM + ilksta_sv7: + type: str + description: |- + Alarm severity for interlock status value 7 (Optional - defaults to NO_ALARM) + default: NO_ALARM + DIRILK1: + type: str + description: |- + Part of ILK1 PV name (dollar(device):dollar(DIRILK1)ILK), named for "direction" of operation controlled by ILK1, e.g. set to OPEN for Bistable valve or leave blank for ordinary valve. (Optional - defaults to "") + default: "" + DIRILK2: + type: str + description: |- + Part of ILK2 PV name (dollar(device):dollar(DIRILK2)ILK), named for "direction" of operation controlled by ILK2, e.g. set to CLOSE for Bistable valves (Optional - defaults to "ILK2") + default: ILK2 + name: + type: id + description: |- + Object name and associated gui name (Optional - defaults to "") + desc: + type: str + description: |- + Box label for gui (Optional - defaults to value of device macro) + default: $(device) + + databases: + - file: $(DLSPLC)/db/NX102_vacValveDebounce.template + args: + .*: diff --git a/tests/test_cli.py b/tests/test_cli.py index 23d641159..6122e3d74 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -217,3 +217,15 @@ def test_fast_vacuum(tmp_epics_root: Path, samples: Path): "fastVacuum", ["fastVacuum"], ) + + +def test_dls_plc(tmp_epics_root: Path, samples: Path): + """ + Cut down copy of dlsPLC containing fast vacuum master and channel + """ + generic_generate( + tmp_epics_root, + samples, + "dlsPLC", + ["dlsPLC", "asyn"], + ) diff --git a/tests/test_support.py b/tests/test_support.py index 838047051..5c357f2af 100644 --- a/tests/test_support.py +++ b/tests/test_support.py @@ -15,6 +15,7 @@ def test_symlink_ibek(tmp_path: Path, samples: Path): "ADCore.ibek.support.yaml", "asyn.ibek.support.yaml", "bad_db.ibek.support.yaml", + "dlsPLC.ibek.support.yaml", "epics.ibek.support.yaml", "fastVacuum.ibek.support.yaml", "gauges.ibek.support.yaml",