Thanks for your suggestion! Using try and catch, the problem is solved. Thank you!
在2014-05-13 20:30:46,岳敏<[email protected]>写道:
> 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
>
> ********************************
>
>
>
>
- References:
- about CSS BOY 岳敏
- Re: about CSS BOY Kasemir, Kay
- Navigate by Date:
- Prev:
64-bit compatible CAEN SYx527 HV app Ru Igarashi
- Next:
no response first time, so I'm trying again Pierrick Hanlet
- 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:
Re: about CSS BOY Kasemir, Kay
- 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
|