Method and system for analyzing and verifying protocol function message of monitoring equipment

By standardizing the parsing and verification methods for monitoring equipment protocol function messages, the problem of low parsing and verification efficiency for multiple protocols and functions is solved, enabling efficient and flexible equipment control and reducing development and maintenance costs.

CN121967567APending Publication Date: 2026-05-01SHANDONG ZHIYANG ELECTRIC
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG ZHIYANG ELECTRIC
Filing Date
2026-02-06
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Because monitoring equipment uses a variety of protocols and has a large number of functions, existing technologies require separate development for different protocols and functions, resulting in a large workload for software development and high maintenance costs, making it difficult to achieve rapid iterative delivery.

Method used

A method for parsing and verifying protocol function messages of monitoring equipment is provided. By obtaining the protocol identifier and function identifier of the message, querying the corresponding ordered message structure, initializing, translating and verifying, and using the initialization method cluster, translation method cluster and verification method cluster for standardization processing, the parsing of message structure and metadata is realized.

Benefits of technology

It improves the efficiency of protocol function parsing and verification in the field of monitoring equipment, has flexibility and customization capabilities, reduces the related costs of equipment control, and improves the maintainability and upkeep of the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121967567A_ABST
    Figure CN121967567A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of message data processing, and particularly relates to a method and a system for analyzing and verifying protocol function messages of monitoring equipment. The method comprises the following steps: acquiring a message which carries a protocol identifier and a function identifier, and querying a message structure according to a protocol; reading an initialization method name of the message structure, and calling a corresponding initialization method from an initialization method cluster to initialize the message structure; performing data translation of the message structure; if the translation method is not in the translation method cluster, translating the content of the message, namely initializing, translating and checking the metadata of the message; and finally, carrying out data verification on the message structure, and obtaining an analyzed message after verification is completed. According to the method and the device, the problems that protocol messages need to be analyzed aiming at different protocols and different functions and the correctness needs to be ensured due to multiple protocol types and a large number of functions are solved.
Need to check novelty before this filing date? Find Prior Art

Description

A method and system for parsing and verifying protocol function messages of monitoring equipment Technical Field

[0001] This invention belongs to the technical field of message data processing, and more specifically, relates to a method and system for parsing and verifying protocol function messages of monitoring equipment. Background Technology

[0002] There are many types of surveillance equipment on the market, and the protocols used by each surveillance system are not the same. For example, there is the national standard GB28181 protocol, the Southern Power Grid protocol specified by the Southern Power Grid industry, the State Grid I1 protocol, etc. Some equipment only supports a single protocol or some industry protocols.

[0003] Chinese patent document CN113872963A discloses a method and system for fast parsing of message protocols based on free tag splicing technology, belonging to the field of communication technology. The method includes: decomposing the message into tag modules; analyzing the message structure and determining the overall byte length of the message; assembling and parsing a fixed message header using header tags; assembling and parsing fixed data using delimiter tags; assembling and parsing the user-required data carried in the message using data bit tags; assembling and parsing the message end-of-message and checksum using end-of-message tags; configuring the tag order; verifying whether the length of the assembled message matches the overall byte length of the message; verifying the checksum is correct; if they do not match, verifying the correctness of each tag splicing in sequence; after message splicing is completed, storing the message splicing scheme; connecting to the device; parsing the message sent by the device; if parsing fails, verifying the correctness of each tag splicing in sequence until the message sent by the device can be parsed normally.

[0004] When a software application platform needs to unify device access, it requires separate development for different protocols. Due to the large number of protocols and functions, it is necessary to parse protocol messages for different protocols and functions while ensuring correctness. If each function of each protocol is developed separately, it will greatly increase the software development workload and subsequent software maintenance costs, and will not be conducive to rapid software iteration and delivery. Summary of the Invention

[0005] The present invention aims to overcome at least one of the defects of the prior art and provide a method and system for parsing and verifying protocol function messages of monitoring equipment, so as to solve the problem that due to the large number of protocol types and functions, it is necessary to parse protocol messages for different protocols and functions and ensure their correctness.

