system.util.getSystemFlags()

How come on one of my gateways when I run system.util.getSystemFlags() in the script console I get 1, but in another gateway in the script console I get an error?

AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'getSystemFlags'

They are both running 8.1.7

Have you tried restarting the designer? I have had script consoles act up in the past and restarting helped fix it.

You probably don’t have the Vision module installed on the gateway/designer where it doesn’t work. This is one of a handful of really old functions that are actually added by the Vision module and don’t exist without it.

2 Likes

That is it. One of the gateways does not have the vision module installed.

Is it safe to use this instead? It seems to work on both of the gateways scripting console.

from com.inductiveautomation.ignition.common.model import ApplicationScope
scope = ApplicationScope.getGlobalScope()

if ApplicationScope.isGateway(scope):
	print 'gateway'
elif ApplicationScope.isClient(scope):
	print 'client'
elif ApplicationScope.isDesigner(scope):
	print 'designer'

This is part of our core platform and is published API so you can definitely use the ApplicationScope class. That being said, some future qualifying releases (this would usually be a major release) of Ignition may change this class implementation but I wouldn’t expect that anytime soon.

By any chance, is there a way to know what type is the client ?

ApplicationScope.isClient​(int scope)

Let’s say a gateway with Vision AND Perspective.
They would booth have the same GatewayScript.
Does the applicationScope can inform on the type of client ?

Thanks!

For legacy functions, "Client" means Vision. A script running in gateway scope, whether Perspective or not, will never have Client scope.

In the Gateway
A script calle test.fun() is defined

In the designer

Under the Vision module
test.fun() is called.

In the Log Viewer
ApplicationScope appear to be “isClient”
*Note that i was not seeing it in the Gateway Logs

In the Perpective Module
In a view, a button call the same script
test.fun()

In the Gateway Logs
ApplicationScope appear to be “isGateway”

In the Tag
A tag is defined and have a Value Changed Script that call test.fun()

In the Gateway Logs.
ApplicationScope appear to be “isGateway”

——————————————
Now that I have expose this demonstration
Is there a way to have a script that would help me to branch on
-Executed from Vision
-Executed from Perspective
-Executed from Tag

Thanks

This is a common misunderstanding. Functions defined in a Project Library, have no scope. They are run in the scope from which they are called.

A function defined in a project library, which is called from a vision component, will run in Vision Client Scope. That same function called from a perspective script transform will run in Gateway (Prespective) Scope. That same function called from a Gateway Event Script will run in Gateway Scope.

If that function is defined in the Gateway Scripting Project and is called from a Tag it will run in Gateway Scope.

As you can see, there are really only two scopes, Gateway and Vision Client.

Prespective is a varient of Gateway Scope, and Designer Scope is a varient of Vision Client Scope.

1 Like

Is it possible to distinguish from a Perspective session and a Gateway Event Script ?

From what I understand, I don’t think so unfortunatly.

Not unless you send an identifier with the function call.

Thank you for responding! :slight_smile:

Well, you can, but it's technically unsupported because it relies on an import from our core Java code.