A multi-protocol data acquisition and dynamic port forwarding system and method
The multi-protocol data acquisition and dynamic port forwarding system solves the problems of wasted port resources, difficulty in data differentiation, and single protocol support in fiber Bragg grating sensing systems. It achieves efficient utilization of port resources, accurate data differentiation, and multi-protocol concurrency, improving the system's flexibility and compatibility to meet the needs of different platforms.
Patent Information
- Application Number
- CN202611269881.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-20
AI Technical Summary
In existing technologies, fiber Bragg grating sensing systems suffer from problems such as wasted port resources, difficulty in data differentiation, poor flexibility, and limited protocol support in large-scale structural health monitoring. This leads to wasted network and system resources, data confusion, and an inability to meet the compatibility requirements of different platforms.
A multi-protocol data acquisition and dynamic port forwarding system is adopted. Through a multi-channel TCP data receiving module, a sensor-physical quantity mapping module, a dynamic data packetization module, and a multi-protocol forwarding module, it achieves efficient utilization of port resources, accurate data differentiation, and concurrent multi-protocol output. The system includes a multi-protocol forwarding module, a dynamic data packetization module, and a graphical parameter configuration module. It supports UDP, Modbus TCP, and Modbus RTU protocols and features automatic reconnection after disconnection.
It achieves efficient utilization of port resources, accurate data differentiation, and multi-protocol concurrency, improving the system's flexibility and compatibility, adapting to the needs of different platforms, and ensuring the continuity and reliability of data transmission.
Smart Images

