Launch Project to Multiple Monitors
Posted by Greg Simpson, Last modified by Dave Fogle on 05/28/2020 12:44 PM
The technique described in this article has been replaced by the system.gui.openDesktop() function in Ignition 7.9.0+.
This article will provide you the steps necessary to create a multi monitor project. This will give you the ability to launch multiple instances of the same project across multiple monitors on a single computer. This is merely an example of how this can be done, and can be modified to fit the needs of your projects. In this example we will launch two instances of a single project to two monitors. For your convenience you can download the MultiMonitor.zip file, it can be found at the bottom of this article. It contains a everything you need for a working example.
How the multi monitor project is achieved
We achieved this multi monitor project by utilizing a batch file, Native Client Launcher, auto login, Client Startup Script, Client Message Handlers, Client tags, and scripting used at login on the actual client. I am going to break this article into sections by each part needed for easier reference and explanation. Some of the steps may or may not make sense as I go through them, but all of the pieces will fit together.
For this project we will need two client tags. The first client tag will be an Int4 type and named ‘Monitor’. This tag’s value will be set in each client instance by the batch file used to launch the clients. It will serve as the monitor reference for each client being launched.
The next tag will be of a dataset type and will be named ‘Monitor Locations’. This tag’s dataset will contain two columns, width and height. Both rows will be of an integer type. The number of rows in this dataset will depend on the number of monitors you want to launch, and values in the width column will depend on the screen resolution of the monitors. The screenshot below is an example of how three monitors with a 1920x1080 resolution would be launched. The number of monitors being launched is also determined by the batch file used to launch the project as well, but this is in a later step.
Client Startup Script
The script below is going to read the two client tags we created in the previous step. The values read into the script will be used to determine what monitor the individual clients will be launched on. As you can see we are calling additional Java libraries to set the location of the client windows. Also make note that we are opening our own login screen. This will be covered in a later step.
Client Message Handlers
The client message handler script will give you the ability to login, switch user, and logout of the multiple client instances from a single client.
Next we are going to configure our project script. You will want to create a new script and name it ‘client’. The script will be defined as seen below. This script will send a message to the client with the appropriate hostname. The message sent to the client was created in the previous step.
Scripting the Project Login
In our client startup script we are calling the system.nav.swapTo() function to open our own login window. We have our project set to auto login. This is configured in Project>Properties>Client>Login.
We are going to validate our user from a window that we have created. The reasons we are doing this is so we can validate the user then send the username and password to the other client instances launched on this computer with the message handler script. This will allow us to login to one client and have the other launched clients automatically login for us. As you can see, the login window we use is very basic.
The Login button is going to handle all of our work with an actionPerformed Event Handler Script.
Native Client Launcher
The Native Client Launcher is used by the batch file created in the next step. The Native Client Launcher can be found on the Ignition Gateway Webpage. Once you download the executable make note of the directory it is in for the next step. For this example we placed the Native Client Launcher on the desktop.
A batch file will need to be created in order to launch our multiple instances of the client. You can create a batch file in Notepad. You will need to change the file extension when saving the file to ‘.bat’. The example of the batch file I am providing will need to be modified with the appropriate username for the logged in user and you may also need to change the gateway address if you are not launching on localhost. If you used the same naming conventions used in the rest of this article you shouldn’t need to change anything else. The batch file is going to use the Native Client Launcher, which should be found in the directory specified in the batch file, to launch our clients. As we launch our clients we are also passing values for the monitor index to the client tags created previously.