EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Multi-threading in BOY Python scripts
From: "Kasemir, Kay" <[email protected]>
To: Márcio Paduan Donadio <[email protected]>
Cc: "[email protected]" <[email protected]>
Date: Wed, 29 Jul 2015 14:58:33 +0000
Hi:

On beamlines, we have the same experience that python can be a very good tool.

We use pcaspy, the Python CA server lib to turn python code into ‘IOCs’. That way, logic that has been implemented in python is available as PVs.

You can also use one of the python CA client libs for a pure client. We use PyEpics because it works well with pcaspy within the same program. That way, your python code can read any PV, do whatever it wants to do, and publish results as PVs.

That way, your good python code can be triggered by PVs, and results can be displayed based on PVs.
At the same time, the worst your bad python code can do is hang itself, because each ‘python IOC’ is its own process.

You certainly want to avoid adding bad python code to the GUI. Even good python code in the GUI should be limited to what’s really desperately required for the GUI. Any code related to computation, automation, .. belongs into an IOC-type service.

Thanks,
Kay 


> On Jul 29, 2015, at 8:59 AM, Márcio Paduan Donadio <[email protected]> wrote:
> 
> 
>         Kasemir,
> 
>     thank you for your answer. Let me tell our story:
> 
>     We saw in CS-Studio a good opportunity to beamline's staff to build 
> their own screens because of the user friendly interface. The problem is 
> that beamline's staff are full of good idea and desires, but have poor 
> programming skills. So, we prepared a 2 days course as they could start 
> to use CS-Studio in a basic way. Even with few programming skills they 
> could build beautiful and useful screens to use the IOCs we developed 
> for them.
> 
>     For complex tasks we created a python framework called py4syn that 
> they use in parallel with CS-Studio.
> 
>     The problem is that some of them adventure themselves to develop 
> complex python scripts and embedded them in BOY widgets. The result is 
> that sometimes CS-Studio freezes because of script issues and the 
> biggest derived problem is that their wrong perception is that CS-Studio 
> is not a good tool. This way, two of our beamlines decided to migrate to 
> MEDM, even when we tried to show that the problem was not caused by the 
> tool.
> 
>     For us in LNLS it is a good strategy to give some freedom to 
> beamline's staff to build some pieces of software in the EPICS client 
> layer, but due to lack of programming skills we don't think it's a good 
> idea to allow them to build their own IOCs.
> 
>     I agree that the best way to work is not to put those scripts 
> inside BOY, but could I suggest to put some protection mechanisms that 
> allow CS-Studio to run smoothly even if an embedded script runs in an 
> accidental continuous loop?
> 
>     Thank you again,
> 
> -- 
> Márcio Paduan Donadio
> Computer Engineer - Beamline Operation Software
> Laboratório Nacional de Luz Síncrotron – (LNLS)
> Centro Nacional de Pesquisa em Energia e Materiais (CNPEM)
> + 55 (19) 3512-3520 - [email protected]
> www .  lnls . cnpem . br
> 
> 
> 
> On 28-07-2015 12:53, Kasemir, Kay wrote:
>>> On Jul 28, 2015, at 10:29 AM, Márcio Paduan Donadio <[email protected]> wrote:
>>> 
>>> 
>>>         Dear Folks,
>>> 
>>>     is there a way to run a python script in a BOY widget in a thread
>>> separate from BOY? We are facing CS-Studio freezing by scripts that take
>>> too much time to run.
>> See BOY Examples/5_6_UseThreadInScript.opi
>> 
>> The use of scripts, however, is discouraged in general.
>> The script API is not guaranteed to stay as it is.
>> In fact any attempt to improve the BOY performance (hxxps://github.com/ControlSystemStudio/cs-studio/issues/1230) is almost guaranteed to break your scripts.
>> Don’t implement any processing logic in a script which should really be on an IOC.
>> If you have to ask how to do things in a script, you’re likely to cause more trouble than good.
>> 
>> Thanks,
>> Kay
> 
> 



Replies:
RE: Multi-threading in BOY Python scripts Williams Jr., Ernest L.
References:
Multi-threading in BOY Python scripts Márcio Paduan Donadio
Re: Multi-threading in BOY Python scripts Kasemir, Kay
Re: Multi-threading in BOY Python scripts Márcio Paduan Donadio

Navigate by Date:
Prev: Re: Multi-threading in BOY Python scripts Pete Jemian
Next: RE: Multi-threading in BOY Python scripts Williams Jr., Ernest L.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Multi-threading in BOY Python scripts Pete Jemian
Next: RE: Multi-threading in BOY Python scripts Williams Jr., Ernest L.
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  <20152016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 16 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·