File conversion method and device, electronic equipment and storage medium

By dynamically identifying key information in Excel files and processing them based on actual header information, the problem of lack of flexibility in DBC file format conversion in the prior art is solved, and efficient and accurate file conversion effect is achieved.

CN119578375APending Publication Date: 2025-03-07QINGLING MOTORS GRP +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411636709.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

When existing algorithms convert the local area network communication protocol information of the Excel document format of automotive controllers into DBC file format, they lack flexibility and rely on fixed protocol headers, resulting in a significant reduction in the adjustment sequence and protocol organization efficiency.

Method used

By obtaining the initial table data and key table header item information, creating a hash table to dynamically identify key information in Excel file, avoiding relying on fixed formats or specific header names, processing based on the actual existing header information, and formatting the initial table data through predefined header enumeration objects.

Benefits of technology

A more efficient and accurate file conversion is achieved, ensuring that the converted DBC file contains all necessary information and avoiding the occurrence of non-standard DBC files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119578375A_ABST
    Figure CN119578375A_ABST
Patent Text Reader

Abstract

The invention provides a file conversion method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining initial table data and key table header item information, determining a column number and a column name of each table header in the initial table data, determining a to-be-processed hash table based on the column number and the column name of each table header in the initial table data, and converting the to-be-processed hash table into a to-be-processed hash table; traversing the to-be-processed hash table according to the predefined header enumeration object, determining an index value according to an index state of each enumeration item of the predefined header enumeration object in the to-be-processed hash table, labeling each enumeration item according to the index value to obtain a to-be-processed header enumeration object, and processing the to-be-processed header enumeration object according to the to-be-processed header enumeration object. If each key header item in the to-be-processed header enumeration object exists, performing format conversion on the initial table data according to the to-be-processed header enumeration object to obtain a target format file; according to the method and the device, the key information is dynamically identified by creating the hash table, processing is performed based on the actually existing header information, dependence on a preset fixed format is avoided, and more efficient and more accurate file conversion is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle control, and in particular to a file conversion method, device, electronic device and storage medium. Background Art

[0002] In the process of processing the integration of the automotive controller area network (CAN) communication protocol, the core task is to convert the automotive controller area network communication protocol information stored in the Excel document format into the DBC file format commonly used in the vehicle network information processing process. DBC (Database for CAN) is a file format used to define the CAN (Controller Area Network) communication protocol, mainly used to describe messages, signals, nodes and other related attributes in the CAN network. As far as the current protocol conversion process is concerned, the conversion of the DBC format in the existing algorithm requires high editing requirements for the editing format of the Excel source file, lacks sufficient flexibility, or uses a fixed protocol header, which greatly reduces the efficiency of the adjustment order and protocol sorting process. Summary of the invention

[0003] The purpose of the embodiments of the present invention is to provide a file conversion method, device, electronic device and storage medium to solve the above technical problems.

[0004] The present invention provides a file conversion method, which comprises: obtaining initial table data and key header item information, and determining the column number and column name of each header in the initial table data; performing hash table conversion based on the column number and column name of each header in the initial table data to obtain a hash table to be processed; traversing the hash table to be processed according to a predefined header enumeration object, and determining an index value according to the index state of each enumeration item of the predefined header enumeration object in the hash table to be processed, and marking each enumeration item according to the index value to obtain the header enumeration object to be processed; determining the existence state of each key header item in the header enumeration object to be processed according to the key header item information; if the existence state of each key header item is existence, performing format conversion on the initial table data according to the header enumeration object to be processed to obtain a target format file.

[0005] In one embodiment of the present invention, format conversion of initial table data according to the header enumeration object to be processed includes: performing data call in the initial table data according to the index value of each enumeration item in the header enumeration object to be processed to obtain a data set to be converted; performing format conversion on the data in the data set to be converted based on a preset format, and performing data verification to obtain a conversion data verification result; if the conversion data verification result is that the verification is correct, the initial conversion data is determined as the target conversion data, so as to be merged to generate a target format file.

[0006] In one embodiment of the present invention, data verification includes numerical format verification, data range verification, and arrangement format verification; the numerical format verification includes verifying the numerical format type of the initial conversion data; the data range verification includes checking whether the numerical value in the initial conversion data is within a preset range to ensure the validity of the numerical value; the arrangement format verification includes verifying the message arrangement of Intel format and Motorola format.

[0007] In one embodiment of the present invention, it also includes: when performing data verification on the initial conversion data, if there is at least one cell error, the cell error is recorded in a preset error list; when the data verification is completed, if the preset error list is empty, the initial conversion data is determined as the target conversion data to merge and generate a target format file; if the preset error list is not empty, the error list is output as a modification warning file.

