Method and device for analyzing messages at battery swap station end, and medium

Through the modular message parser and reflection mechanism, the problem of tight CPU resources and low code readability in traditional methods is solved, efficient and scalable message parsing is achieved, and the reusability and maintainability of the code is improved.

CN120281827APending Publication Date: 2025-07-08AULTON NEW ENERGY AUTOMOBILE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410860719.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-12-29
Filing Date
2024-06-28
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

The traditional method of packet analysis on the battery swap station side can easily lead to tight CPU resources, reduced throughput, and lost data, and low code readability and maintainability.

Method used

The message parser is used to process modularly. Each type of message corresponds to a parser. The basic information transmission object of the battery swap station is dynamically created through the reflection mechanism, reducing duplicate logic and code writing, and improving the reusability and maintainability of the code.

Benefits of technology

It improves the reusability and maintainability of the code, reduces the complexity of the code, enhances the scalability and readability of the analysis process, and avoids data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120281827A_ABST
    Figure CN120281827A_ABST
Patent Text Reader

Abstract

The invention discloses a battery swap station end message analysis method, equipment and a medium, which are used for solving the technical problem that the readability and maintainability of codes used by the existing station end message analysis method are relatively low. The method comprises the following steps: acquiring a station end message sent by a battery swap station end, and acquiring a message analyzer corresponding to the station end message; parsing the station end message through a message parser to obtain message content corresponding to the parsed station end message; and combining and generating a field value array based on each component in the message content, and converting values in the field value array into corresponding basic information transmission objects of the battery swap station.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority from the invention patent application filed with the China National Patent Office on December 29, 2023, with the application number 202311872313.1 and the invention title "A Method, Device and Medium for Message Parsing at the Battery Swap Station". Technical Field

[0002] This application relates to the technical field of message parsing, and specifically relates to a method, device and medium for message parsing at the battery swap station. Background Art

[0003] Message parsing at the battery swap station refers to parsing the messages sent from the battery vehicle terminal and extracting the key information therein for subsequent processing and operations. With the continuous development of the battery swapping service, the number of battery swap stations has gradually increased, and the amount of message data uploaded from the battery swap stations has also become larger and larger. The traditional message parsing method is to use the Netty service to be responsible for receiving the reported station messages and parsing them. However, when the data volume is large, problems such as CPU resource tension are likely to occur. Once the throughput drops, data loss problems will occur.

[0004] To solve the above problems, a station message parsing engine is introduced to encapsulate the message parsing process. In this way, the Netty service only needs to receive and forward the messages, and the specific parsing process is carried out through the parsing logic in the message parsing engine. However, in this way, when parsing each message, a set of codes for constructing the model needs to be written, and the readability and maintainability of the codes are both low. Summary of the Invention

[0005] To solve the above problems, this application proposes a method for message parsing at the battery swap station, including:

[0006] Obtain the station message sent from the battery swap station and obtain the message parser corresponding to the station message;

[0007] Parse the station message through the message parser to obtain the message content corresponding to the parsed station message;

[0008] Based on the respective components in the message content, merge and generate a field value array, and convert the values in the field value array into the corresponding battery swap station basic information transmission object.

[0009] In the embodiments of the present application, the parsing logic of different messages is modularized through a message parser, so that there is a corresponding parser for each type of message. When parsing messages of the same type, there is no need to write new parsing code, which improves the code reusability. Encapsulating the parsing logic in an independent parser can make the logic code more concise and clear. Only by calling the corresponding parser can the message parsing be completed without caring about the specific parsing details. Merging each component in the message content into a field value array can reduce the duplicate logic in the code and make the code more concise and readable. Through the reflection mechanism, the basic information transmission object of the battery swapping station can be dynamically created. When facing the parsing of different message types, only the corresponding parser and the definition of the transmission object need to be modified, without modifying a large amount of business logic code, which improves the code reusability.

[0010] Obtain the station-side message sent by the battery swapping station, and parse the station-side message through a preset message parsing abstract class to obtain the message type corresponding to the station-side message;

[0011] According to the message type, obtain the message parser of the message type from the parsing bean container;

[0012] Parse the station-side message through the message parser to obtain the message header and message body corresponding to the station-side message;

[0013] Merge the message header and the message body into a field value array, and through the reflection mechanism, convert the values in the field value array into the corresponding basic information transmission object of the battery swapping station.

