ServerStatus

<< Click to Display Table of Contents >>

 

ServerStatus

Enum Determines the status of an OPC Server connection. This is a read-only property. The available options are described on the next table.

Available options for ServerStatus

Option

Description

-1 - ServerStatus_Unknown

The OPC Driver is connected to an OPC server but either status is not informed or OPC client's ReconnectPeriod property is set to zero (default)

0 - ServerStatus_NotConnected

The OPC Driver is not connected to an OPC Server. This happens when, for example, an OPC Driver is not active, or a connection was not established yet for any reason

 

The following values are only informed when the ReconnectPeriod property is different from 0 (zero). This time period specifying a status is retrieved from the server. In case this status is not correctly informed, this property can maintain its value in -1 (minus one), or the disconnection can be detected in this case, which brings the ServerSatus property to 0 (zero). Values are based on the five default status types defined for OPC servers.

Available options for ReconnectPeriod different from zero

Option

Description

1 - ServerStatus_Running

Server is executing normally

2 - ServerStatus_Failed

Server is not executing. An unspecified error occurred on the server

3 - ServerStatus_NoConfig

Server is executing, but without information about its configuration

4 - ServerStatus_Suspended

Server was temporarily suspended

5 - ServerStatus_Test

Server is in test mode

 

Example:

Sub CommandButton1_Click()
  Dim status
  status =  Application.GetObject("OPCDriver1").ServerStatus
  MsgBox "Driver status is " & status
  Select Case status
    Case -1
      MsgBox "OPC Driver is connected to the OPC Server_
        but its status was not informed."
    Case 0
      MsgBox "OPC Driver is not connected to an OPC Server."
    Case 1
      MsgBox "The OPC Server is running normally."
    Case 2
      MsgBox "The OPC Server is not running."
    Case 3
      MsgBox "The OPC Server is running without information_
        on its configuration."
    Case 4
      MsgBox "The OPC Server has been temporarily suspended."
    Case 5
      MsgBox "The OPC Server is running in Test Mode."
  End Select
End Sub

 

NOTE

To obtain a behavior equivalent to a Boolean property, it is recommended to use ServerStatus different from 0 (zero). This basically differentiates only between having or not having a connection, without considering more specific server statuses. In addition, this expression does not depend on using the ReconnectPeriod property different from 0 (zero).

Was this page useful?