[0008] In one embodiment of the present invention, checking the arrangement of messages in Intel format and Motorola format includes: if the arrangement format is Intel format, constructing a check matrix according to the starting bit of the signal in the message and the message length, judging whether these positions in the check matrix can be filled with data, and if not, recording them in a preset error list; if the arrangement format is Motorola format, constructing a check matrix according to the starting bit of the signal in the message and the message length, judging the position of the data in the matrix, filling from high to low, if it moves to the end of a row, moving the subscript to the beginning of the next row, and moving the subscript right again to determine whether the data can be filled in, and if not, recording them in a preset error list.

[0009] In one embodiment of the present invention, data verification also includes: obtaining the total number of data rows in the data set to be converted, and performing blank row determination with the total number of rows as the blank row determination range; skipping the blank row data if there is a blank row of data; filling in the default data item with a default value if there is a default data item in the data set to be converted that is empty; if the maximum value, minimum value and initial value verification error of the signal in the data set to be converted exceeds a preset deviation value, assigning a value to a theoretical calculated value.

[0010] In one embodiment of the present invention, after the format conversion of the initial table data is performed according to the header enumeration object to be processed, the file conversion method also includes: performing a signal value description recognition operation on the target format file, the signal value description recognition operation includes using a preset regular expression to identify signal value descriptions of different formats, and matching key-value pairs, extracting keys, value ranges and value descriptions to obtain signal value description information, and marking according to the signal value description information; determining the routing relationship for the sending node and forwarding node of each signal in the target format file; traversing all message channels, determining the routing information according to the signal name, and determining the routing type according to the routing relationship, and constructing a protocol routing table.

[0011] An embodiment of the present invention also provides a file conversion device, which includes: an initial data acquisition module, which is used to acquire initial table data and key header item information, and determine the column number and column name of each header in the initial table data; a conversion standard verification module, which is used to perform hash table conversion based on the column number and column name of each header in the initial table data to obtain a hash table to be processed; traversing the hash table to be processed according to a predefined header enumeration object, and determining an index value according to the index status of each enumeration item of the predefined header enumeration object in the hash table to be processed, and marking each enumeration item according to the index value to obtain the header enumeration object to be processed; determining the existence status of each key header item in the header enumeration object to be processed according to the key header item information; a data format conversion module, which is used to perform format conversion on the initial table data according to the header enumeration object to be processed if the existence status of each key header item is existence, to obtain a target format file.

[0012] An embodiment of the present invention also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the electronic device implements the file conversion method as described in any one of the above embodiments.

[0013] An embodiment of the present invention further provides a computer-readable storage medium on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer is enabled to execute the file conversion method as described in any one of the above embodiments.

[0014] The present invention provides a file conversion method, device, electronic device and storage medium. The method obtains initial table data and key table header item information, determines the column number and column name of each table header in the initial table data, performs hash table conversion based on the column number and column name of each table header in the initial table data, obtains a hash table to be processed, traverses the hash table to be processed according to a predefined table header enumeration object, determines an index value according to the index state of each enumeration item of the predefined table header enumeration object in the hash table to be processed, and marks each enumeration item according to the index value to obtain the table header enumeration object to be processed. If each key item is determined in the table header enumeration object to be processed, the table header enumeration object to be processed is obtained. If all header items exist, the initial table data is formatted according to the header enumeration object to be processed to obtain a target format file; the application first creates a hash table to dynamically identify key information in the Excel file, avoids relying on a fixed format or a specific header name, and processes based on the actual existing header information instead of relying on a preset, fixed format. By checking the existence status of key header items in the header enumeration object to be processed, it is ensured that the converted DBC file can contain all necessary information, avoiding the occurrence of non-standard DBC files, and achieving more efficient and accurate file conversion.

[0015] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0017] Figure 1 is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application;

[0018] Figure 2 is a flowchart of a file conversion method shown in an exemplary embodiment of the present application;

[0019] Figure 3 is a schematic diagram of a specific adaptive header algorithm flow chart shown in an exemplary embodiment of the present application;

[0020] Figure 4 is a schematic diagram of a specific verification process of a numerical value format and range shown in an exemplary embodiment of the present application;

[0021] Figure 5 is a specific schematic diagram of interface operation optimization shown in an exemplary embodiment of the present application;

[0022] Figure 6 is a schematic diagram of a file conversion device shown in an exemplary embodiment of the present application;

[0023] Figure 7 It is a structural diagram of a computer system of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0024] The following will describe the embodiments of the present invention with reference to the accompanying drawings and specific embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.

[0025] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner, and thus the illustrations only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0026] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.

[0027] The "and / or" mentioned in this application describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0028] Figure 1 It is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application.

[0029] Reference Figure 1As shown, the system architecture may include a database 110 and a computer device 120. The computer device 120 obtains the initial table data and key header item information through the database 110, and determines the column number and column name of each header in the initial table data, performs hash table conversion based on the column number and column name of each header in the initial table data, obtains a hash table to be processed, traverses the hash table to be processed according to the predefined header enumeration object, and determines the index value according to the index state of each enumeration item of the predefined header enumeration object in the hash table to be processed, and marks each enumeration item according to the index value to obtain a header enumeration object to be processed, determines the existence state of each key header item in the header enumeration object to be processed according to the key header item information, and if the existence state of each key header item is existence, the initial table data is format converted according to the header enumeration object to be processed to obtain a target format file. The above-mentioned computer device 120 can be at least one of a microcomputer, an embedded computer, a network computer, an industrial computer, etc.; the database 110 is used to store CAN communication protocol data in Excel format.

