Method, device and electronic equipment for generating DBC file
By using a visual editor that automatically generates DBC files and leveraging configuration files and mapping relationships, the Matrix files output by the project can be directly converted into DBC files. This solves the problems of complex operation and error-proneness in existing technologies, and achieves automated conversion that simplifies operation and improves reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-10
- Publication Date
- 2026-03-27
AI Technical Summary
Existing methods for generating DBC files are complex and error-prone. In particular, automated methods are difficult to directly convert to *.dbc files when there are significant differences between the output Matrix file and the template format. Furthermore, manual conversion is prone to errors and difficult to locate.
This paper provides a method for generating DBC files. By automatically generating a visual editor, it utilizes the mapping relationship between placeholders in the configuration file and the table header index of the Matrix file to directly convert the Matrix file output by the project into a DBC file. This includes obtaining the configuration file, determining the actual column data and writing it into the DBC file according to the format specification, and making manual adjustments when the verification fails.
It reduces the complexity of generating DBC files, improves operability, avoids error risks, simplifies tool complexity, and enables automatic conversion directly from the Matrix file output by the project to the DBC file.
Smart Images

Figure CN115470214B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of automobile database development, and particularly relates to a DBC file generation method and device and electronic equipment. BACKGROUND
[0002] CAN (Controller Area Network) and CANFD (CAN with Flexible Data rata) are both serial bus protocols developed and designed by Bosch Company, and have become ISO international standards, and have been widely applied to the field of automobiles. DBC (Database Can) is a database file of CAN and CANFD, which defines the interpretation (Signal) of all bit values of data messages (Message) and message data fields (Data) to be sent and received by each ECU in the vehicle-mounted bus system. In the whole vehicle development project, the CANoe (CAN open environment) bus development environment can establish a simulation model according to the DBC file, which is used in the processes of requirement analysis, software development and software testing. As a key technical document, the DBC file runs through the whole process of the project.
[0003] The existing DBC file creation techniques mainly include manual and automatic methods. For the manual method, such as the CANdb++Editor editor provided by CANoe, it is a visual editor, and engineers repeatedly add Network Nodes, Messages, Signals, Value tables and related attributes manually according to the message matrix file (Matrix) output by a project, and save it as a *.dbc format. This method is extremely dependent on manual operation, the process is complex and the error rate is high; the automatic DBC file creation technique is another solution for creating a DBC file, which needs to develop a fixed format Matrix (commonly in Excel format) as a template, and engineers need to manually convert the Matrix file output by the project into the specified template format, and then input the Matrix conforming to the template into the program script to finally output the *.dbc format file. Although this method can solve the problem of manual operation, it still has some disadvantages: this technical solution cannot directly use the Matrix file output by the project as the input of the program to finally output the *.dbc file, but needs to manually convert the Matrix file output by the project into the Matrix file conforming to the template, and then convert the Matrix file conforming to the template into the *.dbc file through the program, so when the format of the Matrix file output by the project and the template is quite different and is iteratively output, the work load is not essentially simplified, and it is easy to make mistakes in the manual conversion process, and it is difficult to locate the error position, in addition, this technique does not have a visual UI editor as in the manual technique, and in order to run the program, it is necessary to install the necessary development environment (such as python), which increases the complexity of the operation.
[0004] In summary, the existing DBC file generation method has the technical problems of complex operation and easy error. SUMMARY
[0005] Therefore, the purpose of the present application is to provide a DBC file generation method, device and electronic equipment to alleviate the technical problems of complex operation and easy error of the existing DBC file generation method.
[0006] In a first aspect, the embodiments of the present application provide a DBC file generation method applied to a visual editor for automatically generating a DBC file, and the method comprises:
[0007] obtaining a configuration file of a Matrix file output by a project and a worksheet to be converted in the Matrix file, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file;
[0008] determining real column data corresponding to each placeholder in each data row in the worktable to be converted according to the mapping relationship;
[0009] writing the real column data corresponding to each placeholder in each data row into a DBC file according to the format specification of the standard DBC file.
[0010] Further, the configuration file of the Matrix file output by the project is obtained, including:
[0011] analyzing the format specification of the standard DBC file to obtain each attribute contained in the standard DBC file;
[0012] determining a target attribute required by the project from each attribute contained in the standard DBC file, and taking the target attribute as the placeholder;
[0013] establishing a mapping relationship between the placeholder and a table header index of the table header in the Matrix file according to the placeholder and the table header, and further obtaining the configuration file.
[0014] Further, determining real column data corresponding to each placeholder in each data row in the worktable to be converted according to the mapping relationship, including:
[0015] determining the data row contained in the worktable to be converted according to the mapping relationship;
[0016] traversing all the data rows to perform the following steps:
[0017] determining a table header column index corresponding to a target placeholder in the current data row according to the mapping relationship, and further determining real column data corresponding to the table header column index in the current data row, and further obtaining real column data corresponding to each placeholder in the current data row, wherein the target placeholder is any placeholder in the placeholders.
[0018] Further, writing the real column data corresponding to each placeholder in each data row into a DBC file according to the format specification of the standard DBC file, including:
[0019] verifying the real column data corresponding to each placeholder in each data row according to the format specification of the standard DBC file;
[0020] if there is real column data that fails the verification, manually adjusting the real column data that fails the verification, and taking the adjusted real column data and real column data that passes the verification as data to be written;
[0021] If there is no real column data with check failure, all real column data with check success is taken as the data to be written;
[0022] The data to be written is written into the DBC file according to the format specification of the standard DBC file.
[0023] Further, the method further comprises:
[0024] If there is real column data with check failure, a check failure log is output, wherein the check failure log comprises a log level, error real column data and an index of the error real column data in the Matrix file.
[0025] Further, the automatically generated DBC file visual editor comprises a menu bar, a toolbar and a work area;
[0026] The menu bar comprises a config menu and a help menu;
[0027] The toolbar comprises a run button;
[0028] The work area comprises a Matrix file import area, a worktable to be converted selection area and a check failure log printing area.
[0029] Further, the mapping relationship between the placeholder and the table header index of the table header in the Matrix file is established according to the placeholder and the table header, comprising:
[0030] The mapping relationship between the placeholder and the table header index of the table header is established in an artificial configuration manner.
[0031] In a second aspect, the embodiments of the present application further provide a DBC file generation device, applied to an automatically generated DBC file visual editor, the device comprises:
[0032] An acquisition unit is configured to acquire a configuration file of a Matrix file output by a project and a worktable to be converted in the Matrix file, wherein the configuration file comprises a mapping relationship between a placeholder in a standard DBC file and a table header index in the Matrix file;
[0033] A determination unit is configured to determine real column data corresponding to each placeholder in each data row in the worktable to be converted according to the mapping relationship;
[0034] A writing unit is configured to write the real column data corresponding to each placeholder in each data row into a DBC file according to a format specification of the standard DBC file.
[0035] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of the method of any one of the above first aspect when running the computer program.
[0036] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, which stores machine executable instructions, wherein the machine executable instructions, when invoked and run by a processor, cause the processor to run the method of any one of the above first aspect.
[0037] In the embodiment of the present application, a DBC file generation method is provided, which is applied to a visual editor for automatically generating a DBC file, and the method comprises the following steps: obtaining a configuration file of a Matrix file output by a project and a work sheet to be converted in the Matrix file, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file; determining real column data corresponding to each placeholder in each data row in the work sheet to be converted according to the mapping relationship; and writing the real column data corresponding to each placeholder in each data row into the DBC file according to a format specification of the standard DBC file. As known from the above description, in the DBC file generation method of the present application, a visual editor for automatically generating a DBC file is realized, engineers can make some auxiliary settings according to the interface, the complexity of the tool is reduced, the operability is improved, the Matrix file output by the project can be directly and automatically converted into the DBC file through the configuration file, the complexity of the operation when generating the DBC file is reduced, the risk of errors is avoided, and the technical problems of the existing DBC file generation method, such as complex operation and easy errors, are solved. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without any creative effort.
[0039] Figure 1 A flow chart of the DBC file generation method provided by the embodiment of the present application;
[0040] Figure 2 A page schematic diagram of the visual editor for automatically generating a DBC file provided by the embodiment of the present application;
[0041] Figure 3A method flowchart for providing a configuration file of a Matrix file output by a project according to an embodiment of the present application is provided;
[0042] Figure 4 A method flowchart for determining real column data corresponding to each placeholder in each data row in a work sheet to be converted according to a mapping relationship according to an embodiment of the present application is provided;
[0043] Figure 5 Another page schematic diagram of a visual editor for automatically generating a DBC file according to an embodiment of the present application is provided;
[0044] Figure 6 A schematic diagram of a DBC file generation device according to an embodiment of the present application is provided;
[0045] Figure 7 A schematic diagram of an electronic device according to an embodiment of the present application is provided. DETAILED DESCRIPTION
[0046] The technical solutions of the present application will be described clearly and completely in combination with embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0047] In the existing automatic DBC file creation scheme, a fixed format Matrix (commonly in Excel format) needs to be formulated as a template. Engineers need to manually convert the Matrix file output by a project into the specified template format, and then use the Matrix file conforming to the template as input. After processing by a program script, the *.dbc format file is finally output. This technical solution cannot directly use the Matrix file output by a project as input to finally output the *.dbc file. Instead, the Matrix output by the project is manually converted into a Matrix file conforming to the template, and then the Matrix file conforming to the template is converted into a *.dbc file by a program. Therefore, when the format of the Matrix file output by the project and the template is quite different and iterative output, the work load is not essentially simplified, and errors are prone to occur in the manual conversion process. It is difficult to locate the error position. In addition, this technology does not have a visual UI editor as in manual technology. In order to run the program, necessary development environments (such as python) need to be installed, increasing the complexity of operation.
[0048] Based on this, in the DBC file generation method, a visual editor for automatically generating the DBC file is realized, engineers can make some auxiliary settings according to the interface, the complexity of the tool is reduced, the operability is improved, the Matrix file output by the project can be directly and automatically converted into the DBC file through the configuration file, the complexity of the operation when generating the DBC file is reduced, and the risk of errors is avoided.
[0049] To facilitate the understanding of the embodiment, first, a DBC file generation method disclosed by the embodiment is introduced in detail.
[0050] Embodiment one:
[0051] According to the embodiment of the application, an embodiment of a DBC file generation method is provided, it should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a group of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from here.
[0052] Figure 1 is a flowchart of a DBC file generation method according to the embodiment of the application, as shown in Figure 1 , the method comprises the following steps:
[0053] Step S102, obtaining the configuration file of the Matrix file output by the project and the worksheet to be converted in the Matrix file, wherein the configuration file comprises: the mapping relationship between the placeholder in the standard DBC file and the table header index in the Matrix file;
[0054] In the embodiment of the application, the above-mentioned DBC file generation method can be applied to a visual editor for automatically generating the DBC file, as shown in Figure 2 , wherein a page schematic diagram of the visual editor for automatically generating the DBC file is shown. When using the visual editor for automatically generating the DBC file to generate the DBC file, the configuration file (i.e. the config.json configuration file) of the Matrix file needs to be created in advance, after the creation of the configuration file is completed, the visual editor for automatically generating the DBC file reads the configuration file config.json, obtains all key:value information in the configuration file and stores them into variables, such as a dictionary type variable configdict={key:value}, the engineers input the Matrix file (for example, Matrix.xls) in the page, the visual editor for automatically generating the DBC file can obtain the configuration file (obtained in the form of variables) and the Matrix file, when the engineers click Figure 2 , the visual editor for automatically generating the DBC file can automatically generate the DBC file according to the Matrix file and the configuration file, and the engineers can click Figure 2The choose sheet name in the Matrix file will pop up a dialog box Figure 2 The select sheet name in the Matrix file will pop up a dialog box, and the engineer clicks table1 on the left side of the dialog box. Figure 2 The table1 on the left side of the dialog box will enter the right side of the dialog box (such as the table1 shown in the figure).
[0055] The configuration file includes the mapping relationship between the placeholders in the standard DBC file and the table header index in the Matrix file.
[0056] It should be noted that the Matrix file in the present application refers to the Excel format table.
[0057] Step S104, according to the mapping relationship, determining the real column data corresponding to each placeholder in each data row in the converted table;
[0058] Each data row in the converted table is a row other than the table header, and the above determination process will be described in detail below.
[0059] Step S106, according to the format specification of the standard DBC file, writing the real column data corresponding to each placeholder in each data row into the DBC file.
[0060] In the embodiment of the present application, a DBC file generation method is provided, which is applied to a visual editor for automatically generating a DBC file, and the method comprises: obtaining a configuration file of a Matrix file output by a project and a converted table in the Matrix file, wherein the configuration file includes a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file; determining real column data corresponding to each placeholder in each data row in the converted table according to the mapping relationship; and writing the real column data corresponding to each placeholder in each data row into the DBC file according to the format specification of the standard DBC file. As described above, the DBC file generation method of the present application realizes a visual editor for automatically generating a DBC file, and the engineer can make some auxiliary settings according to the interface, which reduces the complexity of the tool and improves the operability. Through the configuration file, the Matrix file output by the project can be directly and automatically converted into a DBC file, which reduces the complexity of the operation when generating the DBC file and avoids the risk of errors, thereby alleviating the technical problems of the existing DBC file generation method, such as complex operation and easy error.
[0061] The above describes the method for generating the DBC file of the present application briefly, and the detailed description of the specific content involved in the method is given below.
[0062] In an optional embodiment of the present application, referring to Figure 3 The step S102 of acquiring the configuration file of the Matrix file output by the project comprises the following steps:
[0063] The step S301 analyzes the format specification of the standard DBC file to obtain each attribute contained in the standard DBC file.
[0064] Specifically, the format specification of the standard DBC file is analyzed first to obtain each attribute contained in the standard DBC file. The standard DBC file is developed by Vector Company, and its format specification needs to be mastered. Then, the DBC file is created according to the format specification of the standard DBC file.
[0065] For example, the format specification of Message is: BO_{MsgID}{MsgName}:{MsgLength}{TxECU}. Wherein, BO_ is the keyword of the format specification, which is used to identify that the content behind it is Message; {MsgID} is an attribute (i.e. a placeholder), which is used to represent the ID of Message, and the value of the ID is expressed in decimal; {MsgName} is also an attribute (i.e. a placeholder), which is used to represent the name field of Message, and the data type is string; {MsgLength} is also an attribute (i.e. a placeholder), which is used to represent the length field of Message, and the data type is Byte; {TxECU} is also an attribute (i.e. a placeholder), which is used to represent the ECU field that sends the Message, and the data type is string. The format specification of Signal is: SG_{SigName}:{SigStartBit}|{SigLength}@{SigByteOrder}+({SigFactor},{SigOffset})[{SigMinValue}|{SigMaxValue}]"{SigUnit}"{RxECU}, and the content in the braces is also an attribute. The format specification information of Network Nodes, value table and attributes are analyzed in the same way.
[0066] The step S302 determines the target attribute required by the project from each attribute contained in the standard DBC file, and takes the target attribute as a placeholder.
[0067] This process can be described as extracting the placeholders from each attribute contained in the standard DBC file, and these placeholders are the key information for constructing the DBC file.
[0068] The target attribute required for the above determination item refers to determining the attribute concerned by the item as the target attribute from all attributes.
[0069] In step S303, a mapping relationship between the placeholder and the table header index of the table header is established according to the placeholder and the table header in the Matrix file, and then the configuration file is obtained.
[0070] The conventional automatic DBC technical solution is to construct the table header of the fixed Matrix template according to the placeholders, but in actual projects, the Matrix file output by the project does not conform to the fixed Matrix template (that is, the project does not use the above fixed template to output the Matrix file), but is constructed according to the placeholders to conform to the Matrix file output by the project, which generally differs from the fixed Matrix template, so manual conversion (conversion of the Matrix output by the project into the Matrix file conforming to the template) is required.
[0071] The placeholders are taken as the keys of the config.json file, and the index [i, j] of the corresponding placeholder in the table header of the Matrix file output by any project is taken as the value of the config.json file. The placeholders in the standard format specification and the Matrix file output in the actual project are connected through the key:value mapping mode, which solves the shortcomings of formulating the fixed Matrix template and improves the self-adaptive ability of the program.
[0072] Specifically, the mapping relationship between the placeholder and the table header index is established in an artificial configuration mode.
[0073] The content of the key in the Config.json configuration file needs to be determined before program development, and then the program is developed for the key. The engineer configures the value according to the table header of the Matrix file output by the project. The following configuration 1 is a configuration file obtained by mapping the corresponding value to the corresponding key according to the table header information in table 1.
[0074] Table 1 (Excel format)
[0075]
[0076] Configuration 1
[0077]
[0078]
[0079] As "MsgID": [2, 3] indicates that the placeholder {MsgID} is in the 2nd row and the 3rd column of the Matrix file, and the data row value in the 3rd column is the actual data of the placeholder. Some placeholders may need multiple key:value pairs in the configuration file, such as the placeholder {TxECU} corresponding to the three key-value pairs "TransmitterFlag": "t", "ECUstart": [2, 16] and "ECUend": [2, 18] in the configuration file. That is, the placeholder corresponding to {TxECU} is TransmitterFlag, the sending flag, and TransmitterFlag corresponds to t in Table 1, and the real column data corresponding to t is ECU1, that is, the real data corresponding to the placeholder {TxECU} is ECU1. It is obvious that the more keys, the richer the parsing fields supported by the program and the stronger the adaptive ability. The value of the value can be empty, and the program will ignore the parsing of it.
[0080] In an optional embodiment of the present application, referring to Figure 4 The step S104 of determining the real column data corresponding to each placeholder in each data row in the worktable to be converted according to the mapping relationship comprises the following steps:
[0081] Step S401, determining the data rows contained in the worktable to be converted according to the mapping relationship;
[0082] Specifically, from the mapping relationship of the configuration 1, it can be seen that the row header index in the table header index corresponding to the placeholder is 2, so the data rows contained in the worktable to be converted are from the 3rd row.
[0083] Step S402, traversing all data rows to execute the following steps:
[0084] According to the mapping relationship, the table header column index corresponding to the target placeholder in the current data row is determined, and then the real column data corresponding to the table header column index in the current data row is determined, and then the real column data corresponding to each placeholder in the current data row is obtained, wherein the target placeholder is any placeholder in the traversed placeholder.
[0085] As in the above example, the data row of the 3rd row of table1 is obtained, and configdict is traversed, such as "MsgName": [2, 2], the table header column index corresponding to the target placeholder MsgName is extracted as 2, that is, the data "Msg1" in the 3rd row and the 2nd column is the real column data of the placeholder {MsgName}. In the same way, the real column data of the corresponding placeholder of all column data in the 3rd row can be parsed in turn, and finally all the rows and all the columns of data and the corresponding placeholders can be parsed.
[0086] In an optional embodiment of the present application, the real column data corresponding to each placeholder in each data row is written into the DBC file according to the format specification of the standard DBC file, specifically including the following steps:
[0087] (1) The real column data corresponding to each placeholder in each data row is checked according to the format specification of the standard DBC file:
[0088] In order to prevent illegal values or invalid values from causing format errors of the DBC file, the parsed real column data needs to be checked. According to the format specification of the standard DBC file, the following checks can be made in the program: the value of {MsgID} can only be a number; the value of {SigStartBit} cannot be negative; the value of {SigFactor} cannot be 0; the value of {SigByteOrder} can only be "Motorola" or "Intel"; the values of {MsgName} and {SigName} are strings and the length is less than 32 bytes.
[0089] (2) If there is real column data that fails the check, the real column data that fails the check is manually adjusted, and the adjusted real column data and the real column data that passes the check are used as the data to be written;
[0090] In addition, if there is real column data that fails the check, a log of the check failure is output, wherein the log of the check failure includes: log level, error real column data, and index of the error real column data in the Matrix file.
[0091] If the check fails, the log window of the visual editor of the DBC file automatically outputs the log of the check failure, and the log content includes: log level, error real column data, and index of the error real column data in the Matrix file. Of course, after the log of the check failure is output, an engineer needs to detect the correctness of the corresponding data of the Matrix file.
[0092] (3) If there is no real column data that fails the check, all real column data that passes the check is used as the data to be written;
[0093] (4) The data to be written is written into the DBC file according to the format specification of the standard DBC file.
[0094] For example: the format specification of Message is: BO_{MsgID}{MsgName}:{MsgLength}{TxECU}, then the data in the 3rd row of Table 1 is written into the DBC file, which is: BO_{0x100}{Msg1}:{64}{ECU1}, that is, the data to be written replaces the attributes (i.e. placeholders) in the format specification of the standard DBC file.
[0095] In the process of writing data to be written into the DBC file, the format specification of the DBC file needs to be met, and the CAN or CANFD protocol specification also needs to be considered. The main processing logic is listed:
[0096] The type of the message needs to be automatically identified according to the value of the Message Length. When the value is greater than 8, the message is identified as a CANFD protocol type, otherwise it is identified as a CAN type;
[0097] The value of the Message ID must be in decimal, and the format of the data needs to be automatically identified. If the format is not decimal, the non-decimal (such as octal, hexadecimal) needs to be converted to decimal;
[0098] The necessary attributes of the message need to be added, such as adding the attribute GenMsgSendType according to the sending type of the message, and adding the attribute GenMsgCycleTime according to the sending cycle of the message;
[0099] The value of the signal byte sequence Byte Order is Motorola and Intel two systems, which will affect the value of the starting bit of the signal in the format specification of the standard DBC file, and different processing is needed in the code processing. The physical initial value needs to be calculated according to the default value SigDefaultValue, the precision SigFactor and the offset SigOffset of the signal, and the formula is physical value = SigDefaultValue * SigFactor + SigOffset. The value is the actual signal transmitted on the bus;
[0100] The type of the signal value needs to be identified according to the maximum value and the minimum value of the signal. For example, when the minimum value is greater than 0, the type of the signal value can be identified as Unsigned. When the minimum value is less than 0, the type of the signal value is identified as Signed;
[0101] The signal value description needs to be added to the value of the signal according to the content of the Value table, which represents the meaning of the signal value.
[0102] In an optional embodiment of the present application, referring to Figure 5 , the automatically generated DBC file visual editor includes a menu bar, a toolbar and a work area;
[0103] The menu bar includes a config menu and a help menu;
[0104] The toolbar comprises a run button.
[0105] The work area comprises a Matrix file import area, a sheet to be converted selection area and a log print area of failed verification.
[0106] Specifically, the menu bar provides a config menu and a help menu. The config menu provides a log and a dbc submenu. The log submenu is used to set the log output level during program running, and provides four levels of 'DEBUG', 'INFO', 'WARNING' and 'ERROR'; the main function of the dbc submenu is to set the path of the config.json file used by the program; a new config.json file is generated in the default path, the key value of the file is fixed, representing the logic that the program can handle, and the value is empty; a Matrix matrix containing only table headers is generated according to the key value of the config.json file. The main function of the help menu is to give the version information of the program and the operation instruction of the UI editor.
[0107] The toolbar only provides a run button to facilitate the running of the program.
[0108] The work area is mainly used to import the Matrix file output by the project; all sheet pages in the imported Matrix file are automatically displayed according to the imported Matrix file, and the engineer can select the sheet page to be converted according to the demand, and multiple sheet selection is supported; the log print area is used to display the log output.
[0109] The method of the application can be realized by python and related open source libraries (wxpython, xlrd, json and logging, etc.), and then the technical solutions of steps S104 and S106 are integrated into the program, and finally packaged as an installation-free exe program.
[0110] The method of the application does not need to make a Matrix template, but directly generates a DBC file through the Matrix file output by the project, and can adapt to any Matrix file output by the project.
[0111] The method of the present application avoids the disadvantages in the prior art automation technology, i.e., the need to formulate a Matrix template and convert the Matrix output by a project into a template, by designing a config.json configuration file. Using the technical solution, an engineer does not need to care about the format of the Matrix, does not need to make any modification and conversion to the Matrix matrix output by a project, and only needs to configure the Value value in the config.json configuration file according to the header information of the Matrix file output by a project, which almost does not produce any workload, so that the Matrix file output by a project can be used as program input to finally output a *.dbc file, instead of using a fixed template file as program input in the prior art. The error risk in the prior art, such as omission, repeated copying and pasting, when converting the Matrix file output by a project into a fixed template is also avoided. In addition, the prior art automation technical solution does not provide UI interface operation, and has the problem of poor operability. No program integration is provided, and if the program is run in a new environment, necessary lib libraries need to be installed. The technical solution essentially realizes a visual DBC automatic conversion editor, an engineer can make some auxiliary settings according to the interface, reduces the complexity of the tool, and improves the operability.
[0112] Embodiment two:
[0113] The embodiment of the present application also provides a DBC file generation device, which is mainly used for executing the DBC file generation method provided in the embodiment one of the present application. The DBC file generation device provided in the embodiment of the present application is specifically introduced as follows.
[0114] Figure 6 It is a schematic diagram of a DBC file generation device according to the embodiment of the present application. The DBC file generation device is applied to a visual editor for automatically generating a DBC file, as shown in FIG. 1, the device mainly comprises: an acquisition unit 10, a determination unit 20 and a writing unit 30, wherein: Figure 6
[0115] The acquisition unit is used to acquire the configuration file and the worksheet to be converted in the Matrix file of the project output, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and header index in the Matrix file.
[0116] The determination unit is used to determine real column data corresponding to each placeholder in each data row in the worksheet to be converted according to the mapping relationship.
[0117] The writing unit is used to write the real column data corresponding to each placeholder in each data row into the DBC file according to the format specification of the standard DBC file.
[0118] In the embodiment of the present application, a DBC file generation device is provided, which is applied to a visual editor for automatically generating a DBC file. The device comprises: a configuration file and a worksheet to be converted in a Matrix file output by a project are obtained, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file; real column data corresponding to each placeholder in each data row in the worksheet to be converted is determined according to the mapping relationship; and the real column data corresponding to each placeholder in each data row is written into the DBC file according to the format specification of the standard DBC file. As can be seen from the above description, in the DBC file generation device of the present application, a visual editor for automatically generating a DBC file is realized. Engineers can make some auxiliary settings according to the interface, which reduces the complexity of the tool and improves the operability. The Matrix file output by the project can be directly and automatically converted into a DBC file through the configuration file, which reduces the complexity of the operation when generating the DBC file and avoids the risk of errors, thereby alleviating the technical problems of the existing DBC file generation method, such as complex operation and high error rate.
[0119] Optionally, the obtaining unit is further configured to: analyze the format specification of the standard DBC file to obtain each attribute contained in the standard DBC file; determine a target attribute required by the project from the each attribute contained in the standard DBC file, and take the target attribute as a placeholder; and establish a mapping relationship between the placeholder and a table header index of the table header in the Matrix file according to the placeholder and the table header, and further obtain the configuration file.
[0120] Optionally, the determining unit is further configured to: determine a data row contained in the worksheet to be converted according to the mapping relationship; and perform the following steps by traversing all the data rows: determine a table header column index corresponding to a target placeholder in a current data row according to the mapping relationship, and further determine real column data corresponding to the table header column index in the current data row, and further obtain the real column data corresponding to each placeholder in the current data row, wherein the target placeholder is any placeholder in the traversed placeholders.
[0121] Optionally, the writing unit is further configured to: check the real column data corresponding to each placeholder in each data row according to the format specification of the standard DBC file; if there is real column data that fails the check, manually adjust the real column data that fails the check, and take the adjusted real column data and the real column data that passes the check as to-be-written data; if there is no real column data that fails the check, take all the real column data that passes the check as to-be-written data; and write the to-be-written data into the DBC file according to the format specification of the standard DBC file.
[0122] Optionally, the writing unit is further configured to output a log of the check failure if there is real column data of the check failure, wherein the log of the check failure comprises a log level, the real column data of the error and an index of the real column data of the error in the Matrix file.
[0123] Optionally, the visual editor for automatically generating the DBC file comprises a menu bar, a toolbar and a work area, the menu bar comprises a config menu and a help menu, the toolbar comprises a run button, and the work area comprises a Matrix file import area, a worktable selection area to be converted and a print area of the log of the check failure.
[0124] Optionally, the obtaining unit is further configured to establish a mapping relationship between the placeholder and the table header index of the table header in a manually configured manner.
[0125] The device provided by the embodiment of the application has the same implementation principle and technical effects as the foregoing method embodiment, and for brevity of description, the part not mentioned in the device embodiment can refer to the corresponding content in the foregoing method embodiment.
[0126] As shown in Figure 7 The embodiment of the application provides an electronic device 600, which comprises a processor 601, a memory 602 and a bus, the memory 602 stores machine readable instructions executable by the processor 601, when the electronic device is running, the processor 601 and the memory 602 communicate through the bus, and the processor 601 executes the machine readable instructions to execute the steps of the method for generating the DBC file.
[0127] Specifically, the memory 602 and the processor 601 can be general memory and processor, which are not specifically limited here, when the processor 601 runs the computer program stored in the memory 602, the method for generating the DBC file can be executed.
[0128] The processor 601 can be an integrated circuit chip having a processing capability of signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit of hardware or the instruction in the form of software in the processor 601. The processor 601 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block diagram disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read only memory, a programmable read only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and combines the hardware to complete the steps of the above method.
[0129] Corresponding to the generation method of the DBC file, the embodiments of the present application further provide a computer readable storage medium, the computer readable storage medium stores computer executable instructions, when the processor calls and runs the computer executable instructions, the computer executable instructions make the processor run the steps of the generation method of the DBC file.
[0130] The generation device of the DBC file provided by the embodiments of the present application can be specific hardware on the device or software or firmware installed on the device. The device provided by the embodiments of the present application has the same implementation principle and technical effects as the foregoing method embodiments. For the sake of brevity, the part of the device embodiment not mentioned in the foregoing method embodiments can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device and unit described above can be referred to the corresponding process in the foregoing method embodiments, which will not be described here.
[0131] In the embodiments of the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. The embodiments described above are merely specific implementation manners of the present application, and for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation; for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, or the among different units, can be indirect couplings or communication connections through some interfaces, communication interfaces, or a combination of other forms, which can be electric, mechanical, or in other forms.
[0132] For another example, the flowcharts and block diagrams in the drawings show the possible implementation architectures, functions and operations of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders from that shown in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and the combination of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0133] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0134] In addition, each functional unit in the embodiments of the present application can be integrated into one processing unit, or each unit can exist physically as a separate unit, or two or more units can be integrated into one unit.
[0135] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts that contribute to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for making an electronic device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the vehicle marking method described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0136] It should be noted that: similar reference numbers and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings, in addition, the terms "first", "second", "third" and the like are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0137] Finally, it should be noted that: the above-described embodiments are only specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, but not to limit them, the protection scope of the present application is not limited thereto, although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art within the technical scope disclosed by the present application can still modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to some technical features thereof; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application. All should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method of generating a DBC file, characterized by, The method applied to a visual editor for automatically generating a DBC file, the method comprises: obtaining a configuration file of a Matrix file output by a project and a worksheet to be converted in the Matrix file, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file; determining real column data corresponding to each of the placeholders in each data row in the worksheet to be converted according to the mapping relationship; writing the real column data corresponding to each of the placeholders in each of the data rows into a DBC file according to a format specification of the standard DBC file; wherein the obtaining of the configuration file of the Matrix file output by the project comprises: analyzing the format specification of the standard DBC file to obtain each attribute contained in the standard DBC file; determining target attributes required by the project from each attribute contained in the standard DBC file, and taking the target attributes as the placeholders; establishing a mapping relationship between the placeholders and table header indexes of table headers in the Matrix file according to the placeholders and the table headers, and thereby obtaining the configuration file; wherein the determining of the real column data corresponding to each of the placeholders in each data row in the worksheet to be converted according to the mapping relationship comprises: determining data rows contained in the worksheet to be converted according to the mapping relationship; iterating through all the data rows to perform the following steps: determining a table header column index corresponding to a target placeholder in a current data row according to the mapping relationship, and thereby determining real column data corresponding to the table header column index in the current data row, and thereby obtaining real column data corresponding to each of the placeholders in the current data row, wherein the target placeholder is any of the placeholders.
2. The method of claim 1, wherein, writing the real column data corresponding to each of the placeholders in each of the data rows into a DBC file according to a format specification of the standard DBC file, comprising: verifying the real column data corresponding to each of the placeholders in each of the data rows according to the format specification of the standard DBC file; if there is real column data that fails the verification, manually adjusting the real column data that fails the verification, and taking the adjusted real column data and real column data that passes the verification as to-be-written data; if there is no real column data that fails the verification, taking all the real column data that passes the verification as the to-be-written data; writing the to-be-written data into the DBC file according to the format specification of the standard DBC file.
3. The method of claim 2, wherein, The method further comprises: if there is real column data that fails the verification, outputting a verification failure log, wherein the verification failure log comprises a log level, error real column data, and an index of the error real column data in the Matrix file.
4. The method of claim 1, wherein, The visual editor for automatically generating a DBC file comprises a menu bar, a toolbar, and a work area; the menu bar comprises a config menu and a help menu; the toolbar comprises a run button; The working area comprises a Matrix file import area, a to-be-converted worksheet selection area and a print area of a log of a verification failure.
5. The method of claim 1, wherein, The mapping relationship between the placeholders and the table header indexes of the table headers is established according to the placeholders and the table headers in the Matrix file, and comprises: The mapping relationship between the placeholders and the table header indexes of the table headers is established by a manual configuration manner.
6. An apparatus for generating a DBC file, characterized by comprising: The device is applied to a visual editor for automatically generating a DBC file, and comprises: An acquisition unit is configured to acquire a configuration file of a Matrix file output by a project and worksheets to be converted in the Matrix file, wherein the configuration file comprises a mapping relationship between placeholders in a standard DBC file and table header indexes in the Matrix file; A determination unit is configured to determine real column data corresponding to each of the placeholders in each data row in the worksheets to be converted according to the mapping relationship; A writing unit is configured to write the real column data corresponding to each of the placeholders in each of the data rows into a DBC file according to a format specification of the standard DBC file; The acquisition unit is further configured to analyze the format specification of the standard DBC file to obtain each attribute contained in the standard DBC file, determine target attributes required by the project from the each attribute contained in the standard DBC file, and take the target attributes as the placeholders; and establish the mapping relationship between the placeholders and the table header indexes of the table headers in the Matrix file according to the placeholders and the table headers in the Matrix file, and thus obtain the configuration file. The determination unit is further configured to determine data rows contained in the worksheets to be converted according to the mapping relationship; and perform the following steps by traversing all the data rows: determine a table header column index corresponding to a target placeholder in a current data row according to the mapping relationship, and thus determine real column data corresponding to the table header column index in the current data row, and thus obtain real column data corresponding to each of the placeholders in the current data row, wherein the target placeholder is any one of the placeholders.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method of any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores machine executable instructions, and when the machine executable instructions are invoked and executed by a processor, the machine executable instructions cause the processor to execute the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Data configuration method, device, server, and storage medium
CN109063181A
DBC file generation method and device based on CAN communication, equipment and medium
CN114780519A