[0014] In the embodiments of the present application, by abstracting the common logic and using design patterns, with the help of the message parsing abstract class, the basic logic of message parsing can be encapsulated, reducing the writing of duplicate code, improving the code reusability, and at the same time improving the readability and maintainability of the code, reducing the code complexity, and facilitating subsequent maintenance and modification. Using the parsing bean container to integrate different message parsers can conveniently add new message parsers and select the corresponding parser according to the message type, thereby enhancing the scalability of the parsing process. Merging the message header and the message body into a field value array can reduce the duplicate logic in the code and make the code more concise and readable. Through the reflection mechanism, the basic information transmission object of the battery swapping station can be dynamically created. When facing the parsing of different message types, only the corresponding parser and the definition of the transmission object need to be modified, without modifying a large amount of business logic code, which improves the code reusability.

[0015] In an implementation manner of the present application, the obtaining of the message parser corresponding to the station-side message includes:

[0016] Obtain the message parser corresponding to the station - side message according to the message type field in the station - side message.

[0017] In the embodiments of the present application, corresponding message parsers are provided for each type of message according to the message type field. There is no need to write separate parsing logic for each message, reducing redundant code and making the code more concise and easy to manage. Encapsulating the parsing logic in independent parsers and dynamically selecting parsers according to the message type enables each parser to be responsible for processing only specific types of messages. When the parsing logic needs to be modified or updated, only the specific parser needs to be concerned, without affecting other parts of the code, greatly improving the maintainability of the code.

[0018] In an implementation manner of the present application, the merging the respective components in the message content to generate a field value array includes:

[0019] Generating the field value array based on the message header and the message body in the message content;

[0020] And / or,

[0021] The converting the values in the field value array into corresponding basic information transmission objects of the battery swapping station includes:

[0022] Converting the values in the field value array into corresponding basic information transmission objects of the battery swapping station through the reflection mechanism.

[0023] In the embodiments of the present application, unifying different parts of the message content into a field value array can achieve standardized processing of the message and reduce the complexity of subsequent parsing. The reflection mechanism can dynamically obtain class information and call its methods or access its fields. Using the reflection mechanism can avoid hard - coding the mapping relationship between fields and objects in the code, reducing the coupling of the code. When the message structure or object structure changes, only the corresponding mapping configuration needs to be modified, without the need to modify a large amount of code, improving the maintainability of the code.

[0024] In an implementation manner of the present application, before converting the values in the field value array into corresponding basic information transmission objects of the battery swapping station through the reflection mechanism, the method further includes:

[0025] Determine at least one basic attribute parameter corresponding to the battery swapping station according to the content of the station - side message, and define an attribute field corresponding to the basic attribute parameter;

[0026] Create a battery swapping information class corresponding to the station - side message according to the attribute field.

[0027] In the embodiments of the present application, the basic attribute parameters of the battery swapping station are defined, and the parsed basic information of the battery swapping station is stored in the battery information class, which can conveniently expand and modify the basic information parameters so as to meet the requirements of the battery swapping station information in different scenarios. By creating the battery information class, the parsed basic information of the battery swapping station can be stored in a structured manner, facilitating subsequent data processing and use.

[0028] In one implementation manner of the present application, before converting the values in the field value array into the corresponding basic information transmission object of the battery swapping station, the method further includes:

[0029] Determine the basic information attributes corresponding to the battery swapping station according to the station-side message, and define the attribute fields corresponding to the basic information attributes;

[0030] Create a battery information class corresponding to the station-side message according to the attribute fields.

[0031] In the embodiments of the present application, by defining the basic information attributes and attribute fields and storing the parsed basic information of the battery swapping station in the battery information class, the basic information attributes can be conveniently expanded and modified so as to meet the requirements of the battery swapping station information in different scenarios. By creating the battery information class, the parsed basic information of the battery swapping station can be stored in a structured manner, facilitating subsequent data processing and use.

[0032] In one implementation manner of the present application, creating a battery swapping information class corresponding to the station-side message according to the attribute fields specifically includes:

[0033] For each attribute field, determine the field order corresponding to the attribute field in the station-side message, and add field annotations to each of the attribute fields according to the field order;

[0034] Locate the attribute field to the position in the field value array that matches the sequence value according to the sequence value carried in the field annotation corresponding to the field order;

[0035] Create a battery swapping information class corresponding to the station-side message according to the attribute field and the field annotation.

[0036] In the embodiments of the present application, by adding field annotations to the attribute fields and carrying field order information in the annotations, the attribute fields can be corresponded to the positions in the field value array, avoiding manually writing complex mapping logics, reducing the generation of errors and duplicate codes, and enhancing the readability of the codes at the same time. Also, when the message structure changes, only the annotations and attribute fields need to be modified, without modifying a large amount of codes, improving the maintainability of the codes.

[0037] In an implementation manner of the present application, according to the attribute fields, a battery information class corresponding to the station - side message is created, specifically including:

[0038] For each attribute field, determine the field order corresponding to the attribute field in the station - side message;

