Multi-protocol data conversion method based on relational mapping configuration
By defining a standardized global model structure and bidirectional mapping rules, and initializing a general conversion framework, the problems of insufficient data abstraction capabilities and low protocol adaptation efficiency in industrial automation are solved, and efficient data conversion and stable communication of protocols such as Modbus and IEC61850 are realized.
Patent Information
- Application Number
- CN202510981937.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-16
- Publication Date
- 2025-10-28
AI Technical Summary
Existing technologies lack a hierarchical definition of a standardized global model structure and an industrial scenario adaptation mechanism in industrial automation scenarios, resulting in insufficient data abstraction capabilities and an inability to achieve structured abstraction of location information, device grouping, and attribute metadata; the lack of bidirectional mapping rules and efficient query mechanisms leads to low protocol adaptation efficiency; and the lack of underlying data structure design and cache management mechanisms for a general conversion framework results in insufficient data processing efficiency and stability.
Define a standardized global model structure, establish bidirectional mapping rules between acquisition and conversion protocols, initialize the data structure, cache, and index table of the general conversion framework, parse data and convert it into a standardized format through parallel acquisition and conversion protocol modules, and optimize performance using cache decoupling and multi-threading mechanisms.
It achieves a unified abstraction of heterogeneous data from protocols such as Modbus and IEC61850 into a logical model, reducing the complexity of cross-system interoperability, ensuring efficient data storage and retrieval, avoiding memory overflow and query latency, and guaranteeing the reliability of connections and the real-time performance of data transmission in industrial settings.
Smart Images

