DrvRsrce

The class DrvRsrce represents the interface to the resources (the configuration file). It is itself derived from the class Resources, and implements driver-specific functions - primarily relating to the driver-internal data points. For the general driver, 4 internal data points exist, which can be placed once per driver. Their assignment to the corresponding data point names is specified in the configuration file (see example below).

The configuration file has a separate section for each driver manager, starting with a driver-specific name (between [ and ]). In addition, each driver can also run repeatedly in the system (for communication with different peripheral components that communicate via the same protocols with WinCC OA), in which case each must be started with a unique number that is specified using the command line option "-num x". For each of these drivers, a separate section can additionally be specified in the configuration file, in which case the number must also be appended to the section name. In the example below, the section [myDrv] handles all drivers of type myDrv, and the section [myDrv_2] only the driver myDrv with number 2.

Each resource entry appears in a separate line, beginning with Resourcename and =, after which come the associated parameters. Comment lines begin with #.

Example of a configuration file

# Section that relates to all drivers of type myDrv

#(the entry could also be WCCOAmyDrv)

[myDrv]

instantGA = "Yes"

# Section that gives the setting for the myDrv with

# Number 2

[myDrv_2]

drvGQ = "_Driver2.GQ:_original.._value"

drvSQ = "_Driver2.SQ:_original.._value"

drvSmoothMode = "_Driver2.SM:_original.._value"

drvErrorMode = "_Driver2.EM:_original.._value"

# The data point _Driver2 of type CommonDriver must be created

The method readSection() must be overwritten in the special driver for processing of these entries:

  1. mydrvRsrce::readSection()
    {
      static char line[200];
      if (!isSection("mydrv")) return PVSS_FALSE;
      getNextEntry();
      while (cfgState != CFG_STATE_START && cfgState != CFG_EOF)
      {
        if (keyWord == "instantGA") cgfStream >> instantGA;
        else if (!commonKeyWord())
        // check if the keyWord belongs to
        //the resources of ComDrv (drv..)
        cerr << "unknown keyWord" << endl; // Error message
        cfgStream.get(line,200,´/n´);
        getNextEntry();
        }
      return PVSS_TRUE;
    }

The function getNextEntry() fetches the respective next entry in the configuration file (the next line), checks the syntactical correctness and allocates the resource name to the variable keyWord.

The class DrvRsrce declares an enum InternalDpIdType, which supplies predefined enums for the following internal data point types of the general driver. This declaration and a description of the single values are shown in the header file ComDrv/DrvRsrce.hxx.

data point type Task
NOT_INTERNAL_DPID for feedback
INTERNAL_GQ_DPID internal data point for general query (drvGQ)
INTERNAL_SQ_DPID internal data point for single query (drvSQ)
INTERNAL_SMOOTHMODE_DPID internal data point for smoothing behavior (drvSmoothMode)
INTERNAL_ERRMSGMODE_DPID internal data point for (drvErrorMode)
INTERNAL_DPID additional internal data point (for own functionality)

The smoothing behavior can be set to one of the following values:

mode Task Execution
SMOOTH_MODE_ALWAYS The smoothing is always done set internal data point drvSmoothMode to 0
SMOOTH_MODE_NOTGQ Smoothing only in case of spontaneous value changes set internal data point drvSmoothMode to 1
SMOOTH_MODE_NEVER No smoothing is done set internal data point drvSmoothMode to 2

The above values generally refer only to the data points for which a smoothing config was configured.

The class DrvRsrce also supplies an interface by means of virtual functions for linking the internal data points:

  • int getNumberOfDpNames() - This function is intended to return the number of the internal data point.

  • CharString& getDpName4Query(int index) - This function is intended to supply the name of the indexed data point (it is needed for obtaining the associated DP identifier from the data manager).

  • void setDpIdentifier(CharString& name, DpIdentifier& dpId) - This function is called up to disclose the DP identifier for the data point called "name".

  • PVSSboolean allIdsGot() - should return PVSS_TRUE if the DP identifier was disclosed for all internal data points.

  • int getNumberOfIds2Connect() - This function is intended to return the number of DP identifiers for which the driver should register with the event manager.

  • DpIdentifier& getId2Connect(int index) - This function is intended to return the DP identifier of the indexed data point for which the driver should register with the event manager.

  • void answer4DpId(const DpIdentifier& dpId, Variable * varPtr) - is called in case of immediate answer to a dpCponnect of an internal data point at the Event Manager . The new value is supplied in varPtr. The function should process this change in value.

  • Spontaneous hotlinks (information) to internal data points are received in the HWService object.

The different functions for name-DpIdentifier mapping and registration for original values were defined to enable the driver to possess internal data points for storing its own information (without registering with the event manager).

The class derived from DrvRsrce must be instantiated in the main() of the special driver!