[0039] Add annotations to each of the attribute fields according to the field order, so as to locate the attribute field at a position in the field value array that matches the order value carried in the annotation according to the order value corresponding to the field order;

[0040] Create a battery information class corresponding to the station - side message according to the attribute field and the annotation.

[0041] In the embodiment of the present application, by adding annotations to the attribute fields, the position and order value of each field in the message can be clearly described. Moreover, by using the order value of the annotation, the attribute field can be corresponded to the position in the field value array, avoiding manually writing complex mapping logic and reducing the generation of errors and duplicate code. Annotations can easily add or modify attribute fields without modifying a large amount of mapping logic. In this way, when the message format changes, only the annotation and the definition of the attribute field need to be modified, without modifying the entire mapping logic.

[0042] In an implementation manner of the present application, through the reflection mechanism, the values in the field value array are converted into corresponding basic information transmission objects of the battery - swapping station, specifically including:

[0043] Construct a static method for converting the field value array into a basic information transmission object of the battery - swapping station;

[0044] Through the reflection mechanism, the values in the field value array are corresponded to the attribute fields with the field annotations in the battery - swapping information class;

[0045] Through the static method, the values in the field value array corresponding to the attribute fields are converted into basic information transmission objects of the battery - swapping station.

[0046] In the embodiment of the present application, by constructing a static method to perform conversion operations on the values in the field value array, this conversion logic can be reused multiple times, improving the code reusability. When it is necessary to support new attribute fields or modify the field mapping relationship, only the annotation and the static method need to be modified, without modifying a large amount of code, improving the code flexibility.

[0047] In an implementation manner of the present application, through the reflection mechanism, the values in the field value array are converted into corresponding basic information transmission objects of the battery - swapping station, specifically including:

[0048] Build a static method for converting the array of field values into a transmission object for the basic information of the power exchange station;

[0049] Through the reflection mechanism, traverse all the attribute fields in the message model class inside the static method, and determine the attribute fields with the annotation, so as to convert the values in the array of field values into the corresponding transmission object for the basic information of the power exchange station through the annotation.

[0050] In the embodiment of the present application, the reflection mechanism can be used to automatically traverse the attribute fields without manually writing the conversion logic, reducing the cumbersome manual conversion work and improving the development efficiency. By using the annotation, the fields to be converted can be flexibly selected, and only need to add the annotation to the corresponding attribute fields. At the same time, the annotation can be extended and customized according to requirements to meet different conversion needs.

[0051] In an implementation manner of the present application, converting the values in the array of field values into the corresponding transmission object for the basic information of the power exchange station through the annotation specifically includes:

[0052] Assign the field values in the array of field values to the attribute fields in the battery information class that match the annotation, so as to generate the corresponding transmission object for the basic information of the power exchange station according to the field values corresponding to the attribute fields.

[0053] In the embodiment of the present application, by encapsulating the conversion logic in the annotation and the reflection mechanism, this logic can be applied to different classes and attribute fields, so that code reuse can be achieved and repeated writing of similar conversion code can be avoided. Through the annotation, the attribute fields that need to be converted can be clearly marked, making the code clearer and easier to understand. At the same time, the annotation can concentrate the conversion logic in one place, facilitating maintenance and modification.

[0054] In an implementation manner of the present application, the attribute fields include message id, battery number, main software version number, and secondary software version number.

[0055] In an implementation manner of the present application, the obtaining the message parser corresponding to the station-side message according to the message type field in the station-side message includes:

[0056] According to the message type field, obtain the message parser corresponding to the station-side message from the parsing bean container;

[0057] Before obtaining the message parser corresponding to the station-side message, the method further includes:

[0058] Register the message parsers corresponding to each message type field into the parsing bean container, and the parsing bean container is used to maintain a key-value pair set composed of the message parser and the message type corresponding to the message parser;

[0059] Construct a message parsing abstract class to encapsulate the message parser through the message parsing abstract class and store the parsing bean container.

[0060] In the embodiment of the present application, during the bean initialization phase, the message parsers corresponding to each message type are registered in the parsing bean container, which is convenient for managing and maintaining the message parsers of different types, and can also avoid the cumbersome process of manual registration. The message parsing abstract class can encapsulate the message parser and provide a unified parsing interface, so that the parsing logic can be decoupled from the specific message parser, improving the readability and maintainability of the code. Through the parsing bean container, the message parsers of different types can be conveniently obtained and managed, and a suitable parser can be dynamically selected for parsing during the parsing process, improving the flexibility and scalability of the code.

[0061] In an implementation manner of the present application, before parsing the station-side message through a preset message parsing abstract class to obtain the message type corresponding to the station-side message, the method further includes:

