Hi All,
I’m new to Perspective.
I’m trying to link running, stopped and faulted of a pump to my tags (running, stopped and tripped).
Can someone please advise.
Thanks
Hi All,
I’m new to Perspective.
I’m trying to link running, stopped and faulted of a pump to my tags (running, stopped and tripped).
Can someone please advise.
Thanks
Have you tried linking it to a tag and using a map transform?
I’m assuming you have those 3 tags as booleans, and there will always be one and only one true
.
You could bind the state
property to an expression structure, and add a little script:
This is probably doable with expressions, but I don’t like them.
I can explain how this works in more details if you’re not familiar with all of this, just let me know.
Another way you could consider if you need the same logic in other places of your project, would be to create a new tag containing the current state, then use a tag binding on the state
property of the pump and add a map transform.
There are many ways to skin this cat. If it's a single tag, I'd echo @rourksb's recommendation of a map transform - it's simple to set up and easy to change later. If you have multiple tags, you could use @pascal.fragnoud's suggestion, though I'd simplify to two elements:
binEnum
to translate it to a single numeric valueSidebar: This is perfectly reasonable if you're more comfortable with scripting, just be aware you're leaving performance on the table. Jython compilation can be a significant bottleneck; the more script transforms you're using the more that can pile up. For a simple task like this I'd strongly recommend an expression based solution.
Yes, I try to use expressions where I can figure out quickly how to do what I want. But if it doesn’t work after a few tries, I’ll just switch to scripting.
To be perfectly honest, it’s not the expressions I don’t like, it’s the doc. More often than not, I find myself confused after reading the doc, or not sure where to go next to find the information I need.
On the other hand, python, even if it’s Jython is quite well documented.
For example, I gave expressions a shot for this case. BinEnum is exactly what I would have wanted to find, but… It’s not like the name speaks for itself, and there’s not much pointing in its direction for the case at hands.
Thanks for all the help gents.
I came right using the map transform but will try the other methods as well.
Could you use expressions here to map multiple tags to the same prop?
i.e. I have one tag that checks if the pump is running but another tag that indicates if it is faulted
Follow what @PGriffith described above using binEnum
.
Yes. If the tags aren't mutually exclusive then use binEnc
.
Code:
//pumpRunning pumpFaulted Result
// 0 0 00 = 0
// 1 0 01 = 1
// 0 1 10 = 2
// 1 1 11 = 3
binEnc({value}['pumpRunning'], {value}['pumpFaulted'])
This worked, thank you!
Thanks for the reply. I ended up having to use binEnc
because I have 1 tag for 'running' and 'stopped' and another tag for 'faulted' so the 3 values are not mutually exclusive.
You can easily accomplish this by using the map transform.
If you use boolean type data tag, simply use true & false instead of numeric input range.
The OP has 3 distinct tags for each state, not a single tag, which is why binEnc was suggested to combine them together before using a map
Yes, If the OP has multiple tags for each state, then using binEnc
to combine them into a single representation before mapping is a practical approach. This ensures that the tags are treated as a unified entity, allowing for efficient mapping and retrieval.