SampleDriver

This example shows a WinCC OA driver that communicates via "named Pipes". Two drivers communicate with each other. One of them is the server that opens the "named Pipe" and sends messages. The second is the client that builds a connection to the server and receives messages.

Preparing the Driver

  1. Set your environment variables for the API and PLATFORM as described in the chapter API installation.

Note:

If you installed the API while installing WinCC OA, these environment variables have already been set!

  1. Copy the directory SampleDriver from $API_ROOT.

  2. Under Windows open the DeveloperStudio and compile the Sample driver. Under VC6 open SampleDriver.vcproj. Under VC9 convert the SampleDriver.dsw first. Thereby, proceed as described in the chapter Create API manager /driver.

  3. Under Linux the driver can be compiled and linked using
    make –f
                            Makefile.api
  4. Thus, the sample driver loads the MS DeveloperStudio project SampleDriver.dsw (for the version 9.0) and you can compile the driver as usual (using the F7 key).

  5. The executables are located in the sub directories "Release" or "Debug".

  6. If you want to start the driver from the WinCC OA console, copy the executables to the /bin directory of your WinCC OA project (PROJ_PATH/bin).

  7. The name of the executable has to start with "WCCOA" so that it is shown in the manager list.

The Project Settings

Before using the SampleDriver, you must create the internal data points.

  1. Start two driver simulators with -num 1 and -num 2 in the console.

  2. Import the file "SampleDriver.asc" using the ASCII manager. You need two simulators because this file specifies periphery addresses for the driver with the numbers 1 and 2.

  3. In the file "SampleDriver.asc" set the "StartValue 20", so the data point is completely defined:

    # DpType

    TypeName

    _SampleDriver._SampleDriver 1

    Counter 20

    ResetCounter 23

    StartValue 20

  4. Stop the simulators.

Using the Driver

  1. Start the driver with "-num 1" (the server by default) to make the connection.

  2. Start the client.

  3. There are two example data points "SampleTest_1" and "SampleTest_2" with which you can send messages from the server ( -num 1) to the client ( -num 2). Only this direction is possible!

  4. The client counts all messages and displays the number in the internal data point "_SampleDriver.Counter".

  5. Use "_SampleDriver_2.ResetCounter" to reset the counter to 0.

Config Settings

All settings are optional as they have default settings. The entries in the following section apply to all SampleDrivers.

For Windows Systems:

[sample]

pipeName = "\\\\.\\pipe\\SampleDriver"

For Linux:

[sample]

pipeName = "/tmp/SampleDriver"

Specifies the name of the connection. As both drivers use the same name it has to be specified for both in this section.

This is the section for driver -num 1:

[sample_1]

server = "Yes"

sampleDpName = "_SampleDriver_1"

Set this driver as server (makes connection). Possible values are "Yes" and "No".

Specify the name of the internal data points. The default is "_SampleDriver_1".

For a redundant system, replace this with "_SampleDriver_2_1" for host2

This is the section for driver -num 2:

[sample_2]

server = "No"

sampleDpName = "_SampleDriver_2"

Set driver 2 as client (connects). Possible values are "Yes" and "No"

Specify the name of the internal data points. The default is "_SampleDriver_2".

For a redundant system, replace this with "_SampleDriver_2_2" for host2