New module in Gateway scope

Hi,

I want to create a module in Ignition that runs in the value changed of one Tag.
I create a skeleton with scopes and hooks for gateway and designer, but I don’t know how make the start of my module in the gateway.
This is my GatewayHook:

[code]package com.txt.mongo_module.gateway;

import com.inductiveautomation.ignition.common.licensing.LicenseState;
import com.inductiveautomation.ignition.gateway.model.AbstractGatewayModuleHook;
import com.inductiveautomation.ignition.gateway.model.GatewayContext;

public class GatewayHook extends AbstractGatewayModuleHook {

@Override
public void setup(GatewayContext context) {
	// TODO Write code, override methods as needed
	
}

@Override
public void shutdown() {

}

@Override
public void startup(LicenseState licenseState) {
		
}

}
[/code]

This is the DesignerHook:

[code]package com.txt.mongo_module.designer;

import com.inductiveautomation.ignition.common.licensing.LicenseState;
import com.inductiveautomation.ignition.designer.model.AbstractDesignerModuleHook;
import com.inductiveautomation.ignition.designer.model.DesignerContext;

public class DesignerHook extends AbstractDesignerModuleHook {

@Override
public void startup(DesignerContext context, LicenseState activationState)
		throws Exception {
	// TODO Write code here, override methods as needed.
}

}
[/code]

I tried to compile it and to load the module in Ignition, but it don’t work in the value change of one Tag.
I attached the rar with the skeleton of the project.

Can you help me?

Thanks,
Andrea

Hi,

The question, as written here, unfortunately doesn’t make a lot of sense. Modules get loaded and do lots of things, they can’t “run in a tag change script”. One of the things modules can do are define scripting function functions, which I think is what you’re getting towards.

Creating modules certainly requires a fair amount of Java knowledge, but I think everything you might need is indeed described in the SDK Programmer’s Guide if you actually need to create a module.

Now I’m going to cheat since I have a little bit of background information about what you’re trying to do, which is to expose a JAR to scripting in all scopes. Unfortunately, the module can’t do this, unless you were to write your own scripting function wrappers.

However, you can get the jar to be available by doing the following:

  1. Using the pack200 tool in the JDK, create a packed version of the jar as well, such as:
pack200 mongo-2.9.1.jar.pack.gz mongo-2.9.1.jar
  1. Place both of the files, mongo-2.9.1.jar and mongo-2.9.1.jar.pack.gz in [tt]{InstallDir}\lib\core\common[/tt]
  2. Restart the gateway

This will send the jar to all of the scopes. Whether or not this is actually useful for you is not clear to me yet, as I’m not sure how possible it will be to use the direct Mongo classes in jython. Also, this method isn’t super great, because you’ll lose the jar files on upgrade/new installation (they won’t be in any backup).

So, I’d recommend reading through the programmer’s guide, and see if it makes sense, and maybe also look at this page about adding scripting functions.

Regards,