Renamed folder sinqAxis to sinqMotor

This commit is contained in:
2025-07-22 13:49:17 +02:00
parent 8e625c2b97
commit 623969de34
9 changed files with 114 additions and 0 deletions

View File

41
tests/sinqMotor/home.py Normal file
View File

@@ -0,0 +1,41 @@
import time
def home(motor, forward):
encoder = motor.read_field('encoder_type')
if encoder == 'absolute':
is_absolute = True
elif encoder == 'incremental':
is_absolute = False
else:
raise ValueError(f'Unknown encoder type {encoder}')
# Start a homing run and observe the motor behaviour depending on the
# encoder type
if forward:
motor.write_field('homeforward')
else:
motor.write_field('homereverse')
# Give the record some time to react
time.sleep(0.5)
if is_absolute:
# Motor should not move at all
assert motor.read_field('moving') == 0
assert motor.read_field('donemoving') == 1
assert not motor.has_error()
else:
# Motor should start movement
assert motor.read_field('moving') == 1
assert motor.read_field('donemoving') == 0
assert not motor.has_error()
assert not motor.is_homed()
motor.wait_for_done()
assert motor.read_field('moving') == 0
assert motor.read_field('donemoving') == 1
assert not motor.has_error()
assert motor.is_homed()

21
tests/sinqMotor/limits.py Normal file
View File

@@ -0,0 +1,21 @@
import time
def reread_limits_from_hw(motor):
"""
sinqAxis motors usually read their limits from the hardware at each poll,
hence any values manually written to DHLM or DLLM should be overwritten
after the next poll at latest
"""
(high_limit, low_limit) = motor.limits()
motor.write_field('dialhighlimit', high_limit-+10)
motor.write_field('diallowlimit', low_limit-10)
# After two seconds, at least one poll has been done
time.sleep(2)
# Values should have been reread
assert motor.read_field('highlimit') == high_limit
assert motor.read_field('lowlimit') == low_limit
assert motor.read_field('dialhighlimit') == high_limit
assert motor.read_field('diallowlimit') == low_limit

View File

View File

@@ -0,0 +1,9 @@
# Prepare
import pytest
from common import TurboPMAC
@pytest.fixture
def lin1():
return TurboPMAC()

View File

@@ -0,0 +1,25 @@
# This module defines fixtures which are shared for all tests of motor "rot1".
import pytest
from common import TurboPMAC, read_config
@pytest.fixture(autouse=True)
def motor():
config = read_config()
return TurboPMAC(config['controllers']['turboPmac1']['ip'],
config['controllers']['turboPmac1']['port'],
config['pvprefix'] + 'turboPmac1:rot1')
def reset(motor):
"""
Reset the motor for the next test. This means the following things:
1) Resetting all errors
2) Enabling the motor
3) Moving to zero
"""
motor.write_field('stop', 1)
motor.write_field('reseterrorpv', 1)
motor.write_field('enable', 1)
motor.move_and_wait(0)

View File

@@ -0,0 +1,18 @@
# Run a selection of common tests
from tests.move import *
from tests.sinqAxis.limits import *
from tests.sinqAxis.turboPmac.rot1.conftest import reset
# def test_move_to_low_limit_switch(motor):
# reset(motor)
# move_to_low_limit_switch(motor)
# def test_move_to_high_limit_switch(motor):
# reset(motor)
# move_to_high_limit_switch(motor)
def test_reread_limits_from_hw(motor):
reread_limits_from_hw(motor)