dpCopy()

Copies a datapoint including the configuration.

Synopsis

void dpCopy(string dpSource, string dpDestination, int &error, [int iDriverNumber]);

Parameters

Parameter Meaning
dpSource Source datapoint to be copied
dpDestination Target datapoint to be created including the configuration of the source datapoint
error Return value of the error code
iDriverNumber Optional parameter for setting the driver number. Default: 1

Return Value

None

Errors

An error code is returned via the variable error, which means the following:

Error code Meaning
0 OK, copying successful
-1 Source DP does not exist
-2 Destination DP empty
-3 Acknowledgement not possible
-4 Deactivation of alert not possible
-5 Setting of configs produced an error
-6 The query of configs produced an error.
-7 The query of the config content produced an error.
-8 Creation of the datapoint failed
-9 The target DP already exists.
-10 The target datapoint does not exist.
-11 Wrong datapoint type
-12 Source datapoint is identical to the target datapoint

Description

The function dpCopy() creates a datapoint named dpDestination with the same datapoint type as dpSource. This includes: original values of configuration (only if the datapoint contains an element resp. node, which shows the pattern *para* in the name - the original values of the elements underneath the node are applied as well as the original values of the elements named *para*), description of datapoints, unit and format of nodes, configs of leafs (_LEAF), inactive bus addresses (if it concerns inactive output addresses; active duplicates are prevented in WinCC OA). Limitations: no alert classes, group alerts without wildcards and lock information. There exists a buffer. If the source datapoint is copied several times, then the information is read only once. The buffer is reloaded, if you copy another source datapoint. If you change the source datapoint of the same datapoint type during copying, then you have to clear the buffer with the function dpCopyBufferClear(). Otherwise the old information would be copied.

The user has to assure the deletion of the buffer with dpCopyBufferClear()!

Refer to nameCheck() for not permitted characters in datapoint names.

This function has no effect on remote systems - the datapoint will not be copied. If you want to create the datapoint without configuration use the dpCreate() - this can also be used for remote systems.

Exampl e

Creating datapoint "test3Copy" and debugging the error code:

main()
{
  int ierr;
  dpCopy("ExampleDP_Arg1", "test3Copy", ierr, 2);
  DebugN(ierr);
}

Example

Creating datapoint "Test_DP_12" with all original values, set on the elements (data point contains no node/element named *para*):

main()
{
  int ierr, i;
  dyn_string allC;
  dyn_anytype para;
  dpCopy("Test_DP_02", "Test_DP_12", ierr);
  if (ierr < 0)
  {
    return;
  }
  allC = dpNames("Test_DP_02"+".**:_original.._value",
  "TestDPT");
  dpGet(allC, para);
  for (i=1; i<=dynlen(allC); i++)
  {
    strreplace(allC[i], "Test_DP_02", "Test_DP_12");
  }
  dpSet(allC, para);
}

Assignment

Datapoint function

Availability

UI, CTRL

See also

dpCreate(), dpCopyBufferClear()