Figure CN120856798A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial automation communication technology, and more specifically to a multi-protocol data conversion method based on relational mapping configuration. Background Technology
[0002] In the process of industrial automation and intelligentization, there are many types of industrial equipment with diverse protocols, and the problem of heterogeneous data formats is prominent. Traditional data conversion methods are not compatible and efficient enough. In order to achieve efficient interoperability and unified processing of multi-protocol data, a multi-protocol data conversion method based on relational mapping configuration has emerged.
[0003] Existing technologies, such as the invention patent application with publication number CN114896322A, disclose a method, apparatus, device, and medium for JSON-based configurable data conversion, relating to the field of data management technology. The method includes: receiving external data by calling a pre-built configuration protocol; reading the data information of the external data using reading rules adapted to the data structure based on the data structure of the external data; determining standardized configuration information, wherein the standardized configuration information includes data name and data type; and determining the mapping relationship between the standardized configuration information and the data information based on a conversion mapping configuration to complete the conversion of the external data. This solves the problems of high development costs and maintenance difficulties associated with developing different code for accessing diverse external data. It only requires adjusting the configuration to quickly adjust the external data access, making the configuration simple and flexible, and reducing development and maintenance costs.
[0004] The above solutions have at least the following technical problems: 1. The above solutions lack a hierarchical definition of a standardized global model structure and an industrial scenario adaptation mechanism, resulting in insufficient data abstraction capabilities. Furthermore, the above solutions only mention "data name and data type" without defining the hierarchical logic, point association rules, and complex metadata of industrial equipment data. This makes it impossible for the above solutions to achieve structured abstraction of location information, equipment grouping, and attribute metadata when facing equipment data of protocols such as Modbus and IEC61850 in industrial automation scenarios. This leads to confusion in the mapping between the data model and physical equipment points, increasing the complexity of cross-system data interoperability.
[0005] 2. The above solutions lack bidirectional mapping rules and efficient query mechanisms between the acquisition protocol and the conversion protocol, which leads to low protocol adaptation efficiency. Furthermore, the above solutions only mention "determining the mapping relationship based on the conversion mapping configuration" without defining specific mapping algorithms, index structures, and consistency verification mechanisms. This makes it impossible to quickly establish the association between protocol points and standardized models when processing multi-protocol data. In particular, mapping query bottlenecks are likely to occur in high-frequency access scenarios, and the accuracy of the mapping relationship cannot be verified, which in turn leads to data conversion errors.
[0006] 3. The above solutions lack the underlying data structure design and cache management mechanism of a general conversion framework, which will lead to insufficient data processing efficiency and stability. The specific field definitions, memory allocation strategies and caching mechanisms of the data structure are not mentioned. It only vaguely mentions "determining standardized configuration information". When processing concurrent data, the above solutions will cause parsing chaos due to inconsistent data formats. In addition, the lack of buffer level control and index optimization will easily lead to problems such as memory overflow and high query latency. Especially in industrial multi-protocol high-concurrency scenarios, the real-time performance and integrity of data cannot be guaranteed. Summary of the Invention
[0007] The purpose of this invention is to provide a multi-protocol data conversion method based on relational mapping configuration, which solves the problems existing in the background technology.
[0008] To solve the above technical problems, the present invention adopts the following technical solution: The present invention provides a multi-protocol data conversion method based on relational mapping configuration, including: S1: defining a standardized global model structure and establishing bidirectional mapping rules between the acquisition protocol, the conversion protocol and the global model.
[0009] S2: Based on the defined global model and mapping rules, initialize the data structure, cache area and index table of the general conversion framework, and dynamically start the acquisition and conversion protocol module.
[0010] S3: The acquisition and conversion protocol module initiated by step S2 acquires multi-protocol data in parallel, parses and encapsulates it into a standardized format, and then forwards it to the general framework. The general framework classifies the data, verifies its validity, compares differences, and then updates the global model cache.
[0011] S4: Based on the mapping rules of step S1, the global model data processed in step S3 is converted into the target protocol format, encapsulated by the conversion module and published according to the strategy. In the process, performance is optimized through caching decoupling and multi-threading mechanisms.
[0012] The beneficial effects of the present invention are as follows: 1. The multi-protocol data conversion method based on relational mapping configuration provided by the embodiments of the present invention, in the process of standardizing model definition, by constructing a five-layer structured system in XML / JSON format, the three-level encoding rules, naming specifications and metadata, such as timestamps and quality stamps, are clearly defined. This is conducive to unifying the abstraction of heterogeneous data of protocols such as Modbus and IEC61850 into a logical model, avoiding the confusion of mapping between industrial equipment data and physical locations, and reducing the complexity of cross-system interoperability.
[0013] 2. In the process of establishing bidirectional mapping rules, this embodiment of the invention constructs a three-level index table of protocol-channel-location and a hash index to achieve O(1) time complexity query. Through integrity verification and high-frequency mapping preloading, it is beneficial to quickly establish the association between protocol locations and models, ensure that the mapping query delay is less than or equal to the set delay time, and avoid data conversion errors caused by incorrect conversion formulas.
[0014] 3. In the general framework initialization process, the present invention defines a data structure of fixed length of 192-196 bytes, a circular buffer of 2048 units and an automatically expanding hash index table, which is conducive to unifying the data formats of different protocols, realizing efficient data storage and O(1) query, and avoiding memory overflow and query delay in industrial high-concurrency scenarios.
[0015] 4. In the dynamic startup process of the protocol module, the present invention dynamically loads the driver libraries of protocols such as Modbus / TCP and IEC104 by parsing the configuration file, and creates an independent acquisition / publishing thread for each protocol. With the help of exponential backoff retry and heartbeat packet mechanism, it is conducive to the parallel acquisition and stable communication of multi-protocol data, and ensures the connection reliability and data transmission without loss when the network fluctuates in the industrial field.
[0016] 5. In the performance optimization process, the embodiments of the present invention decouple the acquisition and conversion modules through a ring buffer, divide priorities based on data types and dynamically adjust the number of threads, which helps to reduce the data processing latency to less than 40% of that in single-threaded mode, ensure that the response to changes in switch states in industrial control is less than or equal to the preset response time, and improve the overall throughput and real-time performance of the system. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the implementation steps of the present invention. Detailed Implementation
[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0020] Please see Figure 1 As shown, the present invention provides a multi-protocol data conversion method based on relational mapping configuration. The method includes: S1: defining a standardized global model structure and establishing bidirectional mapping rules between the acquisition protocol, the conversion protocol and the global model.
[0021] In a specific embodiment, the definition of the standardized global model structure is carried out as follows: First, a hierarchical model framework is constructed using XML or JSON format, and the industrial equipment data is abstracted into a five-layer structured system of location, grouping, equipment, attribute, and value. Among them, the location field follows the three-level coding rule of station-voltage level-interval, the grouping is divided according to function, the equipment name must conform to the specified naming specification, the attribute definition includes name, type and metadata, and the attribute type is limited to basic data type.
[0022] Secondly, establish mapping rules between model entities and physical devices, associate logical models with physical locations through unique identifiers, and verify the integrity of fields, consistency of types, and hierarchical logic of the model structure through standardized verification tools, thereby ensuring that the model is parsed into a unified data structure by the general conversion framework.
[0023] It should be noted that the device name must conform to the IEC61850 naming standard. For example, "MMXU1" indicates a multi-measurement unit. The basic data types include byte, int, and double. For example, the "current value" attribute is defined as a double type, occupying 8 bytes of storage space, and retaining 2 decimal places for precision. The attribute metadata must include a timestamp and a quality stamp. The timestamp is accurate to milliseconds, and the quality stamp is a 4-bit binary code. For example, 1111 indicates that the data is valid. For example, in the transformer temperature monitoring scenario, the "oil temperature" attribute of the global model corresponds to the 40001 register of the Modbus protocol. The conversion formula needs to be defined: actual value = register value × 0.1. For example, when the register value is 250, the actual oil temperature is 25.0℃. At the same time, it is agreed that the acquisition period of this attribute is 500ms, and the threshold alarm range is 0-120℃.
[0024] In a specific embodiment, the establishment of the bidirectional mapping rules between the acquisition protocol, the conversion protocol and the global model is as follows: The mapping from the acquisition protocol to the global model is established by parsing the acquisition protocol configuration file, extracting the protocol type, channel parameters and point address, constructing a three-level index table of protocol, channel and point, and converting each point into a standard attribute of the global model through a mapping algorithm, generating a fixed-length UUID as a unique identifier, establishing a hash index, with the key being the combination of protocol points and the value being a pointer to the model attribute, thus achieving a mapping query with O(1) time complexity.
[0025] Global model to conversion protocol mapping establishment: Based on the target protocol specification, define the conversion rules from model attributes to protocol data structures. Numerical attributes are converted to target protocol specification units according to a preset scaling factor, and Boolean attributes are mapped to protocol status codes. A reverse hash table is generated, with the key being the model attribute ID and the value being a pointer to a protocol data unit.
[0026] Consistency verification and optimization of bidirectional mapping: Perform integrity verification on the established mapping relationship, check whether the protocol points and model attributes correspond one-to-one, whether the conversion formula satisfies mathematical validity, test the mapping accuracy through benchmark dataset, calculate the error rate, preload the frequently accessed mapping relationship into memory, set a cache eviction policy, and ensure that the mapping query latency is stable within 50ms.
[0027] It should be noted that the mapping algorithm, such as Modbus register address 40001, is calculated using the formula Model value = Register value × 0.1. Based on the target protocol specification, such as IEC61850 and IEC104, taking the mapping between Modbus protocol register 40001 and the global model attribute "Transformer oil temperature" as an example: During the integrity verification stage, the configuration file is compared line by line to confirm that the register address uniquely corresponds to the model attribute ID "TR-001-TEMP", and that the conversion formula "Actual temperature = Register value × 0.1" has no syntax errors such as division by zero.
[0028] During benchmark dataset testing, register values of 250, 300, and 350 were injected, and the verified model values were 25.0℃, 30.0℃, and 35.0℃, respectively. The error rate was calculated as |(model value - theoretical value) / theoretical value|×100%, all of which were less than 0.1%. During the optimization phase, this mapping relationship was marked as a high-frequency access item and preloaded into the memory cache at startup. The least recently used strategy was used to manage the cache. When the cache capacity exceeded 1024 records, the least recently accessed mapping was evicted. The actual query latency of this mapping was stable at 0.8ms, meeting the performance requirement of less than 10ms. Furthermore, multiple reverse conversions verified no data distortion. Reverse conversion refers to converting model values to Modbus register values.
[0029] It should also be noted that in data mapping scenarios, UUID is a 128-bit unique numerical identifier generated by a specific algorithm. Here, it specifically refers to a fixed-length unique identifier generated for the mapping relationship from each protocol point to the global model attribute. Its 128-bit length is represented by 16 bytes in computer storage, where 1 byte equals 8 bits. In text transmission, it is usually presented as a 36-character string, including hyphens, to ensure global uniqueness in the distributed system.
[0030] In the process of establishing bidirectional mapping rules, this invention achieves O(1) time complexity query by constructing a three-level index table of protocol-channel-location and hash index. Furthermore, through integrity verification and high-frequency mapping preloading, it is beneficial to quickly establish the association between protocol locations and models, ensuring that the mapping query delay is less than or equal to the set delay time, and avoiding data conversion errors caused by incorrect conversion formulas.
[0031] S2: Based on the defined global model and mapping rules, initialize the data structure, cache area and index table of the general conversion framework, and dynamically start the acquisition and conversion protocol module.
[0032] In a specific embodiment, the initialization process of the general conversion framework's data structure, cache, and index table is as follows: Standardized data structures are generated according to the global model definition. Each structure contains a 16-byte UUID type ID, a 64-byte fixed-length character array position name, a 32-byte group name, a 32-byte device name, and a 32-byte attribute name. Based on the attribute type, 4 to 8 bytes of attribute value storage space, 8 bytes of timestamp, and 4 bytes of quality stamp are allocated. The total size of a single structure is fixed at 192 to 196 bytes.
[0033] The buffer size is set to 2048 structure units based on the expected maximum concurrent data volume. Each unit is pre-allocated 192 bytes of memory. Lock-free data reading and writing is achieved using read pointers and write pointers. The pointer offset is implemented in a circular loop through modulo operation. Flow control is triggered when the buffer water level threshold is set to 75%. Finally, a hash index table is constructed with attribute ID as the key and structure memory address as the value. The table capacity is set to 1.5 times the expected number of points. The table is automatically expanded when the load factor exceeds 0.7. Hash collisions are handled using the chaining method to ensure that the time complexity of point lookup is maintained at O(1).
[0034] In a specific embodiment, the dynamic startup of the acquisition and conversion protocol module is carried out as follows: The acquisition protocol management module first parses the standardized configuration file to extract the slave address, port number, acquisition period, and number of timeout retransmissions for the Modbus / TCP protocol, as well as the master IP address, port number, and link establishment timeout for the IEC104 protocol. Then, it dynamically loads the corresponding driver library file according to the protocol type. After completing the driver parameter initialization, it creates independent acquisition threads for various types of protocols. The Modbus / TCP thread sends a TCP connection request to the target slave and verifies the connection validity through a three-way handshake. At the same time, the IEC104 thread sends the STARTDT link start command and parses the confirmation frame to confirm the link establishment. If the connection fails, the retry interval is adjusted according to the exponential backoff algorithm.
[0035] The conversion protocol module first synchronously parses the target protocol configuration to obtain the service port number, dataset refresh cycle, and GOOSE message lifetime of the IEC61850 protocol, as well as the client IP address, port number, ASDU transmission reason code, and link layer window size of the IEC104 protocol. Then, it dynamically loads the corresponding protocol stack library. After completing the service parameter initialization, it creates an independent publishing thread for each target protocol. The publishing thread then registers a general framework data callback function. When the global model data is updated, the protocol message encapsulation logic is triggered, and a heartbeat mechanism is started to maintain connection activity. If no valid response is received from the target system within a preset time, the current connection is immediately disconnected and a reconnection process is triggered. During the reconnection period, the unsent data is cached in a queue and resent in the order of reception after the connection is restored.
[0036] It should be noted that the specific process for adjusting the retry interval is as follows: the initial retry interval is 100ms, and the interval doubles each time thereafter, with a maximum interval limit of 1000ms, until the connection is successfully established or the preset maximum number of retries is reached.
[0037] The specific process of triggering the protocol message encapsulation logic is as follows: convert the model attribute values into IEC61850 DO object values or IEC104 ASDU data units according to the mapping rules. Among them, the IEC61850 thread sends TESTFR status test frames every 3000ms, and the IEC104 thread synchronously monitors the link response status.
[0038] In the general framework initialization process, this embodiment of the invention defines a data structure of fixed length of 192-196 bytes, a circular buffer of 2048 units, and an automatically expanding hash index table, which is conducive to unifying the data formats of different protocols, realizing efficient data storage and O(1) query, and avoiding memory overflow and query delay in industrial high-concurrency scenarios.
[0039] S3: The acquisition and conversion protocol module initiated by step S2 acquires multi-protocol data in parallel, parses and encapsulates it into a standardized format, and then forwards it to the general framework. The general framework classifies the data, verifies its validity, compares differences, and then updates the global model cache.
[0040] In a specific embodiment, the parallel acquisition of multi-protocol data is carried out as follows: the multi-protocol data includes Modbus / TCP protocol data and IEC104 protocol data. The acquisition protocol driver module starts independent threads for each protocol to perform data acquisition in parallel: the Modbus / TCP thread sends a read holding register request to the specified port of the specified address of the slave station at a set period. After receiving the response, it executes the set verification scheme, parses the 16-bit unsigned integer register value and records the system timestamp.
[0041] The IEC104 thread establishes a long TCP connection with the designated port of the master station IP, parses the message according to the APCI protocol, performs frame length verification on ASDU frames with specified type identifiers, extracts the information object address and 8-bit binary status value, and each thread encapsulates the collected data in a fixed format according to the protocol type, channel number, point address, original value and timestamp, and forwards it to the acquisition protocol management module at a set rate through a thread-safe queue with a capacity of 2048. When the queue is full, a pre-set duration blocking retry mechanism is triggered to ensure parallel acquisition and lossless transmission of data from different protocols, thereby realizing the acquisition of multi-protocol data during the acquisition and conversion protocol module started in step S2.
[0042] In a specific embodiment, the parsed and encapsulated data is forwarded to a general conversion framework after being standardized. The specific process is as follows: The acquisition protocol management module first performs parsing and standardization processing on the raw data of Modbus / TCP and IEC104 protocols. For the holding register response data of the Modbus / TCP protocol, the 16-bit unsigned integer register value is extracted according to function code 03, a floating-point actual value is generated through the conversion formula, and a quality stamp and a system timestamp accurate to milliseconds are added. For the remote signaling ASDU frame of the IEC104 protocol, the 8-bit binary status value is parsed and converted into an enumerated status code according to the mapping rules. At the same time, the validity of the APCI control field and frame length is verified. Subsequently, the parsed protocol data is uniformly encapsulated into a structure containing protocol type, channel number, point ID, physical quantity value, quality stamp and timestamp to ensure that different protocol data have a consistent format definition.
[0043] After standardized encapsulation, data is transmitted to the general conversion framework via a thread-safe lock-free queue. The queue is pre-allocated with 2048 slots, each storing a 196-byte standardized data structure. The acquisition thread writes data to the queue at a rate of 5000 data entries per second, while the forwarding thread reads data in batches at a period of 10ms. The queue is equipped with a 75% water level monitoring mechanism, which triggers flow control when 1536 slots are occupied. When a write operation detects that the water level has exceeded the limit, it automatically blocks for 10ms to prevent the queue from overflowing. After receiving the data, the general conversion framework immediately locates the global model cache through a hash index.
[0044] In a specific embodiment, the general transformation framework updates the global model cache after classifying, validating, and comparing the data. The specific process is as follows: First, according to the hierarchical structure preset by the global model, the parsed and encapsulated standardized data is classified by location field and device group. The data is stored in the corresponding circular queue through a hash allocation algorithm. Second, validity verification is performed, including type matching verification, numerical range verification, and timestamp validity verification. Then, difference comparison is performed.
[0045] For numerical data, the absolute difference between the current value and the cached historical value is calculated and compared with a preset dead zone value. If the difference is exceeded, an update is triggered. For Boolean data, the binary value is directly compared, and the data is marked as valid when the state changes. For string data, the integrity of the data is verified by the CRC32 check algorithm. If the check values are different, the data is determined to be changed. Finally, an incrementing version number is generated for the valid data. The initial value is 0, and it is automatically incremented by 1 with each update. The corresponding data in the global model cache is located by hash index. The data value and version number in the cache are updated in chronological order only when the new version number is greater than the cache version number.
[0046] It should be noted that the version number is a 64-bit unsigned integer, and its value range is sufficient to cover the update needs of the entire life cycle of the industrial system. When the version number reaches the maximum value of the data type, it is cleared to zero through system restart or version number reset interface. When resetting, a version number change log is generated to ensure that the data update order is traceable.
[0047] In the dynamic startup process of the protocol module, this invention dynamically loads the driver libraries of protocols such as Modbus / TCP and IEC104 by parsing the configuration file, creates an independent acquisition / publishing thread for each protocol, and, together with the exponential backoff retry and heartbeat packet mechanism, facilitates the parallel acquisition and stable communication of multi-protocol data, ensuring the reliability of the connection and the transmission of data without loss when the network fluctuates in the industrial field.
[0048] S4: Based on the mapping rules of step S1, the global model data processed in step S3 is converted into the target protocol format, encapsulated by the conversion module and published according to the strategy. In the process, performance is optimized through caching decoupling and multi-threading mechanisms.
[0049] In a specific embodiment, the process of converting the global model data processed in step S3 into the target protocol format is as follows: According to the predefined mapping rules, the attribute values in the global model are converted and mapped according to the target protocol specification. Then, the converted data is encapsulated according to the data structure requirements of the target protocol, and protocol-specific control information is added, including but not limited to message headers, timestamps, and quality codes, so as to perform protocol consistency verification, verify whether the length of the encapsulated message conforms to the protocol specification, whether the field values are within the valid range, and send the verified message to the corresponding system according to the communication mechanism of the target protocol.
[0050] It should be noted that the attribute values in the global model are converted and mapped according to the target protocol specification. For example, the floating-point "bus voltage" value is multiplied by a scaling factor of 10 to convert it to an integer. The unit of the "bus voltage" value is kV, and after conversion to an integer, the unit is 0.1kV.
[0051] Map the Boolean "circuit breaker status" to the status code corresponding to the target protocol, such as 0 indicating open and 1 indicating closed. Encapsulate the converted data according to the data structure requirements of the target protocol, for example, fill the model attribute values into the DataObject and DataAttribute structures of the IEC61850 protocol, or organize them into the ApplicationServiceDataUnit format of the IEC104 protocol.
[0052] In a specific embodiment, the performance optimization through caching decoupling and multi-threading mechanism is carried out as follows: A circular buffer is used to achieve asynchronous decoupling between the acquisition module and the conversion module. The buffer is pre-allocated with 2048 data slots. The acquisition thread writes data in a lock-free manner in FIFO order, and the conversion thread reads data in batches according to a preset period. Flow control is triggered through a water level marking mechanism.
[0053] Based on data type-based processing priorities, switch data is allocated to an independent high-priority thread group, where the number of threads is the same as the number of CPU cores. An immediate processing strategy is then adopted to ensure that the response time for state changes is less than or equal to the preset response time. Analog data is processed through a low-priority thread pool, where the number of threads is three times the number of CPU cores. Compressed sampling is implemented, and the load is balanced through a task queue. Finally, through performance monitoring and dynamic adjustment mechanisms, when the backlog in the task queue exceeds a preset threshold, a dynamic expansion mechanism for the thread pool is triggered, increasing the number of threads by 1 each time. When the CPU utilization is continuously below 50% within a set time, the number of threads is reduced by 1 each time. This ensures that the overall data processing latency remains stable within 40% of that in single-threaded mode, thereby optimizing the performance of the multi-threaded mechanism.
[0054] It should be noted that processing priorities are divided based on data type. Switching data is allocated to a separate high-priority thread group, where the number of threads is the same as the number of CPU cores. An immediate processing strategy is then employed to ensure that the state change response time is less than or equal to a preset response time. Analog data is processed through a low-priority thread pool, where the number of threads is three times the number of CPU cores. Compressed sampling is implemented, and the load is balanced through a task queue. Here, compressed sampling specifically refers to intelligent sampling based on valid information, rather than indiscriminate discarding.
[0055] In the performance optimization process, this invention decouples the acquisition and conversion modules through a ring buffer, prioritizes data types, and dynamically adjusts the number of threads. This helps reduce data processing latency to less than 40% of that in single-threaded mode, ensuring that the response time for changes in switch states in industrial control is less than or equal to the preset response time, thereby improving the overall throughput and real-time performance of the system.
[0056] This invention provides a multi-protocol data conversion method based on relational mapping configuration. In the process of standardizing model definition, by constructing a five-layer structured system in XML / JSON format, it clarifies three-level encoding rules, naming conventions, and metadata, such as timestamps and quality stamps. This is beneficial for unifying and abstracting heterogeneous data from protocols such as Modbus and IEC61850 into a logical model, avoiding confusion in the mapping between industrial equipment data and physical locations, and reducing the complexity of cross-system interoperability.
[0057] The above description is merely an example and illustration of the concept of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described or use similar methods to replace them, as long as they do not deviate from the concept of the invention or exceed the scope defined in this specification, they should all fall within the protection scope of the present invention.
Claims
1. A multi-protocol data conversion method based on relational mapping configuration, characterized in that, include: S1: Define a standardized global model structure and establish bidirectional mapping rules between the acquisition protocol, conversion protocol and global model; S2: Based on the defined global model and mapping rules, initialize the data structure, cache and index table of the general conversion framework, and dynamically start the acquisition and conversion protocol module; S3: The acquisition and conversion protocol module initiated by step S2 acquires multi-protocol data in parallel, parses and encapsulates it into a standardized format, and then forwards it to the general framework. The general framework classifies the data, verifies its validity, compares differences, and then updates the global model cache. S4: Based on the mapping rules of step S1, the global model data processed in step S3 is converted into the target protocol format, encapsulated by the conversion module and published according to the strategy. In the process, performance is optimized through caching decoupling and multi-threading mechanisms.
2. The multi-protocol data conversion method based on relational mapping configuration according to claim 1, characterized in that, The process of defining a standardized global model structure is as follows: First, a hierarchical model framework is constructed using XML or JSON format, abstracting industrial equipment data into a five-layer structured system of location, grouping, equipment, attributes, and values. Among them, the location field follows a three-level coding rule of station-voltage level-interval, grouping is divided according to function, equipment name must conform to the specified naming convention, attribute definition includes name, type, and metadata, and attribute type is limited to basic data type; Secondly, establish mapping rules between model entities and physical devices, associate logical models with physical locations through unique identifiers, and verify the integrity of fields, consistency of types, and hierarchical logic of the model structure through standardized verification tools, thereby ensuring that the model is parsed into a unified data structure by the general conversion framework.
3. The multi-protocol data conversion method based on relational mapping configuration according to claim 2, characterized in that, The specific process for establishing the bidirectional mapping rules between the acquisition protocol, the conversion protocol, and the global model is as follows: Mapping from acquisition protocol to global model: Parse acquisition protocol configuration file, extract protocol type, channel parameters and point address, construct a three-level index table of protocol, channel and point, convert each point into a global model standard attribute through mapping algorithm, generate a fixed-length UUID as a unique identifier, establish hash index, with the key being the protocol point combination and the value being the model attribute pointer, to achieve mapping query with O(1) time complexity; Global model to conversion protocol mapping establishment: Based on the target protocol specification, define the conversion rules from model attributes to protocol data structures. Numerical attributes are converted to target protocol specification units according to a preset scaling factor, and Boolean attributes are mapped to protocol status codes. A reverse hash table is generated, with the key being the model attribute ID and the value being a pointer to a protocol data unit. Consistency verification and optimization of bidirectional mapping: Perform integrity verification on the established mapping relationship, check whether the protocol points and model attributes correspond one-to-one, whether the conversion formula satisfies mathematical validity, test the mapping accuracy through benchmark dataset, calculate the error rate, preload the frequently accessed mapping relationship into memory, set a cache eviction policy, and ensure that the mapping query latency is stable within the preset time.
4. The multi-protocol data conversion method based on relational mapping configuration according to claim 3, characterized in that, The specific process for initializing the data structure, cache, and index table of the general transformation framework is as follows: Standardized data structures are generated according to the global model definition. Each structure contains a 16-byte UUID type ID, a 64-byte fixed-length character array location name, a 32-byte group name, a 32-byte device name, and a 32-byte attribute name. 4 to 8 bytes of attribute value storage space, 8 bytes of timestamp, and 4 bytes of quality stamp are allocated according to the attribute type. The total size of a single structure is fixed at 192 to 196 bytes. The buffer size is set to 2048 structure units based on the expected maximum concurrent data volume. Each unit is pre-allocated 192 bytes of memory. Lock-free data reading and writing is achieved using read pointers and write pointers. The pointer offset is implemented in a circular loop through modulo operation. Flow control is triggered when the buffer water level threshold is set to 75%. Finally, a hash index table is constructed with attribute ID as the key and structure memory address as the value. The table capacity is set to 1.5 times the expected number of points. The table is automatically expanded when the load factor exceeds 0.
7. Hash collisions are handled using the chaining method to ensure that the time complexity of point lookup is maintained at O(1).
5. The multi-protocol data conversion method based on relational mapping configuration according to claim 4, characterized in that, The specific process for dynamically starting the acquisition and conversion protocol module is as follows: The acquisition protocol management module first parses the standardized configuration file, extracting the slave address, port number, acquisition cycle, and timeout retransmission count for the Modbus / TCP protocol, and the master IP address, port number, and link establishment timeout for the IEC104 protocol. Then, it dynamically loads the corresponding driver library file according to the protocol type. After completing the driver parameter initialization, it creates independent acquisition threads for various types of protocols. The Modbus / TCP thread sends a TCP connection request to the target slave and verifies the connection validity through a three-way handshake. At the same time, the IEC104 thread sends the STARTDT link start command, parses the confirmation frame to confirm the link establishment, and adjusts the retry interval according to the exponential backoff algorithm if the connection fails. The conversion protocol module first synchronously parses the target protocol configuration to obtain the service port number, dataset refresh cycle, and GOOSE message lifetime of the IEC61850 protocol, as well as the client IP address, port number, ASDU transmission reason code, and link layer window size of the IEC104 protocol. Then, it dynamically loads the corresponding protocol stack library. After completing the service parameter initialization, it creates an independent publishing thread for each target protocol. The publishing thread then registers a general framework data callback function. When the global model data is updated, the protocol message encapsulation logic is triggered, and a heartbeat mechanism is started to maintain connection activity. If no valid response is received from the target system within a preset time, the current connection is immediately disconnected and a reconnection process is triggered. During the reconnection period, the unsent data is cached in a queue and resent in the order of reception after the connection is restored.
6. The multi-protocol data conversion method based on relational mapping configuration according to claim 5, characterized in that, The parallel acquisition of multi-protocol data follows the specific process as follows: The multi-protocol data includes Modbus / TCP protocol data and IEC104 protocol data. The acquisition protocol driver module starts independent threads for each protocol to perform data acquisition in parallel: the Modbus / TCP thread sends a read holding register request to the specified port of the specified address of the slave station at a set period, executes the set verification scheme after receiving the response, and parses the 16-bit unsigned integer register value and records the system timestamp. The IEC104 thread establishes a long TCP connection with the designated port of the master station IP, parses the message according to the APCI protocol, performs frame length verification on ASDU frames with specified type identifiers, extracts the information object address and 8-bit binary status value, and each thread encapsulates the collected data in a fixed format according to the protocol type, channel number, point address, original value and timestamp, and forwards it to the acquisition protocol management module at a set rate through a thread-safe queue with a capacity of 2048. When the queue is full, a pre-set duration blocking retry mechanism is triggered to ensure parallel acquisition and lossless transmission of data from different protocols, thereby realizing the acquisition of multi-protocol data during the acquisition and conversion protocol module started in step S2.
7. The multi-protocol data conversion method based on relational mapping configuration according to claim 6, characterized in that, The parsed and encapsulated data is then forwarded to a general conversion framework. The specific process is as follows: The acquisition protocol management module first performs parsing and standardization processing on the raw data of Modbus / TCP and IEC104 protocols. For the holding register response data of the Modbus / TCP protocol, it extracts the 16-bit unsigned integer register value according to function code 03, generates the floating-point actual value through the conversion formula, and adds a quality stamp and a system timestamp accurate to milliseconds. For the remote signaling ASDU frame of the IEC104 protocol, it parses the 8-bit binary status value, converts it into an enumerated status code according to the mapping rules, and verifies the validity of the APCI control field and frame length. Then, it uniformly encapsulates the parsed protocol data into a structure containing protocol type, channel number, point ID, physical quantity value, quality stamp and timestamp to ensure that different protocol data have a consistent format definition. After standardized encapsulation, data is transmitted to the general conversion framework via a thread-safe lock-free queue. The queue is pre-allocated with 2048 slots, each storing a 196-byte standardized data structure. The acquisition thread writes data to the queue at a rate of 5000 data entries per second, while the forwarding thread reads data in batches at a period of 10ms. The queue is equipped with a 75% water level monitoring mechanism, which triggers flow control when 1536 slots are occupied. When a write operation detects that the water level has exceeded the limit, it automatically blocks for 10ms to prevent the queue from overflowing. After receiving the data, the general conversion framework immediately locates the global model cache through a hash index.
8. A multi-protocol data conversion method based on relational mapping configuration according to claim 7, characterized in that, The general transformation framework classifies, validates, and compares the differences in the data before updating the global model cache. The specific process is as follows: First, based on the hierarchical structure preset by the global model, the parsed and encapsulated standardized data is classified by location field and device group. The data is then stored in the corresponding circular queue using a hash allocation algorithm. Next, validity checks are performed, including type matching checks, numerical range checks, and timestamp validity checks. Finally, a difference comparison is performed. For numerical data, the absolute difference between the current value and the cached historical value is calculated and compared with a preset dead zone value. If the difference is exceeded, an update is triggered. For Boolean data, the binary value is directly compared, and the data is marked as valid when the state changes. For string data, the integrity of the data is verified by the CRC32 check algorithm. If the check values are different, the data is determined to be changed. Finally, an incrementing version number is generated for the valid data. The initial value is 0, and it is automatically incremented by 1 with each update. The corresponding data in the global model cache is located by hash index. The data value and version number in the cache are updated in chronological order only when the new version number is greater than the cache version number.
9. A multi-protocol data conversion method based on relational mapping configuration according to claim 8, characterized in that, The specific process of converting the global model data processed in step S3 into the target protocol format is as follows: According to the predefined mapping rules, the attribute values in the global model are converted and mapped according to the target protocol specification. Then, the converted data is encapsulated according to the data structure requirements of the target protocol, and protocol-specific control information is added, including but not limited to message headers, timestamps and quality codes, so as to perform protocol consistency verification, verify whether the length of the encapsulated message conforms to the protocol specification, whether the field values are within the valid range, and send the verified message to the corresponding system according to the communication mechanism of the target protocol.
10. A multi-protocol data conversion method based on relational mapping configuration according to claim 9, characterized in that, The performance optimization through caching decoupling and multi-threading mechanisms is as follows: A circular buffer is used to achieve asynchronous decoupling between the acquisition module and the conversion module. The buffer is pre-allocated with 2048 data slots. The acquisition thread writes data in a lock-free manner in FIFO order, and the conversion thread reads data in batches according to a preset period. Flow control is triggered by a water level marking mechanism. Based on data type-based processing priorities, switch data is allocated to an independent high-priority thread group, where the number of threads is the same as the number of CPU cores. An immediate processing strategy is then adopted to ensure that the response time for state changes is less than or equal to the preset response time. Analog data is processed through a low-priority thread pool, where the number of threads is three times the number of CPU cores. Compressed sampling is implemented, and the load is balanced through a task queue. Finally, through performance monitoring and dynamic adjustment mechanisms, when the backlog in the task queue exceeds a preset threshold, a dynamic expansion mechanism for the thread pool is triggered, increasing the number of threads by 1 each time. When the CPU utilization is continuously below 50% within a set time, the number of threads is reduced by 1 each time. This ensures that the overall data processing latency remains stable within 40% of that in single-threaded mode, thereby optimizing the performance of the multi-threaded mechanism.
Citation Information
Patent Citations
Configuration data conversion method, device and equipment based on JSON (JavaScript Object Notation) and medium
CN114896322A
Cited By
Multi-data protocol conversion method and device and electronic speed regulator
CN121078142A
Plug-in-based equipment interface protocol interaction method
CN121418491A
Interface adaptation method and system for reconstruction and integration of complex information system module
CN121462669A
Dynamic decoding rule base-based telemetry data stream analysis method and system
CN121547524A
Method for testing Internet of Vehicles protocol
CN121619267A