Message decoding device and method based on XML (Extensible Markup Language) analyzer

Through the message decoding method based on XML parser, the problem of low efficiency and difficult maintenance of the Modbus encoding and decoding framework in complex communication scenarios and diverse data formats is solved, efficient and flexible data decoding and verification are achieved, and the system's reliability is improved. Scalability and ease of use.

CN118714210APending Publication Date: 2024-09-27XINJIANG HERUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410991782.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

The existing Modbus encoding and decoding framework is inefficient when faced with complex and changeable communication scenarios and diverse data formats, making it difficult to respond flexibly. It is also difficult to maintain and upgrade, affecting system stability and reliability.

Method used

Using the message decoding method based on XML parser, the sensor type, data format and decoding logic are parsed through the XML configuration file to generate specific decoding logic, and the data processor performs decoding, and the data verification and alarm module verifies the validity of the data to form Independent encoding and decoding framework.

Benefits of technology

It improves the decoding efficiency, reduces the difficulty of maintenance and upgrades, enhances the flexibility and scalability of the system, adapts to various industrial Internet of Things application scenarios, and improves the ease of use and maintainability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714210A
    Figure CN118714210A
Patent Text Reader

Abstract

The invention discloses a message decoding device and method based on an XML (Extensible Markup Language) parser, and relates to the technical field of digital information transmission. The method comprises the following steps: S1, a message receiver obtains a message; s2, analyzing the sensor type, the data format and the decoding logic in the XML configuration file by an XML analyzer to obtain an analyzed configuration file; s3, a decoding logic generator generates corresponding decoding logic according to the analyzed configuration file; s4, the data processor executes decoding logic on the message to obtain decoded sensor data; s5, the data verification and alarm module verifies the validity of the decoded sensor data according to the validity check and alarm mechanism in the analyzed configuration file; the device comprises a message receiver, an XML parser, a decoding logic generator, a data processor and a data verification and alarm module which are connected in sequence, decoding is carried out through the XML parser, the decoding logic generator and the like, and the decoding efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of digital information transmission, and in particular to a device and method for message decoding based on XML parser. Background Art

[0002] Modbus communication protocol is a universal communication protocol widely used in automated electronic controllers. Controllers can use this communication protocol to communicate with other controllers via the network. At present, Modbus protocol has formed a unified industrial standard. After years of development, Modbus communication protocol has been carried by RS232, RS485 and other methods, and has developed to be transmitted through the Internet by TCP protocol. The master and slave devices that use Modbus protocol for communication will agree on function codes, and different function codes correspond to different functions. The various functions included in the Modbus protocol can enable the master device to read information from the slave device or manipulate the slave device according to different data scales.

[0003] At present, the existing technology is an integrated Modbus encoding and decoding framework, which is usually embedded in the device operating system. These traditional methods have been widely used in the fields of industrial automation and remote monitoring, and can achieve Modbus data transmission and communication requirements in a fixed mode. However, this integrated encoding and decoding method also has some shortcomings: it relies on manual coding or simple library function calls, and it is difficult to cope with complex and changing communication scenarios. In the case of diverse data formats and complex data communication scenarios, inefficient encoding and decoding has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The present invention provides a device and method for message decoding based on XML parser, which solves the technical problem of low decoding efficiency.

[0005] In order to solve the above technical problems, the technical solutions adopted by the present invention are as follows:

[0006] A method for message decoding based on XML parser, comprising the following steps:

[0007] Step S1: The message receiver receives and obtains the message;

[0008] Step S2: When the XML parser obtains the XML configuration file, the sensor type, data format and decoding logic in the XML configuration file are parsed to obtain a parsed XML configuration file, where the parsed XML configuration file includes decoding logic and configuration data;

[0009] Step S3: The decoding logic generator generates corresponding specific decoding logic according to the parsed XML configuration file;

[0010] Step S4: the data processor executes decoding logic on the message to obtain decoded sensor data;