[0062] Register the message parsers corresponding to each message type in the parsing bean container through the InitializingBean interface;

[0063] Construct a message parsing abstract class to encapsulate the message parser through the message parsing abstract class and store the parsing bean container.

[0064] In the embodiment of the present application, by implementing the InitializingBean interface, the message parsers corresponding to each message type can be registered in the parsing bean container during the bean initialization phase, which is convenient for managing and maintaining the message parsers of different types, and can also avoid the cumbersome process of manual registration. The message parsing abstract class can encapsulate the message parser and provide a unified parsing interface, so that the parsing logic can be decoupled from the specific message parser, improving the readability and maintainability of the code. Through the parsing bean container, the message parsers of different types can be conveniently obtained and managed, and a suitable parser can be dynamically selected for parsing during the parsing process, improving the flexibility and scalability of the code.

[0065] In an implementation manner of the present application, the message parser includes a battery code mapping parser, a battery information parser, a battery cell details parser, a vehicle information parser, an error information parser, and a battery replacement list parser.

[0066] The embodiment of the present application provides a device for parsing the message of the battery swapping station side, and the device includes:

[0067] An acquisition module, configured to acquire a station-side message sent by a battery swapping station terminal and acquire a message parser corresponding to the station-side message;

[0068] An analysis module, configured to analyze the station-side message through the message parser to obtain the message content corresponding to the analyzed station-side message;

[0069] A conversion module, configured to merge and generate a field value array based on each component in the message content, and convert the values in the field value array into corresponding battery swapping station basic information transmission objects.

[0070] An embodiment of the present application provides a device for parsing a station-side message of a battery swapping station. The device includes:

[0071] At least one processor; and,

[0072] A memory communicatively connected to the at least one processor; wherein,

[0073] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the method for parsing a station-side message of a battery swapping station as described in any one of the above.

[0074] An embodiment of the present application provides a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions can implement the method for parsing a station-side message of a battery swapping station as described in any one of the above.

[0075] An embodiment of the present application provides a device for parsing a station-side message of a battery swapping station. The device includes:

[0076] At least one processor; and,

[0077] A memory communicatively connected to the at least one processor; wherein,

[0078] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can:

[0079] Acquire a station-side message sent by a battery swapping station terminal, and analyze the station-side message through a preset message parsing abstract class to obtain the message type corresponding to the station-side message;

[0080] According to the message type, acquire a message parser of the message type from a parsing bean container;

[0081] Analyze the station-side message through the message parser to obtain a message header and a message body corresponding to the station-side message;

[0082] Merge the message header and the message body into an array of field values, and through the reflection mechanism, convert the values in the array of field values into corresponding transmission objects of the basic information of the battery swapping station.

[0083] An embodiment of the present application provides a non-volatile computer storage medium storing computer-executable instructions, and the computer-executable instructions are set as follows:

[0084] Obtain the station-side message sent by the battery swapping station, and parse the station-side message through a preset message parsing abstract class to obtain the message type corresponding to the station-side message;

[0085] According to the message type, obtain the message parser of the message type from the parsing bean container;

[0086] Parse the station-side message through the message parser to obtain the message header and the message body corresponding to the station-side message;

[0087] Merge the message header and the message body into an array of field values, and through the reflection mechanism, convert the values in the array of field values into corresponding transmission objects of the basic information of the battery swapping station. Description of the Drawings

[0088] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:

[0089] Figure 1 It is a schematic flowchart of a method for parsing a station-side message of a battery swapping station provided by an embodiment of the present application;

[0090] Figure 2 It is a specific schematic flowchart of a method for parsing a station-side message of a battery swapping station provided by an embodiment of the present application;

[0091] Figure 3 It is a schematic structural diagram of a device for parsing a station-side message of a battery swapping station provided by an embodiment of the present application;

[0092] Figure 4 It is a schematic structural diagram of a device for parsing a station-side message of a battery swapping station provided by an embodiment of the present application. Detailed Embodiment

[0093] To make the objectives, technical solutions, and advantages of this application clearer, the following will clearly and completely describe the technical solutions of this application in combination with specific embodiments of this application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts belong to the scope of protection of this application.

[0094] The following will, with reference to the drawings, elaborate on the technical solutions provided by each embodiment of this application.

[0095] As Figure 1 shown, a method for parsing messages at the swapping station end provided by an embodiment of this application includes:

[0096] S101: Obtain the station-end message sent by the swapping station end, and obtain the message parser corresponding to the station-end message.

