KB-104004: Closing a remote Viewer via command.

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:

  1. 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).
  2. Then, create a setpoint on the screen, and link it (with a bidirectional/reverse link) to ViewerName tag.
  3. On the same screen, create a command button that sends True to AutoClose tag.
  4. 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”.
  5. 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

Attachment:

CloseViewer.zip

Este artigo foi útil? Was this post helpful?
Yes0
No0

Leave a Reply

Your email address will not be published.Required fields are marked *