From 962f9bcebf50208bacb8798eaecc633671e2384c Mon Sep 17 00:00:00 2001 From: smathis Date: Wed, 23 Jul 2025 09:06:04 +0200 Subject: [PATCH] Got IOC running via ioc/startioc --- common.py | 2 +- ioc/st.cmd | 2 +- ioc/startioc.py | 21 +++++++-------------- tests/sinqMotor/limits.py | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/common.py b/common.py index 0bda0de..a4a4e40 100644 --- a/common.py +++ b/common.py @@ -61,7 +61,7 @@ class Axis: self.write('.' + self.fields[fieldname], value) def read(self, suffix): - return read(self.pv + suffix) + return read(self.pv + suffix).data def read_field(self, fieldname): return self.read('.' + self.fields[fieldname]) diff --git a/ioc/st.cmd b/ioc/st.cmd index 1803999..7cd36c8 100755 --- a/ioc/st.cmd +++ b/ioc/st.cmd @@ -10,7 +10,7 @@ require masterMacs, $(MASTERMACS_VERSION) # Motors # Initialize the motors itself -#< motors/turboPmac1.cmd +< motors/turboPmac1.cmd #< motors/masterMacs1.cmd # Create the test record which is used to detect if the IOC is running diff --git a/ioc/startioc.py b/ioc/startioc.py index 678fed0..1074d96 100755 --- a/ioc/startioc.py +++ b/ioc/startioc.py @@ -13,18 +13,18 @@ from pathlib import Path def startioc(): - root_dir = os.path.dirname(__file__) + '/../' + root_dir = Path(__file__).resolve().parent.parent - with open(root_dir + "config.yaml", "r") as f: + with open(root_dir / "config.yaml", "r") as f: config = yaml.safe_load(f) - with open(root_dir + 'ioc/config.cmd', "w") as out: + 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') + f'epicsEnvSet("IOCDIR", "{root_dir / "ioc"}" )\n') # Motor configuration out.write( @@ -44,17 +44,10 @@ def startioc(): os.environ["EPICS_BASE"] = "/usr/local/epics/base-7.0.7" os.environ["EPICS_HOST_ARCH"] = "RHEL8-x86_64" - # Get the full directory path of the script - script_dir = Path(__file__).resolve().parent - # Change working directory so st.cmd can find other .cmd files - os.chdir(script_dir) - - print("Current working directory:", os.getcwd()) - print("Script directory:", script_dir) - print("Files in directory:", os.listdir()) - - # Run the IOC shell script + os.chdir(root_dir / 'ioc') + + # Run the IOC shell script try: subprocess.run(["/usr/local/bin/iocsh", "st.cmd"], check=True) except subprocess.CalledProcessError as e: diff --git a/tests/sinqMotor/limits.py b/tests/sinqMotor/limits.py index 621ac5a..63e37f5 100644 --- a/tests/sinqMotor/limits.py +++ b/tests/sinqMotor/limits.py @@ -8,7 +8,7 @@ def reread_limits_from_hw(motor): after the next poll at latest """ (high_limit, low_limit) = motor.limits() - motor.write_field('dialhighlimit', high_limit-+10) + motor.write_field('dialhighlimit', high_limit+10) motor.write_field('diallowlimit', low_limit-10) # After two seconds, at least one poll has been done