[0030] Schematically, the computer device 120 obtains the initial table data and the key table header item information through the database 110, and determines the column number and column name of each table header in the initial table data, performs hash table conversion based on the column number and column name of each table header in the initial table data, obtains the hash table to be processed, traverses the hash table to be processed according to the predefined table header enumeration object, and determines the index value according to the index state of each enumeration item of the predefined table header enumeration object in the hash table to be processed, and marks each enumeration item according to the index value to obtain the table header enumeration object to be processed. If each key table header item is determined in the table header enumeration object to be processed, If both exist, the format of the initial table data is converted according to the header enumeration object to be processed to obtain the target format file; the application first creates a hash table to dynamically identify the key information in the Excel file, avoids relying on a fixed format or a specific header name, and processes based on the actual existing header information instead of relying on a preset, fixed format. By checking the existence status of the key header items in the header enumeration object to be processed, it is ensured that the converted DBC file can contain all the necessary information, avoids the occurrence of non-standard DBC files, and achieves more efficient and accurate file conversion.

[0031] Figure 2 is a flowchart of a file conversion method shown in an exemplary embodiment of the present application. The file conversion method can be Figure 1 The implementation environment may be implemented in other implementation environments, and the above implementation environments are not specifically limited here. Figure 2 As shown, the flowchart of the file conversion method includes at least steps S210 to S250, which are described in detail as follows:

[0032] In step S210, initial table data and key table header item information are obtained, and the column number and column name of each table header in the initial table data are determined.

[0033] In one embodiment of the present application, before obtaining the initial table data and key header item information, a header enumeration object is predefined. In this enumeration object, each enumeration represents a header protocol item, such as a message name, a signal name, a precision, an offset, etc. Each enumeration item independently stores the column index value of its corresponding header protocol item in the table. During initialization, the column index value is set to NULL to indicate that the corresponding column has not been found, so as to facilitate subsequent judgment of whether the table conforms to the standard format. Specifically, if the message name is located in the first column of the table, the corresponding column index is represented as "A" in Excel, the second column corresponds to "B", and so on. These column index values ​​store their numerical indexes in integer format (such as 1 represents the "A" column), and also support direct storage of column identifiers in string format (such as "A").

[0034] In one embodiment of the present application, the initial table data refers to CAN communication protocol data in Excel format.

[0035] In step S220, hash table conversion is performed based on the column number and column name of each table header in the initial table data to obtain a hash table to be processed.

[0036] Please combine Figure 3 As shown, Figure 3 is a schematic diagram of a specific adaptive header algorithm flow chart shown in an exemplary embodiment of the present application, combined with Figure 3 Steps S220 to S240 are explained in detail. In one embodiment of the present application, in order to improve the convenience and efficiency of data operations, the header in the Excel table (initial table data) is converted into a temporary HashMap variable, wherein the key (Key) of the HashMap represents the index position (i.e., column subscript) of each column in the Excel table, and the value (Value) is the header name or identifier corresponding to the column. Specifically, first read the row data containing the header from the Excel file, create a HashMap instance to store the header information, this HashMap will exist as a temporary variable, traverse each cell in the read header row, use its column subscript (i.e., the position number of the column where the cell is located) as the key, and the text content in the cell (i.e., the header name) as the value, and store it in the previously created HashMap to obtain a hash table to be processed.

[0037] In step S230, the hash table to be processed is traversed according to the predefined header enumeration object, and the index value is determined according to the index status of each enumeration item of the predefined header enumeration object in the hash table to be processed, and each enumeration item is marked according to the index value to obtain the header enumeration object to be processed.

[0038] In one embodiment of the present application, the Excel header is intelligently matched and labeled through a predefined header enumeration object to achieve adaptive processing of headers of different protocols. The process algorithm is divided into two main loop levels. The outer loop is responsible for traversing the predefined header enumeration object to fill in the correct index value for each enumeration item; the inner loop traverses the HashMap variable of the Excel header, where the cell values ​​in the Excel header are tried one by one according to the regular expression pattern pre-set in the header enumeration object.

[0039] In one embodiment of the present application, if the inner loop matches successfully, it indicates that the current enumeration item exists in Excel. At this time, the column subscript of the cell is recorded in the corresponding header enumeration object, and the successfully matched header item is removed from the HashMap variable of the Excel header to reduce the search space of subsequent loops and effectively reduce the time complexity of the program.

[0040] In one embodiment of the present application, if the inner loop fails to match, the inner loop is continued to be executed until all Excel header items are traversed. If the current enumeration item is not found in the entire Excel header, the column index value of the enumeration object is set to NULL, and then the matching process of the next enumeration item is entered.

