Skip to content

Commit

Permalink
first pass of dlsPLC conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Jan 16, 2025
1 parent 0a524ae commit d5c2726
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/builder2ibek/converters/Hy8401ip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from builder2ibek.converters.epics_base import add_interrupt_vector
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

Expand All @@ -12,6 +11,4 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""

if entity_type == "Hy8401":
vec = add_interrupt_vector()
entity.add_entity(vec)
entity.interrupt_vector = vec.name
entity.remove("name")
5 changes: 1 addition & 4 deletions src/builder2ibek/converters/Hy8402ip.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from builder2ibek.converters.epics_base import add_interrupt_vector
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

Expand All @@ -12,6 +11,4 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""

if entity_type == "Hy8402":
vec = add_interrupt_vector()
entity.add_entity(vec)
entity.interrupt_vector = vec.name
entity.remove("name")
14 changes: 14 additions & 0 deletions src/builder2ibek/converters/IOCInfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

xml_component = "IOCinfo"


@globalHandler
def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the IOCInfo support module
"""

if entity_type == "IOCinfo":
entity.remove("name")
2 changes: 2 additions & 0 deletions src/builder2ibek/converters/digitelMpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
unit = int(entity.get("unit")) # type: ignore
unit_enum = f"{unit:02d}"
entity.unit = unit_enum
elif entity_type in ["digitelMpcIonp", "digitelMpcIonpGroup"]:
entity.remove("name")
24 changes: 24 additions & 0 deletions src/builder2ibek/converters/interlock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC
from builder2ibek.utils import hex_to_int

xml_component = "interlock"

# records the port names of the read100 entities keyed by name
read100Objects = {}


@globalHandler
def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the interlock support module
This module gets converted to dlsPLC equivalents
"""

if entity_type == "interlock":
entity.type = "dlsPLC.interlock"
entity.addr = str(entity.addr) # TODO make int in dlsPLC.ibek.support.yaml
# entity.remove("name")

hex_to_int(entity, "ilk")
2 changes: 1 addition & 1 deletion src/builder2ibek/converters/mks937a.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
XML to YAML specialist convertor function for the mks937a support module
"""
# remove GUI only parameters (except on mks937aGauge which uses it for object ref)
if entity_type != "mks937aGauge":
if entity_type not in ["mks937aGauge", "mks937a"]:
entity.remove("name")
2 changes: 1 addition & 1 deletion src/builder2ibek/converters/mks937b.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""

# remove GUI only parameters (except those that use name for object ref)
if entity_type not in ["mks937bGauge", "mks937bImg"]:
if entity_type not in ["mks937bGauge", "mks937bImg", "mks937b", "mks937bPirg"]:
entity.remove("name")
2 changes: 1 addition & 1 deletion src/builder2ibek/converters/mrfTiming.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
XML to YAML specialist convertor function for the pvlogging support module
"""

# TODO mrfTiming not yet implemented - does it really need a irq
# TODO mrfTiming not yet implemented - does it really need a irq?
if entity_type == "EventReceiverPMC":
vec = add_interrupt_vector()
entity.add_entity(vec)
14 changes: 14 additions & 0 deletions src/builder2ibek/converters/rga.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

xml_component = "rga"


@globalHandler
def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the rga support module
"""

if entity_type == "rga":
entity.remove("name")
15 changes: 15 additions & 0 deletions src/builder2ibek/converters/vacuumSpace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

xml_component = "vacuumSpace"


@globalHandler
def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the vacuumSpace support module
"""

# remove GUI only parameters (except those that use name for object ref)
if entity_type == "spaceTemplate":
entity.remove("name")
42 changes: 42 additions & 0 deletions src/builder2ibek/converters/vacuumValve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from builder2ibek.converters.globalHandler import globalHandler
from builder2ibek.types import Entity, Generic_IOC

xml_component = "vacuumValve"

# records the port names of the read100 entities keyed by name
read100Objects = {}


@globalHandler
def handler(entity: Entity, entity_type: str, ioc: Generic_IOC):
"""
XML to YAML specialist convertor function for the vacuumValve support module
This module gets converted to dlsPLC equivalents
"""

if entity_type == "vacuumValveRead":
# record the port name of this entity
read100Objects[entity.name] = entity.port

entity.type = "dlsPLC.read100"
entity.century = "0" # TODO make int in dlsPLC.ibek.support.yaml
entity.remove("name")

if entity_type == "vacuumValveRead2":
# record the port name of this entity
read100Objects[entity.name] = entity.port

# TODO need an example to work out how to do this, we probably need
# to record in read100Objects, which centry this entity is associated
# WARNING: interlock.interlock will need to know about this (I think)
raise NotImplementedError("vacuumValveRead2 not implemented")

elif entity_type in ["vacuumValve", "vacuumValve_callback"]:
entity.type = "dlsPLC.vacValve"

entity.rename("crate", "vlvcc")
entity.addr = str(int(entity.valve) * 10) # TODO should be int
entity.remove("valve")

entity.port = read100Objects[entity.vlvcc]
15 changes: 15 additions & 0 deletions src/builder2ibek/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from typing import Any

from builder2ibek.types import Entity


def make_bool(value: Any):
value = str(value)
Expand All @@ -15,3 +17,16 @@ def make_bool(value: Any):
raise (ValueError(f"Cannot convert {value} to a boolean"))

return result


def hex_to_int(entity: Entity, prefix: str):
"""
Loop through A-F suffixes on the prefix supplied.
If the entity has a key with that prefix-suffix, rename it to the
# integer equivalent
"""
for n in range(10, 16):
hex_key = f"{prefix}{hex(n)[2:].upper()}"
print(hex_key)
if hex_key in entity:
entity.rename(hex_key, f"{prefix}{n}")

0 comments on commit d5c2726

Please sign in to comment.