Maybe somebody knows how i can call function from script library in gateway event scripts?
Example i have script “myfuncs” with function “myFunction”. I have tryed call function in this way:
It depends on where your event script is placed. If it is a tag event, you can’t use ‘project.’ scripts. You can only use 'shared.’ scripts. Tags aren’t part of a project, so no project resources are available. If you need to trigger on tag changes in a project context, use the project’s event scripts. Same sort of thing applies to any of the global events.
Gateway scripts can’t access project resources, so you’ll have to make sure your scripts are stored in Global / Script Library (shared). In your gateway event script, call your script using shared.myfuncs.myFunction()
I’m calling a project script from a Gateway Event Script. Now I’m confused as to why that’s working. But it’s definitely working. Perhaps I’m misunderstanding the question or the terminology? Under “Project”, there is a section called “Scripts.” Underneath it are “Script Library [project]”, “Client Event Scripts”, and “Gateway Event Scripts.” I’ve added a timer event in the Gateway Even Scripts. It calls project.my_funcs.my_func() with no issues. Under “Global” I have a “Script Library [shared]” but no “Gateway Event Scripts [shared]” or similar. I have no shared scripts at all, so I know I’m not accidentally calling the wrong thing. So what am I missing here? Using version 7.9.9
I am able to access this library from script console. But If I use it in Gateway Tag change event, It gives me an error.
Code
from pyepc import decode
##Code
##Error
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 1, in File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc_init_.py", line 1, in from .epc import SGTIN, SSCC, decode # noqa File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc\epc.py", line 9, in from . import utils File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\pyepc\utils.py", line 11, in import requests File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests_init_.py", line 45, in from .exceptions import RequestsDependencyWarning File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests\exceptions.py", line 9, in from urllib3.exceptions import HTTPError as BaseHTTPError File "D:\Program Files\Inductive Automation\Ignition\user-lib\pylib\site-packages\requests\compat.py", line 42, in if is_py2: ImportError: cannot import name JSONDecodeError