[0041] In step S240, the existence status of each key header item in the header enumeration object to be processed is determined according to the key header item information.

[0042] In one embodiment of the present application, determining the existence status of each key header item in the header enumeration object to be processed based on the key header item information is a secondary verification of the index information annotation in step S230. After the outer loop completes the traversal of all header enumeration objects, it is ensured that all header enumeration objects marked as necessary have correctly obtained the column index value based on the key header item information. If the column index value of any necessary header enumeration object is found to be NULL, it can be concluded that the currently processed Excel file does not meet the requirements of the standard DBC table.

[0043] Since the algorithm adopts a flexible matching strategy based on regular expressions, it can automatically adapt to the Excel format protocols provided by different manufacturers and can achieve accurate column subscript identification without manually adjusting the table header. In addition, the algorithm also supports the addition of user-defined attributes, that is, in addition to the attributes specified by the standard DBC, it can also easily identify and process additional custom attributes, such as "gateway requirement messages", which are not within the scope of the DBC standard but can also be accurately identified and processed through the algorithm, further improving the scope of application and flexibility of the system.

[0044] In step S250, if the existence status of each key header item is existence, the format of the initial table data is converted according to the header enumeration object to be processed to obtain a target format file.

[0045] In one embodiment of the present application, format conversion of initial table data according to the header enumeration object to be processed includes performing data calls in the initial table data according to the index values ​​of each enumeration item in the header enumeration object to be processed to obtain a data set to be converted, performing format conversion on the data in the data set to be converted based on a preset format, and performing data verification to obtain a conversion data verification result. If the conversion data verification result is that the verification is correct, the initial conversion data is determined as the target conversion data to be merged to generate a target format file.

[0046] In one embodiment of the present application, when the initial conversion data is verified, if there is at least one cell error, the cell error is recorded in a preset error list; when the data verification is completed, if the preset error list is empty, the initial conversion data is determined as the target conversion data to be merged to generate a target format file; if the preset error list is not empty, the error list is output as a modification warning file.

[0047] In a specific embodiment of the present application, in order to ensure that exceptions in the data processing process can be effectively captured and recorded, this algorithm designs a complete set of cell exception handling mechanisms. First, a series of error type enumeration variables are defined to clearly distinguish different exception situations. These enumeration variables will be used as members of the "cell error" class defined later, so that the nature of the error can be accurately described when an exception occurs; secondly, a custom exception class inherited from the Exception base class is defined - "cell error". This class not only contains basic exception handling functions, but also specially designed properties for storing detailed error information, including but not limited to the row number and column number where the error occurs, the signal name involved, and the specific error type. As a member variable of the "cell error" class, the error type enumeration ensures the standardization and consistency of error descriptions.

[0048] In a specific embodiment of the present application, an error record list is defined, and its generic parameter is specified as the "cell error" class defined above. The list will be used to store all cell abnormal information detected during the data processing process, and provide data support for the subsequent generation of abnormal reports. In the process of data processing, through conditional judgment or abnormal capture mechanism, once the data or behavior that does not meet the expectations is identified, a new "cell error" instance is immediately created and added to the error record list. Finally, the error record list is checked to determine whether it is empty. If the list is empty, it means that no abnormality was found during the data processing process, and the generated DBC file can be directly output. On the contrary, if there are records in the list, these abnormal information need to be exported to the specified file for the user to review and correct.

[0049] In one embodiment of the present application, data verification includes numerical format verification, data range verification, and arrangement format verification; the numerical format verification includes verifying the numerical format type of the initial conversion data; the data range verification includes checking whether the numerical value in the initial conversion data is within a preset range to ensure the validity of the numerical value; the arrangement format verification includes verifying the message arrangement of Intel format and Motorola format.

[0050] In one embodiment of the present application, data verification also includes string format verification, specifically using a string to verify user input, the string is as follows "\\b[a-zA-Z_]+\\w*", where "\\b" matches the beginning of the string; "[a-Za-z_]+" matches 26 uppercase and lowercase English letters and underscores, and "+" indicates that it appears at least once, meaning that the string must have these character sets as the first character; "\\w+" matches 26 uppercase and lowercase English letters and underscores and numbers, and "+" indicates that it appears once or more times, based on which the input in the string format can be correctly matched, such as signal names and message names, as well as node names.

[0051] Please refer to Figure 4 As shown, Figure 4 FIG. 1 is a schematic diagram of a specific numerical format and range verification process shown in an exemplary embodiment of the present application. Figure 4As shown, in the verification process, it is first determined whether the cell is of a numeric type. If it is a numeric type, a range check is performed based on the value of the numeric type; if it is not a numeric type, it is determined whether the cell is of a formula type. If it is a formula type, the formula calculator is called to obtain the value of the numeric type, and the data range is checked based on the value of the numeric type; if the cell is neither a numeric type nor a formula type, the cell is forcibly regarded as a string type, and it is determined whether the string type cell is a fraction type, a decimal type, or an integer type. If it is a fraction type, the fraction calculation module is called to obtain the value of the numeric type; if it is a decimal type, a double type value is obtained; if it is an integer type, an integer type value is obtained, and a data range check is performed based on the obtained value; if it is neither a fraction type, nor a decimal type, nor an integer type, it is determined to be an error cell, and a range check is performed on the aforementioned obtained value according to the preset data range. If it is within the numeric range, the numeric type data is obtained and the verification is terminated. If the verification data is not within the preset verification data range, it is determined to be an error cell.

