• PI-SDK Dialogs Tutorial

    If you worked through the PI-SDK Tutorial in Chapter 3, then you already have experience working with the Login method. In this tutorial we illustrate the use of the ShowConnectionDialog method when we add the PI-Connection Manager to an application.

    The complete code for the tutorial can be found in the online help file under Tutorial Code.

    Adding the PI-Connection Manager to an Application

    In this tutorial project, we start with the application that we used in the PI-SDK Control tutorial, and add the File/Connections menu item. When the menu item is selected, we call ShowConnectionDialog with no parameters, and the PI-Connection Manager dialog is displayed. When the PI-Connection Manager is used to toggle the connection status of a server, you can then see it move above or below the line in the PI-ServerPickList. Next we enable the PI-Connection Manager to add and delete servers by specifying ReadOnly parameter to be false when we call ShowConnectionDialog.

    1. STEP 1. ADD THE PI-SDK DIALOGS TO YOUR VISUAL BASIC PROJECT

    1. Open the project that you created for the PI-SDK Control tutorial. You should already have added a reference to the PISDK 1.1 Type Library and added the PI-SDK Control component.
    2. Now add a reference to the PI-SDK Dialogs by following the instructions in the section called "Adding the PI-SDK Dialogs to Your Visual Basic Project," above.

      STEP 2. CREATE THE MENU ITEM

    1. Select the form and click on the middle button at the top of the project window ("View Object").
    2. From the Tools menu select the Menu Editor. If it is disabled, change the form from Code view to Object view as described in the previous step. Add the File and Connections entries as shown:

     

     

    After you click the OK button, you should see the menu appear on the form.

     

    1. Click on the File Connections menu item to go to the code window in the implementation of the Click event. Add code to the event that displays the Connections form:

    Private Sub menu_Connections_Click()

    Dim Cxn as New PISDKDlg.Connections

    'We call the method with no parameters so that

    'the Server Information dialogs will be modeless

    'and the user will not be able to edit the Known

    'Server Table (This cause some buttons and menu

    'items to be disabled.)

    '

    Cxn.ShowConnectionDialog

    'The PI-Connection Manager dialog itself is modal

    'so we won't get to this place in the code until

    'after the user clicks the Close button.

    End Sub

    1. STEP 3. TEST THE PI-CONNECTION MANAGER DIALOG

    Save the project. Run the application. Select File/Connections to show the PI-Connection Manager dialog.

    Use the PI-Connection Manager to connect or disconnect a server. To toggle the connection status of a server, select it and then press the space bar. You should see the change reflected in the PI-ServerPickList.

    Double-click a server name to bring up the Server Information dialog. Leave this dialog up (do not click on the Close button.) Now double-click on a different server name to bring up a second Server Information dialog. This illustrates that the Server Information dialogs are modeless. Note that this is a good way to troubleshoot server connections. However, if this were part of an ActiveX control and you tried to drop it onto a Web page, you would get an error.

    Notice that the Edit button is disabled on the Server Information dialog. Also note that the Servers menu item in the right mouse click menu is disabled. This illustrates that the user cannot modify the Known Servers Table.

    1. STEP 4. CHANGE THE PI-CONNECTION MANAGER DIALOG DEFAULTS

    Modify the menu_Connections_Click subroutine as follows to enable the user to edit the Known Servers Table and make the Server Information dialogs modal:

    Private Sub menu_Connections_Click()

    Dim Cxn as New PISDKDlg.Connections

     

    'We set ReadOnly to false so that

    'the user will not be able to edit the Known

    'Server Table. We pass the vbModal constant as

    'the Modal parameter value so that the Server

    'Information dialogs will be modal.

    '

    Cxn.ShowConnectionDialog False, vbModal

    'The PI-Connection Manager dialog itself is modal

    'so we won't get to this place in the code until

    'after the user clicks the Close button.

    End Sub

     

    1. STEP 5. TEST THE PI-CONNECTION MANAGER DIALOG

    Save the project. Run the application. Select File/Connections to show the PI-Connection Manager dialog.

    Double-click a server name to bring up the Server Information dialog (do not click on the Close button.). Now double-click on a different server name to bring up a second Server Information dialog. Nothing should happen. This illustrates that the Server Information dialogs are modal and only one can be open at a time. If this were part of an ActiveX control, you could then drop it into a Web page.

    Notice that the Edit button is now enabled on the Server Information dialog. Note that the Servers menu item in the right mouse click menu is also enabled.

    Add or remove a server. You should see the change reflected in the PI-ServerPickList. To add a server, right click the mouse over the PI-Connection Manager dialog, and select the menu item Servers\Add a Server. To delete a server, select a server in the list and press the Delete key.

    If you get errors when adding or deleting a server, or modifying information about an existing server, it is possible that the Known Servers Table on this computer has been write-protected by the system manager.

    This completes the PI-SDK Dialogs tutorial.

  • Enabling Operational Intelligence