Skip to main content

WEBfactory 2010

WFServerClient Class Overview

Abstract

Check out this article and learn more details about the WFServerClient Class and the parameters involved in its management.

WFServerClient provides methods and events to access already existing WEBfactory 2010 signals from other connectors or OPC Servers.

The following methods are implemented by WFServerClient class:

  • Register Operations

    • int RegisterSignalChangedHandler(string signalName, OnSignalChangedDelegate handler);

    • int UnregisterSignalChangedHandler(string signalName, OnSignalChangedDelegate handler);

  • Read Operation

    • int ReadSignal(string signalName, out object value);

  • Write Operation

    • int WriteSignal(string signalName, object value, out int writeResult);

    • int WriteSignal(string signalName, object value, string user, string userPassword, out int writeResult);

    • int WriteSignals(string[] signalNames, object[] signalValues, out int[] writeResults);

    • int WriteSignals(string[] signalNames, object[] signalValues, string userName, string userPassword, out int[] writeResults);

  • Debug Operation

    • int WriteTrace(WFTraceLevels level, string message);

The following chapters will describe each method of the WFServerClient class.

Register Operations
RegisterSignalChangedHandler

Method definition

int RegisterSignalChangedHandler(string signalName, OnSignalChangedDelegate handler);

Calling parameters

signalName: Signal name

handler: Function to call when signal changes

Return value

-3: Illegal calling parameters

0: Success

Description

This method assigns a delegate to a specific signal. This delegate will be invoked in case of a signal change.

The delegate onSignalChangedDelegate is defined as:

void OnSignalChangedDelegate(string name, object value);

name will contain the signal name that has changed and value will contain the new value.

UnregisterSignalChangedHandler

Method definition

int UnregisterSignalChangedHandler(string signalName, OnSignalChangedDelegate handler);

Calling parameters

signalName: Signal name

handler: Function to call when signal changes

Return value

-3: Illegal calling parameters

0: Success

Description

This method removes a delegate for a specific signal.

This method can be called with the same calling parameters like each previous RegisterSignalChangedHandler call in order to remove the handler binding.

Read Operation
ReadSignal

Method definition

int ReadSignal(string signalName, out object value);

Calling parameters

signalName: Signal name

value: Current signal value

Return value

-3: Illegal calling parameters

0: Success

Description

This method reads a WEBfactory 2010 signal. it does not need to be registered. The read is a synchronous operation.

Write Operation
WriteSignal

Method definition

int WriteSignal(string signalName, object value, out int writeResult);

Calling parameters

signalName: Signal name

value: The value that should be written

writeResult: Delegate to function handling the result

Return value

-3: Illegal calling parameters

0: Success

Description

This method writes a value to a signal.

The writeResult may have one of the following values:

  • 0: Success

  • -4089: Unspecified server error (Login, Write)

  • -4088: Signal is write protected (Write)

WriteSignal

Method definition

int WriteSignal(string signalName, object value, string user, string userPassword, out int writeResult);

Calling parameters

signalName: Signal name

value: The value that should be written

user: User name

userPassword: User password

writeResult: Delegate to function handling the result

Return value

-3: Illegal calling parameters

0: Success

Description

This method writes a value to a signal.

The writeResult may have one of the following values:

  • 0: Success

  • -4095: User login failed (Login)

  • -4094: No user logged in (Write)

  • -4093: Insufficient user authorizations (write)

  • -4092: User already logged in (Login)

  • -4091: Invalid user password (Login)

  • -4090: Max user count reached (Login)

  • -4089: Unspecified server error (Login, Write)

  • -4088: Signal is write protected (Write)

WriteSignals

Method definition

int WriteSignals(string[] signalNames, object[] signalValues, out int[] writeResults);

Calling parameters

signalNames: Signal names

signalValues: The values that should be written

writeResults: Delegate to function handling the results

Return value

-3: Illegal calling parameters

0: Success

5014: Invalid parameters specified. Either signalNames or signalValues are null or signalValues.Length doesn't match the signalNames.Length)

Description

This method writes a value to a signal.

The writeResult may have one of the following values:

  • 0: Success

  • -4089: Unspecified server error (Login, Write)

  • -4088: Signal is write protected (Write)

WriteSignals

Method definition

int WriteSignals(string[] signalNames, object[] signalValues, string userName, string userPassword, out int[] writeResults);

Calling parameters

signalNames: Signal names

signalValues: The values that should be written

userName: User name

userPassword: User password

writeResults: Delegate to function handling the results

Return value

-3: Illegal calling parameters

0: Success

5014: Invalid parameters specified. Either signalNames or signalValues are null or signalValues.Length doesn't match the signalNames.Length)

Description

This method writes a value to a signal.

The writeResult may have one of the following values:

  • 0: Success

  • -4095: User login failed (Login)

  • -4094: No user logged in (Write)

  • -4093: Insufficient user authorizations (write)

  • -4092: User already logged in (Login)

  • -4091: Invalid user password (Login)

  • -4090: Max user count reached (Login)

  • -4089: Unspecified server error (Login, Write)

  • -4088: Signal is write protected (Write)

Debug Operations
WriteTrace

Method definition

int WriteTrace(WFTraceLevels level, string message);

Calling parameters

level: Level of the message

message: Text message

Return value

0: Success

Description

This method writes a message to WEBfactory 2010Activity Analyzer. All error messages from WEBfactory 2010 server modules can be displayed in that tool. This allows finding out any problems between them.

Parameter level is an enumeration:

enum WFTraceLevels
{
	TraceInfo = 4,
	TraceWarning = 2,
	TraceError = 1,
	NoTrace = 0
};