[0011] Step S5: The data verification and alarm module verifies the validity of the decoded sensor data according to the validity check and alarm mechanism in the parsed XML configuration file to obtain a verification result.

[0012] A further technical solution is: in step S1, when the message receiver obtains the message sent by the sensor or device, the message is sent to the XML parser as an original message.

[0013] A further technical solution is: in step S4, when the data processor obtains the message and the specific decoding logic, the specific decoding logic is executed to decode the message to obtain the decoded sensor data.

[0014] A further technical solution is that in step S5, when the data verification and alarm module obtains the decoded sensor data, the validity of the sensor data is verified according to the validity check and alarm mechanism in the parsed XML configuration file, and an alarm message is also generated.

[0015] A device for message decoding based on XML parser, used for the above-mentioned method for message decoding based on XML parser, comprises a message receiver, XML parser, decoding logic generator, data processor and data verification and alarm module connected in sequence to form a coding and decoding framework.

[0016] A further technical solution is that: the message receiver is used to connect to a sensor or a device, obtain a message sent by the sensor or the device, and send the message as an original message to an XML parser.

[0017] A further technical solution is that the XML parser is used to obtain an XML configuration file, parse the sensor type, data format and decoding logic in the XML configuration file, and obtain the parsed XML configuration file, which includes decoding logic and configuration data.

[0018] A further technical solution is that: the decoding logic generator is used to generate corresponding specific decoding logic according to the parsed XML configuration file.

[0019] A further technical solution is that the data processor is used to obtain a message and a specific decoding logic, execute the specific decoding logic, decode the message, and obtain decoded sensor data.

[0020] A further technical solution is that the data verification and alarm module is used to verify the validity of sensor data according to the validity check and alarm mechanism in the parsed XML configuration file, and generate verification results and alarm information.

[0021] The beneficial effects of adopting the above technical solution are:

[0022] A method for message decoding based on XML parser includes the following steps: step S1: a message receiver receives and obtains a message; step S2: when the XML parser obtains an XML configuration file, the sensor type, data format and decoding logic in the XML configuration file are parsed to obtain a parsed XML configuration file, and the parsed XML configuration file includes decoding logic and configuration data; step S3: a decoding logic generator generates corresponding specific decoding logic according to the parsed XML configuration file; step S4: a data processor executes decoding logic on the message to obtain decoded sensor data; step S5: a data verification and alarm module verifies the validity of the decoded sensor data according to the validity check and alarm mechanism in the parsed XML configuration file to obtain a verification result. It is decoded by an XML parser and a decoding logic generator, etc., which improves the decoding efficiency.

[0023] A device for message decoding based on XML parser, used for the above-mentioned method for message decoding based on XML parser, comprises a message receiver, an XML parser, a decoding logic generator, a data processor and a data verification and alarm module connected in sequence, and forms a coding and decoding framework. It performs decoding through the XML parser and the decoding logic generator, etc., thereby improving the decoding efficiency.

[0024] Please refer to the detailed description of the specific implementation method. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a principle block diagram of embodiment 1 of the present invention;

[0026] Figure 2 is a flow chart of Embodiment 2 of the present invention;

[0027] Figure 3 This is a screenshot of the XML configuration file in the health monitoring scenario;

[0028] Figure 4 It is a flowchart of the prior art decoding. DETAILED DESCRIPTION

[0029] The purpose of this application is to achieve efficient encoding and decoding of Modbus data.

[0030] The technical problem of inefficient encoding and decoding is mainly caused by the following factors:

[0031] 1. Diversity of data formats

[0032] Different types of sensors and devices use different Modbus data formats. For example, a temperature sensor may return a simple integer value, while a complex multi-parameter sensor may return a set of floating point numbers or string data. This diversity requires the system to be able to flexibly handle different data formats. The traditional method fixes the data decoding process in the system source code, resulting in the need to rewrite and burn the code every time a new sensor is added or modified, which is inefficient and prone to errors.

[0033] 2. Complexity of data communication