[0097] In the traditional method for parsing messages at the swapping station end, after parsing the message to obtain the message header and message body, a Map is constructed with the message header and message body in the order of service fields. Among them, the key is the field order, and the value is the corresponding data. Then, values are taken from the Map in order to assign values to the corresponding fields, thereby constructing a Model. For example, the format of the station-end message is message id##battery code, hardware version, software version. A certain station-end message is A1126A51639504611|1002|20180709133945##A1126A51639504611,8604,2.58. The parsed message header is [A1126A51639504611|1002|20180709133945], and the message body is [A1126A51639504611,8604,2.58]. The Map constructed based on the message header and message body is:

[0098] {

[0099] "1":"A1126A51639504611|1002|20180709133945",

[0100] "2":"A1126A51639504611",

[0101] "3":"8604",

[0102] "4":"2.58"

[0103] }

[0104] Finally, construct the Model. Retrieve the data with keys 1 - 4 from the Map, which are the value values. Assign the retrieved value values to the fields corresponding to the message ID, battery number, main software version number, and secondary software version number. At this point, the parsing of the station - side message is completed. In this way, when facing different types of messages, a Model needs to be reconstructed each time, resulting in low maintainability and reusability of the code and reduced parsing efficiency. To solve this technical problem, the embodiments of this application provide a method for parsing messages at the battery - swapping station end, which can, when parsing different message types, only modify the corresponding parser and the definition of the transmission object, without the need to modify a large amount of business - logic code, and has strong code maintainability.

[0105] The parsing bean container is a component for storing and managing message parsers. It is used to maintain a collection of key - value pairs, where the key is the message type and the value is the message parser corresponding to that message type. For example, when the message type is a battery - type message, the corresponding message parsers include a battery - code mapping parser, a battery - information parser, a battery - cell details parser, a vehicle - information parser, an error - information parser, and a battery - replacement list parser, etc.

[0106] In one embodiment, during the code - initialization phase, multiple message parsers need to be defined according to business requirements. Each parser is responsible for parsing a specific type of message. Register these message parsers in the parsing bean container according to the message - type fields they handle. This process can be achieved by calling the InitializingBean interface in Spring. During the registration process of the parser, the message - type field should be used as the key, and the message - parser instance should be used as the value and stored in the key - value pair collection. In this way, when a certain message needs to be parsed, the corresponding message parser can be dynamically searched in the parsing bean container according to the message - type field, and the parsing operation can be executed. After the registration of the parser is completed, an abstract message - parsing class needs to be created. The message parser is encapsulated through the abstract message - parsing class, and the parsing bean container registered with the message parser is stored to achieve unified management of the message parser.

[0107] Each type of station - side message corresponds to a message parser. After obtaining the station - side message, read the message - type field in the station - side message. According to the message - type field, the corresponding message parser can be selected from the parsing bean container, and then the parsing of the station - side message can be completed through this message parser.

[0108] In one embodiment, through the InitializingBean interface in Spring, the message parsers corresponding to each message type are registered in the parsing bean container. Among them, the message parsers include a battery code mapping parser, a battery information parser, a battery cell details parser, a vehicle information parser, an error information parser, and a battery replacement list parser. A message parsing abstract class is constructed to encapsulate the message parsers through the message parsing abstract class and store them in the parsing bean container.

[0109] Based on the above encapsulation mechanism corresponding to the message parser, after the server obtains the station-side message sent by the battery swapping station, it needs to parse the station-side message through a preset message parsing abstract class to obtain the message type corresponding to the station-side message. Each message type corresponds to a different message parser.

[0110] S102: According to the message type, obtain the message parser of the message type from the parsing bean container.

[0111] After determining the message type corresponding to the currently received station-side message, the message parser corresponding to the message type can be obtained from the parsing bean container of the parent class according to the message type.

[0112] S102: Parse the station-side message through the message parser to obtain the message content corresponding to the parsed station-side message.

[0113] The message parser can parse the station-side message through its own parsing logic to obtain the message content corresponding to the station-side message.

[0114] The message content includes a message header and a message body. For example, taking the battery information message as an example, the station-side message is A1126A51639504611|1002|20180709133945##A1126A51639504611,8604,2.58. The parsed message header is [A1126A51639504611|1002|20180709133945], and the parsed message body is [A1126A51639504611,8604,2.58].

[0115] S103: Parse the station-side message through the message parser to obtain the message header and message body corresponding to the station-side message.

[0116] Through its own parsing logic, the message parser can parse the station - side message to obtain the corresponding message header and message body of the station - side message. For example, taking the battery information message as an example, the station - side message is A1126A51639504611|1002|20180709133945##A1126A51639504611,8604,2.58. The parsed message header is [A1126A51639504611|1002|20180709133945], and the parsed message body is [A1126A51639504611,8604,2.58].

