Campbell Scientific LoggerNet-SDK Software Development Kit User Manual

Page 63

Advertising
background image

Section 13. Developing an Application Using the CsiLogMonitor Control

Private Sub cmdConnect_Click()
'Connect using the default logon settings.
CsiLogMonitor.serverName = txtServerAddress
CsiLogMonitor.serverPort = txtServerPort
CsiLogMonitor.serverLogonName = txtUsername
CsiLogMonitor.serverLogonPassword = txtPassword

'Start the connection to the LoggerNet server
CsiLogMonitor.serverConnect

Exit Sub

If the connection succeeds, the onServerConnectStarted() event gets triggered.
Otherwise, the onServerConnectFailure() event gets called if the connection
fails.

In order to start monitoring the transaction log, the tranLogMonitorStart()
method must be called. To monitor communication log messages, call the
commLogMonitorStart() method.

The LoggerNet server maintains a buffer of historical log messages. By
default, the last 100 log file messages will be retrieved when log monitoring
first starts. To change the number of historical log messages that are retrieved,
set the commLogRecordsBack and tranLogRecordsBack properties before
starting log monitoring. A basic example of code using these methods to set the
number of historical records received and to start collecting both types of log
messages follows:

Private Sub cmdStart_Click()
'Set the number of historical log messages to retrieve from the
'LoggerNet server when monitoring starts
CsiLogMonitor.commLogRecordsBack = 5
CsiLogMonitor.tranLogRecordsBack = 5

'Start Monitoring the Tranaction Log and the Communications Log
'on the LoggerNet server
CsiLogMonitor.commLogMonitorStart
CsiLogMonitor.tranLogMonitorStart

End Sub

Log messages will be passed as Strings to the onCommLogRecord() and
onTranLogRecord() events respectively as they are generated by the LoggerNet
server. A timestamp for when the log message is generated is also passed to
these events. The String can be displayed or parsed and manipulated by station
name and message type.

Private Sub CsiLogMonitor_onCommLogRecord(ByVal timestamp As Date,
ByVal comm_log_record As String)

lstCommLog.AddItem timestamp & " : " & comm_log_record
If lstCommLog.ListCount = 10 Then
lstCommLog.Clear
End If

End Sub

13-3

Advertising