Skip to content

S7 Example

This example usage of the S7 Device Service demonstrates the onboarding of an S7 device.

Start the S7 Device Service

To start the S7 Device Service, enter the following command:

edgexpert up device-s7

Device Onboarding

Once the S7 Device Service has been started, S7 devices can be onboarded to Edge Xpert using either the Edge Xpert Manager UI or through Edge Xpert REST API commands. Instructions on how to use both methods can be found below.

Device Onboarding with the Edge Xpert Manager UI

Note

Please refer to the Edge Xpert Manager UI Device Management capability for full details.

  1. Ensure the Edge Xpert Manager UI is started, for example:

    edgexpert up xpert-manager
    

  2. Open a browser and go to localhost:9090. The default username and password is admin

  3. Using the device profile upload capability, upload the provided S7 example device profile at /usr/share/edgexpert/examples/device-services/s7/Server.yml

  4. Onboard the device using the device onboarding capability. The following values can be used to provision the S7 Simulation device:

    Field Example Value Description Required
    Name S7-Device The unique name used to identify the device Required
    Description Example S7 Server Any additional information to help identify the device Optional
    Label S7 Any additional information to help identify the device Optional
    Protocol S7 The name of the protocol Required
    Address 0.0.0.0 IP address of the PLC being connected to Required
    Rack 0 Rack number of the CPU to communicate with Required
    Slot 2 Slot number of the CPU to communicate with Required
    Device Profile Server The name of the device profile uploaded above Required
    Device Service device-s7 The name of the appropriate device service Required
    Auto Events Interval: 5s
    OnChange: false
    ResourceName: DB-Test
    Automated events to retrieve the data at specific frequencies

    Note: If OnChange is set to true, values will only be pushed if a change in value has occurred during the specified interval. If set to false, values will be sent on the specified regardless of if there has been a change.
    Optional

Device Onboarding using the Edge Xpert REST API

  1. Upload the provided S7 example device profile:

    curl http://localhost:59881/api/v2/deviceprofile/uploadfile -F "file=@/usr/share/edgexpert/examples/device-services/s7/Server.yml"
    

  2. Onboard the device using similar values as with the Edge Xpert Manager UI:

    curl -X 'POST' \
      'http://localhost:59881/api/v2/device' \
      -H 'Content-Type: application/json' \
      -d '[
      {
        "apiVersion": "v2",
        "device": {
          "name": "S7-Device",
          "description": "Example S7 Server",
          "adminState": "UNLOCKED",
          "operatingState": "UP",
          "labels": [
            "S7"
          ],
          "serviceName": "device-s7",
          "profileName": "Server",
          "protocolName": "s7",
          "autoEvents": [
            {
              "interval": "5s",
              "onChange": false,
              "sourceName": "DB-Test"
            }
          ],
          "protocols": {
            "S7": {
              "IP":"0.0.0.0",
              "Rack": "0",
              "Slot": "2"
            }
          }
        }
      }
    ]'
    

Device Data Flow

Once the device is onboarded to Edge Xpert, data flow between the Device Service and the connected device can be verified in a number of ways.

The Edge Xpert Manager UI supports Read and Write functionality for each device. Readings can also be viewed and queried within the Edge Xpert Manager UI Data Center.

Alternatively, you can read and write data with cURL commands or through REST API applications, such as Postman.

Both the GET and PUT commands can be made to the following address:

http://localhost:59958/api/v2/device/name/{deviceName}/{commandName}
Using the example above, this could be:
http://localhost:59958/api/v2/device/name/S7-Device/DB-Test

For more information on the GET and PUT commands, see the Core Command Microservice.

Note

59958 is the default port for the S7 device service

Any data collected by the Device Service can then be treated like all other Edge Xpert sensor data. The data readings can be exported for data processing in a number of other applications and services. See the Supporting Services and Application Services documentation for more details.

Back to top