Creating a new PowerConfig for a DPT

Clicking on the Create new PowerConfig button opens the panel below for entering the PowerConfig parameters. Select the DPT radio box in order to define a PowerConfig covering the whole data point type (i.e. a DPT-PC).

Screenshot: Panel for defining a new DPT PowerConfig

From the combo box (beside the text field with the gray background displaying "_da_DPT_") select a data point type for which a PowerConfig is to be created. The name of the PowerConfig is displayed in the text field underneath with the gray background.

The PowerConfig name is composed from the following wording: _da_DPT_ + data point-type name. Example: _da_DPT_PUMP1 represents a PowerConfig for the data point type PUMP1.

A DPT-PC is inserted at the root node of the master data point, and allows the configuration of multiple DPEs located in the underlying structure (see also inserting a DPT PowerConfig). Only one DPT-PC can ever be created for one data point type. When selecting a DPT-PC, select the required data point type from the combo box. The data type does not need to be selected here, because insertion at the root node is always associated with the STRING data type. DPT-PCs are always created as "string", because of course they can only be inserted at a root node (and all nodes in WinCC OA are handled as strings - for example, only the PowerConfig "Group alert handling" can be inserted at a node, just like for a string).

When configuring the plain text, you can assign an alternative name to the PowerConfig that is displayed in the Configuration combo box of the PowerConfig Editor. Clicking on OK confirms the entries you have made and closes the panel; Cancel closes the panel without adopting any of the settings.

Example