[0052] In one embodiment of the present application, the message arrangement of the Intel format and the Motorola format is verified, including if the arrangement format is the Intel format, constructing a check matrix according to the start bit of the signal in the message and the message length, judging whether these positions in the check matrix can be filled with data, and if they cannot be filled in, recording them in a preset error list. Specifically, when verifying the Intel arrangement format, a frame of CAN message usually contains 8 bytes of data, each byte contains 8 bits of data, and a total of 8*8=64 bits of data, and the subscripts of these data start from 0 and are counted to 63 subscripts. Therefore, you only need to know the start bit and signal length of a signal to know which positions of the signal are in the 64-bit message matrix. Therefore, we predefine an initial check matrix of length n*8, where n is the message length. At the beginning, all the data in the matrix are 0, and 0 means that no data is filled in. Next, the program obtains the next signal and determines whether these positions in the check matrix are 0 based on the start bit and length. If they are 0, it means that data can be filled in, and the data 1 is filled in these cells at the same time; if they are 1, it means that data has been filled in, and a warning pops up. This cycle continues, filling 1 into the matrix until all signals in a message are checked.

[0053] If the arrangement format is Motorola format, a check matrix is ​​constructed based on the start bit of the signal in the message and the message length, and the position of the data in the matrix is ​​determined. The data is filled from high to low. If it moves to the end of a row, the subscript is moved to the beginning of the next row, and the subscript is moved right again to determine whether the data can be filled in. If it cannot be filled in, it is recorded in the preset error list. The Motorola format includes the check of the Motorola MSB format and the check of the Motorola LSB. The check of the Motorola format is similar to the Intel format. It also determines the position of the data in the matrix based on the start bit and the signal length. The difference is that when the Motorola format crosses bytes, it fills from high to low, while the Intel format fills from low to high. The start bit of the Motorola LSB format is at the end of the data. The algorithm of the Motorola MSB format is reversed, and the start position of the MSB of the signal is calculated using the signal start position of the LSB, and then the check algorithm of the MSB module is called.

[0054] In one embodiment of the present application, data verification also includes obtaining the total number of data rows in the data set to be converted, and performing blank row determination based on the total number of rows as the blank row determination range; if blank row data exists, the blank row data is skipped; if there is a default data item in the data set to be converted that is empty, the default data item is filled with a default value; if the maximum, minimum and initial value verification errors of the signal in the data set to be converted exceed a preset deviation value, the value is assigned as a theoretical calculated value.

[0055] In order to ensure the integrity and accuracy of the protocol file, a correction mechanism is also included, covering aspects such as null value correction, theoretical value correction, and comment correction. The null value correction aspect includes the blank line correction aspect. The program first traverses the table, obtains the row subscript of the last cell containing data, and determines the total number of rows in the protocol file. Then, it determines whether each row is completely empty. If all cells in a row are empty, the row is skipped and moved to the next row. This not only improves the fault tolerance of the program, but also effectively avoids the infinite loop problem caused by blank rows. In terms of message judgment, the program first checks whether the current row contains message information, that is, message ID or message name. As long as one of them exists, the row is considered to be a valid message. If the message ID and message name do not exist at the same time, the missing item is recorded. If the current row has neither message ID nor message name, continue to judge the next row. In terms of signal judgment, the program checks whether the current row contains signal information, that is, signal name or signal description. As long as one of them exists, the row is considered to be a valid signal. If the signal name and signal description do not exist at the same time, the missing item is recorded. If the current row has neither a signal name nor a signal description, continue to judge the next row. In addition, for rows that are neither messages nor signals, the program will skip these rows to further improve the fault tolerance rate. In terms of empty cell correction, for some frequently occurring data items, such as data format (Intel format or Motorola format), data type (usually unsigned type), etc., these cells are allowed to be empty and automatically filled with default values. For example, the data format defaults to Intel format, and the data type defaults to unsigned type. This design reduces the operational burden on users when filling out the protocol and avoids errors caused by empty cells.

[0056] Secondly, for some values ​​that can be calculated from other data, such as maximum value, minimum value and initial value, the algorithm will automatically calculate and fill in. Specifically, in terms of original value calculation, the maximum original value = 2^N-1, N is the length of the signal. For example, if the length of a signal is 4, the maximum original value is 2^4-1=15. The minimum original value is unified as 0, and the initial value is also unified as 0. In terms of physical value calculation, physical value = original value * precision + offset, and original value = (physical value-offset) / precision. When reading these values, if the user's input exceeds the reasonable range, the algorithm will automatically replace these values ​​with theoretical calculated values ​​to ensure the correctness of the data.