[0034] In actual industrial IoT applications, Modbus communication is not limited to simple requests and responses. Data interaction between devices may involve multiple operations, such as batch reading, writing registers, error handling, etc. Each operation requires specific decoding logic and processing flow. The traditional hard-coding method is difficult to adapt to the ever-changing and complex communication needs.

[0035] 3. Difficulty of maintenance and upgrade

[0036] As the scale of the system expands and the number of devices increases, maintenance and upgrades become more frequent and complex. Under traditional methods, each modification or addition of a new device requires rewriting and burning the system code, which not only increases maintenance costs, but may also cause unforeseen problems in the system during the update process, affecting system stability and reliability.

[0037] In the field of smart water management, domestically produced equipment developed based on the open source Hongmeng operating system requires more efficient encoding and decoding methods to improve equipment performance and promote the intelligent development of the environmental monitoring field.

[0038] eXtensible Markup Language, abbreviated as XML, is a standard text format for representing structured data. XML, with its flexibility, platform independence, structured data representation, standardization and wide support, and easy verification and parsing, provides a solid technical foundation for the Modbus data encoding and decoding framework based on the XML language interpreter, enabling the framework to efficiently and reliably adapt to various industrial Internet of Things application scenarios.

[0039] In order to decouple the data decoding process from the system source code, an independent Modbus data encoding and decoding framework is urgently needed. By using this framework to perform data decoding, the data decoding logic can be flexibly adjusted without modifying the system source code. This approach not only reduces the difficulty of maintenance and upgrading, but also improves the flexibility and scalability of the system.

[0040] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present application and its application or use. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0041] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present application. Therefore, the present application is not limited to the specific embodiments disclosed below.

[0042] Embodiment 1:

[0043] like Figure 1 As shown, the present invention discloses a device for message decoding based on XML parser, which includes a message receiver A, an XML parser B, a decoding logic generator C, a data processor D and a data verification and alarm module E which are connected in sequence to form a coding and decoding framework.

[0044] The message receiver A is used to connect to the sensor or device, obtain the message sent by the sensor or device, and send the message to the XML parser B as the original message.

[0045] XML parser B is used to obtain an XML configuration file, parse the sensor type, data format and decoding logic in the XML configuration file, and obtain the parsed XML configuration file, which includes decoding logic and configuration data.

[0046] The decoding logic generator C is used to generate corresponding specific decoding logic according to the parsed XML configuration file.

[0047] The data processor D is used to obtain the original message and the specific decoding logic, execute the specific decoding logic, decode the original message, and obtain the decoded sensor data.

[0048] The data verification and alarm module E is used to verify the validity of sensor data according to the validity check and alarm mechanism in the parsed XML configuration file, and generate verification results and alarm information.

[0049] 1. Modbus message receiver A

[0050] Connection relationship: connected to the sensor or device, responsible for receiving Modbus messages.

[0051] 2. XML Parser B

[0052] Connection relationship: connected to Modbus message receiver A and decoding logic generator C, responsible for reading and parsing XML configuration files.

[0053] 3. Decoding logic generator C

[0054] Connection relationship: connected to XML parser B and data processor D, responsible for generating decoding logic based on XML configuration file.

[0055] 4. Data Processor D

[0056] Connection relationship: connected to the decoding logic generator C and the data verification and alarm module E, executes the decoding logic and processes the Modbus message.

[0057] 5. Data verification and alarm module E

[0058] Connection relationship: connected to data processor D, responsible for data validity checking and generating alarm information.

[0059] Embodiment 2:

[0060] like Figure 2 As shown, the present invention discloses a method for message decoding based on an XML parser, based on the device for message decoding based on an XML parser described in Example 1, comprising the following steps:

[0061] Step S1: Receive Modbus message.

[0062] When the message receiver A receives the message sent by the sensor or device, it sends the message to the XML parser B as the original message.

[0063] Input: Modbus message.

[0064] Processing: Modbus message receiver A receives the Modbus message sent by the sensor or device.

[0065] Output: original Modbus message.

[0066] Step S2: Read and parse the XML configuration file.

