I would like to manipulate hex values - my PLC times are coming in as Hex.
The int field shows as 2048 (dec) -> 800 (hex)
where the 800 is meant to represent 08:00 (8am). I would like to directly read and edit the tag as hex. Can anyone point me in the right direction? I need to provide start/stop times so I want to make these times editable.
Python already has tools to convert between hex and decimal. You could make a function in the script module and call it from anywhere. ie:[code]def toHex(decVal):
#returns a string
return hex(decVal)[2:]
def toDec(hexVal):
#returns an int
return int(str(hexVal), 16)[/code]And call it with[code]
runScript("app.hex.toHex(2048)")
returns '800'
runScript("app.hex.toDec('800')")
returns 2048[/code]The only problem there is that you will never have a truly bidirectional binding. You best bet will be to do your writing in property change events or on a button press.
Thanks - this gives me a good place to start.