Question:
Can I close a remote Viewer via command, that is, without having to access the computer where it’s open?
Solution:
Yes, you can. The E3 Viewer is Elipse E3‘s operational interface. The Viewer object is where you will set up the E3 Viewer’s visualization, either in loco or remotely. A remote Viewer is the one being operated in a different machine, that is, not the one where it has been originaly opened.
In order to close a remote Viewer via command, you will need to use the Viewer’s Exit() method in a user event. This event is activated either via a command sent by the user or via another type of programming logic.
To do so, follow the example below:
- Create two internal tags (one whose Value property is a Boolean, another one as a string) in the server. For example: AutoClose(Boolean) and ViewerName(String).
- Then, create a setpoint on the screen, and link it (with a bidirectional/reverse link) to ViewerName tag.
- On the same screen, create a command button that sends True to AutoClose tag.
- At the Viewer, create a user event (eventClose) that points to the server’s AutoClose tag Value property, whose occurrence is “Whenever the property is True”.
- After that, in the event above, create a script that compares ViewerName tag Value property to the name of the computer from where you wish to close the Viewer; use E3Globals’s GetComputerName() method to retrieve the name of the machine. If they are the same, execute the Viewer Exit method. For example:
Sub Viewer_eventClose() IF Application.GetObject("Data.ViewerName").Value = GetComputerName() THEN Application.Exit() END IF Application.GetObject("Data.AutoClose").Value = False End Sub