[0117] S104: Combine the message header and the message body into a field - value array, and through the reflection mechanism, convert the values in the field - value array into the corresponding basic information transmission object of the battery - swapping station.

[0118] S103: Based on each component in the message content, combine and generate a field - value array, and convert the values in the field - value array into the corresponding basic information transmission object of the battery - swapping station.

[0119] Different from the traditional message parsing method, in the embodiment of the present application when constructing a Model, instead of constructing a corresponding Model for each message, all field values in each component (that is, the message header and the message body) of the message content are merged into an array in a certain order to form a corresponding field - value array. In this way, the value of each field can be accessed through the index of the array, and after obtaining the values in the field array, through the reflection mechanism, the values in the field - value array are converted into the corresponding basic information transmission object of the battery - swapping station.

[0120] Different from the traditional message parsing method, in the embodiment of the present application when constructing a Model, instead of constructing a corresponding Model for each message, all field values in the message header and the message body are merged into an array in a certain order, so that the value of each field can be accessed through the index of the array.

[0121] For example, according to the station - side message format mentioned above, the combined field - value array can be expressed as [A1126A51639504611|1002|20180709133945,A1126A51639504611,8604,2.58]. Then, use the reflection mechanism to dynamically obtain the information of the class, and can create objects and call the methods of the objects through the constructor and methods of the class, so as to convert the values in the field - value array into the corresponding basic information transmission object of the battery - swapping station. In this way, it is possible to flexibly process the types and quantities of different fields without explicitly writing a large amount of code to process each field, which can reduce the code redundancy and improve the maintainability and scalability of the code.

[0122] In one embodiment, according to the content of the station - end message, the basic attribute parameters (basic information attributes) corresponding to the battery swapping station can be determined, and corresponding attribute fields are defined for each basic attribute parameter. Among them, taking the station - end message of the battery type as an example, the corresponding attribute fields include message id, battery number, main software version number, and secondary software version number. After completing the definition of the above - mentioned attribute fields, a battery swapping information class (battery information class) is created according to the attribute fields. The battery swapping information class is a data type used to store the basic information of the battery swapping station, which contains the attribute fields corresponding to the basic attribute parameters and the corresponding access methods. Each attribute field has a corresponding data type to store the corresponding attribute value. For example, a String - type attribute field is defined to store the message id, and an int - type attribute field is defined to store the battery number, etc.

[0123] In one embodiment, according to the station - end message, the basic information attributes corresponding to the battery swapping station can be determined, and corresponding attribute fields are defined for each attribute. Among them, the attribute fields include message id, battery number, main software version number, and secondary software version number. A battery information class is created according to the above - mentioned attribute fields. The battery information class is a data type used to store the basic information of the battery swapping station, which contains the attribute fields corresponding to the basic information attributes and the corresponding access methods. Each attribute field has a corresponding data type to store the corresponding attribute value. For example, a String - type attribute field is defined to store the message id, and an int - type attribute field is defined to store the battery number, etc.

[0124] Among them, when creating the battery swapping information class, for each attribute field, determine the field order corresponding to the attribute field in the station - end message. Add field annotations (annotations) to each attribute field according to the field order, so as to locate the attribute field to the position in the field value array that matches the order value carried in the field annotation according to the order value corresponding to the field order. The purpose of this process is to be able to correspond the attribute field to the value with the same order position in the field array when obtaining the values in the field array later. Create the battery information class corresponding to the station - end message according to the attribute field and the field annotation.

[0125] Among them, when creating the battery information class, for each attribute field, determine the field order corresponding to the attribute field in the station - end message. Add annotations to each attribute field according to the field order, so as to locate the attribute field to the position in the field value array that matches the order value carried in the annotation according to the order value corresponding to the field order. Then, create the battery information class corresponding to the station - end message according to the attribute field and the annotation.

[0126] In addition, converting the values in the field value array into the corresponding basic information transmission object of the battery swapping station depends on a static method. A static method is constructed. Inside the method, through the reflection mechanism, the values in the field value array are made to correspond to the attribute fields with field annotations in the battery swapping information class. In this way, by implementing this static method, the attribute fields with field annotations can be identified, and the values in the field array with the same sequential value as this attribute field are assigned to this attribute field. In this way, the conversion of the values in the field value array is achieved, and the converted basic information transmission object of the battery swapping station is obtained. It should be noted that if an exception occurs during the instantiation process, the error log will be recorded and null will be returned.

