dpConnectExt()

The function calls a callback function if the passed data point values/attributes change.

Synopsis

int dpConnectExt([class object,] string|function_ptr work, [bool answer,] dyn_string dpConn, dyn_string dpExt);

Parameters

Parameter Description
object An object of a Control++ class.
work

Name of the callback function ("work function") that is called when data point values change.

Or

The name of a function pointer to the work function (callback function).

answer Specifies whether the callback function should be executed when dpConnectExt() is called or only after a value change. The default value is TRUE (the first callback is executed when dpConnectExt() is called)
dpConn List of the data points whose value change trigger the work (callback) function.
dpExt

List of the extended data points whose value change does not trigger the work function (callback).

Return Value

The function dpConnectExt() returns 0 and in the event of a failure it returns -1.

Error

Use the function getLastError() to retrieve errors. The function throwError() can be used to write an error message to the PVSS_II.log log file.

Note:
Note that when using the function getLastError(), use it directly after the function call of the dpConnect() as shown in the example below since the function getLastError returns the errors of the last function call.

Description

If a value of a data point element that belongs to the trigger list is changed, the callback function is triggered. The callback function provides:
  • the list of the trigger data points
  • and values of the trigger data points
  • the list of the extended data points
  • and the values of the extended data points.

If a value of a data point element that belongs to the extended list is changed, the callback function is not triggered.

Example of a callback function

CB(dyn_string dsTrigger, dyn_anytype triggerValues,dyn_string dsExt, dyn_anytype extValues)
{
  /* Callback function code */
} 

Example - In the example the text is shown, when the value of either ExampleDP_Rpt1. or ExampleDP_Rpt2. changes.

main(mapping event)
{
  dpConnectExt("CB", false, makeDynString("ExampleDP_Rpt1.", "ExampleDP_Rpt2."), makeDynString("ExampleDP_Rpt3.", "ExampleDP_Rpt4."));
}
                
CB(dyn_string dsTrigger, dyn_anytype triggerValues,
dyn_string dsExt, dyn_anytype extValues)
{
  DebugN("If the value of ExampleDP_Rpt1. or ExampleDP_Rpt2. changes, this text is shown");
}

Assignment

Data point Functions, Waiting Control Functions, Connection Functions.

Availability

UI, CTRL