[0006] The detailed technical solution of this invention is as follows: A method for parsing and verifying protocol function messages of monitoring equipment, the method comprising: S1: acquiring a message carrying a protocol identifier and a function identifier, querying the message structure according to the protocol, retrieving the ordered message structure corresponding to the protocol from the message structure storage unit, and then processing the message structure in sequence; S2: reading the initialization method name of the message structure, calling the corresponding initialization method from the initialization method cluster to initialize the message structure, after initialization, the hexadecimal data field will store the message corresponding to the message structure; S3: performing data translation of the message structure, if the translation method is in the translation method cluster, then directly calling the corresponding method for translation, and storing the translated data in plaintext data; if the translation method is not in the translation method cluster, then translating the message content, i.e., initializing, translating, and verifying the message metadata; S4: finally performing data verification of the message structure, reading the verification method name of the message structure, calling the method in the verification method cluster for verification, and obtaining the parsed message after verification.

[0007] Furthermore, the initialization, translation, and verification of the message metadata specifically include: S31, querying the message type from the message type storage unit based on the unique identifier of the message frame; S32, querying the corresponding ordered message metadata from the message metadata storage unit based on the message type identifier and function identifier; S33, processing each message metadata in sequence: reading the initialization method name of the message metadata, calling the corresponding initialization method from the initialization method cluster to initialize the message metadata, and storing the message metadata in the hexadecimal data field after initialization; S34, translating the message metadata, reading the translation method name in the message metadata, calling the method in the translation method cluster to perform the translation, and storing the translated data in the plaintext data. The translation methods for message metadata all originate from the translation method family; S35, perform message metadata verification, read the verification method name of the message metadata, and call the corresponding verification method from the verification method family for verification; if the message metadata is associated with a target parameter, the verification method will obtain the value of the target parameter from the parameter storage unit and verify it against the plaintext data of the message metadata; after each message metadata completes the above process, the translation of the message content is completed. Once the above process is completed, a complete message structure is obtained, which includes the hexadecimal original message, plaintext data, and verification results of each structure data. This method can improve the parsing and verification efficiency of protocol functions in the field of monitoring equipment, has high flexibility and customization capabilities, can improve the maintainability of equipment control, and reduce related costs.

[0008] Furthermore, the message structure includes a start code, device number, control word, data field length, data field, check code, and end code.

[0009] The message structure initialization, data translation, and data verification are as follows: Start Code: The initialization method `initMethodName` calls the `initMethodName` method to initialize the message structure. `initMethodName` reads the configured data length `n` from the message structure, where `n` represents the message length in bytes, and reads `n` bytes of message data as the hexadecimal data for this structure, thus completing the message structure initialization. No data translation or verification is required. Device Number: The initialization method is `initMethodName`. The translation method for this message structure is named `translateMethod`. `translateMethod` first calls the hexadecimal-to-decimal conversion method, then the decimal-to-ASCII conversion method, translating the device number into ASCII format data and storing it in plaintext data. Translation is complete. No data verification is required. Control Word: The initialization method is `initMethodName`. This message structure requires neither data translation nor verification. Data Field Length: The initialization method is `initMethodName`. `thodName`: The translation method for this message is `translateMethod`, which is a utility method for data translation within the translation method family. No data validation of the message structure is required. Data Field: The initialization method is `initFromBefore`: `initFromBefore` is a custom method that reads the message length `n` from the plaintext data of its preceding message structure (i.e., the length of the data field), then reads `n` bytes of message data as the hexadecimal data of this structure, and then completes the initialization of the message structure. The translation method is `translateData`, which is not added to the translation method family. Checksum: The initialization method name is `initMethodName`. No data translation is required. The validation method is `validateSum`, which uses an accumulation and inversion validation method. It performs arithmetic accumulation, discards bits larger than 8 bits, retains only the last single byte, inverts the single byte, and verifies its correctness. End Code: The initialization method is `initMethodName`. No data translation of the message structure is required. No data validation of the message structure is required.

