CSS BOY handles the connections for you.
By default, your script will only be called if all PVs are connected.
If you do check the option "Execute anyway even if some PVs are disconnected", then yes, you'll have to handle the case that a PV is disconnected.
You could do this:
if pvs[0].isConnected():
value = PVUtil.getDouble(pvs[0])
to check if the PV is connected, but
1) That uses the IPV#isConnected() call, and details of the PV implementation might change, so your script will not be portable.
OK, portability of scripts cannot be guaranteed anyway, but..
2) Race condition: The PV might be connected when you call isConnected(), but then disconnect just before you call getDouble, so you still get the error.
So your best bet might be:
try:
value = PVUtil.getDouble(pvs[0])
except Exception, e:
# Well, something failed. Maybe the PV is disconnected?
pass
-Kay
On May 12, 2014, at 9:49 PM, 岳敏 <[email protected]<mailto:[email protected]>>
wrote:
I meet some problem while using CSS. The problem is when I use PVUtil.getDouble() to get the value of some PV, there will be ERROR in BOY console if the PV is disconnected. An example ERROR information is "2014-05-04 17:12:48 ERROR: Error exists in script/CSS/JavaScript/ECR_Print.js Wrapped java.lang.RuntimeException: PV SSC-LINAC:ECR:AGL-BEAM has no value. (script#23)". How can I check the connecting state in javascript code before I use PVUtil.getDouble()?
--
********************************
岳 敏 Min Yue
Institute of Modern Physics, Chinese Academy of Sciences
509 Nanchang Road, Lanzhou, 730000, P.R.China
Tel:+86-0931-4969469
Handy: +86-18509316383
********************************
- Replies:
- Re: Re: about CSS BOY 岳敏
- References:
- about CSS BOY 岳敏
- Navigate by Date:
- Prev:
Sorry, Please ignore this new Email : Application Export from CSS IDE<EOM> Ganesh Jangir
- Next:
ssrlApps for devIocStats, etc Phillip Sorensen
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
about CSS BOY 岳敏
- Next:
Re: Re: about CSS BOY 岳敏
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|