[0057] Finally, the algorithm is also optimized in terms of annotation correction. When processing message annotations and signal annotations, regular expressions are used to automatically detect and replace characters that do not comply with the DBC standard, such as English double quotes. This automatic error correction function reduces the user's operation steps, ensures that the generated protocol file complies with the DBC standard, and improves the user experience.

[0058] In one embodiment of the present application, after the initial table data is format converted according to the header enumeration object to be processed, a signal value description recognition operation is performed on the target format file. The signal value description recognition operation includes using a preset regular expression to identify signal value descriptions of different formats, matching key-value pairs, extracting keys, value ranges and value descriptions to obtain signal value description information, and marking according to the signal value description information.

[0059] Specifically, the identification of the signal value description first determines the input type. The signal value description cell consists of multiple key-value pairs, each of which represents a value description. For example, in "0x1 = normal;", the numerical value on the left represents the value (key) of the signal, and the key may also be a range (such as "5~7 = reserved"). The middle is separated by an equal sign, and the value description (value) in string format is on the right, and finally the other key-value pairs are separated by a semicolon. The key can be a decimal, hexadecimal or binary number, the separator can be an equal sign, an English colon, a Chinese colon or a space, and the value is usually a string of characters, and the separator can be a semicolon, a carriage return or a period. In addition, there is a case where the numerical value is followed by a value description enclosed in quotation marks and separated by a space, for example: "3'Level three'". The signal value description cell may also contain non-value description content.

[0060] In the embodiment of the present application, three regular expressions are used to identify different input modes. The program first uses regular expression 1 to match once to confirm whether it is a quotation mark semicolon mode; if not, then it is determined whether it is a semicolon separation mode; if not, it can only be a space separation mode. After confirming the input type, the corresponding regular expression is directly used for matching. Using a loop statement, the matching content is obtained in a loop, and the data in the three capture groups are captured, which are startKey, endKey and value. Then it is determined whether the content in endKey is empty. If it is not empty, the keys in startKey and endKey are filled into the value description HashMap in a loop, and the values ​​are all the contents in value; if endKey is empty, it means that the key has only one value, and only one set of key-value pairs is added. Before filling in, binary, hexadecimal and decimal are checked respectively. Non-value description content may still appear in the value description, and other software on the market often ignores this point, resulting in the loss of important information filled in by the user. For this reason, after identifying the value description, this algorithm calls the regular expression just now again, and uses the replacement method to replace all matched content with an empty string "". The remaining content is non-value description content, which is also important data and needs to be retained and finally filled in the comments.

[0061] In one embodiment of the present application, after the format of the initial table data is converted according to the header enumeration object to be processed, the routing relationship is determined for the sending node and forwarding node of each signal in the target format file; all message channels are traversed, the routing information is determined according to the signal name, and the routing type is determined according to the routing relationship to build a protocol routing table.

[0062] Specifically, in the CAN protocol routing table generation and verification algorithm, first, the algorithm identifies the sending node of each signal to determine its sending and receiving relationship. The sending nodes of the signal can be divided into two cases: gateway nodes and non-gateway nodes. The signals of non-gateway nodes must be sent to the gateway, which is called sending signals; and the signals of gateway nodes must be forwarded by the gateway, which is called forwarding signals. The number of nodes sending signals may be zero, one, and more, for a total of three cases; and the number of nodes forwarding signals may also be zero, one, and more, for a total of three cases. Multiplying these two cases, we get 3×3=9, a total of 9 routing relationships. Further classifying these 9 routing relationships, we get the following 4 routing relationships:

[0063] Normal routing: When there is only one sending node and one or more forwarding nodes, it is considered normal routing.

[0064] Edge routing: When a signal does not pass through a gateway and is only transmitted on the current bus, it is considered an edge signal. For example, there is no sending and forwarding node, or there is only one sending node and no forwarding node.

[0065] No signal source: When a signal has only one forwarding node (one or more) but no sending node is found, it is considered to have no signal source.

[0066] Multiple sending sources: When a signal has multiple sending nodes, no matter how many forwarding nodes there are, they are all considered multiple sending sources.

[0067] Additionally, there are two error conditions:

[0068] Source channel sends to source channel: This error is considered when the sending and receiving nodes are on the same CAN channel.

[0069] Inconsistent data definition: the forwarding period (node ​​sent by the gateway) must not be less than the sending period (sent by non-gateway nodes), and the data length, precision or offset is inconsistent.

[0070] Next, define the data structure and create an empty routing table to store the information of sending and forwarding signals, as well as the routing type of each signal. Then traverse all CAN channels and add routing information to this empty routing table according to the signal name. If there is no routing information for the signal in the routing table, add it; if there is routing information for the signal, continue to add the sending and forwarding information to the routing information. After the sending information and forwarding information of all signals are filled in the routing table, check it again. After that, the algorithm adds routing types to the routing table in turn according to the sending node information and the number of forwarding nodes of the signal in the current routing table, according to the routing type identification rules mentioned above. Finally, output the generated routing table to the file to check the problems of the entire vehicle body CAN protocol based on the routing table.