[0010] Furthermore, the message metadata includes: the original password and the new password, which are initialized, translated, and verified sequentially, specifically as follows: Original password: The initialization method is `init`, which is a custom implementation. The `init` method reads the configured data length `n` from the message metadata, where `n` represents the message length of the message metadata in bytes. This method reads `n` bytes of message data from the message as the hexadecimal data of the message metadata, thus completing the initialization of the message metadata. The translation method for the message metadata is `stringAscii`, which exists in the translation method family and is directly called for translation. `stringAscii` calls the string-to-ASCII conversion method for translation. The verification method for the message metadata is `equal`, which is an equality comparison. The target parameter is the original password, which is retrieved from the parameter storage unit, and the verification is performed to determine if it passes. New password: The initialization method is named `init`; the translation method for the message metadata is named `stringAscii`; the verification method for the message metadata is `equal`.

[0011] The method for acquiring a message also includes: configuring protocol functions, configuring message structure, and configuring the basic metadata corresponding to the protocol functions; firstly, configuring the protocol functions: S01. Configure the Southern Power Grid protocol in the protocol configuration; S02. Configure the example function as setting the device password in the function configuration; S03. The protocol function has two parameters, the original password and the new password, and the corresponding parameter key values ​​can be configured in the parameter configuration; configuring the message structure and the basic metadata corresponding to the protocol functions: S04. Configure a record in the protocol message type configuration, the frame type of the record is 02, and the frame type means time synchronization; S05. Configure the basic structure of the message in the protocol message structure configuration, and add records in order; S06. Configure the basic metadata corresponding to the protocol function in the function metadata configuration, and add records in order.

[0012] On the other hand, the present invention also includes a system for implementing a method for parsing and verifying protocol function messages of monitoring equipment. The system includes a protocol function configuration layer, a message configuration layer, and a message processing layer. The protocol function configuration layer includes a protocol configuration module, a function configuration module, and a parameter configuration module. The protocol configuration module is used to configure various types of monitoring equipment communication protocols and manage communication protocols to complete communication. The function configuration module is used to configure the device function information corresponding to the protocol and associate the functions under the protocol with the protocol to complete the function configuration. The parameter configuration module is used to configure the parameter information corresponding to the function and associate the function with the corresponding parameter information to achieve parameter configuration. The parameter information includes parameter key, default parameter value, parameter type, etc., associating the function with the parameter. A function can contain multiple parameters, and a parameter can also have sub-parameters.

[0013] The message configuration layer includes: a protocol message type configuration module, a protocol message structure configuration module, and a functional message metadata configuration module. The message configuration layer first needs to maintain information in the protocol message type configuration module. A message type identifies a type of message characteristic and is a unique identifier for a message, including frame type and frame type meaning. The frame type identifies the type classification of the message within the device's functions and is a unique identifier for the type. When a message is received, the frame type is obtained by parsing the corresponding frame of the message, and further, other message metadata information can be obtained.

[0014] The protocol message type configuration module is used to configure and maintain the basic message type information of the protocol; the protocol message structure configuration module is used to configure the message structure information of the protocol; the functional message metadata configuration module is used to configure the message metadata of the function; the message processing layer includes: a message structure initialization module, a message structure translation module, and a message structure verification module; the message structure initialization module is used to initialize the message structure; the message structure translation module is used to translate the message structure, including plaintext data translation of the message structure, as well as message metadata initialization, message metadata translation, and message metadata verification; the message structure verification module is used to verify the plaintext data in the message structure translation module to check whether the data meets the expected value.

[0015] This system requires the maintenance of configuration information for the protocol function configuration layer and the message configuration layer.

[0016] Furthermore, the protocol configuration module also configures the protocol name and manages the protocol.

[0017] The present invention also includes an electronic device comprising: a processor; and a memory storing a computer program executable on the processor; wherein, when the computer program is executed by the processor, it implements the steps of the method for parsing and verifying a monitoring device protocol function message.

[0018] A computer-readable storage medium storing a computer program, wherein when executed by a processor, the computer program implements the steps of a method for parsing and verifying a monitoring device protocol function message.

[0019] Compared with the prior art, the beneficial effects of the present invention are as follows: The method and system for parsing and verifying protocol function messages of monitoring equipment provided by the present invention have a standardized process, which can greatly improve the implementation efficiency of multiple protocols and functions. At the same time, it improves the parsing and verification efficiency of protocol functions in the field of monitoring equipment, has high flexibility and customization capabilities, can improve the maintainability of equipment control, and reduce related costs. Attached Figure Description

