Retargeting is a special form of navigation which involves navigating to an entirely different project. Retargeting is accomplished through scripting, usually as a response to a button press or other component event. The system.util.retarget()  function allows you to 'retarget' the Client to a different project. 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 current 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.

Retargeting can be as simple as a single line of code, just make sure you are using the project name (no spaces allowed), and not the title. See the retarget function in the appendix for more information.

A typical retargeting strategy actually combines this strategy with one or more other navigation strategies. A simple landing project could be made so that all users would have access to perform basic user management functions, and then use a screen with Button components that retarget approved users out to other projects targeting a specific area of operations. The buttons that retarget to these projects can be hidden or shown based on the user, allowing you to build in an extra layer of security to your projects. Additionally, each of the other projects would utilize navigation strategies that best suit those areas.

On this page ...


Retargeting



In this example, we have two projects (Tank and Motor) that we will set up to retarget to each other. 

  1. On a blank window, add a Button component, and either change the button text or add a label that informs the user that the button retargets to a new project.
  2. Right-click on the Button and select the Scripting option.

  3. On the action > actionPerformed event, add the following script to the script builder.

    Python - Retargeting to Another Project
    # Retarget to another project on the same gateway.
    # This script can be run from any button in a project.
    system.util.retarget("My_Other_Project")
  4. Replace the My_Other_Project text with the name of the project you want to access. In this case, the script text was changed to Tank_Project for the Motor project to navigate to the Tank project when clicked. 



  5. Click OK.

  6. Repeat steps 1-4 in the other project, the Tank project, replacing the Tank_Project script with Motor_Project. This can be repeated with more buttons and scripts that lead to other projects.

  7. Save your projects.

  8. Open the Client and select the Retarget buttons to navigate between the Tank project and Motor project. 




  • No labels