[0067] When XML parser B obtains the XML configuration file, it parses the sensor type, data format and decoding logic in the XML configuration file to obtain the parsed XML configuration file, which includes the decoding logic and configuration data.

[0068] Input: XML configuration file.

[0069] Processing: XML parser B reads and parses the sensor type, data format, and decoding logic in the XML configuration file.

[0070] Output: Decoded logic and configuration data.

[0071] like Figure 3 Shown is a screenshot of a portion of the XML configuration file.

[0072] Step S3: Generate decoding logic according to the configuration file.

[0073] The decoding logic generator C generates corresponding specific decoding logic according to the parsed XML configuration file.

[0074] Input: Decode logic and configuration data.

[0075] Processing: The decoding logic generator C generates the corresponding decoding logic according to the parsed XML configuration file.

[0076] Output: Specific decoding logic.

[0077] Step S4: Execute decoding logic.

[0078] When the data processor D obtains the original message and the specific decoding logic, it executes the specific decoding logic, decodes the original message, and obtains the decoded sensor data.

[0079] Input: Raw Modbus message and decoding logic.

[0080] Processing: Data processor D executes the generated decoding logic to decode the Modbus message.

[0081] Output: Decoded sensor data.

[0082] Step S5: Data validity check and alarm processing.

[0083] When the data verification and alarm module E obtains the decoded sensor data, it verifies the validity of the sensor data according to the validity check and alarm mechanism in the parsed XML configuration file, and generates the verification result and alarm information.

[0084] Input: Decoded sensor data.

[0085] Processing: Data verification and alarm module E verifies data validity and generates alarm information based on the validity check and alarm mechanism in the configuration file.

[0086] Output: verification results and alarm information.

[0087] Embodiment 3:

[0088] The present invention discloses a method for message encoding based on an XML parser, and a device for message decoding based on an XML parser described in Example 1, including an encoding step, and the reverse process of the decoding step in Example 2 is the encoding step, and the similarities are not repeated here.

[0089] How this framework works:

[0090] The Modbus data encoding and decoding framework solves the technical problems in the traditional method through the following process:

[0091] Receiving Modbus messages: Modbus message receiver A receives Modbus messages from sensors or devices to ensure accurate data transmission.

[0092] Read and parse XML configuration files: XML parser B reads and parses the XML configuration files containing sensor data formats and decoding logic, so that the system can flexibly adapt to diverse data formats.

[0093] Generate decoding logic according to configuration file: The decoding logic generator C dynamically generates decoding logic according to the parsed XML configuration file, realizing the automation and flexibility of the decoding process.

[0094] Execute decoding logic: Data processor D executes the generated decoding logic to convert Modbus messages into decoded sensor data to ensure data accuracy and real-time performance.

[0095] Data validity check and alarm processing: The data verification and alarm module E verifies the decoded data and generates alarm information according to the validity check and alarm mechanism in the XML configuration file, thereby improving the reliability and security of the system.

[0096] like Figure 4 The figure shows the message parsing process of the traditional encoding and decoding framework before improvement.

[0097] Compared with traditional methods, the framework of this application decouples the sensor data decoding process from the system source code by introducing XML configuration files and independent parsers, which significantly improves the flexibility, scalability and ease of maintenance of the system.

[0098] Compared with the parsing of Modbus messages by traditional industrial systems, the Modbus data encoding and decoding framework based on the XML language interpreter in this application has significant improvements over traditional methods by introducing flexible configuration files, automatic parsing and generation mechanisms, clear structure and readability, and enhanced data verification and alarm mechanisms. It can better meet the needs of industrial Internet of Things systems and improve the ease of use and maintainability of the system. Its main advantages can be summarized as follows:

[0099] First, flexibility and scalability: The Modbus data encoding and decoding framework based on XML language can easily adapt to different types of sensors and data formats. By defining XML files, sensor types, data formats, and processing logic can be flexibly added or modified without changing the code.

