I have a system that takes coordinates from an Input on an HMI (perspective Edge). The coordinates are input as mm and in the PLC everything is in mm as well. However for my operators everything is inches. I am trying to setup a numeric entry field that will allow the operator to input Inches, I then convert to mm to send to the PLC.
On the screen my Numeric Entry component is bond to a Tag (PLC). With an expression transform:
This converts the PLC tag values to Inches.
round(({value} / 25.4), 3)
On the same component I have a property change script tied to the value property.
This script is working but I get a feedback loop effect, where after a change is made the PLC tag updates and causes the value property to change again (due to the binding and transform).
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
memtag = ["[edge]aLuxwall/Recipe/lengthMem"]
mmtag = ["[edge]HMI_PART_LENGTH/DINT_IN.value"]
mem = system.tag.readBlocking(memtag)
mm_cur = system.tag.readBlocking(mmtag)
mm_val = mm_cur[0].value
mem_val = mem[0].value
value = self.props.value
mm = value * 25.4
mm_new = int(mm)
if currentValue.value != mem_val:
#if previousValue.value != mem_val:
system.tag.writeBlocking(mmtag, mm_new)
system.tag.writeBlocking(memtag, value)
I have not used Derived Tags ever. @Ryan_Allen idea was simple and correct, except for one minor detail. My inch dimensions can be a float, like 18.125 (18 1/8 in) and my coordinate tag is a DINT.
I wonder what the more efficient way to do unit swapping in clients would be: using multiple opc tags with different scaling ans displaying one or the other, or using a single opc tag with derived tags for other units?