[0127] In addition, a static method for converting the field value array into the basic information transmission object of the battery swapping station also needs to be constructed. Inside the method, through the reflection mechanism, all the attribute fields in the message model class inside the static method are traversed, and the attribute fields with annotations are determined. In this way, through the annotations, the values in the field value array can be assigned to the corresponding attribute fields, thereby converting the field value array into the corresponding basic information transmission object of the battery swapping station. It should be noted that if an exception occurs during the instantiation process, the error log will be recorded and null will be returned.

[0128] In one embodiment, the battery information class has a total of four private attribute fields, corresponding to the message id, battery number, main software version number, and secondary software version number respectively. Each attribute field uses a custom annotation and specifies their order in the station-side message. For example, the order of the attribute fields in the station-side message is the message id, battery number, main software version number, and secondary software version number. When adding custom field annotations to the above attribute fields, it is necessary to ensure that the order value in the field annotation can be the same as the position of this attribute field in the field value array. Then, for the attribute field of the message id, its corresponding field annotation is @StationMessageProperty0rder(1), and for the attribute field of the battery number, its corresponding field annotation is @StationMessageProperty0rder(2). In this way, after obtaining the field annotation through the reflection mechanism, according to the order value in the field annotation, the corresponding attribute field can be mapped to the value at the corresponding order in the field value array. Furthermore, according to the mapping relationship, the assignment of the attribute field can be achieved.

[0129] In the embodiment of the present application, by encapsulating the conversion logic in the field annotation and the reflection mechanism, this logic can be applied to different classes and attribute fields, which can achieve code reuse and avoid repeatedly writing similar conversion code. Through the field annotation, the attribute fields that need to be converted can be clearly marked, making the code clearer and easier to understand. At the same time, the field annotation can centralize the conversion logic in one place, facilitating maintenance and modification.

[0130] Figure 2 A method for parsing messages at the switching station end provided by an embodiment of the present application includes:

[0131] S201: Obtain the station-end message sent by the switching station end, and parse the station-end message through a preset message parsing abstract class to obtain the message type corresponding to the station-end message;

[0132] S202: According to the message type, obtain the message parser of the message type from the parsing bean container;

[0133] S203: Parse the station-end message through the message parser to obtain the message header and message body corresponding to the station-end message;

[0134] S204: Combine the message header and message body into a field value array, and through the reflection mechanism, convert the values in the field value array into the corresponding switching station basic information transmission object.

[0135] The above is the method embodiment proposed by the present application. Based on the same idea, some embodiments of the present application also provide the corresponding device, equipment and non-volatile computer storage medium for the above method.

[0136] Figure 3 A structural schematic diagram of a switching station end message parsing device provided by an embodiment of the present application. As Figure 3 shown, the device includes:

[0137] An acquisition module 301, configured to acquire the station-end message sent by the switching station end and acquire the message parser corresponding to the station-end message;

[0138] A parsing module 302, configured to parse the station-end message through the message parser to obtain the message content corresponding to the parsed station-end message;

[0139] A conversion module 303, configured to generate a field value array based on the respective components in the message content and convert the values in the field value array into the corresponding switching station basic information transmission object.

[0140] Figure 4 A structural schematic diagram of a switching station end message parsing device provided by an embodiment of the present application. As Figure 4 shown, it includes:

[0141] At least one processor; and,

[0142] A memory communicatively connected to at least one processor; wherein,

[0143] The memory stores instructions executable by at least one processor. The instructions are executed by the at least one processor so that the at least one processor can implement the message parsing method at the substation end as described in any one of the above.

[0144] An embodiment of the present application provides a non - volatile computer storage medium storing computer - executable instructions that can implement the message parsing method at the substation end as described in any one of the above.

[0145] Figure 2 It is a schematic structural diagram of a message parsing device at the substation end provided by an embodiment of the present application. As Figure 2 shown, it includes:

[0146] At least one processor; and,

[0147] A memory communicatively connected to the at least one processor; wherein,

[0148] The memory stores instructions executable by the at least one processor. The instructions are executed by the at least one processor so that the at least one processor can:

[0149] Obtain the station - end message sent from the substation end, and parse the station - end message through a preset message parsing abstract class to obtain the message type corresponding to the station - end message;

[0150] According to the message type, obtain the message parser of the message type from the parsing bean container;

[0151] Parse the station - end message through the message parser to obtain the message header and message body corresponding to the station - end message;

[0152] Merge the message header and message body into a field value array, and through the reflection mechanism, convert the values in the field value array into the corresponding substation basic information transmission object.

[0153] An embodiment of the present application provides a non - volatile computer storage medium storing computer - executable instructions set to:

[0154] Obtain the station - end message sent from the substation end, and parse the station - end message through a preset message parsing abstract class to obtain the message type corresponding to the station - end message;

[0155] According to the message type, obtain the message parser of the message type from the parsing bean container;