[0020] Figure 1 is a flowchart of a method for parsing and verifying protocol function messages of a monitoring device according to the present invention.

[0021] Figure 2 is a system structure diagram of a monitoring device protocol function message parsing and verification according to Embodiment 2 of the present invention.

[0022] Figure 3 is a schematic diagram of the protocol message structure of the Southern Power Grid protocol in Embodiment 1 of the present invention.

[0023] Figure 4 is a schematic diagram of metadata configuration in Embodiment 1 of the present invention. Detailed Implementation

[0024] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0025] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0026] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0027] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.

[0028] Example 1 This example uses the Southern Power Grid protocol to further illustrate the present invention.

[0029] The message structure specified in this protocol is as follows: Start code: 1 Byte, Device number: 6 Bytes, Control word: 1 Byte, Data field length: 2 Bytes, Data field: variable length, Check code: 1 Byte, End code: 1 Byte.

[0030] First, configure the protocol function: S01. Configure the Southern Power Grid protocol in the protocol configuration; S02. Configure the example function as setting the device password in the function configuration; S03. The protocol function has two parameters, the original password and the new password. Configure the corresponding parameter key values ​​in the parameter configuration; Configure the message structure and the basic metadata corresponding to the protocol function: S04. Configure one record in the protocol message type configuration. The frame type of the record is 02, and the frame type means time synchronization; S05. Configure the basic structure of the message in the protocol message structure configuration. Add records in order. The protocol message structure of the Southern Power Grid protocol is shown in Figure 3; S06. Configure the basic metadata corresponding to the protocol function in the function metadata configuration. Add records in order. The basic metadata configuration is shown in Figure 4.

[0031] The present invention provides a method for parsing and verifying protocol function messages of a monitoring device, as shown in Figure 1. Specifically, it includes: S1: obtaining a message carrying a protocol identifier and a function identifier; querying the message structure according to the protocol; querying the ordered message structure corresponding to the protocol from the message structure storage unit; and then processing the message structure in sequence. Preferably, in this embodiment, there is a message as follows: 68 0D 0F 01 02 03 04 02 00 08 31 32 33 34 35 36 37 382B 16, with the protocol identifier being 1 and the function identifier being 1.

[0032] S2: Read the initialization method name of the message structure, call the corresponding initialization method from the initialization method family to initialize the message structure, and after initialization, the hexadecimal data field will store the message corresponding to the message structure.

[0033] S3: Perform data translation of the message structure. If the translation method is in the translation method family, the corresponding method is called directly for translation, and the translated data is stored in plaintext data. If the translation method is not in the translation method family, the message content must be translated, that is, the message metadata is initialized, translated, and verified.

[0034] The initialization, translation, and verification of the message metadata specifically include: S31, querying the message type from the message type storage unit based on the unique identifier of the message frame. The message consists of multiple message frames. The unique identifier includes the protocol identifier, function identifier, and type identifier.

[0035] S32. Based on the message type identifier and function identifier, retrieve the corresponding ordered message metadata from the message metadata storage unit.

[0036] S33. For each message metadata, process it in sequence: read the initialization method name of the message metadata, call the corresponding initialization method from the initialization method family to initialize the message metadata, and after initialization, the hexadecimal data field will store the message metadata.

[0037] S34. Perform message metadata translation. Read the translation method name from the message metadata, call the method in the translation method family to perform the translation, and store the translated data in plaintext data. All message metadata translation methods come from the translation method family.

[0038] S35. Perform message metadata verification, read the verification method name of the message metadata, and call the corresponding verification method from the verification method family to perform verification; if the message metadata is associated with a target parameter, the verification method will obtain the value of the target parameter from the parameter storage unit and verify it with the plaintext data of the message metadata.

[0039] After each message's metadata completes the above process, the message content translation is finished. Once this process is complete, a complete message structure is obtained, including the hexadecimal original message, plaintext data, and verification results for each structure data element. This method improves the parsing and verification efficiency of protocol functions in monitoring equipment, offering high flexibility and customization capabilities. It also enhances the maintainability of equipment control and reduces related costs.

[0040] S4: Finally, perform data verification of the message structure, read the verification method name of the message structure, call the method in the verification method family to perform the verification, and obtain the parsed message after the verification is completed.