[0071] In a specific embodiment of the present application, in order to solve the problem that the existing conversion process does not provide clear guidance to the user and requires a lot of content to be set before DBC conversion can be performed, please refer to Figure 5 As shown, Figure 5 is a specific schematic diagram of interface operation optimization shown in an exemplary embodiment of the present application, such as Figure 5 As shown, in order to solve this problem, a method is proposed to start from the configuration file. All user operations are generated and stored in the local configuration file when used for the first time. These configuration files are read when used, so as to achieve the purpose of reducing user operation steps. When the user repeatedly modifies the same protocol, the second time, he can directly click the "Start Conversion" button without the need for extra operations.

[0072] Secondly, the solution of this application also adds a logging function to solve the problem that faults cannot be reproduced. Logs are output locally in all places where the program uses printing methods, and a copy of the error log is also output to a local file. The software realizes full tracking of the program's running status.

[0073] The present invention provides a file conversion method, device, electronic device and storage medium. The method obtains initial table data and key table header item information, determines the column number and column name of each table header in the initial table data, performs hash table conversion based on the column number and column name of each table header in the initial table data, obtains a hash table to be processed, traverses the hash table to be processed according to a predefined table header enumeration object, determines an index value according to the index state of each enumeration item of the predefined table header enumeration object in the hash table to be processed, and marks each enumeration item according to the index value to obtain the table header enumeration object to be processed. If each key item is determined in the table header enumeration object to be processed, the table header enumeration object to be processed is obtained. If all header items exist, the initial table data is formatted according to the header enumeration object to be processed to obtain a target format file; the application first creates a hash table to dynamically identify key information in the Excel file, avoids relying on a fixed format or a specific header name, and processes based on the actual existing header information instead of relying on a preset, fixed format. By checking the existence status of key header items in the header enumeration object to be processed, it is ensured that the converted DBC file can contain all necessary information, avoiding the occurrence of non-standard DBC files, and achieving more efficient and accurate file conversion.

[0074] The following describes an apparatus embodiment of the present application, which can be used to execute the file conversion method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned embodiment of the file conversion method of the present application.

[0075] Figure 6 is a schematic diagram of a file conversion device shown in an exemplary embodiment of the present application. The device can be applied to Figure 2 The method implementation process shown in the figure can be based on Figure 1 The present invention is executed in the implementation environment shown in the figure, and may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the apparatus is applicable.

[0076] like Figure 6As shown, the exemplary file conversion device includes: an initial data acquisition module 601, a conversion standard verification module 602, and a data format conversion module 603. The initial data acquisition module 601 is used to acquire the initial table data and key header item information, and determine the column number and column name of each header in the initial table data; the conversion standard verification module 602 is used to perform hash table conversion based on the column number and column name of each header in the initial table data to obtain a hash table to be processed; the hash table to be processed is traversed according to the predefined header enumeration object, and the index value is determined according to the index state of each enumeration item of the predefined header enumeration object in the hash table to be processed, and each enumeration item is marked according to the index value to obtain a header enumeration object to be processed; the existence state of each key header item in the header enumeration object to be processed is determined according to the key header item information; the data format conversion module 603 is used to convert the format of the initial table data according to the header enumeration object to be processed if the existence state of each key header item is existence, and obtain a target format file.

[0077] An embodiment of the present application also provides an electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the electronic device implements the file conversion method provided in the above-mentioned embodiments.

[0078] Figure 7 is a schematic diagram of the structure of a computer system of an electronic device according to an exemplary embodiment of the present application. It should be noted that: Figure 7 The computer system 700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0079] like Figure 7 As shown, computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the program stored in a read-only memory (ROM) 702 or the program loaded from the storage part to a random access memory (RAM) 703, such as executing the method in the above embodiment. In RAM 703, various programs and data required for system operation are also stored. CPU 701, ROM 702 and RAM 703 are connected to each other via a bus. Input / output (I / O) interface 705 is also connected to bus 704.

[0080] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.

[0081] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 709, and / or installed from a removable medium 711. When the computer program is executed by a central processing unit (CPU) 701, various functions defined in the system of the present application are executed.

[0082] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0083] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0084] In the corresponding drawings of the above embodiments, connecting lines may indicate the connection relationship between the various components to indicate more constituent signal paths (constituent_signalpath) and / or one or more ends of some lines may have arrows to indicate the main information flow direction. Connecting lines, as a mark, are not a limitation to the scheme itself, but the use of these lines in combination with one or more exemplary embodiments helps to connect circuits or logic units more easily. Any represented signal (determined by design requirements or preferences) may actually include one or more signals that can be transmitted in either direction and implemented with any appropriate type of signal scheme.

