Hello,
I have created a UDT which stores 6 boolean values. The values represent hand, off, auto commands and indications. That is - auto command, auto indication, hand command, hand indication, etc.
The UDT also contains a member tag which attempts to look at the 3 indication tags and convert these into a string. The problem is - I don't know how to combine the 3 values into a single value which the case statement can look at to determine the string value.
Here is what the UDT structure looks like:
Here was my first attempt at writing an expression to accomplish the above:
First Attempt
// Inspect digital signals and create string format
case(
// Off bit is high, hand bit is low, auto bit is low (OFF)
{[.]DIND_OFF}&&!{[.]DIND_HAND}&&!{[.]DIND_AUTO}, "Off",
// Off bit is low, hand bit is high, auto bit is low (HAND)
!{[.]DIND_OFF}&&{[.]DIND_HAND}&&!{[.]DIND_AUTO}, "Hand",
// Off bit is low, hand bit is low, auto bit is high (AUTO)
!{[.]DIND_OFF}&&{[.]DIND_HAND}&&!{[.]DIND_AUTO}, "Auto",
// Default Return
forceQuality("!BAD STATE!", 0)
)
I think one possible solution could be:
Possible Solution
// Inspect digital signals and create string format
case(
// Value to inspect
toInt(concat({[.]DIND_OFF}&&{[.]DIND_HAND}&&{[.]DIND_AUTO}), -1)
// Off bit is high, hand bit is low, auto bit is low (OFF)
4, "Off",
// Off bit is low, hand bit is high, auto bit is low (HAND)
2, "Hand",
// Off bit is low, hand bit is low, auto bit is high (AUTO)
1, "Auto",
// Default Return
forceQuality("!BAD STATE!", 0)
)
But quite frankly I think this solution is kind of ugly... is there any other solutions you have used in the past?
Thank you!