[0041] The initialization method cluster is a set of initialization methods required by a certain type of protocol; the translation method cluster is a set of translation methods required by a certain type of protocol; and the verification method cluster is a set of data verification methods for a certain type of protocol. These terms will be used directly thereafter.

[0042] In this embodiment, the ordered message structure corresponding to the protocol is queried according to the protocol identifier. The structure is shown in Figure 3. The message structure includes a start code, device number, control word, data field length, data field, check code, and end code.

[0043] The initialization, data translation, and data verification of the message structure are as follows: Start Code: Define an initialization method `initMethodName`. Calling `initMethodName` initializes the message structure. `initMethodName` is a custom implementation. `initMethodName` reads the configured data length `n` from the message structure, where `n` represents the message length in bytes. It then reads `n` bytes of message data as the hexadecimal data for this structure, completing the initialization. This method defaults to reading the message data of the specified data length. In this example, the hexadecimal data read from a message segment is 68. This message structure does not require data translation or verification.

[0044] Device Number: The initialization method for the device number is defined as initMethodName. The initMethodName method is called to initialize the message structure, completing the initialization of the message structure. In this embodiment, a segment of the message reads hexadecimal data as 0D 0F 01 02 03 04. The translation method for this message is named translateMethod. The translateMethod method first calls the hexadecimal to decimal conversion method, and then calls the decimal to ASCII conversion method to translate the device number into ASCII format data and store it in plaintext data. The translation is then complete. This message structure does not require data verification.

[0045] Control word: The initialization method is initMethodName. The initMethodName method is called to initialize the message structure and complete the initialization of the message structure. In this embodiment, the hexadecimal data read in a message is 02. This message structure does not require data translation or data verification.

[0046] Data field length: The initialization method is initMethodName. The initMethodName method is called to initialize the message structure and complete the initialization of the message structure. In this embodiment, the hexadecimal data read in a segment of the message is 00 08. The translation method of this message is translateMethod. translateMethod is a utility method for data translation in the translation method family. No data verification of the message structure is required.

[0047] Data Field: The initialization method is `initFromBefore`: `initFromBefore` is called to initialize the message structure. This is a custom method. `initFromBefore` reads the message length `n` from the plaintext data of its preceding message structure (i.e., the data field length), then reads `n` bytes of message data as the hexadecimal data for this structure, thus completing the message structure initialization. In this embodiment, the hexadecimal data read from a segment of the message is 31 32 33 34 35 36 37 38. The translation method is `translateData`, which is not added to the translation method family. The data field typically does not require verification, as its stored content is business data and does not require validation. However, this embodiment can also support configuring a corresponding verification method for validation.

[0048] The message metadata translation process is a core sub-process within the message initialization, translation, and verification process. The translation method family primarily consists of a collection of data translation utility methods, and the two lack a unified function. To ensure system flexibility, the translation method `translateData` is designated as a special method and is not added to the translation method family. Instead, when this method is encountered, the process enters the message metadata translation sub-process. This allows for flexible configuration of translation methods for the message structure, as well as configuration of the message structure's flow path towards message metadata translation.

[0049] Checksum: The initialization method is named `initMethodName`. Calling `initMethodName` initializes the message structure, completing the initialization. In this example, a segment of the message reads hexadecimal data as 2B; no data translation is required. The verification method is `validateSum`, which uses an accumulation and inversion verification method. Arithmetic accumulation is performed, discarding bits higher than 8 bits, retaining only the last single byte, inverting the single byte to obtain 2B, and verifying its correctness. End Code: The initialization method is also named `initMethodName`. Calling `initMethodName` initializes the message structure, completing the initialization. In this example, a segment of the message reads hexadecimal data as 16; no data translation or verification of the message structure is required.

