Questo cancellerà lapagina "README". Si prega di esserne certi.
The communication repository for the Digital Twin project at the Metal Sheet Assembly Shop-floor, Zoomlion.
Developed by Bohan LENG
This repository contains all the C++ projects developed for building the Digital Twin platform for a Metal Sheet Assembly Shop-floor, mainly for the warehouse system and the logistics system. To process multi-source, heterogeneous data generated by devices and services, a multi-layer architecture is proposed to decouple the function modules.
---
title: Digital Twin Implementation Architecture
---
flowchart BT
ue[Unreal Engine]
web[Web Client]
proxy["`***HTTP Proxy***`"]
iot[IoT, Internet of Things]
rcs[RCS, Robot Control System]
wcs[WCS, Warehouse Control System]
agv[AGV, Automated Guide Vehicle]
dev[Shuttle, Hoist, Conveyor]
asrs[ASRS, Automated Storage and Retrieval System]
wms[WMS, Warehouse Management System]
ue<-- Web Interface -->web
proxy -- "`***TCP***`" --> ue
iot -- "`***HTTP***`" --> proxy
rcs -- HTTP --> iot
wcs -- HTTP --> iot
agv --> rcs
dev --> wcs
asrs --> wms
wms -- "`***HTTP***`" --> proxy
With the data being parsed, change-detected, structured before entering Digital Twin, the Digital Twin application can be developed purely in an event-driven manner. The Digital Twin platform, developed with Unreal Engine 5, is managed in a separate repository.
This repository is focused on the data gathering from IoT and WMS using HTTP, the processing of the data, and the data transmission to Unreal Engine using TCP.
c++20 g++-13 boost-asio curl pybind11 nlohmann-json confluent-kafka pyfilter
---
title: Class Diagram of ZMonitor
---
classDiagram
class Header {
+uint32 type
+uint32 length
}
class TCPMsg {
+Header header
+vector~byte~ body
+operator<<()
+operator>>()
}
class TCPRawMsg {
+vector~byte~ body
+operator<<()
+operator>>()
}
class TCPConn~ ~ {
+ConnectToClient(client_id)
+ConnectToServer(ip, port)
+Disconnect()
+IsConnected() bool
+GetRemoteEndpoint() string
+Send()
}
class ITCPServer~ ~ {
<<interface>>
+Start()
+Stop()
+MessageClient(client, msg)
+OnMessage(client, msg) *
}
class ITCPClient~ ~ {
<<interface>>
+Connect(ip, port)
+Disconnect()
+SendMessage(msg)
+OnMessage(msg) *
}
class ITCPRawMsgSender {
<<interface>>
+Connect(ip, port)
+Disconnect()
+SendMessage(msg)
+OnMessage(msg) *
}
class CMonitorSPI {
<<interface>>
+OnConnected()*
+OnRspAuth(auth_msg)*
+OnDisconnected()*
+On...Update()*
}
class CMonitorAPI {
+CreateAPI() api$
+Init(ip, port, name, spi)
+IsConnected() bool
+Run()
}
class ZMonitorService {
-vector~TCPConn~ consumers
}
class HTTPProxy {
-map~device_name, update~ device_caches
-vector~thread~ acquisiton_threads
+Run()
+SendMonitorMsg(msg_type, msg)
+StartAcquiringHTTPUpdate(http_url)
+ParseUpdate(update)
+StopAcquisitions()
}
direction TB
Header *-- TCPMsg
TCPMsg o-- TCPConn
TCPRawMsg o-- TCPConn
TCPConn *-- ITCPServer
TCPConn *-- ITCPClient
TCPConn *-- ITCPRawMsgSender
ITCPServer <|.. ZMonitorService
ITCPServer <|.. HTTPProxy
ITCPClient <|.. CMonitorAPI
CMonitorSPI *-- CMonitorAPI
link TCPConn "#tcpconn"
link TCPMsg "#tcpconn"
link TCPRawMsg "#tcpconn"
link ITCPServer "#tcpconn"
link ITCPClient "#tcpconn"
link ITCPRawMsgSender "#tcpconn"
link ZMonitorService "#zmonitorservice"
link HTTPProxy "#httpproxy"
link CMonitorAPI "#zmonitorapi"
link CMonitorSPI "#zmonitorapi"
TCPConnTCP communication library developed with BOOST_ASIO. Coded with Pimp (Pointer to Implementation) paradigm to remove the prerequisites for library users.
Two types of TCP messages, TCPMsg and TCPRawMsg are defined, serving the purposes of both header-style message and header-less raw message transmission. TCPMsg can be used for self-created applications for long messages. TCPRawMsg can be used to transmit bytes with custom protocols, but the length of each message is limited to a certain number of bytes.
The socket, server, client classes are built accordingly. Template classes TCPConn, TCPServer, TCPClient can all be instantiated using either TCPMsg or TCPRawMsg, forming into different TCP connections for various scenarios. TCPRawMsgSender sends raw bytes for low-level communications.
A few examples are created under directory TCPConnExample.
ZMonitorAPILibrary containing the monitoring interface for shop-floor device/software data, which is defined in SheetAssemblyMonitorDef.h The consumer applications (e.g. Unreal Engine program) should use this interface to define the behaviour on protocol data received by implementing the corresponded callback functions. An example of use is provided under the directory ZMonitorAPIExample.
Note: Two overloads of CMonitorAPI::Init() are provided, one using smart pointers, one raw pointers. Unreal Engine must use the raw pointer overload.
void Init(const std::string &server_ip, uint16_t server_port, const std::string &consumer_name, std::unique_ptr<CMonitorSpi> spi);
// The signature below supports Unreal Engine use
void Init(const char* server_ip, uint16_t server_port, const char* consumer_name, CMonitorSpi* spi);
ZMonitorServiceService for handling message communications between multiple data producers and multiple data consumers. Direct broadcast is triggered on message received from producers.
The connected client will be treated as data producers by default. Clients to be consumers need to actively request for authentication as consumer by sending a ST_ReqAuth message.
HTTPProxyConnect between HTTP services (e.g. the shop-floor IoT data platform, the Warehouse Management System HTTP interface), and the Digital Twin application. This proxy fetches HTTP data at fixed interval set for each url, parse the JSON into data of interest, and combine data into data frames as described in SheetAssemblyMonitorDef.h.
HTTPProxy manages Digital Twin client connection as the message recipient. Only one Digital Twin application is allowed to connect at a time. The established Digital Twin TCP connection is kept through KeepAlive().
Several example data file fetched from url is saved for development.
PyDTProxyCalls Kafka API to fetch data provided by the IoT platform of the shop-floor. Packed C++ TCP communication functionalities (TCPConn::TCPClient) into python module using pybind so that it can be called in Python, where Kafka data is fetched.
Building PyDTProxy CMake target will generate python library into bin. CMake will also copy PyDTProxy.py from the project folder into bin, which should be the working directory running the script. A virtual environment is recommended to run the script.
python3 -m venv venv
source venv/bin/activate
pip3 install -r PyDTProxy/requirements.txt
cd bin/${OPERATING_SYSTEM} # see the generated
python3 PyDTProxy.py
To build python script (and PyDTProxy library and Kafka) into an executable, run pyinstaller under bin/${OPERATING_SYSTEM}.
# Make sure to use pyinstaller of the venv otherwise the dependencies would not be included
# which pyinstaller
pyinstaller .\PyDTProxy.py --onefile --add-data PyDTProxyConfig.json:.
./dist/PyDTProxy # packaged executable
PyFilterPython scripts for the research on RGV (Rail Guided Vehicle) position filtering, whose data discreteness in time and space make it hard to track. Kalman-based filters are implemented to filter, in real-time, the experimental data generated in a simulation platform built with Unreal Engine.
221 .gitignore
27 CMakeLists.txt
30 HTTPProxy/CMakeLists.txt
505 HTTPProxy/HTTPProxy.cpp
85 HTTPProxy/HTTPProxy.h
1580 HTTPProxy/example_data.json *
114 HTTPProxy/example_storage_rsp_fqhc.json *
16508 HTTPProxy/example_storage_rsp_zd.json *
16 HTTPProxy/http_proxy_cfg.json
85 HTTPProxy/main.cpp
32 PyDTProxy/CMakeLists.txt
220 PyDTProxy/PyDTProxy.cpp
120 PyDTProxy/PyDTProxy.py
11 PyDTProxy/PyDTProxyConfig.json
7 PyDTProxy/requirements.txt
30 PyFilter/listener.py
95 PyFilter/main.py
13 PyFilter/requirements.txt
77 PyFilter/result_plotter.py
143 PyFilter/rgv_filters.py
23 PyFilter/sender.py
22 PyFilter/signal_handler.py
344 README.md
21 TCPConn/CMakeLists.txt
67 TCPConn/TCPClient.h
160 TCPConn/TCPClientImpl.cpp
48 TCPConn/TCPClientImpl.h
78 TCPConn/TCPConn.h
399 TCPConn/TCPConnImpl.cpp
84 TCPConn/TCPConnImpl.h
198 TCPConn/TCPMsg.h
98 TCPConn/TCPMsgQueue.h
86 TCPConn/TCPRawMsgSender.h
253 TCPConn/TCPRawMsgSenderImpl.cpp
66 TCPConn/TCPRawMsgSenderImpl.h
79 TCPConn/TCPServer.h
187 TCPConn/TCPServerImpl.cpp
49 TCPConn/TCPServerImpl.h
25 TCPConnExample/CMakeLists.txt
129 TCPConnExample/TCPClientExample.cpp
72 TCPConnExample/TCPRawMsgSenderExample.cpp
57 TCPConnExample/TCPServerExample.cpp
29 TCPConnExample/TCPServerRawExample.cpp
17 ZMonitorAPI/CMakeLists.txt
121 ZMonitorAPI/MonitorAPI.h
132 ZMonitorAPI/MonitorAPIImp.cpp
41 ZMonitorAPI/MonitorAPIImp.h
27 ZMonitorService/CMakeLists.txt
49 ZMonitorService/MonitorService.cpp
34 ZMonitorService/MonitorService.h
28 ZMonitorService/main.cpp
4 ZMonitorService/monitor_service_cfg.json
15 ZMonitorUserExample/CMakeLists.txt
44 ZMonitorUserExample/MonitorAPIUser.cpp
26 ZMonitorUserExample/MonitorAPIUser.h
12 ZMonitorUserExample/main.cpp
31 include/LogMacros.h
771 include/SheetAssemblyMonitorDef.h
5643 total
source of release v1.0, * file not accounting for total lines
Questo cancellerà lapagina "README". Si prega di esserne certi.