dpSetAndWaitForValue()

This function is a combination of the functions dpSet() and dpWaitForValue().

Synopsis

int dpSetAndWaitForValue(dyn_string dpNamesSet, dyn_anytype dpValuesSet,

dyn_string dpNamesWait, dyn_anytype conditions, dyn_string dpNamesReturn, dyn_anytype &returnValues, time timeout [,bool &timeExpired]);

Parameters

Parameter Description
dpNamesSet The data point attribute a value is assigned to.
dpValuesSet The value that is assigned to the data point attribute.
dpNamesWait A data point list that is compared to the values of conditions.
conditions Target values of arbitrary type and number. The values must correspond to the dp list dpNamesWait. The function waits for a value change that fulfills the conditions.
dpNamesReturn DP list whose values are returned. dpNamesWait and dpNamesReturncan contain same DPs.
returnValues Values that are returned from the list dpNamesReturn via dpSet().
timeout A time interval that specifies how long the function waits for the conditions to be fulfilled. The value 0 means that the function never expires.
timeExpired Optional parameter that is set to TRUE when the function expires (see timeout above).

Return Value

In the event of an error -1, otherwise 0

Errors

Errors can be retrieved with getLastError(). An error message is issued in the event of missing or incorrect arguments.

Description

The function triggers a verify function and subsequently sets values according to the dpSet function. The function returns back like the function dpWaitForValue() first when either the condition is fulfilled (this can be fulfilled via the dpSet functionality directly or indirectly) or when the timeout expires.

Example

The example sets the value of the text field for the data point ExampleDP_Arg2 and returns the connect value of the work function. The dpSetAndWaitForValue sets values until the condition (value of the text field "EditValue") is fulfilled or until the timeout expires. The timeout is set via the function CountDown(). The panel contains two visible text fields "editValue" and "Timeout" as well as an invisible text field "Countdown" below the CLICK button. The timeout is shown in the Timeout text field.

Figure: The panel demonstrates the use of the function dpSetAndWaitForValue

main()
{
  dyn_anytype returnValues;
  bool bExpired = 0;
  int iTimeOut = Timeout.text();
  dyn_string dpNamesSet =
  makeDynString("System1:ExampleDP_Arg1.:_original.._value"); /*
  Data point attribute for which a value is set */
  dyn_anytype dpValuesSet = makeDynFloat(editValue.text()); /* The
  value that is set for the data point above */
  dyn_anytype conditions = makeDynFloat(editValue.text()); /*
  Target values of arbitrary type and number. The values must
  correspond to the values of the 
  dp listdpNamesWait.The function waits for a value change
  that fulfills the conditions */
  dyn_string dpNamesWait =
  makeDynString("ExampleDP_Arg2.:_original.._value"); /* A data
  point list that is compared to the values of conditions.*/
  dyn_string dpNamesReturn =
  makeDynString("ExampleDP_Arg2.:_original.._value");/* DP list
  whose values are returned. The
  parametersdpNamesWaitanddpNamesReturncan 
  contain same DPs.*/
                                
  dpConnect("work",true,"System1:ExampleDP_Arg1.:_original.._value");
  /*Calls the callback function "work" when the passed data point
  values change */
  DebugTN("Work function call via dpConnect");
  startThread("CountDown");
  delay(10);
  /* The function "dpSetAndWaitForValue" compares the values of
  the paramater conditions with the values of the parameter
  dpNamesWait until the condition is fulfilled or 
  the timeout expires */
  dpSetAndWaitForValue(dpNamesSet, dpValuesSet ,dpNamesWait
  ,conditions ,dpNamesReturn, returnValues,iTimeOut,bExpired);
  DebugN("dpSetAndWaitForValue call");
  DebugTN("bExpired = " + bExpired);
}
void work(string dp, float value)
{
  delay(5);
  dpSet("ExampleDP_Arg2.:_original.._value",value);
  DebugTN("Connect Value of the work function, dpSet:
  ExampleDP_Arg2.:_original.._value = " + value);
}
void CountDown()
{
  for(int i = 0; i <= 6; i++)
  {
    Countdown.text(6-i);
    delay(1,0);
  }
}

Assignment

Data point function, waiting Control function

Availability

CTRL