[0050] Further, the message metadata is retrieved based on the message type identifier and function identifier. The message metadata includes the original password and the new password, as shown in Figure 4. The process proceeds sequentially: message metadata initialization, message metadata translation, and message metadata verification. Specifically: Original password: The initialization method is `init`, a custom-implemented method. The logic of the `init` method is similar to the `initMethodName` method of the message structure. Since they operate on different objects, this embodiment uses different method names for distinction. The `init` method reads the configured data length `n` from the message metadata, where `n` represents the message length of the message metadata (in bytes). This method reads `n` bytes of message data from the message as the hexadecimal data of the message metadata, completing the initialization of the message metadata. The translation method for this message metadata is `stringAscii`, which exists in the translation method family and is directly called for translation. `stringAscii` calls the string-to-ASCII conversion method for translation. The verification method for this message metadata is `equal`, a value comparison. The target parameter is the original password, which is retrieved from the parameter storage unit, and the verification is performed. Original password: The actual password in the device under the current state. New password: The new password that will be changed.

[0051] New password: The initialization method is named init; the translation method for the message metadata is named stringAscii; the verification method for the message metadata is equal.

[0052] When coding a single function of a single protocol in a traditional way, the average time for a single function is 5 standard man-days. Taking the Southern Power Grid protocol as an example, this protocol has 61 functions, and the coding development cycle is at least 300 standard man-days. Moreover, the coding style varies, resulting in poor maintainability and a high bug rate.

[0053] Using this method, the average configuration and debugging time for a single function is 1 standard working day, and only 60 standard working days are needed to complete the implementation and debugging of the Southern Power Grid protocol function. It also has a standardized process and is convenient for troubleshooting.

[0054] This method improves efficiency by 80% compared to traditional methods. This embodiment uses the efficiency comparison between multi-protocol development and the adaptation efficiency of this invention as an example, as shown in Table 1: Table 1: Efficiency Comparison of Multi-Protocol Development and Adaptation.

[0055] Example 2 This example provides a system based on a method for parsing and verifying protocol function messages of monitoring devices, as shown in Figure 2. The system includes a protocol function configuration layer, a message configuration layer, and a message processing layer. The protocol function configuration layer includes a protocol configuration module, a function configuration module, and a parameter configuration module. The protocol configuration module is used to configure various types of monitoring device communication protocols and manage communication protocols to complete communication. The function configuration module is used to configure the device function information corresponding to the protocol and associate the functions under the protocol with the protocol to complete the function configuration. The parameter configuration module is used to configure the parameter information corresponding to the function and associate the function with the corresponding parameter information to achieve parameter configuration. The parameter information includes parameter key, default parameter value, parameter type, etc., associating the function with the parameter. A function can contain multiple parameters, and a parameter can also have sub-parameters.

[0056] The message configuration layer includes: a protocol message type configuration module, a protocol message structure configuration module, and a functional message metadata configuration module. The message configuration layer first needs to maintain information in the protocol message type configuration module. A message type identifies a type of message characteristic and is a unique identifier for a message, including frame type and frame type meaning. The frame type identifies the type classification of the message within the device's functions and is a unique identifier for the type. When a message is received, the frame type is obtained by parsing the corresponding frame of the message, and further, other message metadata information can be obtained.

[0057] The protocol message type configuration module is used to configure and maintain the basic message type information of the protocol, which identifies the basic message type categories of the protocol. The protocol message structure configuration module is used to configure the message structure information of the protocol, which constitutes a message structure of the protocol. The function message metadata configuration module is used to configure the message metadata of a function, which identifies the specific message information, message content, etc. of a certain function. The message processing layer includes: a message structure initialization module, a message structure translation module, and a message structure verification module. The message structure initialization module is used to initialize the message structure, and the initialized message structure is used for subsequent processes. The message structure translation module is used to translate the message structure and is the core part of the system. It includes plaintext data translation of the message structure, as well as message metadata initialization, message metadata translation, and message metadata verification. The message structure verification module is used to verify the plaintext data in the message structure translation module to check whether the data meets the expected value.

[0058] This system requires the maintenance of configuration information for the protocol function configuration layer and the message configuration layer.

[0059] The protocol configuration module configures the protocol name and manages the protocol.

[0060] The protocol message structure configuration module in this embodiment needs to be configured with the contents shown in Table 2 below. The message structure defines the basic message structure composition of the protocol.

[0061] Table 2 Protocol Message Structure Configuration Table

