[quote="Dravik"]I think Z is wondering if a feature could be added to define say a tag as F,and on using it for a screen bind it as C(or set an override 'unit') and have Ignition do the conversion for it.
I'd imagine there would need to be a prebuilt conversion table for simple ones(F to C, C to F, inches to cm, etc) and possibly a user defined table for more esoteric conversions.[/quote]
I've been playing with this:
Yes, you can do it with script (in fact, there is no other option for now), but you must do it for every TAG (or label or input field).
I found that the 'easiest' way to do it is to set scaling of tag to 0 (OFF) or 1 (linear scaling).
Somewhere on the screen I put two radio buttons (one for Celsius and one for Fahrenheit). Then in property change event of this two radio buttons I change the 'ScaleMode' of the tag:
# For Fahrenheit
system.tag.writeToTag('Vipa/MW20.ScaleMode', 1)
# For Celsius
system.tag.writeToTag('Vipa/MW20.ScaleMode', 0)
The 'problem' is, you have to do it for all tags. For example I have 20 temperatures and I have to write 20 writeToTag commands (or writeAll, with the predefined tags paths and values).
The second problem I have is, that I want to change the EngUnit also:
# For Fahrenheit
system.tag.writeToTag('Vipa/MW20.ScaleMode', 1)
system.tag.writeToTag('Vipa/MW20.EngUnit', "F")
# For Celsius
system.tag.writeToTag('Vipa/MW20.ScaleMode', 0)
system.tag.writeToTag('Vipa/MW20.EngUnit', "C")
The change to EngUnit works only for first write (for examle 'F'). The second write ('C') writes the 'C' in the EngUnit, but something overwrites it back to 'F'. I was unable to find what is doing this.
The third 'problem' I see with this (changing the 'ScaleMode') is, that every time I change ScaleMode, the tag quality changes for a second (becomes bad and then good again). I understand why (the tag must be unsubscribed and subscribe again to use new setting), but maybe, if this was on some 'system' or project level, we can avoid that.
I think also, that making the 'Scale Mode' property in the Tag editor bindable to another tag or property or expression will help a lot.