A PowerConfig covering a data point type (i.e. a DPT-PC) is to be created for the data point type "TrafficLights" (the structure of this data point type is also given in the Example of mass configuration). By adding the DPT PowerConfig to the root node of the master data point, the 4 elements of the data point type (red, yellow, green, malfunction)are configured with a periphery address (OPC input). Server, Group, Item and Address-activation are to be the dynamic attributes (those that can be changed at configuration at the data point).

  1. Click on the Create new PowerConfig button in the PowerConfig Editor.
  2. Enter the following parameters in the panel for defining a new PowerConfig:
    Figure 1. Screenshot: Defining a new PowerConfig
  3. Select the PowerConfig just created "S - TrafficLights - DPT-PC" from the combo box containing the defined configurations, in order to set the variables and scripts on the tabs in the following steps.
  4. On the Variables tab, declare all the variables that are required in the subsequent scripts for setting/reading the attributes of the PowerConfig (further information on the Variables tab page). You need to define the following variables for this example:
    Name Type Default value Description
    leaf_red string ".red" Data point element
    leaf_yellow string ".yellow" Data point element
    leaf_green string ".green" Data point element
    leaf_malfunction string ".malfunction" Data point element
    dp string dpSubStr($DPE,DPSUB_DP) Data-point name
    ref1 string Additional ID for item
    ref2 string Additional ID for item
    ref3 string Additional ID for item
    ref4 string Additional ID for item
    Server string "EXAMPLESERVER" Part of the peripherals address
    Group string "STATE" Part of the peripherals address
    Item string dpSubStr($DPE,DPSUB_DP)+"_OPCITEM" Part of the peripherals address
    _reference string Reference string (defines the address)
    _active bool Address activation
    _direction int Specifies the direction (input or output).
    _drv_ident string "OPCCLIENT" Driver type
  5. In this step you enter in the Input tab a script that reads the current values of the attributes and writes them to defined variables (for example, when opening the PowerConfig configuration panel from the data point). Enter the following script in this tab:
    dpGet(dp+leaf_red+":_address.._reference",_reference,
    dp+leaf_red+":_address.._active",_active,
    dp+leaf_red+":_address.._drv_ident",_drv_ident,
    dp+leaf_red+":_address.._direction",_direction);
  6. Enter in the Input calculation tab a script that splits up the reference string and writes the values to the variables Server, Group and Item ( no "real" WinCC OA attributes are used for Server, Group and Item for an OPC peripherals address). These variables are intended to be used as dynamic attributes, which can be changed at each data point. Define the following script, which splits up the string:
    Server = substr(_reference, 0, strpos(_reference, "$"));
    _reference = substr(_reference, strpos(_reference, "$")+1, strlen(_reference));
    Group = substr(_reference, 0, strpos(_reference, "$"));
    Item = substr(_reference, strpos(_reference, "$")+1, strlen(_reference));
  7. On the Manual inputtab, select the variables (dynamic attributes) whose parameters can be set at each data point and can thus be changed at each element of the data point (more information on this tab is given on the Manual input tab page). For this example the variables Server, Group, Item and _active have been used. Since the variable names are already used in other PowerConfig scripts, the plain text name of the dynamic attributes from the da.cat catalog file is also used.
  8. Since the reference string has already been split up, so that the individual parameters can be set for each DP using PowerConfig configuration (click on OK in the configuration panel), the address (reference string) must be re-assembled on the Output calculation tab. This ensures that the attribute _address.._reference is set correctly for the OPC peripherals address. The following script re-assembles the string:
    _reference = Server+"$"+Group+"$"+Item;
    ref1 = _reference;
    ref2 = _reference+"_1";
    ref3 = _reference+"_2";
    ref4 = _reference+"_3";
  9. The script defined on the Output tab is used to set the values that the variables have assumed to the specific attributes of the Configs. For this example, write the following script in this tab:
    dpSetWait(dp+leaf_red+":_address.._reference",ref1,
    dp+leaf_red+":_address.._active",_active,
    dp+leaf_red+":_address.._direction",_direction,
    dp+leaf_red+":_address.._drv_ident",_drv_ident);
    dpSetWait(dp+leaf_yellow+":_address.._reference",ref2,
    dp+leaf_yellow+":_address.._active",_active,
    dp+leaf_yellow+":_address.._direction",_direction,
    dp+leaf_yellow+":_address.._drv_ident",_drv_ident);
    dpSetWait(dp+leaf_green+":_address.._reference",ref3,
    dp+leaf_green+":_address.._active",_active,
    dp+leaf_green+":_address.._direction",_direction,
    dp+leaf_green+":_address.._drv_ident",_drv_ident);
    dpSetWait(dp+leaf_malfunction+":_address.._reference",ref4,
    dp+leaf_malfunction+":_address.._active",_active,
    dp+leaf_malfunction+":_address.._direction",_direction,
    dp+leaf_malfunction+":_address.._drv_ident",_drv_ident);
    err = getLastError();
    if (dynlen(err) > 0)
    {
      throwError(err);
    }
  10. The last step in creating the new PowerConfig involves using a script in the Default tab to set values to attributes that will be configured to the individual elements of the data point when the PowerConfig is inserted at the root node of the master data point. When writing this script, make sure that the type of the Config that is to be set at the elements is defined (in this example _distrib.._type and _address.._type). If these attributes are not set, the DPT PowerConfig cannot be selected for insertion at the master data point (see also Inserting a DPT PowerConfig).

    In this example the following attributes are given values:

    _reference = Server+"$"+Group+"$"+Item;
    ref1 = _reference;
    ref2 = _reference+"_1";
    ref3 = _reference+"_2";
    ref4 = _reference+"_3";
    dpSet(dp+leaf_red+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
    dp+leaf_red+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
    dp+leaf_red+":_address.._reference",ref1,
    dp+leaf_red+":_address.._active",FALSE,
    dp+leaf_red+":_address.._direction","\2",
    dp+leaf_red+":_address.._drv_ident",_drv_ident);
    dpSet(dp+leaf_yellow+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
    dp+leaf_yellow+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
    dp+leaf_yellow+":_address.._reference",ref2,
    dp+leaf_yellow+":_address.._active",FALSE,
    dp+leaf_yellow+":_address.._direction","\2",
    dp+leaf_yellow+":_address.._drv_ident",_drv_ident);
    dpSet(dp+leaf_green+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
    dp+leaf_green+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
    dp+leaf_green+":_address.._reference",ref3,
    dp+leaf_green+":_address.._active",FALSE,
    dp+leaf_green+":_address.._direction","\2",
    dp+leaf_green+":_address.._drv_ident",_drv_ident);
    dpSet(dp+leaf_malfunction+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
    dp+leaf_malfunction+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
    dp+leaf_malfunction+":_address.._reference",ref4,
    dp+leaf_malfunction+":_address.._active",FALSE,
    dp+leaf_malfunction+":_address.._direction","\2",
    dp+leaf_malfunction+":_address.._drv_ident",_drv_ident);
  11. On the last tab, Source code, you can view the script of the created PowerConfig and check its syntax. A new section containing the settings for the new PowerConfig is added to the powerconfig file (you can find more information on the structure of this file on the page Structure of the powerconfig file). The script for this example should look as follows:
    definition34()
    {
      // definition start
      //_da_DPT_Ampel:STRING
      // variables definition
      string leaf_red=".red";
      string leaf_yellow=".yellow";
      string leaf_green=".green";
      string leaf_malfunction=".malfunction";
      string dp=dpSubStr($DPE,DPSUB_DP);
      string _drv_ident="OPCCLIENT";
      bool _active;
      int _direction;
      string _reference;
      string Server="EXAMPLESERVER";
      string Group="STATE";
      string Item=dpSubStr($DPE,DPSUB_DP)+"_OPCITEM";
      string ref1;
      string ref2;
      string ref3;
      string ref4;
      // dpGet
      dpGet(dp+leaf_red+":_address.._reference",_reference,
      dp+leaf_red+":_address.._active",_active,
      dp+leaf_red+":_address.._drv_ident",_drv_ident,
      dp+leaf_red+":_address.._direction",_direction);
      // calculate input
      Server = substr(_reference, 0, strpos(_reference, "$"));
      _reference = substr(_reference, strpos(_reference, "$")+1, strlen(_reference));
      Group = substr(_reference, 0, strpos(_reference, "$"));
      Item = substr(_reference, strpos(_reference, "$")+1, strlen(_reference));
      // variables input
      //_active
      //Server
      //Group
      //Item
      // calculate output
      _reference = Server+"$"+Group+"$"+Item;
      ref1 = _reference;
      ref2 = _reference+"_1";
      ref3 = _reference+"_2";
      ref4 = _reference+"_3";
      // dpSet
      dpSetWait(dp+leaf_red+":_address.._reference",ref1,
      dp+leaf_red+":_address.._active",_active,
      dp+leaf_red+":_address.._direction",_direction,
      dp+leaf_red+":_address.._drv_ident",_drv_ident);
      dpSetWait(dp+leaf_yellow+":_address.._reference",ref2,
      dp+leaf_yellow+":_address.._active",_active,
      dp+leaf_yellow+":_address.._direction",_direction,
      dp+leaf_yellow+":_address.._drv_ident",_drv_ident);
      dpSetWait(dp+leaf_green+":_address.._reference",ref3,
      dp+leaf_green+":_address.._active",_active,
      dp+leaf_green+":_address.._direction",_direction,
      dp+leaf_green+":_address.._drv_ident",_drv_ident);
      dpSetWait(dp+leaf_malfunction+":_address.._reference",ref4,
      dp+leaf_malfunction+":_address.._active",_active,
      dp+leaf_malfunction+":_address.._direction",_direction,
      dp+leaf_malfunction+":_address.._drv_ident",_drv_ident);
      err = getLastError();
      if (dynlen(err) > 0)
      {
        throwError(err);
      }
      // default
      _reference = Server+"$"+Group+"$"+Item;
      ref1 = _reference;
      ref2 = _reference+"_1";
      ref3 = _reference+"_2";
      ref4 = _reference+"_3";
      dpSet(dp+leaf_red+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
      dp+leaf_red+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
      dp+leaf_red+":_address.._reference",ref1,
      dp+leaf_red+":_address.._active",FALSE,
      dp+leaf_red+":_address.._direction","\2",
      dp+leaf_red+":_address.._drv_ident",_drv_ident);
      dpSet(dp+leaf_yellow+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
      dp+leaf_yellow+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
      dp+leaf_yellow+":_address.._reference",ref2,
      dp+leaf_yellow+":_address.._active",FALSE,
      dp+leaf_yellow+":_address.._direction","\2",
      dp+leaf_yellow+":_address.._drv_ident",_drv_ident);
      dpSet(dp+leaf_green+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
      dp+leaf_green+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
      dp+leaf_green+":_address.._reference",ref3,
      dp+leaf_green+":_address.._active",FALSE,
      dp+leaf_green+":_address.._direction","\2",
      dp+leaf_green+":_address.._drv_ident",_drv_ident);
      dpSet(dp+leaf_malfunction+":_distrib.._type",DPCONFIG_DISTRIBUTION_INFO,
      dp+leaf_malfunction+":_address.._type",DPCONFIG_PERIPH_ADDR_MAIN,
      dp+leaf_malfunction+":_address.._reference",ref4,
      dp+leaf_malfunction+":_address.._active",FALSE,
      dp+leaf_malfunction+":_address.._direction","\2",
      dp+leaf_malfunction+":_address.._drv_ident",_drv_ident);
      // definition end
    }
  12. After the PowerConfig was created, the GEDI has to be restarted in order that the new PowerConfig will be available/visible.

The PowerConfig created in this example can now be inserted in the PARA Module at the root node of the master data point. Enabling the DPT-PC check box results in the values defined in the Default section of the PowerConfig script being set (see also Inserting a DPT PowerConfig).