41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
# This script is used to start the test IOC and is usually run as part of a
|
|
# test startup procedure. It autogenerates an IOC shell script from motors.yaml
|
|
# which contains the IP adresses and ports of the motor controllers.
|
|
|
|
import yaml
|
|
import os
|
|
import subprocess
|
|
|
|
|
|
def startioc():
|
|
|
|
root_dir = os.path.dirname(__file__) + '/../'
|
|
|
|
with open(root_dir + "config.yaml", "r") as f:
|
|
config = yaml.safe_load(f)
|
|
|
|
with open(root_dir + 'ioc/config.cmd', "w") as out:
|
|
|
|
# General configuration
|
|
out.write(
|
|
f'epicsEnvSet("PVPREFIX"," {config["pvprefix"]})\n')
|
|
out.write(
|
|
f'epicsEnvSet("IOCDIR", "{root_dir + "ioc"}" )\n')
|
|
|
|
# Motor configuration
|
|
out.write(
|
|
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("MASTERMACS1_IP", "{config["controllers"]["masterMacs1"]["ip"]}")\n')
|
|
out.write(
|
|
f'epicsEnvSet("MASTERMACS1_PORT", "{config["controllers"]["masterMacs1"]["port"]}")\n')
|
|
|
|
# Start the IOC itself
|
|
subprocess.run("st.cmd")
|