This function is used in Python Scripting.

Description

Retrieves the current state of the given OPC server connection. If the given server is not found, the return value will be None. Otherwise, the return value will be one of these strings:

  • UNKNOWN
  • FAULTED
  • CONNECTING
  • CLOSED
  • CONNECTED
  • DISABLED

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.opc.getServerState(opcServer)

  • Parameters

String opcServer - The name of an OPC server connection.

  • Returns

String - A string representing the current state of the connection, or None if the connection doesn't exist.

  • Scope

Gateway, Vision Client, Perspective Session

Code Examples
Code Snippet
# The following checks the state of all configured servers and shows them in a message box. 
# This code interacts in the Client scope, so it should be placed on a component, such as a Button. 
 
# Retrieve a list of all servers in the Gateway.
allServers = system.opc.getServers()

# Initialize a message. The example will append the state of each server to this message.
# The "\n" at the end of the string adds a new line
message = "Server State:\n"

# Iterate through each server.
for server in allServers:

	# For each server, append the server name, a colon, the state of the server, and a new line.
	message += server + ": " + system.opc.getServerState(server) + "\n"

# Show the state of the servers in a message box.
system.gui.messageBox(message)
Keywords

system opc getServerState, opc.getServerState