diff --git a/example_custom_script.py b/example_custom_script.py old mode 100644 new mode 100755 index ed22cda..5de93f3 --- a/example_custom_script.py +++ b/example_custom_script.py @@ -23,4 +23,4 @@ motor.write_field('enable', 0) time.sleep(2) # Reenable the motor -motor.write_field('enable', 0) +motor.write_field('enable', 1) diff --git a/ioc/motors/masterMacs1.cmd b/ioc/motors/masterMacs1.cmd index ad8b208..fcb6689 100755 --- a/ioc/motors/masterMacs1.cmd +++ b/ioc/motors/masterMacs1.cmd @@ -6,7 +6,9 @@ epicsEnvSet("ASYN_PORT","p$(NAME)") drvAsynIPPortConfigure("$(ASYN_PORT)","$(MASTERMACS1_IP):$(MASTERMACS1_PORT)") masterMacsController("$(NAME)","$(ASYN_PORT)",8,$(MASTERMACS1_BUSYPOLL),$(MASTERMACS1_IDLEPOLL),0.3); masterMacsAxis("$(NAME)",1); -# masterMacsAxis("$(NAME)",2); +masterMacsAxis("$(NAME)",2); +#masterMacsAxis("$(NAME)",3); +#masterMacsAxis("$(NAME)",4); epicsEnvSet("SINQDBPATH","$(masterMacs_DB)/sinqMotor.db") dbLoadTemplate("$(IOCDIR)/motors/$(NAME).substitutions", "INSTR=$(PVPREFIX):$(NAME):,CONTROLLER=$(NAME)") diff --git a/ioc/motors/masterMacs1.substitutions b/ioc/motors/masterMacs1.substitutions index 2edc237..94692f9 100755 --- a/ioc/motors/masterMacs1.substitutions +++ b/ioc/motors/masterMacs1.substitutions @@ -1,6 +1,9 @@ file $(SINQDBPATH) { pattern -{ AXIS, M, EGU, DIR, MRES, ENABLEMOVWATCHDOG, LIMITSOFFSET, CANSETSPEED } -{ 1, "lin1", mm, Pos, 0.001, 1, 1.0, 1 } +{ AXIS, M, EGU, DIR, MRES, ENABLEMOVWATCHDOG, LIMITSOFFSET, CANSETSPEED } +{ 1, "lin1", mm, Pos, 0.001, 1, 1.0, 1 } +{ 2, "rot1", deg, Pos, 0.001, 1, 1.0, 1 } +#{ 3, "doesnotexist1", mm, Pos, 0.001, 1, 1.0, 1 } +#{ 4, "doesnotexist2", mm, Pos, 0.001, 1, 1.0, 1 } } diff --git a/ioc/st.cmd b/ioc/st.cmd index 7cd36c8..fa919fe 100755 --- a/ioc/st.cmd +++ b/ioc/st.cmd @@ -11,7 +11,7 @@ require masterMacs, $(MASTERMACS_VERSION) # Initialize the motors itself < motors/turboPmac1.cmd -#< motors/masterMacs1.cmd +< motors/masterMacs1.cmd # Create the test record which is used to detect if the IOC is running dbLoadRecords("$(IOCDIR)/db/ready.db", "PVPREFIX=$(PVPREFIX)") diff --git a/tests/move.py b/tests/move.py index 0d60658..111dc77 100755 --- a/tests/move.py +++ b/tests/move.py @@ -34,6 +34,10 @@ def move_while_move(motor, first_target, second_target): assert motor.at_target() assert not motor.has_error() +def stop_then_move(motor, target): + motor.write_field('stop', 1) + motor.write_field('writepv', target) + def stop(motor, target): """ diff --git a/tests/sinqMotor/turboPmac/common.py b/tests/sinqMotor/turboPmac/common.py new file mode 100644 index 0000000..801a0e5 --- /dev/null +++ b/tests/sinqMotor/turboPmac/common.py @@ -0,0 +1,21 @@ +import time +import pytest + +def stop_reset_enable_move_sequence(motor, target): + + motor.write_field('stop', 1) + motor.write_field('reseterrorpv', 1) + motor.write_field('enable', 1) + + # Wait until the motor is enabled. + now = time.time() + max_enable_time = 10 + while motor.read_field('enable_rbv') == 0: + # Wait a maximum of max_enable_time seconds until enabling + if time.time() > now + max_enable_time: + pytest.fail(f'Motor {self.pv} could not be enabled in {max_enable_time} seconds') + time.sleep(0.1) + + motor.move_and_wait(target) + assert motor.at_target(target) + assert not motor.has_error() \ No newline at end of file diff --git a/tests/sinqMotor/turboPmac/reset.py b/tests/sinqMotor/turboPmac/reset.py old mode 100644 new mode 100755 index 36b35a8..7bfb9fb --- a/tests/sinqMotor/turboPmac/reset.py +++ b/tests/sinqMotor/turboPmac/reset.py @@ -9,20 +9,19 @@ def reset(motor, initpos=0): 4) Moving to zero """ - # motor.write_field('stop', 1) + motor.write_field('stop', 1) # Reset any errors motor.write_field('reseterrorpv', 1) - # The reset may take some time -> Wait a bit - time.sleep(1) + time.sleep(2*motor.idlepoll) if motor.read_field('enable_rbv') == 0: motor.write_field('enable', 1) # Wait until the motor is enabled. now = time.time() - max_enable_time = 5 + max_enable_time = 10 while motor.read_field('enable_rbv') == 0: # Wait a maximum of max_enable_time seconds until enabling if time.time() > now + max_enable_time: diff --git a/tests/sinqMotor/turboPmac/rot1/test_common.py b/tests/sinqMotor/turboPmac/rot1/test_common.py index 295ed2b..30943f9 100755 --- a/tests/sinqMotor/turboPmac/rot1/test_common.py +++ b/tests/sinqMotor/turboPmac/rot1/test_common.py @@ -2,8 +2,11 @@ from tests.move import * from tests.sinqMotor.limits import * +from tests.sinqMotor.turboPmac.common import * from tests.sinqMotor.turboPmac.reset import reset +def stop_reset_enable_move_sequence(motor): + stop_reset_enable_move(motor, 5) def test_move_to_low_limit_switch(motor): reset(motor) @@ -21,5 +24,11 @@ def test_stop(motor): reset(motor) stop(motor, 3000) +def test_stop_then_move(motor): + reset(motor) + stop_then_move(motor, 0) + + + #def test_reread_limits_from_hw(motor): # reread_limits_from_hw(motor)