dpCopyConfig()

The function dpCopyConfig() copies a config from a source data point element into a target data point element.

Synopsis

void dpCopyConfig(string dpSource, string dpDestination, dyn_string sConfig, int &error, int iDriverNumber = -1);

Parameters

Parameter Meaning
dpSource dpSource
dpDestination dpDestination (must be the same DPT as the Source DP)
sConfig Config to be copied. Note that you cannot copy the original config.
&error Returns error code in case of errors. See Error description below.
iDriverNumber

Driver number. If the number is not defined the driver-number defined at the source-dp will be used.

When the driver number is changed in a CTRL script, then the driver-specific configs get lost. For copying to another driver number the following syntax must be used::

dpCopyConfig(dpsource , dpsource ,
                                    makeDynString("_distrib", "_address", "_smooth", "_cmd_conv",
                                    "_msg_conv"), error, iDriverNumber);

When using dpCopyConfig() to copy _address-configs you have to specify the driver-number which shall be used with the parameter iDriverNumber. If the number is not defined the driver-number defined at the source-dp will be used. You also have to specify all configs which are stored at the driver: _distrib, _smooth, _address, _msg_conv, _cmd_conv.

Return values

None.

Errors

See function dpCopy() for the possible error codes.

Description

This function copies any existing config from a source data point to a new target data point and automatically replaces alert handling, driver addresses etc.

dpCopyConfig can only be used for 2 data points of the same data point type! Moreover, the data point elements must be of the same type.

Note that you cannot copy the original config.

Note that the _general config is not copied by default.

The values of the attributes are not copied by default in the function since the code does not show which of the attributes are set.

If you use a defined list of the attributes of the _general config in your project, you can use the list in the function of wincc_oa_path\scripts\libs\mp.ctl library. Only set necessary attributes in order to minimize the disc space used as well as the memory of the Event Manager. You can find an example of attributes in the script mp.ctl in wincc_oa_path\scripts\libs.

Example

Copies the _address config of the data point "ExampleDP_Arg1" to the data point "ExampleDP_Arg2".

main()
{
  dyn_string conf;
  int error;
  conf = makeDynString("_address", "_distrib",
  "_smooth","_msg_conv","_cmd_conv")
  dpCopyConfig("ExampleDP_Arg1.","ExampleDP_Arg2.",conf,error);
  DebugN(conf);
}

Assignment

Data point function

Availability

CTRL