2 csiserverdirect control application example – Campbell Scientific LoggerNet-SDK Software Development Kit User Manual
Page 20
Section 3. Developing an Application Using the CsiServerDirect Control
CsiLogMonitor 1.0 Type Library
CsiServerDirect 1.0 Type Library
Check the box next to the CsiServerDirect 1.0 Type Library, click Apply, and
then close the window. Now an icon for the CsiServerDirect control and other
common controls will appear in the toolbox.
3.2.2 CsiServerDirect Control Application Example
Begin creating an application that will start and stop the limited LoggerNet
server. An example of a user interface that accomplishes this task is shown in
Figure 3-1. This interface includes the CsiServerDirect control and other
objects on the form to create a functional application that will start and stop the
limited LoggerNet server.
FIGURE 3-1. CsiServerDirect Example
Now that the interface has been designed, the code can be organized to
accomplish the requirements of the application. Initially, the one required
parameter, serverWorkDir, must be set and then the startServer() method can
be called to start the LoggerNet server. A basic example of code used to start
the LoggerNet server is listed in the table below:
Private Sub cmdStart_Click()
'Set the required properties for the LoggerNet Server
CsiServer.serverWorkDir = "c:\campbellsci\loggernet\sys\bin"
'Start the LoggerNet Server
If CsiServer.serverStarted Then
txtServer.Text = "Server Already Started"
Else
CsiServer.startServer
txtServer.Text = "Server Started"
cmdStart.Enabled = False
cmdStop.Enabled = True
End If
End Sub
3-2