Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for wire devices and yaml generation #183

Merged
merged 11 commits into from
Aug 13, 2024
73 changes: 71 additions & 2 deletions lcls_tools/common/devices/wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@ class IntegerModel(BaseModel):
value: conint(strict=True)


class PlaneModel(BaseModel):
plane: str

@field_validator('plane')
def x_y_u_plane(cls, v):
if v.lower() in ['x', 'y', 'u']:
return v
else:
raise ValueError("basePlane must be X, Y, or U")


class WirePVSet(PVSet):
motr: PV
# velo: PV
# rbv: PV
velo: PV
rbv: PV
initialize: PV
initialized: PV
retract: PV
Expand All @@ -68,6 +79,7 @@ class WirePVSet(PVSet):
enabled: PV
homed: PV
timeout: PV
abort: PV

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down Expand Up @@ -143,6 +155,55 @@ def usize(self):
print(EPICS_ERROR_MESSAGE)
# TODO: Returning wire size from yaml file instead

def use(self, plane: str, val: bool) -> None:
try:
PlaneModel(value=plane)
BooleanModel(value=val)
except ValidationError as e:
print("Plane must be X, Y, or U:", e)
return
property_name = "use_" + plane.lower() + "_wire"
setattr(self, property_name, val)

def set_range(self, plane: str, val: list) -> None:
try:
PlaneModel(value=plane)
RangeModel(value=val)
property_name = plane.lower() + "_range"
setattr(self, property_name, val)
except ValidationError as e:
print("Plane must be X, Y, or U:", e)

def set_inner_range(self, plane: str, val: int) -> None:
try:
PlaneModel(value=plane)
IntegerModel(value=val)
property_name = plane.lower() + "_wire_inner"
outer_property = plane.lower() + "_wire_outer"
outer_range = getattr(self, outer_property)
if val < outer_range:
setattr(self, property_name, val)
else:
print("Scan range value failed validation")
raise ValidationError
except ValidationError as e:
print("Plane must be X, Y, or U:", e)

def set_outer_range(self, plane: str, val: int) -> None:
try:
PlaneModel(value=plane)
IntegerModel(value=val)
property_name = plane.lower() + "_wire_outer"
inner_property = plane.lower() + "_wire_inner"
inner_range = getattr(self, inner_property)
if val > inner_range:
setattr(self, property_name, val)
else:
print("Scan range value failed validation")
raise ValidationError
except ValidationError as e:
print("Plane must be X, Y, or U:", e)

@property
def use_x_wire(self):
"""Checks if the X plane will be scanned."""
Expand Down Expand Up @@ -347,6 +408,14 @@ def retract(self):
"""Retracts the wire scanner"""
self.controls_information.PVs.retract.put(value=1)

def start_scan(self):
"""Starts a wire scan using current parameters"""
self.controls_information.PVs.startscan.put(value=1)

def abort_scan(self):
"""Aborts active wire scan"""
self.controls_information.PVs.abort.put(value=1)