[0100] Second, automatic parsing and generation: Using the XML parser, the structure and data in the XML file can be automatically parsed, which greatly simplifies the encoding and decoding process of the Modbus message. The definition in the XML file can be directly mapped to the encoding and decoding logic, reducing the complexity and error rate of manual coding.

[0101] Third, clear structure and readability: XML files have good readability and structure. Developers and maintenance personnel can intuitively understand the logic and process of data encoding and decoding, which is helpful for system maintenance and expansion.

[0102] Fourth, data validation and alarm mechanism: Through XML definition, you can set the validity range of data, such as min and max, and define the conditions and reaction logic for triggering alarms, such as trigger and reaction. This enhances the robustness and real-time monitoring capabilities of the system.

[0103] Embodiment 4:

[0104] The present invention discloses a device for message decoding based on XML parser, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. The memory and the processor form an electronic terminal. When the processor executes the computer program, the steps of Example 2 are implemented.

[0105] Embodiment 5:

[0106] The present invention discloses a device for message encoding based on XML parser, comprising a memory, a processor and a computer program stored in the memory and executable on the processor. The memory and the processor form an electronic terminal. When the processor executes the computer program, the steps of Example 3 are implemented.

[0107] Embodiment 6:

[0108] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in Embodiment 2 are implemented.

[0109] Embodiment 7:

[0110] The present invention discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in Embodiment 3 are implemented.

Claims

1. A method for message decoding based on XML parser, characterized in that: The following steps are included: Step S1: The message receiver receives and obtains the message; Step S2: When the XML parser obtains the XML configuration file, the sensor type, data format and decoding logic in the XML configuration file are parsed to obtain the parsed XML configuration file, where the parsed XML configuration file includes the decoding logic and configuration data; Step S3: The decoding logic generator generates corresponding specific decoding logic according to the parsed XML configuration file; Step S4: the data processor executes decoding logic on the message to obtain decoded sensor data; Step S5: The data verification and alarm module verifies the validity of the decoded sensor data according to the validity check and alarm mechanism in the parsed XML configuration file to obtain a verification result.

2. The method for message decoding based on XML parser according to claim 1, characterized in that: In step S1, when the message receiver obtains the message sent by the sensor or device, the message is sent to the XML parser as an original message.

3. The method for message decoding based on XML parser according to claim 1, characterized in that: In step S4, when the data processor obtains the message and the specific decoding logic, the specific decoding logic is executed to decode the message to obtain the decoded sensor data.

4. The method for message decoding based on XML parser according to claim 1, characterized in that: In step S5, when the data verification and alarm module obtains the decoded sensor data, the validity of the sensor data is verified according to the validity check and alarm mechanism in the parsed XML configuration file, and an alarm message is generated.

5. A device for message decoding based on an XML parser, used in the method for message decoding based on an XML parser as claimed in any one of claims 1 to 4, characterized in that: It includes a message receiver, an XML parser, a decoding logic generator, a data processor and a data verification and alarm module which are connected in sequence to form a coding and decoding framework.

6. The device for message decoding based on XML parser according to claim 5, characterized in that: The message receiver is used to connect to the sensor or device, obtain the message sent by the sensor or device, and send the message as the original message to the XML parser.

7. The device for message decoding based on XML parser according to claim 5, characterized in that: The XML parser is used to obtain an XML configuration file, parse the sensor type, data format and decoding logic in the XML configuration file, and obtain the parsed XML configuration file, which includes the decoding logic and configuration data.

8. The device for message decoding based on XML parser according to claim 5, characterized in that: The decoding logic generator is used to generate corresponding specific decoding logic according to the parsed XML configuration file.

9. The device for message decoding based on XML parser according to claim 5, characterized in that: The data processor is used to obtain the message and the specific decoding logic, execute the specific decoding logic, decode the message, and obtain the decoded sensor data.

10. The device for message decoding based on XML parser according to claim 5, characterized in that: The data verification and alarm module is used to verify the validity of sensor data according to the validity check and alarm mechanism in the parsed XML configuration file, and generate verification results and alarm information.