[0156] Parse the station - end message through the message parser to obtain the message header and message body corresponding to the station - end message;

[0157] Merge the message header and the message body into an array of field values, and through the reflection mechanism, convert the values in the array of field values into the corresponding basic information transmission object of the battery swapping station.

[0158] Each embodiment in this application is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. The key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the embodiments of the device and the medium, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the corresponding descriptions in the method embodiments.

[0159] The device and the medium provided by the embodiments of this application correspond one-to-one with the method. Therefore, the device and the medium also have beneficial technical effects similar to those of the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the device and the medium will not be elaborated here.

[0160] Those skilled in the art should understand that the embodiments of this application can be provided as a method, a system, or a computer program product. Therefore, this application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented 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.

[0161] This application is described with reference to the flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of this application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0162] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device realizes the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 steps of the functions specified in one block or multiple blocks.

[0164] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0165] The memory may include non-permanent memory in the computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.

[0166] Computer-readable media includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

[0167] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, commodity or device including the said element.

[0168] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.

Claims

1. A method for parsing messages at the battery swapping station end, characterized in that, The method includes: Obtaining a station-side message sent by a battery swapping station terminal, and obtaining a message parser corresponding to the station-side message; Parsing the station-side message through the message parser to obtain the message content corresponding to the parsed station-side message; Based on each component in the message content, merging and generating a field value array, and converting the values in the field value array into corresponding battery swapping station basic information transmission objects.

2. The method for parsing messages at the battery swapping station end according to claim 1, wherein The obtaining the message parser corresponding to the station-side message includes: According to the message type field in the station-side message, obtaining the message parser corresponding to the station-side message.

3. The method for parsing messages at the battery swapping station terminal according to claim 1, wherein The merging and generating the field value array based on each component in the message content includes: Based on the message header and message body in the message content, merging and generating the field value array; And / or The converting the values in the field value array into corresponding battery swapping station basic information transmission objects includes: Through the reflection mechanism, converting the values in the field value array into corresponding battery swapping station basic information transmission objects.

4. The method for parsing messages at the battery swapping station end according to claim 3, wherein Before converting the values in the field value array into corresponding battery swapping station basic information transmission objects through the reflection mechanism, the method further includes: Determining at least one basic attribute parameter corresponding to the battery swapping station according to the content of the station-side message, and defining an attribute field corresponding to the basic attribute parameter; According to the attribute field, creating a battery swapping information class corresponding to the station-side message.

5. The method for parsing messages at the battery swapping station terminal according to claim 4, wherein The creating the battery swapping information class corresponding to the station-side message according to the attribute field specifically includes: For each attribute field, determining the field order corresponding to the attribute field in the station-side message, and adding a field annotation to each attribute field according to the field order; According to the sequence value corresponding to the field order carried in the field annotation, positioning the attribute field to the position in the field value array that matches the sequence value; According to the attribute field and the field annotation, creating a battery swapping information class corresponding to the station-side message.

6. The method for parsing messages at the battery swapping station end according to claim 5, wherein, Converting the values in the field value array into corresponding battery swapping station basic information transmission objects through the reflection mechanism specifically includes: Constructing a static method for converting the field value array into a battery swapping station basic information transmission object; Through the reflection mechanism, making the values in the field value array correspond to the attribute fields with the field annotation in the battery swapping information class; Through the static method, converting the values in the field value array corresponding to the attribute fields into battery swapping station basic information transmission objects.

7. The method for parsing messages at the battery swapping station end according to claim 2, wherein The obtaining the message parser corresponding to the station-side message according to the message type field in the station-side message includes: According to the message type field, obtaining the message parser corresponding to the station-side message from the parsing bean container; Before obtaining the message parser corresponding to the station-side message, the method further includes: Registering the message parsers corresponding to each message type field into the parsing bean container, where the parsing bean container is used to maintain a key-value pair set composed of message parsers and the message types corresponding to the message parsers; Construct a message parsing abstract class to encapsulate the message parser through the message parsing abstract class and store the parsing bean container.

8. A message parsing device at the battery swapping station end, characterized in that, The device includes: An acquisition module, configured to acquire the station-side message sent by the swapping station terminal and acquire the message parser corresponding to the station-side message; A parsing module, configured to parse the station-side message through the message parser to obtain the message content corresponding to the parsed station-side message; A conversion module, configured to merge and generate a field value array based on each component in the message content, and convert the values in the field value array into corresponding swapping station basic information transmission objects.

9. A message parsing device at the battery swapping station end, characterized in that, The device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the swapping station terminal message parsing method according to any one of claims 1-7.

10. A non-volatile computer storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions can implement the swapping station terminal message parsing method according to any one of claims 1-7.