[0085] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0086] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above method is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.

[0087] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0088] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0089] It should be noted that the present application can be used in many general or special computing system environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0090] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0091] It should be understood that the above content of the present application is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application should be the scope of protection required by the claims.

Claims

1. A file conversion method, characterized in that: The file conversion method comprises: Obtain the initial table data and key table header item information, and determine the column number and column name of each table header in the initial table data; Perform hash table conversion based on the column number and column name of each table header in the initial table data to obtain a hash table to be processed; The to-be-processed hash table is traversed according to the predefined header enumeration object, and an index value is determined according to the index state of each enumeration item of the predefined header enumeration object in the to-be-processed hash table, and each enumeration item is marked according to the index value to obtain the to-be-processed header enumeration object; Determine the existence status of each key header item in the header enumeration object to be processed according to the key header item information; If the existence status of each key header item is existence, the format of the initial table data is converted according to the header enumeration object to be processed to obtain a target format file.

2. The file conversion method according to claim 1, characterized in that: The format conversion of the initial table data according to the table header enumeration object to be processed includes: According to the index value of each enumeration item in the header enumeration object to be processed, data is called in the initial table data to obtain the data set to be converted; Performing format conversion on the data in the data set to be converted based on a preset format, and performing data verification to obtain a conversion data verification result; If the conversion data verification result is that the verification is correct, the initial conversion data is determined as the target conversion data to be merged to generate a target format file.

3. The file conversion method according to claim 2, characterized in that: Data verification includes value format verification, data range verification, and arrangement format verification; The numerical format verification includes verifying the numerical format type of the initial conversion data; The data range check includes checking whether the value in the initial conversion data is within a preset range to ensure the validity of the value; The arrangement format check includes checking the message arrangement of the Intel format and the Motorola format.

4. The file conversion method according to claim 3, characterized in that: Also includes: When performing data verification on the initial conversion data, if there is at least one cell error, the cell error is recorded in a preset error list; When the data verification is completed, if the preset error list is empty, the initial conversion data is determined as the target conversion data to be merged to generate a target format file; If the preset error list is not empty, the error list is output as a modification warning file.

5. The file conversion method according to claim 3, characterized in that: Verification of Intel and Motorola message alignment includes: If the arrangement format is the Intel format, a check matrix is ​​constructed according to the start bit of the signal in the message and the message length, and it is determined whether these positions in the check matrix can be filled with data. If not, they are recorded in a preset error list; If the arrangement format is Motorola format, a check matrix is ​​constructed based on the start bit of the signal in the message and the message length, and the position of the data in the matrix is ​​determined. It is filled from high to low. If it moves to the end of a row, the subscript is moved to the beginning of the next row, and the subscript is moved right again to determine whether the data can be filled in. If it cannot be filled in, it is recorded in the preset error list.

6. The file conversion method according to claim 2, characterized in that: Data verification also includes: Get the total number of rows of the data set to be converted, and use the total number of rows as the blank row determination range to perform blank row determination; if there is a blank row of data, skip the blank row of data; If there is a default data item in the data set to be converted that is empty, fill the default data item with a default value; If the verification error of the maximum value, minimum value and initial value of the signal in the data set to be converted exceeds the preset deviation value, the value assigned is the theoretical calculated value.

7. The file conversion method according to any one of claims 1 to 6, characterized in that: After the format of the initial table data is converted according to the table header enumeration object to be processed, the file conversion method further includes: Performing a signal value description recognition operation on the target format file, wherein the signal value description recognition operation includes using a preset regular expression to recognize signal value descriptions of different formats, matching key-value pairs, extracting keys, value ranges, and value descriptions to obtain signal value description information, and marking according to the signal value description information; For the sending node and forwarding node of each signal in the target format file, the routing relationship is determined; all message channels are traversed, the routing information is determined according to the signal name, and the routing type is determined according to the routing relationship, and a protocol routing table is constructed.

8. A file conversion device, characterized in that: The file conversion device comprises: The initial data acquisition module is used to acquire the initial table data and key table header item information, and determine the column number and column name of each table header in the initial table data; A conversion standard verification module is used to perform hash table conversion based on the column number and column name of each header in the initial table data to obtain a hash table to be processed; traverse the hash table to be processed according to a predefined header enumeration object, and determine an index value according to the index status of each enumeration item of the predefined header enumeration object in the hash table to be processed, and mark each enumeration item according to the index value to obtain a header enumeration object to be processed; determine the existence status of each key header item in the header enumeration object to be processed according to the key header item information; The data format conversion module is used to convert the format of the initial table data according to the header enumeration object to be processed to obtain a target format file if the existence status of each key header item is existence.

9. An electronic device, characterized in that: It comprises a processor, a memory and a communication bus; the communication bus is used to connect the processor and the memory; the processor is used to execute the computer program stored in the memory to implement the file conversion method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is used to enable a computer to execute the file conversion method as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Brush data packet conversion method and device, electronic equipment and storage medium

    CN121278015A