I'm trying to find how many Perspective sessions are currently open with Session Monitor. I've tried to use PerspectiveContext.get(context) inside GatewayHook, but it causes the module to fault. Is there some reason this can't be called in setup()?
I'm not sure of where to go from here and can't find very much on why it wouldn't work. If you know the proper way to use it or why it might cause problems please do reply with it, thanks
It isn't an independent singleton in the same way as Ignition's gateway context. If you look at the static method definition, you'll find it needs one argument.
Yes, I have supplied the argument
public void setup(GatewayContext gatewayContext) {
this.context = gatewayContext;
logger.info("setup()");
PerspectiveContext pc = PerspectiveContext.get(gatewayContext);
Then in the gateway, it faults, giving the error:
Faulted
com/. . . /perspective/common/PerspectiveModuleRpc
Does your module declare the Perspective module as a dependency?
If it does, and this still doesn't work, you'll just have to try doing it later in the hook. Maybe in startup()
instead.
Sorry, still learning module development. How do I declare Perspective as a dependency?
Putting in startup caused an exception, so I'll try that and see if it still happens.
Are you building with Maven, Gradle, or something else?
With the first two, you need to adjust the Ignition module plugin settings in your build files to have perspective as a dependency in the output module XML. It should be fairly straightforward to set up.
If you're using some other build tool, that's still what you have to do, but there's no convenient module plugin available.
Ah, was using maven. Thanks for the help, was able to find SDK transfert data from gateway to perspective - Module Development - Inductive Automation Forum
Once I got
<depends>
<depend>
<scope>G</scope>
<moduleId>com.inductiveautomation.perspective</moduleId>
</depend>
<depend>
<scope>D</scope>
<moduleId>com.inductiveautomation.perspective</moduleId>
</depend>
</depends>
in the gateway pom it worked
1 Like