Gateway Scripting Project Not Working - Modules Not Found

I am unable to access my scripts in my project that is defined as my “Gateway Scripting Project” from other projects. I am running Ignition 8.1.1.

In my Gateway Settings I have the project defined:

I have some scripts defined:
image

I then try to call those scripts from another project’s button click event:

I have tried the code in various ways to get it to work, none of them seem to result in a successful function call:

code:

print(shared.chris_test_module.test2.addtest(1))

error:

NameError: name 'shared' is not defined

code:

print(chris_test_module.test2.addtest(1))

error:

NameError: name 'chris_test_module' is not defined

code:

import chris_test_module
print(chris_test_module.test2.addtest(1))

error:

ImportError: No module named chris_test_module

code:

print(IGN01_GatewayTasks.chris_test_module.test2.addtest(1))

error:

NameError: name 'IGN01_GatewayTasks' is not defined

code:

from chris_test_module import *
print(chris_test_module.test2.addtest(1))

error:

ImportError: No module named chris_test_module

I’ve tried quite a few different variations of the above with no success. I’ve also tried changing the advanced settings on the button from “legacy scoping” to “standard scoping” and back again with the various ways I’ve written the code and it has not worked.

The original purpose of this was to create a gateway level function I could call in a runscript() expression on a tag since those must be globally scoped to run on a tag and not project scoped but I started noticing it was not working, so I moved it to a Vision window while testing to simplify the issue and take runscript() out of the equation.

I’ve tried restarting the gateway and that did not fix it either. Is there some syntax I am missing when calling a Gateway Scripting Project library? Some other setting I do not have configured correctly?

The gateway scripting project is used for gateway scripts that aren’t in a project (tag events, in particular). It is not relevant in any client scope nor any gateway scopes that are part of projects.

If you need some scripts to be available to multiple projects, put those scripts in an inheritable project, and make the other projects inherit it. The project chosen as the gateway scripting project can inherit from such a common parent project, too.

1 Like

I thought I understood this part but I guess I did not fully, however, that is what I am trying to do. I have a tag object I want to execute from an expression:

runScript(customFunctionHere())

I tried moving it to a Vision window for easier troubleshooting, but if you're saying that won't work, I've tried to move it back to the tag and still get an error configuration when doing it this way:

runScript(chris_test_module.test2.addtest(1))

Tag JSON:

{
  "expression": "runScript(chris_test_module.test2.addtest(1))",
  "dataType": "Int4",
  "executionMode": "FixedRate",
  "name": "Avg Pressure Reading",
  "tagType": "AtomicTag"
}

I am not looking to share this across multiple projects or anything like that. My end goal is to run

system.tag.queryTagCalculations

From a function that is executed by a tag so I can get a rolling 12 hour history inside of a tag itself.

My tag would have something like:

runScript(customHistoryCall("path_to_tag_I_want_history_on"))

Which would call the custom function running:

def customHistoryCall(path):
    historyDS = system.tag.queryTagCalculations(paths=[path], calculations=["simpleAverage"], rangeHours=12
    historyValue = historyDS.getValueAt(0,0)
    return historyValue

This was simply a syntax issue on my original runScript call:

incorrect:

runScript(chris_test_module.test2.addtest(x=1))

correct:

runScript("chris_test_module.test2.addtest", 0, 1)
1 Like