mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-05-28 23:50:42 +02:00
Code formatting
This commit is contained in:
parent
26f834b933
commit
519859caac
@ -556,4 +556,4 @@ class GalilMotor(Device, PositionerBase):
|
|||||||
|
|
||||||
def stop(self, *, success=False):
|
def stop(self, *, success=False):
|
||||||
self.controller.stop_all_axes()
|
self.controller.stop_all_axes()
|
||||||
return super().stop(success=success)
|
return super().stop(success=success)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Summary on communication commands for SGalilMotor
|
# Summary on communication commands for SGalilMotor
|
||||||
## sgalil_y - vertical axis (samy)
|
## sgalil_y - vertical axis (samy)
|
||||||
- Axis 2 || C
|
- Axis 2, C
|
||||||
- in motion: "MG _BG{axis_char}", e.g. "MG _BGC" , 0 or 1
|
- in motion: "MG _BG{axis_char}", e.g. "MG _BGC" , 0 or 1
|
||||||
- limit switch not pressed: "MG _LR{axis_char}, _LF{axis_char}" , 0 or 1
|
- limit switch not pressed: "MG _LR{axis_char}, _LF{axis_char}" , 0 or 1
|
||||||
- position: "MG _TP{axis_char}/mm" , position in mm
|
- position: "MG _TP{axis_char}/mm" , position in mm
|
||||||
@ -13,7 +13,7 @@
|
|||||||
- set_final_pos: "PA{axis_char}={val:04f}*mm", target pos in mm
|
- set_final_pos: "PA{axis_char}={val:04f}*mm", target pos in mm
|
||||||
- start motion: "BG{axis_char}", start motion
|
- start motion: "BG{axis_char}", start motion
|
||||||
## sgalil_y - horizontal axis (samx) - due to hardware modifications a bit more complicated
|
## sgalil_y - horizontal axis (samx) - due to hardware modifications a bit more complicated
|
||||||
- initiate with Axis 4 || E
|
- initiate with Axis 4, E
|
||||||
**Specific for sgalil_x**
|
**Specific for sgalil_x**
|
||||||
- set_final_pos: "targ{axis_char}={val:04f}", e.g. "targE=2.0000"
|
- set_final_pos: "targ{axis_char}={val:04f}", e.g. "targE=2.0000"
|
||||||
- start motion: "XQ#POSE,{axis_char}"
|
- start motion: "XQ#POSE,{axis_char}"
|
||||||
|
@ -135,8 +135,8 @@ class GalilController(Controller):
|
|||||||
|
|
||||||
def is_axis_moving(self, axis_Id, axis_Id_numeric) -> bool:
|
def is_axis_moving(self, axis_Id, axis_Id_numeric) -> bool:
|
||||||
is_moving = bool(float(self.socket_put_and_receive(f"MG_BG{axis_Id}")) != 0)
|
is_moving = bool(float(self.socket_put_and_receive(f"MG_BG{axis_Id}")) != 0)
|
||||||
#backlash_is_active = bool(float(self.socket_put_and_receive(f"MGbcklact[axis]")) != 0)
|
# backlash_is_active = bool(float(self.socket_put_and_receive(f"MGbcklact[axis]")) != 0)
|
||||||
return bool(is_moving)#bool(is_moving or backlash_is_active)
|
return bool(is_moving) # bool(is_moving or backlash_is_active)
|
||||||
|
|
||||||
def is_thread_active(self, thread_id: int) -> bool:
|
def is_thread_active(self, thread_id: int) -> bool:
|
||||||
val = float(self.socket_put_and_receive(f"MG_XQ{thread_id}"))
|
val = float(self.socket_put_and_receive(f"MG_XQ{thread_id}"))
|
||||||
@ -171,11 +171,11 @@ class GalilController(Controller):
|
|||||||
return not bool(float(self.socket_put_and_receive(f"MG _MO{axis_Id}").strip()))
|
return not bool(float(self.socket_put_and_receive(f"MG _MO{axis_Id}").strip()))
|
||||||
|
|
||||||
def get_motor_limit_switch(self, axis_Id) -> list:
|
def get_motor_limit_switch(self, axis_Id) -> list:
|
||||||
# SGalil specific
|
# SGalil specific
|
||||||
if axis_id == 2:
|
if axis_id == 2:
|
||||||
ret = self.socket_put_and_receive(f"MG _LF{axis_Id}, _LR{axis_Id}")
|
ret = self.socket_put_and_receive(f"MG _LF{axis_Id}, _LR{axis_Id}")
|
||||||
high, low = ret.strip().split(" ")
|
high, low = ret.strip().split(" ")
|
||||||
elif axis_id ==4:
|
elif axis_id == 4:
|
||||||
ret = self.socket_put_and_receive(f"MG _LF{'F'}, _LR{'F'}")
|
ret = self.socket_put_and_receive(f"MG _LF{'F'}, _LR{'F'}")
|
||||||
high, low = ret.strip().split(" ")
|
high, low = ret.strip().split(" ")
|
||||||
return [not bool(float(low)), not bool(float(high))]
|
return [not bool(float(low)), not bool(float(high))]
|
||||||
@ -245,9 +245,11 @@ class GalilReadbackSignal(GalilSignalRO):
|
|||||||
float: Readback value after adjusting for sign and motor resolution.
|
float: Readback value after adjusting for sign and motor resolution.
|
||||||
"""
|
"""
|
||||||
if self.parent.axis_Id_numeric == 2:
|
if self.parent.axis_Id_numeric == 2:
|
||||||
current_pos = float(self.controller.socket_put_and_receive(f"MG _TP{self.parent.axis_Id}/mm"))
|
current_pos = float(
|
||||||
|
self.controller.socket_put_and_receive(f"MG _TP{self.parent.axis_Id}/mm")
|
||||||
|
)
|
||||||
elif self.parent.axis_Id_numeric == 4:
|
elif self.parent.axis_Id_numeric == 4:
|
||||||
#hardware controller readback from axis 4 is on axis 0, A instead of E
|
# hardware controller readback from axis 4 is on axis 0, A instead of E
|
||||||
current_pos = float(self.controller.socket_put_and_receive(f"MG _TP{'A'}/mm"))
|
current_pos = float(self.controller.socket_put_and_receive(f"MG _TP{'A'}/mm"))
|
||||||
current_pos *= self.parent.sign
|
current_pos *= self.parent.sign
|
||||||
return current_pos
|
return current_pos
|
||||||
@ -310,7 +312,7 @@ class GalilMotorIsMoving(GalilSignalRO):
|
|||||||
return ret
|
return ret
|
||||||
if self.parent.axis_Id_numeric == 4:
|
if self.parent.axis_Id_numeric == 4:
|
||||||
# Motion signal from axis 4 is mapped to axis 5
|
# Motion signal from axis 4 is mapped to axis 5
|
||||||
ret = self.controller.is_axis_moving('F', 5)
|
ret = self.controller.is_axis_moving("F", 5)
|
||||||
return ret or self.controller.is_thread_active(4)
|
return ret or self.controller.is_thread_active(4)
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
@ -329,12 +331,14 @@ class GalilAxesReferenced(GalilSignalRO):
|
|||||||
def _socket_get(self):
|
def _socket_get(self):
|
||||||
return self.controller.socket_put_and_receive("MG allaxref")
|
return self.controller.socket_put_and_receive("MG allaxref")
|
||||||
|
|
||||||
|
|
||||||
class SGalilMotor(Device, PositionerBase):
|
class SGalilMotor(Device, PositionerBase):
|
||||||
""""SGalil Motors at cSAXS have a
|
""" "SGalil Motors at cSAXS have a
|
||||||
DC motor (y axis - vertical) - implemented as C
|
DC motor (y axis - vertical) - implemented as C
|
||||||
and a step motor (x-axis horizontal) - implemented as E
|
and a step motor (x-axis horizontal) - implemented as E
|
||||||
that require different communication for control
|
that require different communication for control
|
||||||
"""
|
"""
|
||||||
|
|
||||||
USER_ACCESS = ["controller"]
|
USER_ACCESS = ["controller"]
|
||||||
readback = Cpt(
|
readback = Cpt(
|
||||||
GalilReadbackSignal,
|
GalilReadbackSignal,
|
||||||
@ -507,8 +511,10 @@ class SGalilMotor(Device, PositionerBase):
|
|||||||
if isinstance(val, str):
|
if isinstance(val, str):
|
||||||
if len(val) != 1:
|
if len(val) != 1:
|
||||||
raise ValueError(f"Only single-character axis_Ids are supported.")
|
raise ValueError(f"Only single-character axis_Ids are supported.")
|
||||||
if val not in ['C', 'E']:
|
if val not in ["C", "E"]:
|
||||||
raise ValueError(f"axis_id {val} is currently not supported, please use either 'C' or 'E'.")
|
raise ValueError(
|
||||||
|
f"axis_id {val} is currently not supported, please use either 'C' or 'E'."
|
||||||
|
)
|
||||||
self._axis_Id_alpha = val
|
self._axis_Id_alpha = val
|
||||||
self._axis_Id_numeric = ord(val.lower()) - 97
|
self._axis_Id_numeric = ord(val.lower()) - 97
|
||||||
else:
|
else:
|
||||||
@ -537,6 +543,7 @@ class SGalilMotor(Device, PositionerBase):
|
|||||||
self.controller.stop_all_axes()
|
self.controller.stop_all_axes()
|
||||||
return super().stop(success=success)
|
return super().stop(success=success)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
mock = False
|
mock = False
|
||||||
if not mock:
|
if not mock:
|
||||||
@ -544,11 +551,8 @@ if __name__ == "__main__":
|
|||||||
samx = SGalilMotor("E", name="samx", host="129.129.122.26", port=23, sign=-1)
|
samx = SGalilMotor("E", name="samx", host="129.129.122.26", port=23, sign=-1)
|
||||||
else:
|
else:
|
||||||
from ophyd_devices.utils.socket import SocketMock
|
from ophyd_devices.utils.socket import SocketMock
|
||||||
samx = SGalilMotor(
|
|
||||||
"E", name="samx", host="129.129.122.26", port=23, socket_cls=SocketMock
|
samx = SGalilMotor("E", name="samx", host="129.129.122.26", port=23, socket_cls=SocketMock)
|
||||||
)
|
samy = SGalilMotor("C", name="samy", host="129.129.122.26", port=23, socket_cls=SocketMock)
|
||||||
samy = SGalilMotor(
|
|
||||||
"C", name="samy", host="129.129.122.26", port=23, socket_cls=SocketMock
|
|
||||||
)
|
|
||||||
|
|
||||||
samx.controller.galil_show_all()
|
samx.controller.galil_show_all()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user