Energy data within an organisation can often be distributed across different data endpoints with varied meta-data representation, which hinders seamless data collection and access from a single point for visualization and analytics. Moreover, there can be security and privacy constraints at data endpoints preventing data sharing and management. Thus, a local digital thread is required to aggregate the data from distributed data sources of an organization to standardize the data collection, representation, and preparation for further processing.
This repository contains instructions on how to initialize and run the current POC of the Local Digital Thread application.
The following Figure represents the architecture of the local digital thread:
- Python 3.X
- Pip3
- MySQL/Influx DB
- Telegraf 1.29.1
The application uses a REST API to interact with the data. Follow these commands to run the REST API:
cd app
flask run --host=0.0.0.0 --port=5000
To interact with the REST API, you can import the OPC UA.postman_collection.json collection into your Postman environment. This collection includes pre-configured requests for interacting with the API. The following are the steps:
- Register Local Data Source: POST /datasource
- Populate the Common Information Model(CIM): POST /mapping
- Restart the OPC UA server
The OPC UA server implements the CORDS' local digital thread's CIM as an OPC UA representation. The local database schemas can then be mapped to OPC UA object instances defined through the Data Transformation API.
cd opcua_server
python server.py
Telegraf is used to collect data pushed to the OPC UA server. The data that is being collected are pushed to an Influx DB instance for persistence. So make sure that a Influx DB instance is running and a bucket name "Local Digital Thread" exists in the DB.
cd telegraf
telegraf --config telegraf.conf
To insert data into the OPC UA server, you can run the OPC UA client. Use the following command:
python opc_client.py --opcua_reference_id="name_of_opc_ua_object"
Make sure that databases are initialized. Follow the Step 1 in previous step.
Change the app/config/config.yaml
as requred.
cd app
docker build -t flask-app .
docker compose up
Change the app/config/config.yaml
as requred.
docker build -t opc_server .
docker compose up