mirror of
https://github.com/bec-project/ophyd_devices.git
synced 2025-06-24 03:38:00 +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.
|
||||
# Official language image. Look for the different tagged releases at:
|
||||
# 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.
|
||||
before_script:
|
||||
- pip install -r ./requirements.txt
|
||||
@ -18,7 +19,6 @@ formatter:
|
||||
pytest:
|
||||
stage: Test
|
||||
script:
|
||||
- apt-get update && apt-get install -y git
|
||||
- git clone https://oauth2:$CI_BEC_KEY@gitlab.psi.ch/bec/bec.git
|
||||
- pip install -e ./bec/bec_utils
|
||||
- pytest -v ./tests
|
||||
|
@ -134,8 +134,10 @@ class GalilController(Controller):
|
||||
f"Expected return value of ':' but instead received {return_val}"
|
||||
)
|
||||
|
||||
def is_axis_moving(self, axis_Id) -> bool:
|
||||
return bool(float(self.socket_put_and_receive(f"MG_BG{axis_Id}")))
|
||||
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)
|
||||
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:
|
||||
val = float(self.socket_put_and_receive(f"MG_XQ{thread_id}"))
|
||||
@ -250,12 +252,13 @@ class GalilReadbackSignal(GalilSignalRO):
|
||||
return current_pos / step_mm
|
||||
|
||||
def read(self):
|
||||
self._metadata["timestamp"] = time.time()
|
||||
val = super().read()
|
||||
if self.parent.axis_Id_numeric == 2:
|
||||
try:
|
||||
self.parent.device_manager.devices[
|
||||
self.parent.rt
|
||||
].obj.controller.set_rotation_angle(val[self.parent.name]["value"])
|
||||
rt = self.parent.device_manager.devices[self.parent.rt]
|
||||
if rt.enabled:
|
||||
rt.obj.controller.set_rotation_angle(val[self.parent.name]["value"])
|
||||
except KeyError:
|
||||
logger.warning("Failed to set RT value during readback.")
|
||||
return val
|
||||
@ -305,6 +308,8 @@ class GalilSetpointSignal(GalilSignalBase):
|
||||
self.controller.socket_put_confirmed(f"ntarget={target_val:.3f}")
|
||||
self.controller.socket_put_confirmed("movereq=1")
|
||||
self.controller.socket_put_confirmed("XQ#NEWPAR")
|
||||
while self.controller.is_thread_active(0):
|
||||
time.sleep(0.005)
|
||||
else:
|
||||
raise GalilError("Not all axes are referenced.")
|
||||
|
||||
@ -322,7 +327,7 @@ class GalilMotorIsMoving(GalilSignalRO):
|
||||
@threadlocked
|
||||
def _socket_get(self):
|
||||
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(2)
|
||||
)
|
||||
@ -493,9 +498,10 @@ class GalilMotor(Device, PositionerBase):
|
||||
position,
|
||||
atol=self.tolerance,
|
||||
)
|
||||
self._done_moving(success=success)
|
||||
|
||||
if not success:
|
||||
print(" stop")
|
||||
self._done_moving(success=success)
|
||||
logger.info("Move finished")
|
||||
|
||||
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()
|
||||
time.sleep(0.01)
|
||||
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(",")
|
||||
# logger.info(f"{return_table}")
|
||||
logger.info(f"Read {read_counter} out of {number_of_positions_planned}")
|
||||
|
@ -6,10 +6,12 @@ import time
|
||||
import typing
|
||||
|
||||
import numpy as np
|
||||
from bec_utils import bec_logger
|
||||
from ophyd import Signal
|
||||
from ophyd.utils.errors import DisconnectedError
|
||||
|
||||
logger = logging.getLogger("socket")
|
||||
logger = bec_logger.logger
|
||||
# logger = bec_logger.logger("socket")
|
||||
|
||||
|
||||
def raise_if_disconnected(fcn):
|
||||
|
@ -40,6 +40,7 @@ def test_axis_get(pos, msg, sign):
|
||||
b"ntarget=0.000\r",
|
||||
b"movereq=1\r",
|
||||
b"XQ#NEWPAR\r",
|
||||
b"MG_XQ0\r",
|
||||
],
|
||||
[
|
||||
b"1.00",
|
||||
@ -48,6 +49,7 @@ def test_axis_get(pos, msg, sign):
|
||||
b":",
|
||||
b":",
|
||||
b":",
|
||||
b"-1",
|
||||
],
|
||||
),
|
||||
],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
import socket
|
||||
|
||||
from ophyd_devices.utils.socket import SocketIO
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user