I have long wanted a clean way in Ignition to create an internal boolean tag that points at an OPC based integer or short so I can easily link graphics to set/clear a bit of an OPC tag without scripting. I have used the setBit and getBit functions in scripting posted elsewhere in the forum but this seems overly complex. I have a number of modbus devices that don’t allow the function to mask write an integer, so I cannot do this directly through OPC tags.
I thought derived tags should be able to do a masked read and write from a base integer tag pretty easily - create a boolean derived tag and point it to the integer OPC tag. In the Read Expression section - take the source value from the int tag, shift and AND it appropriately to mask out the bit, and in the In the Write Expression, reverse the process and rebuild the tag out of the source.
However, Ignition doesn’t seem to like me making a derived tag of a different type than the source tag it points to. It’ll work if I don’t change the Read Expression and Write Expression, just converting the int tag directly into a bool and back. But as soon as I change the read and write expressions it breaks. Here are two pictures of the setup:
I’ve toyed around with conversions and such, but believe the derived tag is doing conversions behind the scenes before I get the source and value.
Is there a way to achieve bit masking with the derived tag?