Skip to content

Commit

Permalink
adding pmac convertor
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 27, 2023
1 parent ed6f3d1 commit 374c6f5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
38 changes: 24 additions & 14 deletions src/builder2ibek/convertors/pmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,36 @@
# (currently not used) TODO it would be good to pull in the schema and
# verify that the YAML we generate is valid against it.
schema = (
"https://github.com/epics-containers/ioc-pmac/releases/"
"download/1.2.1/ioc.ibek.schema.yaml"
"https://github.com/epics-containers/ioc-pmac/releases/download/"
"2023.11.1/ibek.ioc.schema.json"
)

# A list of Tags and their default attributes
# These should match defaults supplied in builder.py __init__()
# NOTE: the build2ibek.support.py tool will now pick up the defaults
# from the builder.py __init__() function, so these are no longer needed
defaults = {
"pmac.GeoBrick": {
"numAxes": 8,
"idlePoll": 100,
"movingPoll": 500,
}
}


def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the pmac support module
"""
if entity_type == "pmacDisableLimitsCheck":
entity.remove("name")

elif (
entity_type == "dls_pmac_asyn_motor" or entity_type == "dls_cs_pmac_asyn_motor"
):
entity.rename("PORT", "Controller")
entity.remove("SPORT")
entity.remove("gda_desc")
entity.remove("gda_name")
if entity.DIR == 1:
entity.DIR = "Neg"
else:
entity.DIR = "Pos"
if entity.VMAX is not None:
entity.VMAX = str(entity.VMAX)

elif entity_type == "GeoBrickTrajectoryControlT":
entity.type = "pmac.GeoBrickTrajectoryControl"
entity.remove("name")
entity.rename("PORT", "PmacController")

elif entity_type == "autohome":
entity.rename("PORT", "PmacController")
12 changes: 8 additions & 4 deletions src/builder2ibek/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ class Entity(Dict[str, Any]):
"""

def __getattr__(self, __name: str) -> Any:
return self[__name]
if __name in self:
return self[__name]
return None

def __setattr__(self, __name: str, value) -> Any:
self[__name] = value

def remove(self, attr: str):
del self[attr]
if attr in self:
del self[attr]

def rename(self, attr: str, new: str):
self[new] = self[attr]
del self[attr]
if attr in self:
self[new] = self[attr]
del self[attr]


# Generic XML classes ##########################################################
Expand Down

0 comments on commit 374c6f5

Please sign in to comment.