Using the Viewer in Elipse E3: Chapter 10 – Viewer Tags.

In the Viewer object, you can create a folder with the following tag types: Conter, Demo, Internal, and Timer.

These variables must be created separately in each Viewer when the information is different in each case.

Example: On daylight saving time, the server’s time is not updated, while the other computers’ times are.  When viewing a CurrentTime demo tag created in the server, this variable’s value will be off one hour from the same one in the Viewer, because the Viewer tag will display the time from the computer connected to the application.

Semaphore

In some applications, you must insert a logic operation to keep a screen from being open by more than one user at the same time.

Identifying the computer

The first step is identifying the name of the computer running the Viewer. Since several Viewers can be connected, each with a different name, this information must be saved in a variable in the Viewer object. To do so, follow these procedures:

  • At the Viewer object, create an internal tag called ComputerName.
  • At ComputerName tag’s OnStartRunning event, insert a script searching for the computer’s name.

Accessing the Exclusive Screen

When calling the exclusive screen, you must first check if it is already being accessed, or even if it allows any access. If access is granted to the screen, you must save in one variable the name of the computer to which the screen is exclusive.  Since this is a unique variable, used for all computers connected to the application, it must exist in the server. To do so, follow these procedures:

  • At the data server, create an internal tag called AccessExclusiveScreen.
  • At the button set up to call the exclusive screen, create the following script:
Sub CommandButton1_Click()
‘Access to exclusive screen

if Application.GetObject(“Data.AccessExclusiveScreen”).Value <> “” then   
  ‘Access denied
  MsgBox “This screen has already been opened by another user!”, “Warning”, vbInformation
else   
  ‘Passes the name of the computer to the exclusive screen 
  Application.GetObject(“Data.AccessExclusiveScreen”).Value = Application.Item(“ComputerName”).Value
  ‘Opens the screen
  Application.DoModal “ExclusiveScreen”, “”, 0, 0,  ,  , 0, 1+2+64+2048
end if    
       
End Sub

Clearing access

When closing the exclusive screen, you must clear the variable storing the name of the computer that was being connected. To do so, insert the following script at OnStopRunning event:

Sub ExclusiveScreen_OnStopRunning()
  ‘Clears access to another user
  Application.GetObject(“Data.AccessExclusiveScreen”).Value = “”   
End Sub

Exercises

  1. Create an application implementing the exclusive screen logic.
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

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