Extending System Function library?

I want to extend the “system.tag.configure” method, but I’m not sure the setup.
Do I need to initialize something from the ClientModuleHook class and/or pom.xml to trigger the method override?

public class TagScriptHook extends ClientTagUtilities {

    private final LoggerEx logger = LogUtil.getLogger(getClass().getSimpleName());

    public TagScriptUtilities(ClientContext context, ClientTagManager tagManager) {
        super(context, tagManager);
    }

    @Override
    protected List<QualityCode> saveTagConfigs(String s, List<TagConfiguration> list, CollisionPolicy collisionPolicy) {
        this.logger.info("Testing this here...");
        //do stuff
        return super.saveTagConfigs(s, list, collisionPolicy);
    }
}

What do you mean by extend, exactly?
Jython’s method resolution is opaque, so even if you are loading your defined script module correctly, I don’t think it’s likely to be actually used.

As for your main question - are you overriding public void initializeScriptManager(ScriptManager manager) on your hook? You would call manager.addScriptModule(new TagScriptHook()) or some equivalent override.

Don’t mean to hijack the thread, I had a similar question for an idea I just had thought of today. I have (currently as a script in jython) a function that takes a named query, and populates a window in vision, populating components with the database values retrieved by using some predefined naming conventions on the components. It would be really cool if I could make it system.gui.populate('someWindow', 'namedQuery', queryParams), but I am guessing Ignition would not be happy for liability reasons about allowing 3rd parties to make functions that look like they’re from IA. That’s my intuition, is that correct?

Thanks! I just want “system.tag.configure” to do additional stuff when it gets executed.

Adding the code you suggested to the clientModuleHook seems to do it.

public class ClientHook extends AbstractClientModuleHook {

    @Override
    public void initializeScriptManager(ScriptManager manager) {
        super.initializeScriptManager(manager);
        manager.addScriptModule("system.tag", TagScriptUtilities.class);
    }
}

You can extend it to something like “system.3rdparty.gui.populate”…
Don’t see any harm in that.

2 Likes

Disclaimer: This is not legal advice.
We certainly don't do anything to stop you from doing that. The general convention, which I would recommend following, is for any third party modules to namespace their extensions under a unique 'package' name, so system.$yourPackage.function.

1 Like

How would I use the gateway log from the client scope?
Logging in the client scope gives me an “AuditManager” warning on the gateway log.
It looks like LoggerEx works best in the gateway scope.

I’m just trying to think of a way to sell it to my coworkers that its worth it to give me time to learn the SDK and develop on it. Think being able to call a function with our company name in it might be even better for that cause, so don’t have to worry about me causing any legal troubles :wink:

Eh. I deploy some functions into existing namespaces where it fits. And some completely separate namespaces. The only caveat is IA doesn't promise to not preempt any given name or namespace. At which point the deployment fails.

Which goes back to @son122's question. The answer is no, you can't replace system.tag.configure with an enhanced implementation.

2 Likes

This is such a timely discussion for me because I’m going to add a function into the system.security namespace so that I can check if a user’s password has expired yet. Good to know that doing that is possible.

1 Like

Yeah, so far after testing this, it doesn’t seem like it allows me to enhance the implementation of “system.tag.configure”. I thought I triggered a log entry from the code, but it turns out the log was from an audit log configuration.

Which is kind of disappointing, because I’ll have to run a search for that function call everywhere just so that I can append my enhancement code before & after the call. If someone calls that system function without my knowledge, it’ll miss that code enhancement.

Unless I’m missing something?

Hope springs eternal?

No, you're not missing something. Sorry.