[0062] In this embodiment, the functional message metadata configuration module needs to configure the metadata required for a single function. The field data is shown in the table below, which adds message type and target parameter compared to the previous table. The message type is used to associate with the data in the message type configuration, and the target parameter is used to verify the value of the message, as shown in Table 3: Table 3 Functional Message Metadata Configuration Table

[0063] The message processing layer is the core logic of message processing, and this part relies on the data configured in the aforementioned protocol function configuration layer and message configuration layer.

[0064] Example 3 This example also provides a computer-readable storage medium storing executable instructions, which, when executed, cause the machine to perform a method for parsing and verifying monitoring device protocol function messages as described above.

[0065] Specifically, a system or apparatus equipped with a readable storage medium may be provided, on which software program code implementing the functions of any of the embodiments described above is stored, and the computer or processor of the system or apparatus can read and execute the instructions stored in the readable storage medium.

[0066] In this case, the program code itself, which can be read from the readable medium, can perform the functions of any of the above embodiments, and therefore the computer-readable code and the readable storage medium storing the computer-readable code constitute a part of this specification.

[0067] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, program code can be downloaded from a server computer or the cloud via a communication network.

[0068] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0069] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solutions of the present invention, and are not intended to limit the specific implementation of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention should be included within the protection scope of the claims of the present invention.

Claims

1. A method for parsing and verifying protocol function messages of a monitoring device, characterized in that, The method includes: S1: Acquiring a message carrying a protocol identifier and a function identifier; querying the message structure according to the protocol; retrieving the ordered message structure corresponding to the protocol from the message structure storage unit; and then processing the message structure sequentially; S2: Reading the initialization method name of the message structure; calling the corresponding initialization method from the initialization method cluster to initialize the message structure; after initialization, the hexadecimal data field will store the message corresponding to the message structure; S3: Performing data translation of the message structure; if the translation method is in the translation method cluster, the corresponding method is directly called for translation, and the translated data is stored in plaintext data; if the translation method is not in the translation method cluster, the message content needs to be translated, i.e., initializing, translating, and verifying the message metadata; S4: Finally, performing data verification of the message structure; reading the verification method name of the message structure; calling the method in the verification method cluster for verification; and obtaining the parsed message after verification.

2. The method for parsing and verifying protocol function messages of a monitoring device according to claim 1, characterized in that, The initialization, translation, and verification of the message metadata specifically include: S31, retrieving the message type from the message type storage unit based on the unique identifier of the message frame; S32, retrieving the corresponding ordered message metadata from the message metadata storage unit based on the message type identifier and function identifier; S33, processing each message metadata sequentially: reading the initialization method name of the message metadata, calling the corresponding initialization method from the initialization method family to initialize the message metadata, and after initialization, storing the message metadata in the hexadecimal data field; S34, performing message metadata processing. Translation: The translation method name is read from the message metadata, and the method in the translation method family is called to perform the translation. The translated data is stored in the plaintext data. The translation methods of the message metadata all come from the translation method family. S35: Message metadata verification: The verification method name of the message metadata is read, and the corresponding verification method is called from the verification method family to perform the verification. If the message metadata is associated with a target parameter, the verification method will obtain the value of the target parameter from the parameter storage unit and verify it with the plaintext data of the message metadata. After each message metadata completes the above process, the translation of the message content is completed.

3. The method for parsing and verifying protocol function messages of a monitoring device according to claim 2, characterized in that, The message structure includes a start code, device number, control word, data field length, data field, check code, and end code.

