Skip to content

Commit

Permalink
updates for ioc-dlslinuxvac
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed May 30, 2024
1 parent 70034cb commit c2a7972
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/builder2ibek/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 7 additions & 3 deletions src/builder2ibek/convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Generic XML to YAML conversion functions
"""

from typing import Any, Dict, List

from builder2ibek.builder import Builder, Element
Expand All @@ -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,
)

Expand Down
9 changes: 7 additions & 2 deletions src/builder2ibek/converters/deviocstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions src/builder2ibek/converters/dlsPLC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit c2a7972

Please sign in to comment.