Skip to main content
Version: 8.1

system.util.retarget

This function is used in Python Scripting.

Description​

This function allows you to programmatically 'retarget' a Vision Client to a different project and/or different Gateway. You can have it switch to another project on the same Gateway, or another Gateway entirely, even across a WAN. This feature makes the vision of a seamless, enterprise-wide SCADA application a reality.

The retarget feature will attempt to transfer the current user credentials over to the new project / Gateway. If the credentials fail on that project, the user will be prompted for a valid username and password. Once valid authentication has been achieved, the currently running project is shut down, and the new project is loaded.

You can pass any information to the other project through the parameters dictionary. All entries in this dictionary will be set in the global scripting namespace in the other project. Even if you don't specify any parameters, the system will set the variable _RETARGET_FROM_PROJECT to the name of the current project and _RETARGET_FROM_GATEWAY to the address of the current Gateway. Parameters can be accessed from the other project by calling system.util.getGlobals[parameterKey].

note

You cannot retarget across different major Ignition versions, such as 7.9 to 8.0.

Client Permission Restrictions​

This scripting function has no Client Permission restrictions.

Syntax​

tip

This function accepts keyword arguments.

system.util.retarget(project, [addresses], [params], [windows])

Parameters​

TypeParameterDescription
StringprojectThe name of the project to retarget to.
String or ListaddressesThe address of the Gateway that the project resides on. If omitted, the current Gateway will be used. Format is host:port when not using SSL/TLS, or https://host:port when SSL/TLS is enabled on the target gateway. This can be a list of strings. When using a list, the function will try each address in order, waiting for the timeout period between each address attempt. [optional]
Dictionary[String, Any]paramsA dictionary of parameters that will be passed to the new project. They will be set as global variables in the new project's Python scripting environment. [optional]
List[String]windowsA list of window paths to use as the startup windows. If omitted, the project's normal startup windows will be opened. If specified, the project's normal startup windows will be ignored, and this list will be used instead. [optional]

Returns​

Nothing

Scope​

Vision Client

Code Examples​

Example #1
# This code would switch to a project named 'TankControl' on the same Gateway
# as the currently running project
system.util.retarget("TankControl")
Example #2
# Similar to the above example, except passes a parameter to the new project via keyword arguments.
system.util.retarget("TankControl", params = {"SomeParameter":1234})
Example #3
# This code would switch to a project named "TankControl" on a
# Gateway located at a different IP address running on port 8080, and
# would open the window named "Graph", and set a global JYTHON variable in the
# new project named "retargetOccured" to the value 1 (one).
system.util.retarget("TankControl", "10.30.2.33:8080", {"retargetOccured":1}, ["Graph"])
Example #4
# This example is similar to the previous, except it could be used to retarget to a gateway that
# has SSL/TLS enabled. Simply specify "https://" at the start of the address.
system.util.retarget("TankControl", "https://10.30.2.33:8043", {"retargetOccured":1}, ["Graph"])
Example #5
# This code would switch to a project named "TankControl" on a
# Gateway located at a different IP address using SSL on port 8043.
system.util.retarget("TankControl", "https://10.30.2.34:8043")
Example #6
# This code would be put in a button in the target that was retargeted to,
# and act as a 'back' button, that would retarget back to the original project.

# Fetch the global values that are automatically created when you retarget.
project = system.util.getGlobals()['_RETARGET_FROM_PROJECT']
gateway = system.util.getGlobals()['_RETARGET_FROM_GATEWAY']

# Retarget.
system.util.retarget(project, gateway)

Keywords​

system util retarget, util.retarget