Hi All
I am on an interesting and long journey to master Ignition and just stumbled on something that surprised me.
On the Gateway there is a setting in Config\Gateway Scripting Project which is blank in my gateway. I heard from my colleague that it is always a good practice to set up Gateway Scripting Project - otherwise gateway scripts defined in the developer will execute in different and a lot less efficient way.
I hope it makes sense what i wrote. I don’t remember if this subject was mentioned in the ignition training and i wonder if anybody could please share some more info or confirm recommended approach.
So tag event scripts , gateway event scripts, message handlers (and I’m sure a few more that I’m not thinking about) aren’t scoped or part of a project. They are global gateway scope. So if you have a “common” library of scripting that you use across all your projects and the gateway scope objects need access to that, then you have to point this configuration to that project.
If you don't have a gateway scripting project set, then global scripting events (primarily, tag related, such as tag event scripts or runScript calls from tags) just won't work.
The 'gateway scripting project' has no relevance to 'gateway event scripts' you define in the designer (startup, shutdown, update, message handler, etc) - those are actually 'project' resources thus always 'know' which project they run under. Only truly global objects (tags) need a specific reference to use.
This should have been struck through as well. Or "global" inserted after "gateway". The gateway has multiple scopes: global, projects, and Perspective sessions (extended from a project scope). Vision clients have one scope, of the current project. The designer has two-ish: preview scope and script console scope, both of the current project, and not entirely separate.
Just for clarification, if I have a Gateway Scripting Project specified as 'global' and then write a gateway script in a different project (not the one in the 'Gateway Scripting Project'), then the script will not work?
For example, if my project is named 'local' and I write a gateway script in 'local' that will be used in the 'local' project, it will not work because my scripts all have to be written in the 'global' project?
Depends on where you need to use your script. If you're using it in a tag change script or anything else that runs on the gateway, you'll have to make sure your script is in the defined gateway scripting project. If it's used in any HMI views/windows/etc then it needs to be in the same project as those views/windows/etc.
The gateway scripting project only applies to scripts that are executed outside of any project context.
Effectively, this means the scripts you configure directly on tags (the value changed/quality change/etc) scripts, and using runScript in expression tags.
Anything you configure in a project, including 'Gateway Event Scripts' like startup/shutdown/update/message, and, confusing, tag change scripts, is always executed in that project's context and doesn't care at all about the gateway scripting project setting.