dpCopy()
Copies a data point including the configuration.
Synopsis
void dpCopy(string dpSource, string dpDestination, int &error, [int iDriverNumber]);
Parameters
Parameter | Meaning |
---|---|
dpSource | Source data point to be copied |
dpDestination | Target data point to be created including the configuration of the source data point |
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 data point failed |
-9 | The target DP already exists. |
-10 | The target data point does not exist. |
-11 | Wrong data point type |
-12 | Source data point is identical to the target data point |
Description
The function dpCopy() creates a data point named dpDestination with the same data point type as dpSource. This includes: original values of configuration (only if the data point 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 data points, 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 data point is copied several times, then the information is read only once. The buffer is reloaded, if you copy another source data point. If you change the source data point of the same data point 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 data point names.
This function has no effect on remote systems - the data point will not be copied. If you want to create the data point without configuration use the dpCreate() - this can also be used for remote systems.
Exampl e
Creating data point "test3Copy" and debugging the error code:
main()
{
int ierr;
dpCopy("ExampleDP_Arg1", "test3Copy", ierr, 2);
DebugN(ierr);
}
Example
Creating data point "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
Data point function
Availability
UI, CTRL
See also
dpCreate(), dpCopyBufferClear()