Document Version: V1.0
Version | Date | Content |
---|---|---|
1.0 | 2023-05-11 | Document created |
This document guides you how to customize a TPE application, which subscribes tag data from ThingsPro Edge, calculates and then publishes the results back to ThingsPro Edge as virtual tags.
item | Note / Command |
---|---|
Linux OS | A x86 CPU virtual machine with Ubuntu Server 18.04 OS |
Install Docker | https://docs.docker.com/install/linux/docker-ce/ubuntu/ |
Install ARM32 emulator | A tool to convert x86/x64 docker image to ARM CPU. >apt-get update >apt-get install -y qemu-user-static |
$ wget https://tpe2.thingspro.io/tpe2/Python3/TagProcess.tar.gz
$ mkdir TagProcess
$ tar -zxvf TagProcess.tar.gz -C TagProcess
Name | Type | Note |
---|---|---|
Dockerfile | File | Generates the docker image for our application. |
docker-compose.yml | File | Use by ThingsPro Edge to launch this application. |
metadata.yml | File | Use by ThingsPro Edge to understand this application. |
nginx.conf | File | A Nginx file to declare this application exposes restful API path, and plug-into ThingsPro Edge API framework. |
requirements.txt | File | A file that specifies the required python modules. |
config.json | File | Describes the source tags and the target tags. |
/app/sample.py | File | The main entry point where we implment our logic. |
/app/tpeHelper.py | File | A helper class that interacts with ThingsPro Edge. |
Note: For more detailed information about each files, please refer to Build and Run "Hello World" Application.
$ cd TagProcess
$ docker run --rm -it -v $(pwd):/app/ -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock moxa2019/thingspro-app-builder:1.0 bash
$ cd app
2.3.3 Build docker image with image name: tag_process_sample:1.0.0. The image name must match the image name that's specified in docker-compose.yml.
$ docker build . -t tag_process_sample:1.0.0
$ tdk pack
If the application packing went well, a file tag_process_sample_1.0.0_armhf.mpkg
will be created in the same folder.
The easiest way to install a mpkg file is to tranfer the file to the target unit with scp
, then install it with command appman app install tag_process_sample_1.0.0_armhf.mpkg
.
-
Availability of the Source Tags
Please make sure the source tags specified in config.json exists.
-
Leverage Tag Management to Monitor the Result
We can monitor the result tags by selecting them in the tag management tab on ThingsPro Edge's web page. Virtual tags can also be selected when configuring device to cloud telemetry messages.