diff --git a/src/builder2ibek/__main__.py b/src/builder2ibek/__main__.py index 076ceb5..034d278 100644 --- a/src/builder2ibek/__main__.py +++ b/src/builder2ibek/__main__.py @@ -37,7 +37,8 @@ def file( xml: Path = typer.Argument(..., help="Filename of the builder XML file"), yaml: Optional[Path] = typer.Option(..., help="Output file"), schema: Optional[str] = typer.Option( - None, help="Generic IOC schema (added to top of the yaml output)" + "/epics/ibek-defs/ioc.schema.json", + help="Generic IOC schema (added to top of the yaml output)", ), ): def tidy_up(yaml): @@ -67,10 +68,7 @@ def tidy_up(yaml): yaml_map = CommentedMap(ioc.model_dump()) # add support yaml schema - if schema: - yaml_map.yaml_add_eol_comment( - f"yaml-language-server: $schema={schema}", column=0 - ) + yaml_map.yaml_add_eol_comment(f"yaml-language-server: $schema={schema}", column=0) ruamel.indent(mapping=2, sequence=4, offset=2) diff --git a/src/builder2ibek/convert.py b/src/builder2ibek/convert.py index 5902dbd..eaae778 100644 --- a/src/builder2ibek/convert.py +++ b/src/builder2ibek/convert.py @@ -1,6 +1,7 @@ """ Generic XML to YAML conversion functions """ + from typing import Any, Dict, List from builder2ibek.builder import Builder, Element @@ -14,10 +15,13 @@ def dispatch(builder: Builder, filename) -> Generic_IOC: and build a generic IOC from the converted Entities """ ioc = Generic_IOC( - # ioc_name=builder.name.lower(), - ioc_name="{{ ioc_yaml_file_name }}", + ioc_name="{{ __utils__.get_env('IOC_NAME') }}", description="auto-generated by https://github.com/epics-containers/builder2ibek", - entities=[], + # some default entities for all IOC instances + entities=[ + {"type": "epics.EpicsEnvSet", "name": "EPICS_TS_MIN_WEST", "value": "0"}, + {"type": "devIocStats.iocAdminSoft", "IOC": "{{ ioc_name | upper }}"}, + ], source_file=filename, ) diff --git a/src/builder2ibek/converters/deviocstats.py b/src/builder2ibek/converters/deviocstats.py index 11358e7..e8dafdb 100644 --- a/src/builder2ibek/converters/deviocstats.py +++ b/src/builder2ibek/converters/deviocstats.py @@ -14,12 +14,17 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): if ( - entity_type == "devIocStatsHelper" - or entity_type == "iocAdminSoft" + entity_type == "devIocStatsHelper" or entity_type == "iocAdminSoft" # TODO - to do the right thing here we need to know arch somehow # TODO but at present this is a Generic IOC target thing - not in the yaml # and ioc.arch == "linux-x86_64" ): + print(f"removing {Entity}") + entity.delete_me() + return + # in fact the above is nice because we by default add devIocStats.iocAdminSoft + # using the env var IOC_NAME + entity.type = f"{xml_component}.iocAdminSoft" if "ioc" in entity: entity.rename("ioc", "IOC") diff --git a/src/builder2ibek/converters/dlsPLC.py b/src/builder2ibek/converters/dlsPLC.py index bc208fa..e9e4326 100644 --- a/src/builder2ibek/converters/dlsPLC.py +++ b/src/builder2ibek/converters/dlsPLC.py @@ -12,3 +12,5 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC): id = int(entity.get("id")) id_enum = f"{id:02d}" entity.id = id_enum + elif entity_type == "NX102_readReal": + entity.remove("name")