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):
https://github.com/ControlSystemStudio/cs-studio/blob/master/applications/opibuilder/opibuilder-plugins/org.csstudio.opibuilder/src/org/csstudio/opibuilder/scriptUtil/PVUtil.java
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