Scripting libraries for V8 and V7.9

Hi,

I see that there is a significant difference in the scripting libraries such as tag library between version 8 and version 7.9 (V7.9 has more functions than V8).

Also , why are readAll and writeAll functions not provided in V8. They are supposed to be faster for group of variables., then how to read/write a bunch of tags in one go in V8?

Also the documentation such as sample code etc are missing in V8. Is it under preparation/updation!

readAll and writeAll still exist, but they are hidden (this is how deprecate scripting functions).

They’ve been replaced by readAsync, readBlocking, writeAsync, and writeBlocking, all of which accept multiple tag paths.

These functions are all documented in the Designer and in the beta manual.

1 Like

Ok, however for older versions <8.0, the asyncRead/Write functions will not exist , so do we have to use the readAll/writeAll functions, or will the Async versions also be supported in older versions as well? Do we have to maintain two versions of our scripts for v8 and <8? What’s the suggestion?

regards

Up to you I guess. I think we’d expect you to just use the right function for the version of Ignition you’re on.

1 Like

Which scripting function in system.tag libraries allow reading the tag properties such as:

General properties, Numerical properties, Metadata properties, Permission properties, Alarm properties, etc (I am mainly interested in the meta data such as engg units, documentation, format for display etc).

Is there a way to identify from the tag values read using tag read scripts, if a tag is in alarm state and in which state is it now (without having to assign scripts to tag alarm events). In other words, I should be able to get initial value of a tag’s alarm state (active, acknowledged, reset).

Also instead of assigning a script to alarm event of a tag manually from the designer, is there a way to subscribe an an alarm event for a given tag(s) thru script?

https://docs.inductiveautomation.com/display/DOC80/system.tag.getConfiguration

1 Like

Thanks a lot Ryan. However the V8 library seems to be different from 7.9 , which was more complete with examples. Hopefully V8 documentation will also be updated with examples soon!

While this gives the static configuration details of tags as well as including alarm configuration details, however how to get alarm status for tags (whether in alarm state, ack, reset state) and get alarm triggers?

import json doesn’t seem to work in python scripts version 7.9 of Ignition where as in version 8.0 its working fine! in 7.9 it gives - ImportError: No module named json??)

Is that so or am I missing some thing?

The JSON module doesn’t exist in 7.9. We upgraded from Jython 2.5 to 2.7 in Ignition 8.

On 7.9, you need to use system.util.jsonDecode and system.util.jsonEncode.

Thanks a lot Kevin for the confirmation. One more doubt, I hope the read file read and read tag script functions are synchronous in both versions (8 and <8). They seem to be so to me right now, but I hope they will continue to be supported in version 8+, so that our scripts works across >8 and <8 versions without any change?

Thanks a lot Sanderd17 for the hint, but I used the “ast” module and got it working. Hope its ok to use this as well? Or do you see any problems with it and suggest your suggested libraries?

I observe that system.date.now function is not supported in Ignition 7.7. Also the documentation for Ignition is give from Ignition version 7.8, 7.9 and 8. Can we assume that 7.7 and lower versions will not be required to be supported? I am just trying to ensure that my scripting modules work on older versions as well? Whats the minimum version that should test for?

You decide for yourself what versions to support. v7.7 is an LTS, so I support that. I will support v7.9 for a long time for the same reason. I also support v7.8 because it is easy, being between two versions I do support.

FWIW, 7.7’s LTS period expires in July 2019.

1 Like

Thanks a lot all of you. Only challenge is that we need to test our scripts on all the versions to ensure they really work. e.g. import json was not supported in version 7.9 so we had to find an alternative solution. Similarly the system.date.now function doesn’t seem to be present in 7.7.Perhaps testing for a lower version of Ignition will ensure upward compatibility, unless higher versions of python library deprecate some of the previous version functions (e.g. some functions are replaced with their asynchronous versions e.g. file reads or tag reads etc, in that case we need to redesign the modules, unless the synchronous versions are still supported.

I think its best to test for each major version to ensure things are working.

This doesn’t seem to work! ast.literal_eval works fine!

Scripting supports the windows (awt) and timer events. How can we add our own event listeners in scripting?

Implement the functionality in a jython class that extends the appropriate Adapter class and overrides the methods of interest. Add instances of that class to your components using the corresponding .add***Listener() method.

jython class created , extending the adapter class. However how to override the methods of the class that extends the Adapter class? By simply redefining these abstract?

No, just implement the method in jython. If there are multiple signatures for a method in java, the one method will override all of them. You’ll have to leverage *args and check argument types yourself to re-implement all of them.

Event Adapter types generally don’t have that problem, so you just implement the methods of interest.

1 Like