class WireCollection(BaseModel):
wires: Dict[str, SerializeAsAny[Wire]]
Expand Down
3 changes: 3 additions & 0 deletions lcls_tools/common/devices/yaml/BC1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,13 @@ wires:
WS13:
controls_information:
PVs:
abort: WIRE:LI21:301:MOTR.STOP
enabled: WIRE:LI21:301:MOTR_ENABLED_STS
homed: WIRE:LI21:301:MOTR_HOMED_STS
initialize: WIRE:LI21:301:MOTR_INIT
initialized: WIRE:LI21:301:MOTR_INIT_STS
motr: WIRE:LI21:301:MOTR
rbv: WIRE:LI21:301:MOTR.RBV
retract: WIRE:LI21:301:MOTR_RETRACT
startscan: WIRE:LI21:301:STARTSCAN
timeout: WIRE:LI21:301:MOTR_TIMEOUTEN
Expand All @@ -584,6 +586,7 @@ wires:
usize: WIRE:LI21:301:UWIRESIZE
uwireinner: WIRE:LI21:301:UWIREINNER
uwireouter: WIRE:LI21:301:UWIREOUTER
velo: WIRE:LI21:301:MOTR.VELO
xsize: WIRE:LI21:301:XWIRESIZE
xwireinner: WIRE:LI21:301:XWIREINNER
xwireouter: WIRE:LI21:301:XWIREOUTER
Expand Down
3 changes: 3 additions & 0 deletions lcls_tools/common/devices/yaml/BC2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,18 @@ wires:
WS24:
controls_information:
PVs:
abort: WIRE:LI24:705:MOTR.STOP
enabled: WIRE:LI24:705:MOTR_ENABLED_STS
initialized: WIRE:LI24:705:MOTR_INIT_STS
motr: WIRE:LI24:705:MOTR
rbv: WIRE:LI24:705:MOTR.RBV
startscan: WIRE:LI24:705:STARTSCAN
useuwire: WIRE:LI24:705:USEUWIRE
usexwire: WIRE:LI24:705:USEXWIRE
useywire: WIRE:LI24:705:USEYWIRE
uwireinner: WIRE:LI24:705:UWIREINNER
uwireouter: WIRE:LI24:705:UWIREOUTER
velo: WIRE:LI24:705:MOTR.VELO
xwireinner: WIRE:LI24:705:XWIREINNER
xwireouter: WIRE:LI24:705:XWIREOUTER
ywireinner: WIRE:LI24:705:YWIREINNER
Expand Down
9 changes: 9 additions & 0 deletions lcls_tools/common/devices/yaml/BYP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,13 @@ wires:
WSBP2:
controls_information:
PVs:
abort: WIRE:BPN12:850:MOTR.STOP
enabled: WIRE:BPN12:850:MOTR_ENABLED_STS
homed: WIRE:BPN12:850:MOTR_HOMED_STS
initialize: WIRE:BPN12:850:MOTR_INIT
initialized: WIRE:BPN12:850:MOTR_INIT_STS
motr: WIRE:BPN12:850:MOTR
rbv: WIRE:BPN12:850:MOTR.RBV
retract: WIRE:BPN12:850:MOTR_RETRACT
startscan: WIRE:BPN12:850:STARTSCAN
timeout: WIRE:BPN12:850:MOTR_TIMEOUTEN
Expand All @@ -1241,6 +1243,7 @@ wires:
usize: WIRE:BPN12:850:UWIRESIZE
uwireinner: WIRE:BPN12:850:UWIREINNER
uwireouter: WIRE:BPN12:850:UWIREOUTER
velo: WIRE:BPN12:850:MOTR.VELO
xsize: WIRE:BPN12:850:XWIRESIZE
xwireinner: WIRE:BPN12:850:XWIREINNER
xwireouter: WIRE:BPN12:850:XWIREOUTER
Expand All @@ -1264,11 +1267,13 @@ wires:
WSBP3:
controls_information:
PVs:
abort: WIRE:BPN14:850:MOTR.STOP
enabled: WIRE:BPN14:850:MOTR_ENABLED_STS
homed: WIRE:BPN14:850:MOTR_HOMED_STS
initialize: WIRE:BPN14:850:MOTR_INIT
initialized: WIRE:BPN14:850:MOTR_INIT_STS
motr: WIRE:BPN14:850:MOTR
rbv: WIRE:BPN14:850:MOTR.RBV
retract: WIRE:BPN14:850:MOTR_RETRACT
startscan: WIRE:BPN14:850:STARTSCAN
timeout: WIRE:BPN14:850:MOTR_TIMEOUTEN
Expand All @@ -1278,6 +1283,7 @@ wires:
usize: WIRE:BPN14:850:UWIRESIZE
uwireinner: WIRE:BPN14:850:UWIREINNER
uwireouter: WIRE:BPN14:850:UWIREOUTER
velo: WIRE:BPN14:850:MOTR.VELO
xsize: WIRE:BPN14:850:XWIRESIZE
xwireinner: WIRE:BPN14:850:XWIREINNER
xwireouter: WIRE:BPN14:850:XWIREOUTER
Expand All @@ -1301,11 +1307,13 @@ wires:
WSBP4:
controls_information:
PVs:
abort: WIRE:BPN16:850:MOTR.STOP
enabled: WIRE:BPN16:850:MOTR_ENABLED_STS
homed: WIRE:BPN16:850:MOTR_HOMED_STS
initialize: WIRE:BPN16:850:MOTR_INIT
initialized: WIRE:BPN16:850:MOTR_INIT_STS
motr: WIRE:BPN16:850:MOTR
rbv: WIRE:BPN16:850:MOTR.RBV
retract: WIRE:BPN16:850:MOTR_RETRACT
startscan: WIRE:BPN16:850:STARTSCAN
timeout: WIRE:BPN16:850:MOTR_TIMEOUTEN
Expand All @@ -1315,6 +1323,7 @@ wires:
usize: WIRE:BPN16:850:UWIRESIZE
uwireinner: WIRE:BPN16:850:UWIREINNER
uwireouter: WIRE:BPN16:850:UWIREOUTER
velo: WIRE:BPN16:850:MOTR.VELO
xsize: WIRE:BPN16:850:XWIRESIZE
xwireinner: WIRE:BPN16:850:XWIREINNER
xwireouter: WIRE:BPN16:850:XWIREOUTER
Expand Down
12 changes: 12 additions & 0 deletions lcls_tools/common/devices/yaml/COL1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,13 @@ wires:
WSC104:
controls_information:
PVs:
abort: WIRE:COL1:360:MOTR.STOP
enabled: WIRE:COL1:360:MOTR_ENABLED_STS
homed: WIRE:COL1:360:MOTR_HOMED_STS
initialize: WIRE:COL1:360:MOTR_INIT
initialized: WIRE:COL1:360:MOTR_INIT_STS
motr: WIRE:COL1:360:MOTR
rbv: WIRE:COL1:360:MOTR.RBV
retract: WIRE:COL1:360:MOTR_RETRACT
startscan: WIRE:COL1:360:STARTSCAN
timeout: WIRE:COL1:360:MOTR_TIMEOUTEN
Expand All @@ -569,6 +571,7 @@ wires:
usize: WIRE:COL1:360:UWIRESIZE
uwireinner: WIRE:COL1:360:UWIREINNER
uwireouter: WIRE:COL1:360:UWIREOUTER
velo: WIRE:COL1:360:MOTR.VELO
xsize: WIRE:COL1:360:XWIRESIZE
xwireinner: WIRE:COL1:360:XWIREINNER
xwireouter: WIRE:COL1:360:XWIREOUTER
Expand All @@ -592,11 +595,13 @@ wires:
WSC106:
controls_information:
PVs:
abort: WIRE:COL1:520:MOTR.STOP
enabled: WIRE:COL1:520:MOTR_ENABLED_STS
homed: WIRE:COL1:520:MOTR_HOMED_STS
initialize: WIRE:COL1:520:MOTR_INIT
initialized: WIRE:COL1:520:MOTR_INIT_STS
motr: WIRE:COL1:520:MOTR
rbv: WIRE:COL1:520:MOTR.RBV
retract: WIRE:COL1:520:MOTR_RETRACT
startscan: WIRE:COL1:520:STARTSCAN
timeout: WIRE:COL1:520:MOTR_TIMEOUTEN
Expand All @@ -606,6 +611,7 @@ wires:
usize: WIRE:COL1:520:UWIRESIZE
uwireinner: WIRE:COL1:520:UWIREINNER
uwireouter: WIRE:COL1:520:UWIREOUTER
velo: WIRE:COL1:520:MOTR.VELO
xsize: WIRE:COL1:520:XWIRESIZE
xwireinner: WIRE:COL1:520:XWIREINNER
xwireouter: WIRE:COL1:520:XWIREOUTER
Expand All @@ -629,11 +635,13 @@ wires:
WSC108:
controls_information:
PVs:
abort: WIRE:COL1:680:MOTR.STOP
enabled: WIRE:COL1:680:MOTR_ENABLED_STS
homed: WIRE:COL1:680:MOTR_HOMED_STS
initialize: WIRE:COL1:680:MOTR_INIT
initialized: WIRE:COL1:680:MOTR_INIT_STS
motr: WIRE:COL1:680:MOTR
rbv: WIRE:COL1:680:MOTR.RBV
retract: WIRE:COL1:680:MOTR_RETRACT
startscan: WIRE:COL1:680:STARTSCAN
timeout: WIRE:COL1:680:MOTR_TIMEOUTEN
Expand All @@ -643,6 +651,7 @@ wires:
usize: WIRE:COL1:680:UWIRESIZE
uwireinner: WIRE:COL1:680:UWIREINNER
uwireouter: WIRE:COL1:680:UWIREOUTER
velo: WIRE:COL1:680:MOTR.VELO
xsize: WIRE:COL1:680:XWIRESIZE
xwireinner: WIRE:COL1:680:XWIREINNER
xwireouter: WIRE:COL1:680:XWIREOUTER
Expand All @@ -666,11 +675,13 @@ wires:
WSC110:
controls_information:
PVs:
abort: WIRE:COL1:840:MOTR.STOP
enabled: WIRE:COL1:840:MOTR_ENABLED_STS
homed: WIRE:COL1:840:MOTR_HOMED_STS
initialize: WIRE:COL1:840:MOTR_INIT
initialized: WIRE:COL1:840:MOTR_INIT_STS
motr: WIRE:COL1:840:MOTR
rbv: WIRE:COL1:840:MOTR.RBV
retract: WIRE:COL1:840:MOTR_RETRACT
startscan: WIRE:COL1:840:STARTSCAN
timeout: WIRE:COL1:840:MOTR_TIMEOUTEN
Expand All @@ -680,6 +691,7 @@ wires:
usize: WIRE:COL1:840:UWIRESIZE
uwireinner: WIRE:COL1:840:UWIREINNER
uwireouter: WIRE:COL1:840:UWIREOUTER
velo: WIRE:COL1:840:MOTR.VELO
xsize: WIRE:COL1:840:XWIRESIZE
xwireinner: WIRE:COL1:840:XWIREINNER
xwireouter: WIRE:COL1:840:XWIREOUTER
Expand Down
3 changes: 3 additions & 0 deletions lcls_tools/common/devices/yaml/DIAG0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,17 @@ wires:
WSDG01:
controls_information:
PVs:
abort: WIRE:DIAG0:424:MOTR.STOP
motr: WIRE:DIAG0:424:MOTR
rbv: WIRE:DIAG0:424:MOTR.RBV
startscan: WIRE:DIAG0:424:STARTSCAN
useuwire: WIRE:DIAG0:424:USEUWIRE
usexwire: WIRE:DIAG0:424:USEXWIRE
useywire: WIRE:DIAG0:424:USEYWIRE
usize: WIRE:DIAG0:424:UWIRESIZE
uwireinner: WIRE:DIAG0:424:UWIREINNER
uwireouter: WIRE:DIAG0:424:UWIREOUTER
velo: WIRE:DIAG0:424:MOTR.VELO
xsize: WIRE:DIAG0:424:XWIRESIZE
xwireinner: WIRE:DIAG0:424:XWIREINNER
xwireouter: WIRE:DIAG0:424:XWIREOUTER
Expand Down
12 changes: 12 additions & 0 deletions lcls_tools/common/devices/yaml/DL1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,19 @@ wires:
WS01:
controls_information:
PVs:
abort: WIRE:IN20:531:MOTR.STOP
enabled: WIRE:IN20:531:MOTR_ENABLED_STS
initialized: WIRE:IN20:531:MOTR_INIT_STS
motr: WIRE:IN20:531:MOTR
rbv: WIRE:IN20:531:MOTR.RBV
startscan: WIRE:IN20:531:STARTSCAN
useuwire: WIRE:IN20:531:USEUWIRE
usexwire: WIRE:IN20:531:USEXWIRE
useywire: WIRE:IN20:531:USEYWIRE
usize: WIRE:IN20:531:UWIRESIZE
uwireinner: WIRE:IN20:531:UWIREINNER
uwireouter: WIRE:IN20:531:UWIREOUTER
velo: WIRE:IN20:531:MOTR.VELO
xsize: WIRE:IN20:531:XWIRESIZE
xwireinner: WIRE:IN20:531:XWIREINNER
xwireouter: WIRE:IN20:531:XWIREOUTER
Expand All @@ -731,11 +734,13 @@ wires:
WS02:
controls_information:
PVs:
abort: WIRE:IN20:561:MOTR.STOP
enabled: WIRE:IN20:561:MOTR_ENABLED_STS
homed: WIRE:IN20:561:MOTR_HOMED_STS
initialize: WIRE:IN20:561:MOTR_INIT
initialized: WIRE:IN20:561:MOTR_INIT_STS
motr: WIRE:IN20:561:MOTR
rbv: WIRE:IN20:561:MOTR.RBV
retract: WIRE:IN20:561:MOTR_RETRACT
startscan: WIRE:IN20:561:STARTSCAN
timeout: WIRE:IN20:561:MOTR_TIMEOUTEN
Expand All @@ -745,6 +750,7 @@ wires:
usize: WIRE:IN20:561:UWIRESIZE
uwireinner: WIRE:IN20:561:UWIREINNER
uwireouter: WIRE:IN20:561:UWIREOUTER
velo: WIRE:IN20:561:MOTR.VELO
xsize: WIRE:IN20:561:XWIRESIZE
xwireinner: WIRE:IN20:561:XWIREINNER
xwireouter: WIRE:IN20:561:XWIREOUTER
Expand All @@ -767,11 +773,13 @@ wires:
WS03:
controls_information:
PVs:
abort: WIRE:IN20:611:MOTR.STOP
enabled: WIRE:IN20:611:MOTR_ENABLED_STS
homed: WIRE:IN20:611:MOTR_HOMED_STS
initialize: WIRE:IN20:611:MOTR_INIT
initialized: WIRE:IN20:611:MOTR_INIT_STS
motr: WIRE:IN20:611:MOTR
rbv: WIRE:IN20:611:MOTR.RBV
retract: WIRE:IN20:611:MOTR_RETRACT
startscan: WIRE:IN20:611:STARTSCAN
timeout: WIRE:IN20:611:MOTR_TIMEOUTEN
Expand All @@ -781,6 +789,7 @@ wires:
usize: WIRE:IN20:611:UWIRESIZE
uwireinner: WIRE:IN20:611:UWIREINNER
uwireouter: WIRE:IN20:611:UWIREOUTER
velo: WIRE:IN20:611:MOTR.VELO
xsize: WIRE:IN20:611:XWIRESIZE
xwireinner: WIRE:IN20:611:XWIREINNER
xwireouter: WIRE:IN20:611:XWIREOUTER
Expand All @@ -803,16 +812,19 @@ wires:
WS04:
controls_information:
PVs:
abort: WIRE:IN20:741:MOTR.STOP
enabled: WIRE:IN20:741:MOTR_ENABLED_STS
initialized: WIRE:IN20:741:MOTR_INIT_STS
motr: WIRE:IN20:741:MOTR
rbv: WIRE:IN20:741:MOTR.RBV
startscan: WIRE:IN20:741:STARTSCAN
useuwire: WIRE:IN20:741:USEUWIRE
usexwire: WIRE:IN20:741:USEXWIRE
useywire: WIRE:IN20:741:USEYWIRE
usize: WIRE:IN20:741:UWIRESIZE
uwireinner: WIRE:IN20:741:UWIREINNER
uwireouter: WIRE:IN20:741:UWIREOUTER
velo: WIRE:IN20:741:MOTR.VELO
xsize: WIRE:IN20:741:XWIRESIZE
xwireinner: WIRE:IN20:741:XWIREINNER
xwireouter: WIRE:IN20:741:XWIREOUTER
Expand Down
Loading
Loading