Streaming Analytics Limited Bandwidth Sample

This example shows how Apama can be used on a thin-edge device to process and filter events to reduce the frequency of messages sent to the cloud.

The EPL file in this sample (ThinEdgeIoExample.mon) collates temperature, pressure and vibration events, averages them and sends a measurement combining those averages at 5 second intervals to thin-edge.io via MQTT.

COPYRIGHT NOTICE

Copyright (c) 2022-2023 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG

Prerequisites

Follow the setup and configuration instructions in the README file in the parent directory before running this sample.

Ensure that the thin-edge device has Python 3 installed, that it is on your $path, and that you have installed paho-mqtt:

sudo apt-get install python3
pip install paho-mqtt

How to run the sample

Note: If you intend to modify or extend this sample it is recommended that you delete the provided config.yaml file and use engine_deploy from a full Apama installation to build a deployable version of your project which you then copy to the thin-edge device. This is because changing this sample could break the configuration in config.yaml and using engine_deploy works out the correct initialization order when creating a deployable project.

Zip the project located in the LimitedBandwidth directory of this repository. Note that you must use the zip format and not some other compression utility. Then use your tenant to deploy the zipped project to your thin-edge device by following these steps:

  1. In your Cumulocity IoT tenant, go to the Device Management app and go to the Management menu option and select the Software repository.
  2. Click Add software at the right of the top menu bar.
  3. In the ADD SOFTWARE dialog enter the following details:
  4. Software: apama-limited-bandwidth
  5. Description: apama-limited-bandwidth (or something else if you choose)
  6. Device Filter Type: (leave empty)
  7. Software Type: apama
  8. Version: 1.0::apama
  9. SOFTWARE FILE: select the Upload a binary option and either drag and drop the project zip file created previously, or use the file chooser to navigate to it in your file system.
  10. Click the Add software button.
  11. Now return to the Devices menu option and then select All devices.
  12. In the list of devices, select the thin-edge device installed previously.
  13. In the sub-menu for the device, select the Software option.
  14. Click the Install software button in the bottom left; the apama-limited-bandwidth project should be listed.
  15. Click the drop-down arrow on the right and check the 1.0::apama radio button. Then, click Install.
  16. Finally, click the Apply changes button in the lower right of the panel.
  17. Copy the demo_publisher.py script in the LimitedBandwidth directory to the /etc/tedge/apama/project directory on the thin-edge device. Execute the script to send some fake temperature, pressure and vibration measurements to the Apama application.
  18. If you have configured thin-edge.io to connect to Cumulocity IoT or another cloud service you should see the measurement(s) appear there.