mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-24 11:41:09 +02:00
Merge branch 'online_changes' into 'master'
Online changes See merge request bec/ophyd_devices!2
This commit is contained in:
@ -1,7 +1,8 @@
|
|||||||
# This file is a template, and might need editing before it works on your project.
|
# This file is a template, and might need editing before it works on your project.
|
||||||
# Official language image. Look for the different tagged releases at:
|
# Official language image. Look for the different tagged releases at:
|
||||||
# https://hub.docker.com/r/library/python/tags/
|
# https://hub.docker.com/r/library/python/tags/
|
||||||
image: "python:3.8"
|
image: python:3.8
|
||||||
|
|
||||||
#commands to run in the Docker container before starting each job.
|
#commands to run in the Docker container before starting each job.
|
||||||
before_script:
|
before_script:
|
||||||
- pip install -r ./requirements.txt
|
- pip install -r ./requirements.txt
|
||||||
@ -18,7 +19,6 @@ formatter:
|
|||||||
pytest:
|
pytest:
|
||||||
stage: Test
|
stage: Test
|
||||||
script:
|
script:
|
||||||
- apt-get update && apt-get install -y git
|
- git clone https://oauth2:$CI_BEC_KEY@gitlab.psi.ch/bec/bec.git
|
||||||
- git clone https://oauth2:$CI_BEC_KEY@gitlab.psi.ch/bec/bec.git
|
- pip install -e ./bec/bec_utils
|
||||||
- pip install -e ./bec/bec_utils
|
- pytest -v ./tests
|
||||||
- pytest -v ./tests
|
|
||||||
|
@ -134,8 +134,10 @@ class GalilController(Controller):
|
|||||||
f"Expected return value of ':' but instead received {return_val}"
|
f"Expected return value of ':' but instead received {return_val}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_axis_moving(self, axis_Id) -> bool:
|
def is_axis_moving(self, axis_Id, axis_Id_numeric) -> bool:
|
||||||
return bool(float(self.socket_put_and_receive(f"MG_BG{axis_Id}")))
|
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)
|
||||||
|
return 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}"))
|
||||||
@ -250,12 +252,13 @@ class GalilReadbackSignal(GalilSignalRO):
|
|||||||
return current_pos / step_mm
|
return current_pos / step_mm
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
self._metadata["timestamp"] = time.time()
|
||||||
val = super().read()
|
val = super().read()
|
||||||
if self.parent.axis_Id_numeric == 2:
|
if self.parent.axis_Id_numeric == 2:
|
||||||
try:
|
try:
|
||||||
self.parent.device_manager.devices[
|
rt = self.parent.device_manager.devices[self.parent.rt]
|
||||||
self.parent.rt
|
if rt.enabled:
|
||||||
].obj.controller.set_rotation_angle(val[self.parent.name]["value"])
|
rt.obj.controller.set_rotation_angle(val[self.parent.name]["value"])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.warning("Failed to set RT value during readback.")
|
logger.warning("Failed to set RT value during readback.")
|
||||||
return val
|
return val
|
||||||
@ -305,6 +308,8 @@ class GalilSetpointSignal(GalilSignalBase):
|
|||||||
self.controller.socket_put_confirmed(f"ntarget={target_val:.3f}")
|
self.controller.socket_put_confirmed(f"ntarget={target_val:.3f}")
|
||||||
self.controller.socket_put_confirmed("movereq=1")
|
self.controller.socket_put_confirmed("movereq=1")
|
||||||
self.controller.socket_put_confirmed("XQ#NEWPAR")
|
self.controller.socket_put_confirmed("XQ#NEWPAR")
|
||||||
|
while self.controller.is_thread_active(0):
|
||||||
|
time.sleep(0.005)
|
||||||
else:
|
else:
|
||||||
raise GalilError("Not all axes are referenced.")
|
raise GalilError("Not all axes are referenced.")
|
||||||
|
|
||||||
@ -322,7 +327,7 @@ class GalilMotorIsMoving(GalilSignalRO):
|
|||||||
@threadlocked
|
@threadlocked
|
||||||
def _socket_get(self):
|
def _socket_get(self):
|
||||||
return (
|
return (
|
||||||
self.controller.is_axis_moving(self.parent.axis_Id)
|
self.controller.is_axis_moving(self.parent.axis_Id, self.parent.axis_Id_numeric)
|
||||||
or self.controller.is_thread_active(0)
|
or self.controller.is_thread_active(0)
|
||||||
or self.controller.is_thread_active(2)
|
or self.controller.is_thread_active(2)
|
||||||
)
|
)
|
||||||
@ -493,9 +498,10 @@ class GalilMotor(Device, PositionerBase):
|
|||||||
position,
|
position,
|
||||||
atol=self.tolerance,
|
atol=self.tolerance,
|
||||||
)
|
)
|
||||||
self._done_moving(success=success)
|
|
||||||
if not success:
|
if not success:
|
||||||
print(" stop")
|
print(" stop")
|
||||||
|
self._done_moving(success=success)
|
||||||
logger.info("Move finished")
|
logger.info("Move finished")
|
||||||
|
|
||||||
threading.Thread(target=move_and_finish, daemon=True).start()
|
threading.Thread(target=move_and_finish, daemon=True).start()
|
||||||
|
@ -363,7 +363,7 @@ class RtLamniController(Controller):
|
|||||||
mode, number_of_positions_planned, current_position_in_scan = self.get_scan_status()
|
mode, number_of_positions_planned, current_position_in_scan = self.get_scan_status()
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
if current_position_in_scan > 5:
|
if current_position_in_scan > 5:
|
||||||
while current_position_in_scan > read_counter:
|
while current_position_in_scan > read_counter + 1:
|
||||||
return_table = (self.socket_put_and_receive(f"r{read_counter}")).split(",")
|
return_table = (self.socket_put_and_receive(f"r{read_counter}")).split(",")
|
||||||
# logger.info(f"{return_table}")
|
# logger.info(f"{return_table}")
|
||||||
logger.info(f"Read {read_counter} out of {number_of_positions_planned}")
|
logger.info(f"Read {read_counter} out of {number_of_positions_planned}")
|
||||||
|
@ -6,10 +6,12 @@ import time
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from bec_utils import bec_logger
|
||||||
from ophyd import Signal
|
from ophyd import Signal
|
||||||
from ophyd.utils.errors import DisconnectedError
|
from ophyd.utils.errors import DisconnectedError
|
||||||
|
|
||||||
logger = logging.getLogger("socket")
|
logger = bec_logger.logger
|
||||||
|
# logger = bec_logger.logger("socket")
|
||||||
|
|
||||||
|
|
||||||
def raise_if_disconnected(fcn):
|
def raise_if_disconnected(fcn):
|
||||||
|
@ -40,6 +40,7 @@ def test_axis_get(pos, msg, sign):
|
|||||||
b"ntarget=0.000\r",
|
b"ntarget=0.000\r",
|
||||||
b"movereq=1\r",
|
b"movereq=1\r",
|
||||||
b"XQ#NEWPAR\r",
|
b"XQ#NEWPAR\r",
|
||||||
|
b"MG_XQ0\r",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
b"1.00",
|
b"1.00",
|
||||||
@ -48,6 +49,7 @@ def test_axis_get(pos, msg, sign):
|
|||||||
b":",
|
b":",
|
||||||
b":",
|
b":",
|
||||||
b":",
|
b":",
|
||||||
|
b"-1",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import pytest
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from ophyd_devices.utils.socket import SocketIO
|
from ophyd_devices.utils.socket import SocketIO
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user