diff --git a/common.py b/common.py index 70590f6..ea30e6a 100644 --- a/common.py +++ b/common.py @@ -50,10 +50,13 @@ class Motor: 'alarm_severity': 'SEVR', } - def __init__(self, ip, port, pv): - self.ip = ip - self.port = port - self.pv = pv + def __init__(self, controller, name): + config = read_config() + self.ip = config['controllers'][controller]['ip'] + self.port = config['controllers'][controller]['port'] + self.busypoll = config['controllers'][controller]['busypoll'] + self.idlepoll = config['controllers'][controller]['idlepoll'] + self.pv = f'{config['pvprefix']}:{controller}:{name}' def write(self, suffix, value): write(self.pv + suffix, value) diff --git a/config.yaml b/config.yaml index 4c78e68..ffa4ecd 100644 --- a/config.yaml +++ b/config.yaml @@ -6,6 +6,10 @@ controllers: turboPmac1: ip: "172.28.101.24" port: 1025 + busypoll: 0.05 + idlepoll: 1 masterMacs1: ip: "172.28.101.66" - port: 1912 \ No newline at end of file + port: 1912 + busypoll: 0.05 + idlepoll: 1 \ No newline at end of file diff --git a/ioc/motors/masterMacs1.cmd b/ioc/motors/masterMacs1.cmd index ff624e8..ad8b208 100755 --- a/ioc/motors/masterMacs1.cmd +++ b/ioc/motors/masterMacs1.cmd @@ -4,7 +4,7 @@ epicsEnvSet("NAME","masterMacs1") epicsEnvSet("ASYN_PORT","p$(NAME)") drvAsynIPPortConfigure("$(ASYN_PORT)","$(MASTERMACS1_IP):$(MASTERMACS1_PORT)") -masterMacsController("$(NAME)","$(ASYN_PORT)",8,0.05,0.05,0.3); +masterMacsController("$(NAME)","$(ASYN_PORT)",8,$(MASTERMACS1_BUSYPOLL),$(MASTERMACS1_IDLEPOLL),0.3); masterMacsAxis("$(NAME)",1); # masterMacsAxis("$(NAME)",2); diff --git a/ioc/motors/turboPmac1.cmd b/ioc/motors/turboPmac1.cmd index dd7f99b..6a2f271 100755 --- a/ioc/motors/turboPmac1.cmd +++ b/ioc/motors/turboPmac1.cmd @@ -5,7 +5,7 @@ # turboPmacController: # Creates the controller object and specifies busy poll period, idle poll period and communication timeout. # A typical call looks like this: -# turboPmacController("$(NAME)","$(ASYN_PORT)",8,0.01,0.01,0.05); +# turboPmacController("$(NAME)","$(ASYN_PORT)",8,0.05,1,0.05); # with # 8 = Total number of axes # 0.05 = Busy poll period in seconds @@ -28,7 +28,7 @@ epicsEnvSet("ASYN_PORT","p$(NAME)") pmacAsynIPPortConfigure("$(ASYN_PORT)","$(TURBOPMAC1_IP):$(TURBOPMAC1_PORT)") -turboPmacController("$(NAME)","$(ASYN_PORT)",8,0.01,1,1); +turboPmacController("$(NAME)","$(ASYN_PORT)",8,$(TURBOPMAC1_BUSYPOLL),$(TURBOPMAC1_IDLEPOLL),1); turboPmacAxis("$(NAME)",1); turboPmacAxis("$(NAME)",5); diff --git a/ioc/startioc.py b/ioc/startioc.py index 1074d96..b4a7280 100755 --- a/ioc/startioc.py +++ b/ioc/startioc.py @@ -31,14 +31,24 @@ def startioc(): f'epicsEnvSet("TURBOPMAC_VERSION", "{config["versions"]["turboPmac"]}")\n') out.write( f'epicsEnvSet("MASTERMACS_VERSION", "{config["versions"]["masterMacs"]}")\n') + out.write( f'epicsEnvSet("TURBOPMAC1_IP", "{config["controllers"]["turboPmac1"]["ip"]}")\n') out.write( f'epicsEnvSet("TURBOPMAC1_PORT", "{config["controllers"]["turboPmac1"]["port"]}")\n') + out.write( + f'epicsEnvSet("TURBOPMAC1_BUSYPOLL", "{config["controllers"]["turboPmac1"]["busypoll"]}")\n') + out.write( + f'epicsEnvSet("TURBOPMAC1_IDLEPOLL", "{config["controllers"]["turboPmac1"]["idlepoll"]}")\n') + out.write( f'epicsEnvSet("MASTERMACS1_IP", "{config["controllers"]["masterMacs1"]["ip"]}")\n') out.write( f'epicsEnvSet("MASTERMACS1_PORT", "{config["controllers"]["masterMacs1"]["port"]}")\n') + out.write( + f'epicsEnvSet("MASTERMACS1_BUSYPOLL", "{config["controllers"]["masterMacs1"]["busypoll"]}")\n') + out.write( + f'epicsEnvSet("MASTERMACS1_IDLEPOLL", "{config["controllers"]["masterMacs1"]["idlepoll"]}")\n') # Set environment variables os.environ["EPICS_BASE"] = "/usr/local/epics/base-7.0.7" @@ -46,7 +56,7 @@ def startioc(): # Change working directory so st.cmd can find other .cmd files os.chdir(root_dir / 'ioc') - + # Run the IOC shell script try: subprocess.run(["/usr/local/bin/iocsh", "st.cmd"], check=True) diff --git a/tests/sinqMotor/limits.py b/tests/sinqMotor/limits.py index feee65c..05f9e7e 100644 --- a/tests/sinqMotor/limits.py +++ b/tests/sinqMotor/limits.py @@ -1,6 +1,8 @@ import time import math +from common import read_config + def reread_limits_from_hw(motor): """ @@ -8,12 +10,13 @@ def reread_limits_from_hw(motor): 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) + # Wait two idle poll periods + time.sleep(2 * motor.idlepoll) # Values should have been reread assert math.isclose(motor.read_field('highlimit'), diff --git a/tests/sinqMotor/turboPmac/rot1/conftest.py b/tests/sinqMotor/turboPmac/rot1/conftest.py index eaaba85..e725ef3 100644 --- a/tests/sinqMotor/turboPmac/rot1/conftest.py +++ b/tests/sinqMotor/turboPmac/rot1/conftest.py @@ -6,10 +6,7 @@ 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') + return TurboPMAC('turboPmac1', 'rot1') def reset(motor):