Hello Baeg,
You may want to understand that an external command invoked from a CSS action button is executed in the client machine environment, where CSS is installed. All the
requirements the external script depends on should be well-installed and tested to make it work. For your case, it seems you need to have “pyepics” installed on ALL workstations where CSS is deployed and this ActionButton to be used.
Your pictured sequential controls could also be implemented in an external script. It's not as neat as using a dedicated EPICS record, but it offers flexibility. As
you may also note that passing the scripts in the form of a file is cumbersome, so you may want to enclose them as a one-line command, for instance:
python3 -c "from subprocess import Popen;Popen('caput YOUR_MOTOR_PV 180;<logic between the two moves>;caput YOUR_MOTOR_PV -180', shell=True)”
Then OPI file should be self-contained everywhere in your CSS environment.
Cheers,
Tong
From: Tech-talk <tech-talk-bounces at aps.anl.gov>
On Behalf Of whitetiger1123 via Tech-talk
Sent: Tuesday, August 6, 2024 02:21
To: tech-talk at aps.anl.gov
Subject: How to use CSS script?
[EXTERNAL] This email originated from outside of FRIB
Hello, all.
We need to use python script in CSS for the recent new stage. We’ve
looked up several documents, but we are sending you an email to ask for advice.
We build EPICS IOC on a Linux-based server, and css can read pv of IOC in the same ip band based on windows.
When we press action button in CSS execution window, We dreaming of driving the motor once at 180 cw and then again at -180
ccw right away.
I think we need to apply python script to apply this method.
But If we execute python script to action of action button, the error keeps happening.
We’d
like to ask for the cause and advice of this issue.
Attached is the test code below. (This code was just tested with a code that reads the pv value of the motor.)
import sys, time
from epics
import PV
motor_pv = PV('TEST1:TEST6’)
print(motor_pv.value)
The code above is the code I applied with CSS PYTHON SCRIPT.
The error on the console is as follows:
ERROR: Error exists in script ../SCRIPT/test.py
Traceback (most recent call last):
File "<script>", line 2, in <module>
ImportError: No module named epics
I’ve
tried python running on epics ioc and there was no problem.
Please advice me on the cause of the problem.
Thank you always for your help and advice.
Best and Regards,
Baeg