4. The method for parsing and verifying protocol function messages of a monitoring device according to claim 3, characterized in that, The message structure initialization, message structure data translation, and message structure data verification are as follows: Start Code: The initialization method `initMethodName` calls the `initMethodName` method to initialize the message structure. `initMethodName` reads the configured data length `n` from the message structure, where `n` represents the message length in bytes, and reads `n` bytes of message data as the hexadecimal data for this structure, thus completing the message structure initialization. No message structure data translation or verification is required. Device Number: The initialization method is `initMethodName`. The translation method for this message structure is named `translateMethod`. The `translateMethod` method first calls the hexadecimal-to-decimal conversion method, then the decimal-to-ASCII conversion method, translating the device number into ASCII format data and storing it in plaintext data. Translation is then complete. No data validation of the message structure is required; Control word: Initialization method is initMethodName; this message structure does not require data translation or verification; Data field length: Initialization method is initMethodName; the translation method for this message is translateMethod, which is a utility method for data translation within the translation method family; no data verification of the message structure is required; Data field: Initialization method is initFromBefore: calling initFromBefore, which is a custom method, and initFromBefore is the plaintext number of its preceding message structure, i.e., the data field length. The message length n is read from the data, and then n bytes of message data are read from the message as the hexadecimal data of this structure. Then the message structure initialization is completed. The translation method is translateData, which is not added to the translation method family. Checksum: The initialization method name is initMethodName; no data translation is required. The verification method is validateSum, which uses an accumulation and inversion verification method. It performs arithmetic accumulation, discards bits above 8 bits, keeps only the last single byte, inverts the single byte, and verifies whether it is correct. End code: The initialization method is initMethodName; no data translation of the message structure is required. No data verification of the message structure is required.

5. The method for parsing and verifying protocol function messages of a monitoring device according to claim 3, characterized in that, The message metadata includes: the original password and the new password. The process proceeds sequentially as follows: message metadata initialization, message metadata translation, and message metadata verification. Specifically: Original password: The initialization method is `init`, a custom implementation. The `init` method reads the configured data length `n` from the message metadata, where `n` represents the message length in bytes. This method reads `n` bytes of message data as the hexadecimal data of the message metadata, completing the initialization. The translation method for this message metadata is `stringAscii`, which exists in the translation method family and is directly called for translation. `stringAscii` uses a string-to-ASCII conversion method for translation. The verification method for this message metadata is `equal`, a value comparison. The target parameter is the original password, which is retrieved from the parameter storage unit, and the verification is performed. New password: The initialization method is `init`; the translation method for this message metadata is `stringAscii`; the verification method for this message metadata is `equal`.

6. The method for parsing and verifying protocol function messages of a monitoring device according to claim 3, characterized in that, The method for acquiring a message also includes: configuring protocol functions, configuring message structure, and configuring the basic metadata corresponding to the protocol functions; firstly, configuring the protocol functions: S01. Configure the Southern Power Grid protocol in the protocol configuration; S02. Configure the example function as setting the device password in the function configuration; S03. The protocol function has two parameters, the original password and the new password, and the corresponding parameter key values ​​can be configured in the parameter configuration; configuring the message structure and the basic metadata corresponding to the protocol functions: S04. Configure a record in the protocol message type configuration, the frame type of the record is 02, and the frame type means time synchronization; S05. Configure the basic structure of the message in the protocol message structure configuration, and add records in order; S06. Configure the basic metadata corresponding to the protocol function in the function metadata configuration, and add records in order.

7. A system for implementing protocol function message parsing and verification of monitoring equipment, characterized in that, The system includes a protocol function configuration layer, a message configuration layer, and a message processing layer. The protocol function configuration layer includes a protocol configuration module, a function configuration module, and a parameter configuration module. The protocol configuration module configures various monitoring device communication protocols and manages these protocols to complete communication. The function configuration module configures device function information corresponding to the protocols, associating functions with the protocols to complete function configuration. The parameter configuration module configures parameter information corresponding to the functions, associating functions with corresponding parameter information to achieve parameter configuration. The message configuration layer includes a protocol message type configuration module, a protocol message structure configuration module, and a function message metadata configuration module. The protocol message type configuration module is used for... The configuration and maintenance layer includes: a basic message type information for the protocol; a protocol message structure configuration module for configuring the message structure information of the protocol; a functional message metadata configuration module for configuring the message metadata of the function; and a message processing layer comprising: a message structure initialization module, a message structure translation module, and a message structure verification module. The message structure initialization module initializes the message structure; the message structure translation module translates the message structure, including translating plaintext data of the message structure, as well as initializing, translating, and verifying message metadata; and the message structure verification module verifies the plaintext data in the message structure translation module to determine whether the data meets the expected value.

8. An electronic device, characterized in that, The electronic device includes: a processor; a memory storing a computer program executable on the processor; wherein, when the computer program is executed by the processor, it implements the steps of a method for parsing and verifying a monitoring device protocol function message as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and system for quickly analyzing message protocol based on free label splicing technology

    CN113872963A