dpDisconnect()

The function unregisters function work().

Synopsis

int dpDisconnect([class object,] string|function_ptr work, string dp1 [, string dp2...|dyn_string dp_list]);

Parameters

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

Name of the callback function ("work function") that is called when the values or attributes are changed.

Or

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

dp1, dp2, ...

|

dp_list

Data point attributes (for example, "A.:_original.._value", "B.:_original.._value") or a data point list to be unregistered. If you pass a data point list, the DPEs and values in the work function are passed as a dyn_string dp-list and dyn_<type> Values. See example using dpConnect().

Return Value

dpDisconnect() returns 0, in the event of a failure returns -1.

Errors

Errors can be retrieved with getLastError() . This includes missing arguments or if the data point or work function does not exist.

Description

The function dpDisconnect() unregisters the function work() for call if values of the data point attributes dp1, dp2 ... are changed. The work function is no longer executed spontaneously.

A dpDisconnect() can only be made in the same script like the dpConnect()!

If there exists no definition for a config or attribute, the following defaults are used and added internal:

Function Default
dpSet*() _original.._value
dpGet() _online.._value
dpGetAsynch() _offline.._value
dpGetPeriod() _offline.._value
dpConnect() _online.._value
dpDisconnect() _online.._value

Example


main()
{
  dpConnect("startCalc","D.:_original.._value")
}
startCalc(string dp1, int d)
{
  if(d == 1)
  dpConnect("add","A.:_original.._value",
  "B.:_original.._value")
  else
  dpDisconnect("add","A.:_original.._value",
  "B.:_original.._value")
}
add(string dp1, int a, string dp2, int b)
{
  dpSet("C.:_original.._value",a+b);
}

Example

This example uses a Control++ class and an object of a Control++ class to output values that are set for specific data points via the PARA module. The scope lib of a panel contains the class DpCon and the work function that outputs the values set for specific data points via PARA. The data points are specified via dpConnect().

ScopeLib of a panel:

class DpCon
{
  public void work(dyn_string dp, dyn_float value)
  {
    DebugTN(value);
  }
};
DpCon dpCon;

Below you see a code for e.g. a button. In the code dpConnect uses the object dpCon of the class DpCon and the function pointer dpCon.work that points to the work (callback) function. dpConnect connects to the data points ExampleDP_Arg1. and ExampleDP_Arg2. The values set to the data points are output via the class DpCon and the DebugTN() of the work function. After 10 seconds the connection is disconnected via a dpDisconnect().

void main(mapping event)
{
  dyn_string dpList = makeDynString("ExampleDP_Arg1.", "ExampleDP_Arg2.");
  dpConnect(dpCon, dpCon.work, TRUE, dpList);





  delay(10);


  int i = dpDisconnect(dpCon, dpCon.work,dpList);


  DebugN("dpDisconnect:", i);
}

The function outputs the values set to the data points ExampleDP_Arg1. and ExampleDP_Arg2. via PARA.

E.g.

WCCOAui1:2017.07.11 15:43:11.695[dyn_float 2 items

WCCOAui1: 1: 80

WCCOAui1: 2: 100

WCCOAui1:]

Assignment

Data point function, waiting Control function

Availability

CTRL