How can I test whether the executing code is running in client, gw, or designer?
Hmm. Something like this (untested):
from com.inductiveautomation.ignition.common.model import ApplicationScope
scope = ApplicationScope.getGlobalScope()
if (ApplicationScope.isClient(scope)):
...
if (ApplicationScope.isDesigner(scope)):
...
if (ApplicationScope.isGateway(scope)):
...
2 Likes
This would also work, but I like Kevin’s solution.
def getLocation():
try:
if system.util.getSystemFlags() & system.util.CLIENT_FLAG:
location = 1
elif system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
location = 2
except:
location = 0
return location
3 Likes
The problem with getSystemFlags()
is that it only exists in C/D scope. It would error out in G scope.
edit: Durh, your code accounts for that.
I iz smrt Kevin!!
More characters…
3 Likes