Figure CN123145339A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data transmission technology, specifically to a multi-protocol data acquisition and dynamic port forwarding system and method. Background Technology
[0002] Fiber Bragg grating (FBG) sensing technology is widely used in the health monitoring of large structures such as bridges, dams, and wind power plants. However, a monitoring system typically requires multiple FBG demodulators, each of which may have multiple data acquisition cards, and each data acquisition card corresponds to a set of sensors.
[0003] In practical engineering, to save costs, users often purchase demodulator equipment with fewer sensor groups than the number of sensor groups. For example, a project may require monitoring 10 different sensor configurations (such as displacement, strain, temperature, etc.), but only 2 demodulators are purchased (each supporting 2 acquisition cards, with a maximum of 4 data groups acquired simultaneously). Therefore, during experiments or monitoring, it is necessary to switch between data groups and ensure that the data from different groups can be distinguished and correctly forwarded to the customer's data platform and third-party display software.
[0004] In existing technologies, data acquisition and forwarding software typically employs a fixed port mapping method, meaning that one data type or one acquisition channel corresponds to a fixed network port. For example, demodulator A's channel 1 data is sent through TCP port 8000, and demodulator A's channel 2 data is sent through TCP port 8001. Its system architecture is as follows: Sensor Group 1 → Data Acquisition Card 1 → Forwarding Software → TCP:8000 → Client Platform Sensor Group 2 → Data Acquisition Card 2 → Forwarding Software → TCP:8001 → Client Platform However, the aforementioned existing technology has the following problems: (1) Port resource waste: If the device only supports 4 groups of simultaneous acquisition, but the project has 10 groups of sensors, then 10 ports need to be pre-configured. Most of the time the ports are idle, resulting in a waste of network and system resources.
[0005] (2) Difficulty in distinguishing data: When switching sensor groups, the receiver cannot distinguish which sensor group the current data belongs to by the port number alone, which can easily cause data confusion.
[0006] (3) Poor flexibility: The IP address, port number, Modbus slave address and other parameters of the sensor group are fixed in the code or configuration file and cannot be dynamically adjusted. If the parameters need to be modified, it is usually necessary to stop the software, modify the configuration and restart, which affects the continuity of monitoring.
[0007] (4) Single protocol support: The forwarding software only supports a single protocol, which cannot simultaneously meet the different needs of the customer platform (such as UDP protocol) and the local display software (such as Modbus TCP protocol), thus limiting the system's compatibility and application scope.
[0008] Therefore, we propose a system and method that enables efficient utilization of port resources, accurate data differentiation, flexible parameter configuration, and concurrent output of multiple protocols in scenarios involving switching and acquiring data from multiple sets of sensors. Summary of the Invention
[0009] The purpose of this invention is to provide a multi-protocol data acquisition and dynamic port forwarding system and method, which solves the problems of low utilization efficiency of traditional port resources, low accuracy of data differentiation, poor flexibility of parameter configuration, and single protocol support.
[0010] This invention is achieved through the following technical solution: A multi-protocol data acquisition and dynamic port forwarding system, comprising: The multi-channel TCP data receiving module is used to connect multiple demodulators simultaneously. Each demodulator has at least one data channel, and each data channel corresponds to a unique device identifier. The sensor-physical quantity mapping module is used to parse the received private protocol data packets and extract the sensor number and physical quantity from them, storing them in a key-value pair mapping structure; The dynamic data packaging module is used to write the physical quantities in the key-value pair mapping structure into a predetermined offset range of the global data buffer according to the currently active device identifier. Different device identifiers correspond to different offset ranges. The multi-protocol forwarding module includes a UDP forwarding unit and a Modbus protocol forwarding unit. The UDP forwarding unit is used to periodically read all or part of the data in the global data buffer and send it to an external platform via the UDP protocol. The Modbus protocol forwarding unit is used to respond to external Modbus read requests, read data from the corresponding offset address in the global data buffer, encapsulate it into a Modbus response frame, and return it.
[0011] Furthermore, the multi-protocol forwarding module also includes a serial port forwarding unit, used to respond to requests from external master stations via the Modbus RTU protocol through the serial port.
[0012] Furthermore, the global data buffer is a fixed-length byte array, and the physical quantities corresponding to different device identifiers are written into different fixed offset areas of the byte array. The UDP forwarding unit sends the entire contents of the byte array each time.
[0013] Furthermore, the proprietary protocol data packets parsed by the sensor-physical quantity mapping module use 0x5C5C5C5C as the frame header, and the extracted physical quantities include strain values and / or temperature values. The key-value pair mapping structure is QMap.<quint16,float> .
[0014] Furthermore, the system also includes an automatic reconnection module, which polls the status of all TCP and Modbus connections using a timer and automatically triggers reconnection when a connection interruption is detected.
[0015] Furthermore, the system also includes a graphical parameter configuration module, which is used to dynamically modify the demodulator's IP address, port number, Modbus port number, and serial port parameters through a user interface, and save the modified parameters to a configuration file. The system can dynamically rebuild the connection after the parameters are modified without restarting.
[0016] A method for multi-protocol data acquisition and dynamic port forwarding includes the following steps: S1. Establish TCP connections with multiple data channels of multiple demodulators, each data channel having a unique device identifier; S2. Receive and parse private protocol data packets, extract sensor numbers and physical quantities, and store them in a key-value pair mapping structure; S3. Based on the currently active device identifier, write the physical quantities in the key-value pair mapping structure into the predetermined offset range of the global data buffer. Different device identifiers correspond to different offset ranges. S4. Periodically read and send all or part of the data in the global data buffer to an external platform via the UDP protocol; S5. Respond to external Modbus read requests, read data from the corresponding offset address in the global data buffer, encapsulate it into a Modbus response frame, and return it.
[0017] Furthermore, in S3, the global data buffer is a fixed-length byte array. The physical quantity corresponding to each device identifier is written into a different fixed offset area of the byte array, and the offset address of the physical quantity of different sensor groups in the byte array is fixed in advance and does not change with the switching of sensor groups.
[0018] Furthermore, the process of receiving and parsing the private protocol data packet includes: identifying the frame header 0x5C5C5C5C, extracting the sensor number and the corresponding floating-point physical quantity, and then converting the physical quantity into a standardized value with engineering units and storing it.
[0019] Furthermore, the method also includes: The demodulator's IP address, port number, Modbus port number, and serial port parameters can be dynamically configured through the user interface, saved to the configuration file, and hot-loaded. It also polls the status of all TCP and Modbus connections using a timer, and automatically triggers reconnection when a connection interruption is detected.
[0020] The technical solution of the present invention has at least the following advantages and beneficial effects: This invention discloses a multi-protocol data acquisition and dynamic port forwarding system and method. By writing the physical quantities corresponding to different device identifiers into different offset intervals of the same global data buffer, only one UDP port is needed to carry the data output of all sensor groups. There is no need to pre-allocate independent ports for each sensor group, which greatly reduces network port occupation and system resource overhead.
[0021] In addition, since the offset address of the data of each sensor group in the global buffer is fixed, the receiving end only needs to read the corresponding byte segment directly according to the predetermined offset position to uniquely determine which sensor group the current data belongs to, thus completely eliminating the risk of data confusion caused by port number changes when switching sensor groups.
[0022] Furthermore, the same data, after being collected and parsed, is simultaneously accessed by both the UDP forwarding unit and the Modbus protocol forwarding unit, and output to the customer platform and third-party display software in the form of UDP packets and Modbus response frames, respectively. This eliminates the need to maintain multiple independent data paths for different protocols, significantly improving the system's compatibility and deployment efficiency in different application environments.
[0023] The data corresponding to different device identifiers are physically isolated within the global data buffer according to a predetermined offset range, with no overlap between them, avoiding data overwriting or misalignment, while ensuring that the data sent by UDP at regular intervals is completely consistent with the data obtained by Modbus reading on demand.
[0024] It is important to note that the global data buffer uses a fixed-length byte array. The UDP forwarding unit sends the entire array content each time, and the receiving end only needs to parse the fixed offset position to distinguish sensor groups. This avoids the additional computational overhead of dynamic packet assembly and disassembly, and simplifies the logic design of the receiving end. By identifying specific frame header flags and using key-value pair storage, physical quantities such as strain and temperature can be extracted quickly and accurately from the proprietary protocol, improving the universality and scalability of protocol parsing and facilitating the addition of new physical quantity types in the future. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of a multi-protocol data acquisition and dynamic port forwarding system according to the present invention; Figure 2 This is a schematic diagram of a multi-protocol data acquisition and dynamic port forwarding method according to the present invention; Figure 3 This is a schematic diagram of an electronic device structure according to the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0027] Example 1 This embodiment is based on the practical application scenario of fiber Bragg grating sensing technology in the health monitoring of large structures such as bridges, dams, and wind power plants. It addresses problems in existing technologies such as wasted port resources, difficulty in data differentiation, poor flexibility, and limited protocol support, providing solutions such as… Figure 1 The multi-protocol data acquisition and dynamic port forwarding system shown includes: The multi-channel TCP data receiving module is used to connect multiple demodulators simultaneously. Each demodulator has at least one data channel, and each data channel corresponds to a unique device identifier (device_id). For example, 0x1101 represents "Group 1 - Server 1 - Channel 101". Each channel corresponds to an independent MyTcpSocket object, which is uniquely identified by device_id.
[0028] By assigning an independent MyTcpSocket object to each data channel and assigning it a unique device_id, the connection limitations of existing technologies are broken, enabling concurrent connections between multiple demodulators and multiple channels, laying the foundation for subsequent switching and acquisition of multiple sets of data. This eliminates the need for frequent switching of demodulator connection states, improving the continuity of data acquisition. Furthermore, the device_id uniquely identifies each channel, providing a core identifier for subsequent data differentiation and isolated storage, avoiding confusion between data from different channels, and providing a basis for data differentiation for dynamic port mapping, indirectly reducing the waste of port resources.
[0029] The sensor-physical quantity mapping module is used to parse the received private protocol data packets and extract the sensor number and physical quantity from them, storing them in a key-value pair mapping structure; In addition, the proprietary protocol data packets parsed by the sensor-physical quantity mapping module have a frame header of 0x5C5C5C5C, and the extracted physical quantities include strain values and / or temperature values. The key-value pair mapping structure is QMap.<quint16, float> ; This module is used to extract sensor numbers and their corresponding floating-point physical quantities, using QMap.<quint16, float> Key-value pair storage enables rapid indexing of physical quantities corresponding to sensors and adapts to different types of physical quantity data (such as strain and temperature), solving the problems of difficult parsing of proprietary protocols and chaotic data storage. It realizes the conversion from proprietary protocols to standardized physical quantities, parsing the raw waveform data output by the demodulator into directly usable physical quantities such as strain and temperature, eliminating the need for additional parsing at the receiver and reducing the processing burden on the receiver. The QMap key-value pair storage method achieves a one-to-one correspondence between sensor numbers and physical quantities, facilitating rapid subsequent data retrieval and modification, while improving the universality and scalability of data parsing, making it easier to add new physical quantity types or adapt to new proprietary protocol formats in the future.
[0030] The dynamic data packing module is used to write the physical quantities in the key-value pair mapping structure into a predetermined offset range of the global data buffer according to the currently active device identifier. Different device identifiers correspond to different offset ranges, thereby achieving physical isolation of data in memory. The global data buffer is a fixed-length byte array of 1226 bytes (myTransData.pack_data). The dynamic data packing module calls the corresponding packing function (such as pack_g1_101_data()) according to the different device_ids to fill the physical quantities in QMap into the global data buffer according to the predefined offset addresses. This module is based on the design concept of "memory offset isolation." It writes sensor group data corresponding to different device_ids into different fixed offset ranges in a global buffer, eliminating the need to allocate independent ports for each sensor group; the data is distinguished only by offset addresses. Simultaneously, combined with a global data buffer design (1226 bytes), a dedicated packing function is called to ensure the accuracy and standardization of data filling, avoiding overlapping and overwriting of different data groups. This solves the problem of wasted port resources, eliminating the need to pre-allocate independent ports for each sensor group; multiple data groups can be isolated and stored using only a single global buffer, reducing network and system resource consumption. The fixed offset ranges corresponding to different device identifiers achieve physical isolation of data in memory, preventing data overwriting or misalignment, and providing a unified data source for subsequent multi-protocol forwarding, ensuring complete consistency of data forwarded by different protocols. The design of the packing function improves the efficiency and accuracy of data packing, adapts to the physical quantity formats of different sensor groups, and enhances the system's flexibility.
[0031] The multi-protocol forwarding module includes a UDP forwarding unit and a Modbus protocol forwarding unit. The UDP forwarding unit reads all data from the global data buffer periodically (every 1 second), adds a lifetime field and CRC checksum, and then sends it to the client platform (IP and port are configurable). The Modbus protocol forwarding unit starts multiple MyModBusSlave instances, each bound to a different IP and port (e.g., 502, 503). When third-party software sends a Modbus read request, it reads data from the corresponding offset address in the global data buffer and encapsulates it into a Modbus response frame for return. The serial port forwarding unit uses the MySerialPort class to respond to external master station requests using the Modbus RTU protocol with data from the global data buffer. This module is based on the design concept of "one-time acquisition, multiple protocol outputs." Using unified data in a global data buffer as a foundation, it designs three forwarding units: UDP, Modbus TCP, and Modbus RTU. The UDP forwarding unit employs a timed transmission mode to ensure real-time data acquisition by the client platform, and adds a lifetime field and CRC checksum to improve data transmission reliability. The Modbus TCP unit uses multiple instances bound to different ports to adapt to different request requirements from third-party software. The serial port forwarding unit adapts to the Modbus RTU protocol commonly used in industrial scenarios, expanding the system's application scope. Furthermore, with configurable parameter design, the client platform's IP address and port, as well as the Modbus TCP binding port, can be flexibly configured, improving system adaptability. The system solves the problem of supporting only one protocol, simultaneously supporting UDP, Modbus TCP, and Modbus RTU protocols. This meets the diverse integration needs of customer platforms, third-party display software, and external master stations, significantly improving system compatibility and application scope. The same memory data can be accessed by three forwarding units simultaneously, eliminating the need to maintain multiple independent data paths for different protocols, simplifying the system structure and reducing maintenance costs. Timed sending, CRC checksum verification, and lifetime fields in UDP forwarding enhance the real-time performance and reliability of data transmission, preventing data loss or errors. The Modbus TCP multi-instance design and configurable parameters enhance system flexibility and adaptability to various industrial application scenarios. The serial port forwarding unit design adapts to common serial communication needs in industrial scenarios, further expanding the system's applicability.
[0032] In summary, the system in this embodiment 1, through the collaborative design of its modules, achieves port reuse, accurate data differentiation, multi-protocol concurrent support, and high flexibility. It can perfectly adapt to the actual needs of "multi-group sensor switching and acquisition, and multi-platform docking" in large-scale structural health monitoring, and improves the efficiency, reliability, and compatibility of data acquisition and forwarding.
[0033] Example 2 As a preferred embodiment, this system, based on Embodiment 1, further adds an automatic reconnection module and a graphical parameter configuration module. These two modules further optimize the system's stability and configuration flexibility in long-term industrial operation scenarios. The specific structure, design principles, and unique technical effects are as follows: The automatic reconnection module uses a timer to poll the status of all TCP and Modbus connections. When a connection interruption is detected, it automatically triggers reconnection without manual intervention. Through a periodic polling mechanism, it synchronously monitors the demodulator connection status of multiple TCP data receiving modules and the Modbus TCP / RTU connection status of multi-protocol forwarding modules. Once a disconnection flag is detected, it immediately initiates automatic reconnection according to the parameters stored in the configuration file, such as IP address, port, and slave address. This meets the core requirements of unattended operation and long-term stable operation in industrial settings. Furthermore, it completely eliminates the need for manual restarts after a connection failure, ensuring the continuity of data acquisition and forwarding. The timer polling has no additional high resource consumption and is compatible with embedded and industrial PC operating environments. The reconnection logic reuses the original system connection configuration, eliminating the need to reinitialize the entire system, resulting in high reconnection efficiency and significantly reducing the risk of data interruption.
[0034] In addition, the graphical parameter configuration module is used to dynamically modify the demodulator's IP address, port number, Modbus port number, and serial port parameters through the user interface (UI), and save the modified parameters to the configuration file (settings.ini). The system can dynamically rebuild the connection after the parameters are modified without restarting. By adopting a graphical interactive design, all configurable parameters are displayed visually, allowing users to directly edit and modify them through the interface. After a parameter is modified, a hot-reload mechanism is triggered, rebuilding only the connection channel for the corresponding parameter without affecting other normally operating modules. Simultaneously, the parameter is persistently stored in the configuration file, retaining the latest configuration even after a system restart. This achieves a triple effect of dynamic parameter configuration, hot-reload, and persistence, eliminating the need for system downtime and ensuring uninterrupted monitoring. The graphical interface lowers the operational threshold, allowing non-professionals to quickly adjust parameters. It supports automatic startup and automatic configuration loading, adapting to scenarios requiring rapid deployment and long-term operation in engineering projects, comprehensively improving system flexibility and ease of use.
[0035] Example 3 like Figure 2 The multi-protocol data acquisition and dynamic port forwarding method shown is implemented based on the system architecture of Embodiment 1 and Embodiment 2, and includes the following steps: S1. Establish TCP connections with multiple data channels of multiple demodulators, each data channel having a unique device identifier; After system startup, it prioritizes reading the configuration file (settings.ini), initializes the TCP client, and establishes multiple TCP connections with multiple fiber Bragg grating demodulators simultaneously based on pre-configured information. Each data channel is assigned a unique device_id (e.g., 0x1101) and a corresponding independent MyTcpSocket object. Addressing cost control scenarios in engineering projects involving "few demodulators, multiple sensor groups," it overcomes the single-channel, single-connection limitation, laying the foundation for subsequent group switching and acquisition through multi-channel concurrent connections. Furthermore, it supports multiple demodulators and multiple channels online simultaneously, eliminating the need to re-establish physical connections when switching sensor groups, thus improving acquisition efficiency. The unique device_id provides a core identifier for data differentiation and memory mapping.
[0036] S2. Receive and parse private protocol data packets, extract sensor numbers and physical quantities, and store them in a key-value pair mapping structure; The process of receiving and parsing the private protocol data packet includes: identifying the frame header 0x5C5C5C5C, extracting the sensor number and the corresponding floating-point physical quantity, and converting the physical quantity into a standardized value with engineering units before storing it. This step effectively customizes the parsing logic for the demodulator's proprietary protocol, completing the conversion from raw data to engineering physical quantities and achieving one-click conversion from proprietary protocol to standardized data, eliminating the need for secondary parsing at the receiving end; the key-value pair storage supports fast indexing and updating, adapting to high-frequency acquisition scenarios.
[0037] S3. Based on the currently active device identifier, write the physical quantities in the key-value pair mapping structure into the predetermined offset range of the global data buffer. Different device identifiers correspond to different offset ranges. Based on the activated device identifier selected by the user interface, the corresponding packing function (such as pack_g1_101_data()) is called to write the physical quantities into a predefined offset range of a 1226-byte fixed-length global data buffer (myTransData.pack_data). Different device identifiers correspond to different fixed offset regions, and the offset address does not change with the switching of sensor groups, achieving physical isolation between data and memory. In this case, a single UDP port can transmit data from all groups, greatly saving port resources. The fixed offset address allows the receiving end to accurately distinguish sensor groups, completely avoiding data confusion. Memory isolation prevents data overwriting and misalignment, ensuring data integrity.
[0038] S4. Periodically read and send all or part of the data in the global data buffer to an external platform via the UDP protocol; The UDP forwarding unit reads the entire contents of the global data buffer every 1 second, adds a lifetime field and CRC checksum, encapsulates it into a custom UDP frame, and sends it to the external platform. The platform IP and port can be dynamically configured. It can meet the platform's need for high-frequency, real-time reception and monitoring data, and the verification mechanism improves transmission reliability. In addition, timed transmission ensures data real-time performance. The verification field reduces the probability of packet loss and error. Single-port forwarding simplifies the deployment logic of the receiving end.
[0039] S5. Respond to external Modbus read requests, read data from the corresponding offset address in the global data buffer, encapsulate it into a Modbus response frame, and return it. It can launch multiple MyModBusSlave instances bound to different ports (502, 503, etc.) to receive Modbus TCP read requests from third-party software; or respond to external master station requests via serial port using the Modbus RTU protocol, reading data from the corresponding offset address in the buffer and encapsulating it into a standard response frame for return; it reuses the same buffer data, simultaneously meeting the needs of both UDP push and Modbus on-demand reading, without the need to maintain dual data paths; it achieves one-time acquisition and multi-protocol output, compatible with customer platforms and third-party display software; it supports TCP / RTU dual modes, adapting to all scenarios in industrial sites.
[0040] In addition, this method also includes: The demodulator's IP address, port number, Modbus port number, and serial port parameters can be dynamically configured through the user interface, saved to the configuration file, and hot-loaded. It also polls the status of all TCP and Modbus connections using a timer, and automatically triggers reconnection when a connection interruption is detected.
[0041] It can solve the core defects of parameter fixation and disconnection and downtime, adapt to unattended industrial scenarios, and ensure that parameter adjustment does not interrupt monitoring; automatic reconnection ensures stable operation 24 / 7, and the system robustness is greatly improved.
[0042] Example 4 As attached Figure 3 An electronic device shown includes: Processor, memory, communication interface; The memory is used to store the executable instructions of the processor; The processor is configured to execute the aforementioned multi-protocol data acquisition and dynamic port forwarding method by executing the executable instructions.
[0043] A readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described multi-protocol data acquisition and dynamic port forwarding method.
[0044] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A multi-protocol data acquisition and dynamic port forwarding system, characterized in that, include: The multi-channel TCP data receiving module is used to connect multiple demodulators simultaneously. Each demodulator has at least one data channel, and each data channel corresponds to a unique device identifier. The sensor-physical quantity mapping module is used to parse the received private protocol data packets and extract the sensor number and physical quantity from them, storing them in a key-value pair mapping structure; The dynamic data packaging module is used to write the physical quantities in the key-value pair mapping structure into a predetermined offset range of the global data buffer according to the currently active device identifier. Different device identifiers correspond to different offset ranges. The multi-protocol forwarding module includes a UDP forwarding unit and a Modbus protocol forwarding unit. The UDP forwarding unit is used to periodically read all or part of the data in the global data buffer and send it to an external platform via the UDP protocol. The Modbus protocol forwarding unit is used to respond to external Modbus read requests, read data from the corresponding offset address in the global data buffer, encapsulate it into a Modbus response frame, and return it.
2. The multi-protocol data acquisition and dynamic port forwarding system according to claim 1, characterized in that: The multi-protocol forwarding module also includes a serial port forwarding unit, which is used to respond to requests from external master stations via the Modbus RTU protocol through the serial port.
3. The multi-protocol data acquisition and dynamic port forwarding system according to claim 1, characterized in that: The global data buffer is a fixed-length byte array. The physical quantities corresponding to different device identifiers are written into different fixed offset areas of the byte array. The UDP forwarding unit sends the entire contents of the byte array each time.
4. The multi-protocol data acquisition and dynamic port forwarding system according to claim 1, characterized in that: The proprietary protocol data packets parsed by the sensor-physical quantity mapping module have a frame header of 0x5C5C5C5C, and the extracted physical quantities include strain values and / or temperature values. The key-value pair mapping structure is QMap.<quint16, float> .
5. The multi-protocol data acquisition and dynamic port forwarding system according to claim 1, characterized in that: The system also includes an automatic reconnection module, which polls the status of all TCP and Modbus connections using a timer and automatically triggers reconnection when a connection interruption is detected.
6. The multi-protocol data acquisition and dynamic port forwarding system according to claim 1, characterized in that: The system also includes a graphical parameter configuration module, which is used to dynamically modify the demodulator's IP address, port number, Modbus port number, and serial port parameters through a user interface, and save the modified parameters to a configuration file. The system can dynamically rebuild the connection after the parameters are modified without restarting.
7. A method for multi-protocol data acquisition and dynamic port forwarding, characterized in that, Includes the following steps: S1. Establish TCP connections with multiple data channels of multiple demodulators, each data channel having a unique device identifier; S2. Receive and parse private protocol data packets, extract sensor numbers and physical quantities, and store them in a key-value pair mapping structure; S3. Based on the currently active device identifier, write the physical quantities in the key-value pair mapping structure into the predetermined offset range of the global data buffer. Different device identifiers correspond to different offset ranges. S4. Periodically read and send all or part of the data in the global data buffer to an external platform via the UDP protocol; S5. Respond to external Modbus read requests, read data from the corresponding offset address in the global data buffer, encapsulate it into a Modbus response frame, and return it.
8. The multi-protocol data acquisition and dynamic port forwarding method according to claim 7, characterized in that: In S3, the global data buffer is a fixed-length byte array. The physical quantity corresponding to each device identifier is written into a different fixed offset area of the byte array, and the offset address of the physical quantity of different sensor groups in the byte array is fixed in advance and does not change with the switching of sensor groups.
9. The multi-protocol data acquisition and dynamic port forwarding method according to claim 7, characterized in that: The process of receiving and parsing the private protocol data packet includes: identifying the frame header 0x5C5C5C5C, extracting the sensor number and the corresponding floating-point physical quantity, and then converting the physical quantity into a standardized value with engineering units and storing it.
10. The multi-protocol data acquisition and dynamic port forwarding method according to claim 7, characterized in that: The method further includes: The demodulator's IP address, port number, Modbus port number, and serial port parameters can be dynamically configured through the user interface, saved to the configuration file, and hot-loaded. It also polls the status of all TCP and Modbus connections using a timer, and automatically triggers reconnection when a connection interruption is detected.
