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 | 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 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Compare two string-type PVs in CSS/BOY rule |
From: | "Hu, Yong via Tech-talk" <tech-talk at aps.anl.gov> |
To: | "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Thu, 14 May 2020 03:13:37 +0000 |
Hello everyone, Hope this post finds you and your loved ones safe and healthy. This post is mainly for CS-Studio developers as well as for anyone who has experience of using BOY Rule. Yesterday, I was prototyping a project which utilizes CS-Studio BOY Rule to compare two PVs (string-like type). At the beginning, I thought it should be a straightforward and easy task as I have used pvStr0
== “my message” successfully in the past. So, I wrote the Boolean _expression_ as shown in the screenshot attached. The BOY Rule is simple. Two Input PVs (again, see attached screenshot):
#0 is sys://user which is a CS-Studio system PV, the username who runs CS-Studio. For me, when I run css, the value is “yhu”; #1 is username-Str which is an IOC PV (stringin) I have created; this PV can be changed by caput; The rule is just about comparing two strings. After caput username-Str "yhu”, the Boolean _expression_ “pvStr0 == pvStr1” should be true so that the background color should be changed to green. However, I do
not see any background color change for the widget with the rule ‘back_color’. I finally figured out what is the problem. As always, strings are tricky. In BOY Rule, it seems we have to use “String(pvStr0) == String(pvStr1)” to compare two strings-type PVs. The way I found this solution is by looking at the BOY Generated Script as well as the code below (search getString): Probably, this is a bug in the BOY Rule to be fixed by CSS developers. I do not think CSS users need to think about using String() to cast pvStr* to whatever String data type BOY understands. For ordinary
users, pvStr0 == pvStr1 is a straightforward thinking, just like using pvStr0 == “my message”.
The problem happens on CS-Studio 4.5.1 which is the production version used at NSLS-II. I have not tried this kind of Rule on newer CSS versions. Maybe someone can give a try on the latest version. Cheers, Yong Hu NSLS-II Controls Group |
Attachment:
BOY-rule.png
Description: BOY-rule.png