So I'm working on a tool for authorized users to be able to change specific tag values; (On/Off Settings, Cycle Count Thresholds, etc); a mix of PLC and Memory Tags. I wanted to make it dynamic where I can pass in the tag, system looks at the tag, and provides the right "option" for adjustment (Checkbox vs Textfield vs ...). As I was working on it, I noticed some interesting behavior of newly created tags, and tags when changing data types. On Ignition 8.1.32 with plans to upgrade soon.
When using system.tag.getConfiguration on newly created tags:
- When a new tag is created, 'value' key is missing - which would obviously be Null initially
- If your new tag keeps the default data type of Int, 'dataType' key is missing.
The other issue I ran into was data type conversions; I made a default Int tag, set the value to 2, changed it to a string, added mumbo jumbo ie: 2dsaw, then changed it back to Int, where Tag Browser preview showed it back to 2. When I did system.tag.getConfiguration, it showed the 'value' key as '2dsaw', but when I did system.tag.readBlocking on the tag, it showed the proper 2?
All in all, no show stoppers and I can work around it (do .get on the configuration for error handling and make assumptions), but I was surprised those fields aren't created initially, and I was curious if anyone knew why that behavior exists?