Parametrized busypoll and idlepoll
This commit is contained in:
11
common.py
11
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)
|
||||
|
||||
@@ -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
|
||||
port: 1912
|
||||
busypoll: 0.05
|
||||
idlepoll: 1
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user