I am trying to read a Modbus Boolean register that has multiple bits under the register with alarm points of a devices. I am trying to figure our a way to script a Text Area Persepctive component to read a register and add an IF statement to display a string of text based of if any bit is true. Any suggestions on how to accomplish this? Here is the register map, I would like to read register 9 and any bits 0-15 read true, display the string/text based on the last right column. I currently am connected to this device via UDT and here is my verification of an active alarm "ns=1;s=[{deviceName}]{unitId}.HR10.5" (Bit 5 is active and = TRUE).
I have also given the following Expression Binding a try, I am 100% sure bit 5 is TRUE, but this expression returns "No Alarms Present":
coalesce(
if (getBit({[Sample_Tags]STM Facility/RSF/RSF1-UPS23-DC/PowerMod-Bkr-Alarms},4), "Power Module is Disabled", None),
if (getBit({[Sample_Tags]STM Facility/RSF/RSF1-UPS23-DC/PowerMod-Bkr-Alarms},5), "Power Module Lifetime Error: Close to End",None),
"No Alarms Present"
)
Tip: post your code as preformatted text with the </> button.
Is it possible to have more than one of those alarms active at a time, and if so how would you want to handle that?
I am not clear on exactly how your tags are setup but my first thought as to read that register as a Boolean array, then create a string array memory tag and put your descriptions in the corresponding elements. I played around with this for a few min and to handle the idea of multiple alarms i settled on using the markdown component instead of a label, with this expression binding.
Yes, it is possible to have more than one active alarm present withing that boolean. My first step was to get the alarm text to populate with my one current alarm, then work on generating a list of some sort that would populate one after the other......but how to do that is another piece to this post.