A method and system for automatic generation of an engineering project
By automatically generating database files and based on user configuration parameters, the system automatically generates scripts, panels, and system variable files for engineering projects, solving the problem of low efficiency in engineering project generation in existing technologies and achieving efficient automated construction of engineering projects and adaptation to DBC changes.
Patent Information
- Application Number
- CN202610987807.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-03
- Publication Date
- 2026-08-25
AI Technical Summary
In existing technologies, functional safety testing of vehicle controllers requires manual coding and configuration item by item, which results in time-consuming project setup and inability to reuse across projects, leading to low project generation efficiency. In particular, when iterating vehicle models, all aspects need to be redone, making it impossible to efficiently adapt to DBC changes.
This paper provides a method and system for automatically generating engineering projects. By receiving user configuration parameters, parsing database files, filtering target messages, generating script files, panel files, and system variable files, and automatically associating verification codes with project configuration files, the entire process of automatic generation is achieved.
It achieves fully automated generation of engineering projects, shortens the construction cycle, improves project generation efficiency, and can quickly generate new projects by simply updating configuration parameters, adapting to DBC changes.
Smart Images

Figure CN122633157A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of automotive electronic functional safety testing technology, and in particular to an automatic generation method and system for engineering projects. Background Technology
[0002] Functional safety testing of the vehicle controller requires verification of abnormal responses through fault injection on the CAN bus. This test is based on a CANoe environment and involves channel configuration, node modeling, signal manipulation, and verification recalculation. Frequent changes to the DBC due to vehicle model iterations necessitate synchronous adaptation of the test engineering, making the efficient construction of a reliable environment a critical prerequisite.
[0003] In existing technologies, testers first need to manually create a CANoe project and configure the channel and node parameters. Next, they need to write CAPL scripts for each packet under test to achieve signal reception, tampering, and forwarding. Simultaneously, they need to design controls through a panel and bind system variables to control the injection's start / stop and parameter settings, and define various control variables in the variable editor. Then, for packets with CRC or E2E checksums, a separate checksum algorithm needs to be written and recalculated after tampering. If simulating adversary nodes is required, additional files and configuration functions for the simulated nodes must be created.
[0004] Because existing technologies generate engineering projects through a fully manual, item-by-item coding and configuration process, the construction of engineering projects is time-consuming and cannot be reused across projects. Once a change occurs, all steps must be redone, which greatly affects the efficiency of project generation. Summary of the Invention
[0005] In view of the shortcomings of the prior art, this application provides an automatic generation method and system for engineering projects to solve the problem of low efficiency in project generation.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] The first aspect of this application provides a method for automatically generating engineering projects, including:
[0008] The system receives configuration parameters for the target project input by the user; wherein the configuration parameters include at least the name of the target node, the name of the network where the target node is located, the verification algorithm type, the database file path, and the simulation architecture configuration information.
[0009] The database file is read according to the specified database file path, and the database file is parsed to obtain a parsed file; wherein the parsed file includes at least message information and verification information;
[0010] Based on the name and the network name, the target message corresponding to the target node is filtered out from the message information;
[0011] Select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm;
[0012] Based on the target message, the template engine generates the script file, panel file, and system variable file for the project.
[0013] Based on the simulation architecture configuration information, the corresponding project configuration file is selected from the preset built-in template directory, and the script file, the panel file, the system variable file and the verification code are associated with the project configuration file to generate the project.
[0014] Optionally, in the above-described method for automatically generating engineering projects, parsing the database file to obtain a parsed file includes:
[0015] The database text corresponding to the database file is read using a character encoding algorithm, and the database text is repaired using regular expressions to obtain a repaired file;
[0016] The repaired file is parsed using strict parsing mode;
[0017] If the parsing of the repair file fails, the repair file is re-parsed using a non-strict parsing mode to obtain the target message information and signal information;
[0018] Overlap detection is performed on the bits occupied by each message signal in the target message information, and each message signal with bit overlap is marked to obtain the message information;
[0019] Identify signals containing verification keywords from the signal information as verification signals;
[0020] Extract the start bit, length, and byte position of the verification signal, and extract the data identifier value and sorting information from the annotation of the verification signal to obtain the verification information.
[0021] Optionally, in the above-described method for automatically generating engineering projects, the step of generating the script file for the engineering project using a template engine based on the target message includes:
[0022] The message processing function is used to check the enable status and signal tampering enable status of the target message;
[0023] When the target message passes the check, it is determined whether the target message is allowed to perform signal tampering based on the fault injection mode;
[0024] If the target message allows signal tampering, then the target message is subjected to signal tampering operation according to preset coefficients and offsets, and the check value of the tampered target message is calculated.
[0025] Based on the verification value, the target message is updated, and the updated target message is forwarded to obtain the script file of the project.
[0026] Optionally, in the above-described method for automatically generating engineering projects, the step of generating the panel file of the engineering project using a template engine based on the target message includes:
[0027] Obtain the global parameters set by the user and the signal information in the parsed file, and configure the global setting area according to the global parameters;
[0028] Based on the number of packets in the target message, determine the number of rows in the message enable area, and based on the number of signals in the signal information, determine the tag height;
[0029] Based on the number of rows in the message enable area, a message enable area is set, and based on the tag height, a message signal tampering area is set.
[0030] When the simulation architecture configuration information indicates the generation of simulation nodes, the simulation node control area is set, and the panel file of the project is generated according to the global setting area, the message enable area, the message signal tampering area, and the simulation node control area; wherein, the simulation node control area contains control controls corresponding to each simulation node.
[0031] Optionally, in the above-described method for automatically generating engineering projects, the step of generating the system variable file of the engineering project using a template engine based on the target message includes:
[0032] Under the preset control namespace, set the fault injection master switch variable, duration mode switch variable, frame number mode switch variable, duration variable and frame number variable of the target message;
[0033] Under the preset message namespace, a sub-namespace for the target message is created, and the tampering control variable, coefficient variable, and offset variable of the target message are set in the sub-namespace;
[0034] Under the preset root namespace, set the recording control variables for the target message;
[0035] When the simulation architecture configuration information indicates that simulation nodes should be generated, the node control variables for each simulation node are set under the control namespace.
[0036] Based on the set variables, a variable list is generated, and the variable list is deduplicated using a combination of namespace and variable name as the key to obtain the system variable file of the project.
[0037] Optionally, the above-mentioned method for automatically generating engineering projects also includes:
[0038] When the duration mode switch variable is switched from the off state to the on state, the frame count mode switch variable is set to the off state;
[0039] When the frame count mode switch variable switches from the off state to the on state, the duration mode switch variable is set to the off state; wherein, the duration mode switch variable and the frame count mode switch variable are mutually exclusive, and the duration mode switch variable and the frame count mode switch variable are respectively provided with an edge detection flag, the edge detection flag is used to trigger a mutual exclusion operation when the variable is detected to switch from the off state to the on state.
[0040] Optionally, the above-mentioned method for automatically generating engineering projects also includes:
[0041] When the duration mode switch variable switches from the off state to the on state, a timer start flag is generated, and the timer is started when the first frame of the target message arrives;
[0042] When the timer expires, the duration mode switch variable is set to the off state, and the duration mode flag is cleared;
[0043] When the frame count mode switch variable is switched from the off state to the on state, the number of received frames of the target message is counted, and when the accumulated number of received frames reaches the preset frame count threshold, the frame count mode switch variable is set to the off state and the frame count mode flag is cleared.
[0044] Optionally, in the above-described method for automatically generating engineering projects, the step of selecting the corresponding project configuration file from a preset built-in template directory based on the simulation architecture configuration information includes:
[0045] When the simulation architecture configuration information indicates that no simulation node is generated, the channel mode is determined to be dual-channel mode, and the project configuration file corresponding to the dual-channel mode is selected from the preset built-in template directory;
[0046] When the simulation architecture configuration information indicates the generation of simulation nodes, the channel mode is determined to be a three-channel mode, and a simulation control script file is generated based on each simulation node; wherein, the simulation control script file contains node start control and node stop control logic, and the control variables in the simulation control script file are bound to the corresponding node control variables;
[0047] Select the configuration file corresponding to the three-channel mode from the preset built-in template directory, and add the simulation control script file to the configuration file to obtain the project configuration file.
[0048] Optionally, the above-mentioned method for automatically generating engineering projects also includes:
[0049] Merge the system variable file into the system variable configuration block of the project configuration file, and replace the path in the merged project configuration file with the actual project path;
[0050] Scan all script files in the replaced project configuration file and create blank template files for any script files that have not yet been generated.
[0051] The second aspect of this application provides an automatic project generation system, comprising:
[0052] The receiving unit is used to receive configuration parameters of the target project input by the user; wherein, the configuration parameters include at least the name of the target node, the network name where the target node is located, the verification algorithm type, the database file path, and the simulation architecture configuration information;
[0053] The parsing unit is used to read the database file according to the database file path and parse the database file to obtain a parsed file; wherein the parsed file includes at least message information and verification information;
[0054] The filtering unit is used to filter out the target packets corresponding to the target node from the packet information based on the name and the network name;
[0055] The selection unit is used to select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm;
[0056] The file generation unit is used to generate script files, panel files, and system variable files for the project based on the target message through a template engine.
[0057] The selection unit is used to select the corresponding project configuration file from the preset built-in template directory according to the simulation architecture configuration information, and associate the script file, the panel file, the system variable file and the verification code with the project configuration file to generate the project.
[0058] Optionally, in the above-mentioned automatic generation system for engineering projects, the parsing unit includes:
[0059] The repair unit is used to read the database text corresponding to the database file through a character encoding algorithm, and to repair the database text using regular expressions to obtain a repaired file;
[0060] The repaired file is parsed using strict parsing mode;
[0061] The file parsing unit is used to re-parse the repaired file in a non-strict parsing mode if the parsing of the repaired file fails, so as to obtain the target message information and signal information.
[0062] The detection unit is used to perform overlap detection on the bits occupied by each message signal in the target message information, and to mark each message signal with bit overlap to obtain the message information;
[0063] A signal determination unit is used to identify signals containing verification keywords from the signal information as verification signals;
[0064] The extraction unit is used to extract the start bit, length, and byte position of the verification signal, and to extract the data identifier value and sorting information from the annotation of the verification signal to obtain the verification information.
[0065] Optionally, in the above-mentioned automatic generation system for engineering projects, the document generation unit includes:
[0066] The inspection unit is used to check the enable status and signal tampering enable status of the target message using a message processing function.
[0067] The judgment unit is used to determine whether the target message is allowed to perform signal tampering based on the fault injection mode when the target message passes the inspection.
[0068] The tampering unit is used to perform signal tampering operation on the target message according to a preset coefficient and offset if the target message allows signal tampering, and to calculate the check value of the tampered target message.
[0069] The forwarding unit is used to update the target packet based on the check value and forward the updated target packet to obtain the script file of the project.
[0070] Optionally, in the above-mentioned automatic generation system for engineering projects, the document generation unit includes:
[0071] The configuration unit is used to obtain the global parameters set by the user and the signal information in the parsed file, and configure the global setting area according to the global parameters;
[0072] The determining unit is used to determine the number of rows of the message enable area based on the number of messages in the target message, and to determine the tag height based on the number of signals in the signal information;
[0073] The first setting unit is used to set the message enabling area based on the number of rows of the message enabling area, and to set the message signal tampering area based on the tag height;
[0074] The first generation unit is configured to set a simulation node control area when the simulation architecture configuration information indicates the generation of simulation nodes, and generate a panel file of the project according to the global setting area, the message enable area, the message signal tampering area, and the simulation node control area; wherein, the simulation node control area contains control controls corresponding to each simulation node.
[0075] Optionally, in the above-mentioned automatic generation system for engineering projects, the document generation unit includes:
[0076] The second setting unit is used to set the fault injection master switch variable, duration mode switch variable, frame number mode switch variable, duration variable and frame number variable of the target message under the preset control namespace;
[0077] A creation unit is used to create a sub-namespace of the target message under a preset message namespace, and to set the tampering control variable, coefficient variable and offset variable of the target message in the sub-namespace;
[0078] The third setting unit is used to set the recording control variables of the target message under a preset root namespace;
[0079] The fourth setting unit is used to set the node control variables of each simulation node under the control namespace when the simulation architecture configuration information indicates that simulation nodes are generated;
[0080] The deduplication unit is used to generate a variable list based on the set variables, and to perform deduplication on the variable list using a combination of namespace and variable name as the key to obtain the system variable file of the project.
[0081] Optionally, the above-mentioned automatic generation system for engineering projects also includes:
[0082] The first switching unit is used to set the frame count mode switch variable to the off state when the duration mode switch variable is switched from the off state to the on state.
[0083] The second switching unit is used to set the duration mode switch variable to the off state when the frame count mode switch variable is switched from the off state to the on state; wherein the duration mode switch variable and the frame count mode switch variable are mutually exclusive, and the duration mode switch variable and the frame count mode switch variable are respectively provided with an edge detection flag, the edge detection flag is used to trigger a mutual exclusion operation when the variable is detected to be switched from the off state to the on state.
[0084] Optionally, the above-mentioned automatic generation system for engineering projects also includes:
[0085] The startup unit is used to generate a timer startup flag when the duration mode switch variable is switched from the off state to the on state, and to start the timer when the first frame of the target message arrives;
[0086] The first clearing unit is used to set the duration mode switch variable to the off state and clear the duration mode flag when the timer expires.
[0087] The second clearing unit is used to count the number of received frames of the target message when the frame count mode switch variable is switched from the off state to the on state, and when the accumulated number of received frames reaches a preset frame count threshold, to set the frame count mode switch variable to the off state and clear the frame count mode flag.
[0088] Optionally, in the above-mentioned automatic generation system for engineering projects, the selection unit includes:
[0089] The first mode determination unit is used to determine the channel mode as dual-channel mode when the simulation architecture configuration information indicates that no simulation node is generated, and to select the project configuration file corresponding to the dual-channel mode from the preset built-in template directory.
[0090] The second mode determination unit is used to determine the channel mode as a three-channel mode when the simulation architecture configuration information indicates the generation of simulation nodes, and to generate a simulation control script file based on each simulation node; wherein, the simulation control script file contains node start control and node stop control logic, and the control variables in the simulation control script file are bound to the corresponding node control variables;
[0091] The addition unit is used to select the configuration file corresponding to the three-channel mode from the preset built-in template directory and add the simulation control script file to the configuration file to obtain the project configuration file.
[0092] Optionally, the above-mentioned automatic generation system for engineering projects also includes:
[0093] The merging unit is used to merge the system variable file into the system variable configuration block in the project configuration file, and replace the path in the merged project configuration file with the actual project path.
[0094] The scanning unit is used to scan all script files in the replaced project configuration file and create blank template files for script files that have not yet been generated.
[0095] This application provides an automatic generation method for engineering projects. The method involves receiving configuration parameters of the target project input by a user. These parameters include at least the name of the target node, the network name where the target node resides, the verification algorithm type, the database file path, and simulation architecture configuration information. Next, the method reads the database file according to the database file path and parses it to obtain a parsed file. This parsed file includes at least message information and verification information. Then, based on the name and network name, the method filters the target message corresponding to the target node from the message information. Next, it selects the verification algorithm corresponding to the verification algorithm type from the verification algorithm database and generates verification code based on the verification algorithm. Then, based on the target message, the method generates the project's script file, panel file, and system variable file using a template engine. Finally, based on the simulation architecture configuration information, the method selects the corresponding project configuration file from a preset built-in template directory and associates the script file, panel file, system variable file, and verification code with the project configuration file to generate the engineering project. By parsing the database file and automatically filtering target messages based on user configuration parameters, combined with the template engine to generate script files, panel files and system variable files, and automatically associating the verification code with the project configuration file, the entire process of project generation is automated. There is no need for manual coding and configuration item by item, which greatly shortens the project construction cycle. Moreover, when the database file changes, only the configuration parameters need to be updated to quickly generate a new project, which significantly improves the efficiency of project generation. Attached Figure Description
[0096] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0097] Figure 1 An architecture diagram of an automatic project generation system provided in this application embodiment;
[0098] Figure 2 A flowchart illustrating an automatic project generation method provided in this application embodiment;
[0099] Figure 3 A flowchart illustrating a database file parsing method provided in another embodiment of this application;
[0100] Figure 4 A flowchart illustrating a method for generating a script file according to another embodiment of this application;
[0101] Figure 5 A flowchart illustrating a method for generating a panel file according to another embodiment of this application;
[0102] Figure 6 A flowchart illustrating a method for generating a system variable file, provided in another embodiment of this application;
[0103] Figure 7 This is a schematic diagram of the structure of an automatic project generation system provided in another embodiment of this application. Detailed Implementation
[0104] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0105] In this application, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0106] This application provides an automatic project generation method, which is applied to an automatic project generation system to solve the problem of low project generation efficiency caused by manual item-by-item coding and configuration in the prior art.
[0107] It should be noted that the automatic project generation system parses database files and, based on user configuration parameters, automatically generates script files, panel files, and system variable files using a template engine. It also automatically associates validation codes with project configuration files, thereby achieving fully automated generation of project workflows.
[0108] Optionally, such as Figure 1 As shown in the figure, this application provides an architecture diagram of an automatic project generation system. Figure 1 It includes: GUI interaction module, DBC file parsing module, CAPL code auto-generation module, panel file auto-generation module, system variable auto-generation module, CRC check code generation module, and CANoe project configuration assembly module.
[0109] The GUI interaction module is used to receive configuration parameters input by the user and perform input validation.
[0110] The DBC file parsing module is used to read the database file according to the database file path, and parse the database file to obtain message information, signal information and check information.
[0111] The CAPL code auto-generation module is used to automatically generate script files based on the template engine, according to the configuration parameters and the parsed message and signal information.
[0112] The panel file automatic generation module is used to automatically generate panel files based on the parsed message and signal information.
[0113] The automatic system variable generation module is used to automatically generate system variable files based on the parsed message and signal information.
[0114] The CRC check code generation module is used to automatically generate check code files based on the check algorithm type in the configuration parameters and the parsed check information.
[0115] The CANoe project configuration assembly module is used to determine the channel mode based on the simulation architecture configuration information, copy the corresponding channel mode's project configuration file template from the built-in template directory, associate the generated files with the project configuration file, and output a complete project.
[0116] Based on the system architecture described above, the embodiments of this application provide a method for automatically generating engineering projects, such as... Figure 2 As shown, the specific steps include:
[0117] S201. Receive the configuration parameters of the target project input by the user.
[0118] The configuration parameters include at least the name of the target node, the name of the network where the target node is located, the verification algorithm type, the database file path, and the simulation architecture configuration information.
[0119] It should be noted that the target node name refers to the node name of the device under test in the DBC database file. This name must be exactly the same as the definition in the DBC file and is case-sensitive. Multiple nodes are supported, separated by commas. The network name (Networks) of the target node is used to determine the CAN network channel where the target message is located. The verification algorithm type is used to generate the corresponding CRC or E2E check code. Users can choose from three algorithms: CRC8, CRC16, and XOR. The database file path (DBC file path) is specified by the user through the file selection dialog box, specifying a local .dbc file. The simulation architecture configuration information is used to control whether to generate a three-channel project that includes simulation nodes.
[0120] Optionally, the system provides a graphical configuration interface where users can input relevant information and click the generate button. The GUI module will validate the user input; if any required field is empty, an error message will pop up. After successful validation, the parameters will be passed to subsequent modules. The GUI interaction module is implemented using Python tkinter.
[0121] S202. Read the database file according to the database file path, and parse the database file to obtain the parsed file.
[0122] The parsed file may include message information, checksum information, and signal information.
[0123] Specifically, the database file (DBC file) is parsed through the DBC file parsing module. The parsing methods include: DBC compatibility parsing, signal bit overlap detection, CRC / Checksum signal identification, and E2E check information collection, thereby obtaining the parsed file.
[0124] Optionally, in another embodiment of this application, one specific implementation of step S202 is as follows: Figure 3 As shown, the specific steps include:
[0125] S301. Read the database text corresponding to the database file through a character encoding algorithm, and perform regular expression repair on the database text to obtain the repaired file.
[0126] It should be noted that, due to the differences in the format of DBC files provided by different vendors, a multi-level compatibility parsing strategy is adopted in this application. Specifically, firstly, multiple character encodings (including utf-8-sig, utf-8, gbk, cp1252, and latin-1) are tried to read the DBC file content to resolve encoding compatibility issues. Then, regular expression repair is performed on the read DBC text to add quotes to the STRING type BA_ attribute values (such as GenSigStartRemark and GenSigEvent) that are not enclosed, making them conform to the requirements of subsequent parsing tools.
[0127] S302. Use strict parsing mode to parse the repair file.
[0128] Specifically, strict parsing mode refers to the strict mode. In strict mode, the parser performs rigorous checks on the syntax and attribute integrity of the database file, requiring all signal definitions to fully reference their corresponding attributes (such as start bit, length, byte order, etc.), and that each attribute value must conform to the format specification. This mode can effectively identify non-standard or redundant definitions in the database file, ensuring the quality of the parsing results.
[0129] S303. Determine whether the repaired file was successfully parsed.
[0130] It should be noted that if an UnsupportedDatabaseFormatError exception is thrown during strict mode parsing, it means that the parsing of the repair file has failed, i.e., step S304 should be executed.
[0131] Optionally, if no UnsupportedDatabaseFormatError exception is thrown during strict mode parsing, it indicates that the repair file parsing was successful, the target message information and signal information are obtained, and then step S305 is executed.
[0132] S304. The repaired file is re-parsed using a non-strict parsing mode to obtain the target message information and signal information.
[0133] Specifically, when parsing a patch file fails, the strict mode is downgraded to non-strict mode to re-parse the patch file, thereby ensuring compatibility with DBC files of different formats.
[0134] S305. Perform overlap detection on the bits occupied by each message signal in the target message information, and mark each message signal with bit overlap to obtain the message information.
[0135] It should be noted that signal bit overlap detection is performed bit-by-bit according to the signal tree structure of cantools. Specifically, a bitmap array is constructed for each message signal in the target message information, with an array length of 8 times the message byte length. Then, the signal tree (which supports multiplexed signals) is recursively traversed, and the bit range of each message signal is filled into the bitmap. If a bit is already occupied by another signal, both signals are marked as overlapping signals. Marked overlapping signals will be excluded from the subsequent generation process of system variables, panels, and script files, and a warning message will pop up after generation, thereby avoiding the generation of incorrect code.
[0136] S306. Identify signals containing verification keywords from the signal information as verification signals.
[0137] It should be noted that the verification keywords include "crc" or "checksum". The system automatically identifies signals whose names contain the above keywords as verification signals.
[0138] S307. Extract the start bit, length, and byte position of the check signal, and extract the data identifier value and sorting information from the annotation of the check signal to obtain the check information.
[0139] It should be noted that after obtaining the check signal, it is also necessary to extract its start bit, length, and byte position, etc., for subsequent CRC check code generation. Next, for E2E Profile 1 type messages, it is also necessary to extract the E2E_Order sorting information from the check signal annotation, extract the DataID value from the Checksum signal annotation, identify the Counter signal, and calculate the start bit and length of each signal. The information extracted above together constitutes the check information.
[0140] S203. Based on the name and network name, filter out the target message corresponding to the target node from the message information.
[0141] Specifically, each message is iterated through from the message information, and it is determined whether the receiving node of the message matches the target node name entered by the user, and whether the network to which the message belongs matches the network name entered by the user. When both conditions are met, the message is marked as a target message. If the target node supports multiple nodes separated by commas, then any matching node name is considered to meet the conditions.
[0142] S204. Select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm.
[0143] It should be noted that the verification algorithms supported in this application include CRC8 (SAE J1850, polynomial 0x1D, initial value 0xFF, output XOR 0xFF), CRC16 (polynomial 0x1021, initial value 0xFFFF, output XOR 0x0000), XOR checksum (summing all bytes and then inverting), E2E Profile1, E2E Profile2, and E2E Profile5, totaling six algorithms. The system only generates the code corresponding to the verification algorithm actually referenced by the message in the database file, avoiding the generation of redundant code.
[0144] Specifically, for the CRC8 (SAE J1850) algorithm, the polynomial is 0x1D, the initial value is 0xFF, and the output XOR value is 0xFF. During calculation, each byte of the message is processed sequentially, with 8 bit iterations within each byte, i.e., performing XOR and shift operations bit by bit. This initial value and output XOR configuration ensures that the check result of a zero-byte message is not zero, thus enabling the detection of all-zero messages.
[0145] For the CRC16 algorithm, the polynomial is 0x1021, the initial value is 0xFFFF, and the output XOR value is 0x0000. The calculation is performed bit-by-bit, meaning each bit of the message is XORed and shifted sequentially, rather than byte-by-byte. This configuration can cover all bits in the message and is suitable for verifying short CAN messages.
[0146] The XOR checksum algorithm calculates the checksum by performing a bitwise XOR operation on each byte of data in the message and accumulating the results. Then, the result is inverted bit by bit to obtain the final checksum. This checksum method is simple to implement and suitable for messages with high real-time requirements and low error detection requirements.
[0147] For the E2E Profile1 algorithm, the checksum generation process includes: extracting each signal value sequentially according to the E2E_Order order; calculating the padding bits and filling them into the signal group buffer bit by bit; selecting the high and low bytes of DataID based on the parity of the Counter signal; and combining DataID, the signal group buffer, and Counter to calculate the CRC8 checksum (polynomial 0x1D, initial value 0x00, output XOR 0x00).
[0148] For the E2E Profile2 algorithm, CRC8 is used for calculation, with a polynomial of 0x2F and an initial value of 0xFF. The result is then inverted bit by bit. For the E2E Profile5 algorithm, CRC16 is used for calculation, with a polynomial of 0x1021 and an initial value of 0xFFFF. The high and low bytes of DataID are appended to the end of the data before calculation.
[0149] For messages containing CRC or Checksum signals, after tampering with the non-checksum signal, the system extracts the data byte based on the byte position of the CRC signal and calls the corresponding CRC algorithm function to recalculate the checksum value. The CRC signal itself is modified only after recalculation to ensure consistency of internal message verification. The system supports both consecutive and non-consecutive CRC signal positions at the end of the message.
[0150] S205. Based on the target message, generate the project's script files, panel files, and system variable files using the template engine.
[0151] Specifically, the script file generates CAPL code based on the Jinja2 template, which includes message processing, fault injection control, and CRC check recalculation.
[0152] The panel file uses a dynamic layout algorithm to generate an XML structure panel, which includes message enable, global settings and signal tampering controls, and binds the corresponding system variables.
[0153] The system variable file generates various control variables according to the control namespace, message namespace and root namespace and removes duplicates. The three types of files maintain binding consistency through a unified variable naming system.
[0154] Optionally, in another embodiment of this application, a specific implementation of step S205, which generates a script file for the project based on the target message using a template engine, is as follows: Figure 4 As shown, the specific steps include:
[0155] S401. Use message processing functions to check the enable status and signal tampering enable status of the target message.
[0156] It should be noted that the CAPL code auto-generation module is implemented based on the Jinja2 template engine. The generated script file (Gateway.can) contains the message handling function corresponding to the target message. In the message handling function, the message direction is first checked (only messages in the receiving direction are processed), then the enable / disable state of the message is checked, and whether any signals need to be tampered with.
[0157] S402. When the target message passes the inspection, determine whether the target message is allowed to be tampered with based on the fault injection mode.
[0158] It should be noted that the fault injection modes include three types: manual mode, duration-based mode, and frame-based mode. The system calculates the allowTamper flag based on the currently active mode to determine whether the target packet is allowed to perform signal tampering operations. When it is determined that the target packet is allowed to perform signal tampering operations, step S403 is executed.
[0159] Optionally, when it is determined that the target message is not allowed to perform signal tampering operations, the target message is forwarded back to the CAN1 channel, which is the source channel.
[0160] S403. Perform signal tampering operation on the target message according to the preset coefficients and offsets, and calculate the check value of the tampered target message.
[0161] It should be noted that when the target message allows signal tampering, the signal tampering is performed using a factor plus offset method, that is, the tampering formula is: phys_new=Factor×phys_orig+Offset.
[0162] Where `phys_orig` is the original physical value of the signal, `Factor` is the tampering coefficient (default value is 1, meaning the signal value is not changed), and `Offset` is the tampering offset (default value is 0, meaning the signal value is not offset). The advantages of this tampering method are: when the coefficient is 0 and the offset is a fixed value, the signal can be forced to a specific value; when the coefficient is -1 and the offset is 0, the signal value can be inverted; when the coefficient is 1 and the offset is positive, a fixed offset can be added; and when the coefficient is greater than 1, the signal value can be amplified.
[0163] S404. Based on the checksum, update the target message and forward the updated target message to obtain the script file for the project.
[0164] It should be noted that the obtained checksum is used to update the target message, and the updated target message is directly forwarded to the target channel in the message processing function. Other messages that are not processed separately are forwarded through the wildcard processor, where messages from the source channel are forwarded to the target channel, and messages from the target channel are forwarded back to the source channel (without being tampered with).
[0165] Optionally, in another embodiment of this application, a specific implementation of step S205, which generates a panel file for the project based on the target message using a template engine, is as follows: Figure 5 As shown, the specific steps include:
[0166] S501: Obtain the global parameters set by the user and the signal information in the parsing file, and configure the global setting area according to the global parameters.
[0167] It should be noted that the global settings area includes global parameters such as the Logging switch, the overall fault injection switch, fault injection by duration (including the duration input box), and fault injection by frame count (including the frame count input box). Users can configure these global parameters in a file titled "Global Settings" within the GroupBox container.
[0168] The Logging switch consists of an LED control and a static text label.
[0169] Start fault injection: CheckBox, bound to FaultInject_Start.
[0170] Inject faults by duration: CheckBox + TextBox (duration / ms), bound to FaultInject_ByDuration and FaultInject_DurationMs.
[0171] Inject faults by frame: CheckBox + TextBox (frame number), bind FaultInject_ByFrameCount and FaultInject_FrameCount.
[0172] S502. Determine the number of rows in the message enable area based on the number of messages in the target message, and determine the tag height based on the number of signals in the signal information.
[0173] Specifically, the panel employs a dynamic layout algorithm, the core of which lies in automatically adapting the control layout based on the number of target messages and signals. Therefore, the layout parameters must be calculated before generating the specific controls. Optionally, the message enable area uses a grid layout, with each message corresponding to a checkbox control, arranged in 6 columns and automatically wrapping. Therefore, the required number of rows for this area is determined by dividing the total number of messages by 6 and rounding up. The number of rows determines the vertical space occupied by this area in the panel. The tab height is determined by the number of signals contained in the current message—the more signals, the greater the required tab height—the system calculates the appropriate height for the tab based on the number of signals. These two parameters are key inputs to the dynamic layout.
[0174] S503. Based on the number of rows in the message enable area, set the message enable area, and based on the tag height, set the message signal tampering area.
[0175] It should be noted that the message enable area (Enable Tx of Msg) uses a GroupBox container with the title "Enable Tx of Msg". Each message ID corresponds to a CheckBox control, which uses a 6-column grid layout with automatic line wrapping, and is bound to the Msg_XXX system variable under the IL_Control namespace. It is checked by default (indicating forwarding), and unchecked will intercept the message.
[0176] The message signal tampering area uses TabControl labels, with each signal corresponding to a row of controls:
[0177] -CheckBox: Signal tampering switch, bound to msg::msg_XXX::SignalName_Ctrl- TextBox.
[0178] (Factor): The coefficient input, bound to msg::msg_XXX::SignalName_factor-TextBox.
[0179] (Offset): Offset input, bound to msg::msg_XXX::SignalName_offset.
[0180] S504. When the simulation architecture configuration information indicates the generation of simulation nodes, set the simulation node control area, and generate the panel file of the project according to the global setting area, message enable area, message signal tampering area and simulation node control area.
[0181] The simulation node control area contains the control controls corresponding to each simulation node.
[0182] It should be noted that when the simulation architecture configuration information indicates the generation of simulation nodes, that is, in three-channel mode, the simulation node control area is set. This area uses a GroupBox container, titled "Simulation Node", with each sending node corresponding to a CheckBox control. It adopts a 3-column grid layout with automatic line wrapping and is bound to the Node_XXX system variable under the IL_Control namespace.
[0183] It should also be noted that the panel file automatic generation module builds the CANoe panel XML structure based on xml.etree.ElementTree and generates the CANTamper.xvp panel file.
[0184] Optionally, in another embodiment of this application, a specific implementation of step S205, which generates a system variable file for the project based on the target message using a template engine, is as follows: Figure 6 As shown, the specific steps include:
[0185] S601. Under the preset control namespace, set the fault injection master switch variable, duration mode switch variable, frame number mode switch variable, duration variable, and frame number variable for the target message.
[0186] It should be noted that the control namespace is IL_Control. Under this namespace, a Msg_XXX packet enable control variable is generated for each target packet. This variable has an On_Off / Invalid value table, and the initial value is 1 (indicating forwarding enabled).
[0187] FaultInject_Start: The main switch variable for fault injection, with an initial value of 0.
[0188] FaultInject_ByDuration: A variable to toggle the duration mode; initial value is 0.
[0189] FaultInject_ByFrameCount: A variable that toggles frame-by-frame mode; initial value is 0.
[0190] FaultInject_DurationMs: Fault injection duration (ms) (duration variable), range 1~6000000, initial value 1000.
[0191] FaultInject_FrameCount: Number of frames injected due to fault (frame count variable), ranging from 1 to 1,000,000, with an initial value of 10.
[0192] S602. Under the preset message namespace, create a sub-namespace for the target message, and set the tamper control variable, coefficient variable and offset variable of the target message in the sub-namespace.
[0193] It should be noted that the message namespace is msg. Each target message corresponds to a msg_XXX sub-namespace. In each sub-namespace, three variables are generated for each signal: SignalName_Ctrl (signal tampering control switch, initial value is 0, indicating no tampering), SignalName_factor (tampering coefficient, initial value is 1), and SignalName_offset (tampering offset, initial value is 0).
[0194] S603. Under the preset root namespace, set the recording control variables for the target message.
[0195] Specifically, Logging: records control variables with an On_Off value table, initialized to 0.
[0196] S604. When the simulation architecture configuration information indicates that simulation nodes should be generated, set the node control variables for each simulation node under the control namespace.
[0197] It should be noted that when the simulation architecture configuration information indicates that simulation nodes are generated, a Node_XXX node control variable is generated for each simulation node under the IL_Control namespace, with an On_Off / Invalid value table, and the initial value is 1 (indicating that the node is enabled).
[0198] S605. Based on the set variables, generate a variable list, and use the combination of namespace and variable name as the key to remove duplicates from the variable list, thus obtaining the system variable file of the project.
[0199] It should be noted that the system variable automatic generation module generates the .vsysvar system variable file based on the Jinja2 template engine. Before generation, the variable list is deduplicated, using (namespace, name) as the key to ensure that the same variable is not defined repeatedly. The variable list consists of the variables described in steps S601 to S604 above.
[0200] Optionally, in another embodiment of this application, mutual exclusion control logic for three fault injection modes (manual mode, duration-based mode, and frame-based mode) is designed. Duration-based mode and frame-based mode are mutually exclusive, with only one mode active at a time. Mutual exclusion control is implemented through an edge detection mechanism, where each mode maintains a "seen" flag, and mutual exclusion is performed only on the rising edge when the system variable value changes from 0 to 1. Therefore, another embodiment of this application also provides a method for mutual exclusion control of fault injection modes, specifically including the following processes A1-A2:
[0201] A1: When the long mode switch variable is switched from the off state to the on state, the frame rate mode switch variable is set to the off state.
[0202] Specifically, when the duration mode switch variable changes from 0 (off) to 1 (on), the system automatically sets the frame count mode switch variable to 0 (off). The purpose of this operation is to force the system to cancel the frame count mode when the user selects to inject faults based on duration, ensuring that the two automatic injection modes based on time or quantity do not run simultaneously.
[0203] A2: When the frame rate mode switch variable is switched from off to on, the duration mode switch variable is set to off.
[0204] Among them, the duration mode switch variable and the frame number mode switch variable are mutually exclusive, and the duration mode switch variable and the frame number mode switch variable are respectively equipped with edge detection flags. The edge detection flags are used to trigger a mutual exclusion operation when the variable is detected to switch from the off state to the on state.
[0205] Specifically, when the frame rate mode switch variable is switched from 0 to 1, the system automatically sets the duration mode switch variable to 0.
[0206] It's important to note that the duration mode switch variable and the frame count mode switch variable are mutually exclusive; that is, they cannot both be 1 at the same time. To achieve reliable mutual exclusion control, each switch variable has an edge detection flag (faultInjByDurSeen and faultInjByFcSeen), which records the previous state of the variable. The system triggers the mutual exclusion operation only when it detects a rising edge of the variable value changing from 0 to 1—that is, it sets the other mode switch variable to 0. If the variable value remains unchanged (e.g., the same value is rewritten when the panel refreshes), the system will not trigger the mutual exclusion operation again because the Seen flag is equal to the current value. This mechanism solves the race condition problem caused by panel refresh: when the panel refreshes, the system variable value bound to the control does not actually change, but the refresh operation may rewrite the variable value. Without edge detection, the system may repeatedly execute the mutual exclusion operation when the variable value has not changed, leading to abnormal states. Through edge detection, the system only executes mutual exclusion when the user actively switches modes, avoiding interference from panel refresh on the mode state.
[0207] Optionally, in another embodiment of this application, when generating the script file of the project through the template engine in step S205, a specific implementation of configuring the mutual exclusion control logic of the fault injection mode in the script file is also included, specifically comprising the following processes B1-B3:
[0208] B1: When the long-mode switch variable switches from the off state to the on state, a timer start flag is generated, and the timer is started when the first frame of the target message arrives.
[0209] Specifically, when the user switches the duration mode switch variable from 0 (off state) to 1 (on state) via the panel, the system does not directly start the timer. Instead, it first generates a timer start flag (i.e., sets the Ready flag to 1). Subsequently, in the message processing function of the CAPL code, when the first eligible message (i.e., the target message whose state is on and whose signal needs to be tampered with) is received, if the Ready flag is detected to be 1, the timer is started and the Ready flag is cleared. This scheme uses the Ready flag as an intermediate state to avoid timing races between system variable updates and message reception—if the timer is started directly when the system variable is updated, the timer's start point may deviate from the user's expectations, leading to a decrease in duration control accuracy.
[0210] B2: When the timer expires, set the duration mode switch variable to the off state and clear the duration mode flag.
[0211] Specifically, after the started timer reaches its preset duration (specified by the FaultInject_DurationMs system variable), the timer expiration handling function is triggered. This function performs the following operations: sets the duration mode switch variable to 0 (off state), clears the duration mode flag, and cancels the timer's running state. Simultaneously, it clears all tampering control variables corresponding to signals (i.e., sets each SignalName_Ctrl variable to 0), causing the system to exit the fault injection state and preventing signals from being continuously tampered with due to residual tampering control variables after the duration expires.
[0212] B3: When the frame count mode switch variable is switched from the off state to the on state, the number of received frames of the target message is counted, and when the cumulative number of received frames reaches the preset frame count threshold, the frame count mode switch variable is set to the off state and the frame count mode flag is cleared.
[0213] When the frame count mode switch variable changes from 0 (off) to 1 (on), unlike duration mode, frame count mode does not rely on a timer but is controlled by a frame counter. Specifically, the system maintains a frame counter (faultInjFramesLeft_XXX) for each target packet and counts the frames each time the packet is received. When the cumulative number of received frames reaches the preset frame count threshold (specified by the FaultInject_FrameCount system variable), the system sets the frame count mode switch variable to 0 (off), clears the frame count mode flag, and simultaneously clears all tampered control variables corresponding to the signals, causing the system to exit the fault injection state of frame count mode. Frame count mode and duration mode are mutually exclusive (see processes A1 and A2 above), therefore, when the frame count mode switch is set to off, the duration mode switch variable is unaffected.
[0214] S206. Based on the simulation architecture configuration information, select the corresponding project configuration file from the preset built-in template directory, and associate the script file, panel file, system variable file and verification code with the project configuration file to generate the project.
[0215] It should be noted that the CANoe project configuration assembly module first creates a standardized project directory structure, including: 00_database / (for storing database files), 01_capl / (for storing script files), 02_panel / (for storing panel files), and 03_sysvar / (for storing system variable files). Then, based on the simulation architecture configuration information, it copies the corresponding configuration file template from the built-in template directory and associates the generated script files, panel files, system variable files, and verification code with the configuration file template to obtain a complete project.
[0216] Optionally, in another embodiment of this application, a specific implementation of step S206, which involves selecting the corresponding project configuration file from a preset built-in template directory based on the simulation architecture configuration information, specifically includes the following processes C1-C3:
[0217] C1: When the simulation architecture configuration information indicates that no simulation node is generated, the channel mode is determined to be dual-channel mode, and the corresponding project configuration file for dual-channel mode is selected from the preset built-in template directory.
[0218] It should be noted that the channel mode is determined based on whether the user generates simulation nodes in the graphical configuration interface. Specifically, when the simulation architecture configuration information indicates that no simulation nodes should be generated, the channel mode is determined to be dual-channel mode. Dual-channel mode copies the can_fault_injection template, including configuration files such as cfg, stcfg, and cfg.ini. Dual-channel mode is used to insert the tool between the actual vehicle and the test part for data manipulation.
[0219] C2: When the simulation architecture configuration information indicates the generation of simulation nodes, determine the channel mode as three-channel mode, and generate simulation control script files based on each simulation node.
[0220] The simulation control script file contains node start control and node stop control logic, and the control variables in the simulation control script file are bound to the corresponding node control variables.
[0221] It should be noted that when the simulation architecture configuration information indicates the generation of simulation nodes, the channel mode is determined to be three-channel mode. The three-channel mode copies the `can_fault_injection_simulation` template, including configuration files such as `cfg`, `stcfg`, `ini`, and `xpa`. In the three-channel mode, additional simulations are performed to send messages to the device node in scenarios without a real vehicle. The simulation control script file contains the `ILNodeControlStart` and `ILNodeControlStop` control logic and binds update callbacks for the `IL_Control::Node_XXX` system variables.
[0222] C3: Select the configuration file corresponding to the three-channel mode from the preset built-in template directory, and add the simulation control script file to the configuration file to obtain the project configuration file.
[0223] Specifically, first copy the CANoe configuration template (including cfg, stcfg, ini, and xpa files) corresponding to the three-channel mode. Then, write the reference information of the simulation control script file corresponding to each simulation node into the script file reference list of the cfg main configuration file, so that all simulation control scripts can be loaded together when the configuration file is loaded, and finally form a three-channel mode project configuration file that can be directly loaded and run by CANoe.
[0224] Optionally, in another embodiment of this application, a post-processing method for engineering configuration assembly is further included after step S206, specifically including the following processes D1-D2:
[0225] D1: Merge the system variable files into the system variable configuration block of the project configuration file, and replace the paths in the merged project configuration file with the actual project paths.
[0226] It should be noted that the contents of the generated sysvar.vsysvar file (system variable file) are merged into the VSVConfigurationStreamer embedded XML block in the CANoe configuration file to ensure that the panel and CAPL can parse the same set of system variable definitions.
[0227] The system variable merging process includes: reading the VSVConfigurationStreamer block from the cfg file, replacing the old embedded XML with the newly generated system variable file content, updating the byte length marker, and then writing it back to the cfg file. Path reference corrections include replacing the template path GW.can with 01_capl\Gateway.can, Sysvars.vsysvar with 03_sysvar\sysvar.vsysvar, and CANTamper.xvp with 02_panel\CANTamper.xvp.
[0228] D2: Scan all script files in the replaced project configuration file and create blank template files for script files that have not yet been generated.
[0229] It should be noted that scanning all .can files (script files) referenced in the cfg file (the replaced project configuration file) creates blank script template files for those that have not yet been generated, thus avoiding errors during loading.
[0230] This application provides an automatic generation method for engineering projects. The method involves receiving configuration parameters of the target project input by a user. These parameters include at least the name of the target node, the network name where the target node resides, the verification algorithm type, the database file path, and simulation architecture configuration information. Next, the method reads the database file according to the database file path and parses it to obtain a parsed file. This parsed file includes at least message information and verification information. Then, based on the name and network name, the method filters the target message corresponding to the target node from the message information. Next, it selects the verification algorithm corresponding to the verification algorithm type from the verification algorithm database and generates verification code based on the verification algorithm. Then, based on the target message, the method generates the project's script file, panel file, and system variable file using a template engine. Finally, based on the simulation architecture configuration information, the method selects the corresponding project configuration file from a preset built-in template directory and associates the script file, panel file, system variable file, and verification code with the project configuration file to generate the engineering project. By parsing the database file and automatically filtering target messages based on user configuration parameters, combined with the template engine to generate script files, panel files and system variable files, and automatically associating the verification code with the project configuration file, the entire process of project generation is automated. There is no need for manual coding and configuration item by item, which greatly shortens the project construction cycle. Moreover, when the database file changes, only the configuration parameters need to be updated to quickly generate a new project, which significantly improves the efficiency of project generation.
[0231] Another embodiment of this application provides an automatic project generation system, such as... Figure 7 As shown, it specifically includes the following units:
[0232] The receiving unit 701 is used to receive configuration parameters of the target project input by the user. These configuration parameters include at least the name of the target node, the name of the network where the target node resides, the verification algorithm type, the database file path, and the simulation architecture configuration information.
[0233] The parsing unit 702 is used to read the database file according to the database file path and parse the database file to obtain a parsed file. The parsed file includes at least message information and verification information.
[0234] The filtering unit 703 is used to filter out the target packets corresponding to the target node from the packet information based on the name and network name.
[0235] Selection unit 704 is used to select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm.
[0236] The file generation unit 705 is used to generate script files, panel files, and system variable files for the project based on the target message using a template engine.
[0237] Unit 706 is selected to select the corresponding project configuration file from the preset built-in template directory according to the simulation architecture configuration information, and associate the script file, panel file, system variable file and verification code with the project configuration file to generate the project.
[0238] It should be noted that the specific working process of the above modules in the embodiments of this application can be referred to steps S201 to S206 in the above method embodiments, and will not be repeated here.
[0239] Optionally, in another embodiment of this application, an automatic project generation system includes a parsing unit 702, comprising:
[0240] The repair unit is used to read the database text corresponding to the database file through a character encoding algorithm, and to repair the database text using regular expressions to obtain a repaired file.
[0241] The repair file is parsed using a strict parsing mode.
[0242] The file parsing unit is used to re-parse the repaired file in a non-strict parsing mode if the repaired file parsing fails, so as to obtain the target message information and signal information.
[0243] The detection unit is used to detect the overlap of bits occupied by each message signal in the target message information, and to mark each message signal with bit overlap to obtain the message information.
[0244] The signal determination unit is used to identify signals containing verification keywords from signal information as verification signals.
[0245] The extraction unit is used to extract the start bit, length, and byte position of the verification signal, and to extract the data identifier value and sorting information from the annotation of the verification signal to obtain the verification information.
[0246] Optionally, in another embodiment of this application, an automatic project generation system includes a document generation unit 705 comprising:
[0247] The inspection unit is used to check the enable status and signal tampering enable status of the target message using message processing functions.
[0248] The judgment unit is used to determine whether the target message is allowed to be tampered with, based on the fault injection mode, when the target message passes the inspection.
[0249] The tampering unit is used to perform signal tampering on the target message according to preset coefficients and offsets if the target message allows signal tampering, and to calculate the check value of the tampered target message.
[0250] The forwarding unit is used to update the target message based on the checksum and forward the updated target message to obtain the script file of the project.
[0251] Optionally, in another embodiment of this application, an automatic project generation system includes a document generation unit 705 comprising:
[0252] The configuration unit is used to obtain the global parameters set by the user and the signal information in the parsed file, and configure the global setting area according to the global parameters.
[0253] The determination unit is used to determine the number of rows of the message enable area based on the number of messages in the target message, and to determine the tag height based on the number of signals in the signal information.
[0254] The first setting unit is used to set the message enable area based on the number of rows of the message enable area, and to set the message signal tampering area based on the tag height.
[0255] The first generation unit is used to set the simulation node control area when the simulation architecture configuration information indicates that simulation nodes should be generated, and to generate the panel file of the project based on the global setting area, message enable area, message signal tampering area, and simulation node control area. The simulation node control area contains the control controls corresponding to each simulation node.
[0256] Optionally, in another embodiment of this application, an automatic project generation system includes a document generation unit 705 comprising:
[0257] The second setting unit is used to set the fault injection master switch variable, duration mode switch variable, frame number mode switch variable, duration variable, and frame number variable of the target message under the preset control namespace.
[0258] The creation unit is used to create a sub-namespace of the target message under the preset message namespace, and to set the tamper control variables, coefficient variables and offset variables of the target message in the sub-namespace.
[0259] The third setting unit is used to set the recording control variables of the target message under the preset root namespace.
[0260] The fourth setting unit is used to set the node control variables of each simulation node under the control namespace when the simulation architecture configuration information indicates that simulation nodes should be generated.
[0261] The deduplication unit is used to generate a variable list based on the set variables, and to deduplicate the variable list using a combination of namespace and variable name as the key, thus obtaining the system variable file of the project.
[0262] Optionally, another embodiment of this application provides an automatic project generation system that further includes:
[0263] The first switching unit is used to set the frame count mode switch variable to the off state when the time mode switch variable is switched from the off state to the on state.
[0264] The second switching unit is used to set the duration mode switch variable to the off state when the frame count mode switch variable switches from the off state to the on state. The duration mode switch variable and the frame count mode switch variable are mutually exclusive, and both are equipped with edge detection flags. The edge detection flags are used to trigger a mutual exclusion operation when a switch from the off state to the on state is detected.
[0265] Optionally, another embodiment of this application provides an automatic project generation system that further includes:
[0266] The startup unit is used to generate a timer start flag when the long-time mode switch variable switches from the off state to the on state, and to start the timer when the first frame of the target message arrives.
[0267] The first clearing unit is used to set the duration mode switch variable to the off state and clear the duration mode flag when the timer expires.
[0268] The second clearing unit is used to count the number of received frames of the target message when the frame count mode switch variable is switched from the off state to the on state, and when the accumulated number of received frames reaches the preset frame count threshold, to set the frame count mode switch variable to the off state and clear the frame count mode flag.
[0269] Optionally, in another embodiment of the present application, in an automatic project generation system, unit 706 includes:
[0270] The first mode determination unit is used to determine the channel mode as dual-channel mode when the simulation architecture configuration information indicates that no simulation node is generated, and to select the project configuration file corresponding to the dual-channel mode from the preset built-in template directory.
[0271] The second mode determination unit is used to determine the channel mode as a three-channel mode when the simulation architecture configuration information indicates the generation of simulation nodes, and to generate a simulation control script file based on each simulation node. The simulation control script file contains node start control and node stop control logic, and the control variables in the simulation control script file are bound to the corresponding node control variables.
[0272] The Add Unit is used to select the configuration file corresponding to the three-channel mode from the preset built-in template directory and add the simulation control script file to the configuration file to obtain the project configuration file.
[0273] Optionally, another embodiment of this application provides an automatic project generation system that further includes:
[0274] The merge unit is used to merge system variable files into the system variable configuration block in the project configuration file, and replace the path in the merged project configuration file with the actual project path.
[0275] The scanning unit is used to scan all script files in the replaced project configuration file and create blank template files for script files that have not yet been generated.
[0276] It should be noted that the specific working process of each module provided in the above embodiments of this application can be referred to the corresponding steps in the above method embodiments, and will not be repeated here.
[0277] It should also be noted that the automatic generation system for engineering projects provided in this application has the technical effects of any of the above embodiments, and will not be described in detail here.
[0278] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0279] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for automatically generating engineering projects, characterized in that, include: The system receives configuration parameters for the target project input by the user; wherein the configuration parameters include at least the name of the target node, the name of the network where the target node is located, the verification algorithm type, the database file path, and the simulation architecture configuration information. The database file is read according to the specified database file path, and the database file is parsed to obtain a parsed file; wherein the parsed file includes at least message information and verification information; Based on the name and the network name, the target message corresponding to the target node is filtered out from the message information; Select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm; Based on the target message, the template engine generates the script file, panel file, and system variable file for the project. Based on the simulation architecture configuration information, the corresponding project configuration file is selected from the preset built-in template directory, and the script file, the panel file, the system variable file and the verification code are associated with the project configuration file to generate the project.
2. The method according to claim 1, characterized in that, The process of parsing the database file to obtain a parsed file includes: The database text corresponding to the database file is read using a character encoding algorithm, and the database text is repaired using regular expressions to obtain a repaired file; The repaired file is parsed using strict parsing mode; If the parsing of the repair file fails, the repair file is re-parsed using a non-strict parsing mode to obtain the target message information and signal information; Overlap detection is performed on the bits occupied by each message signal in the target message information, and each message signal with bit overlap is marked to obtain the message information; Identify signals containing verification keywords from the signal information as verification signals; Extract the start bit, length, and byte position of the verification signal, and extract the data identifier value and sorting information from the annotation of the verification signal to obtain the verification information.
3. The method according to claim 1, characterized in that, The step of generating the script file for the project using a template engine based on the target message includes: The message processing function is used to check the enable status and signal tampering enable status of the target message; When the target message passes the check, it is determined whether the target message is allowed to perform signal tampering based on the fault injection mode; If the target message allows signal tampering, then the target message is subjected to signal tampering operation according to preset coefficients and offsets, and the check value of the tampered target message is calculated. Based on the verification value, the target message is updated, and the updated target message is forwarded to obtain the script file of the project.
4. The method according to claim 1, characterized in that, The step of generating the panel file for the project using a template engine based on the target message includes: Obtain the global parameters set by the user and the signal information in the parsed file, and configure the global setting area according to the global parameters; Based on the number of packets in the target message, determine the number of rows in the message enable area, and based on the number of signals in the signal information, determine the tag height; Based on the number of rows in the message enable area, a message enable area is set, and based on the tag height, a message signal tampering area is set. When the simulation architecture configuration information indicates the generation of simulation nodes, the simulation node control area is set, and the panel file of the project is generated according to the global setting area, the message enable area, the message signal tampering area, and the simulation node control area; wherein, the simulation node control area contains control controls corresponding to each simulation node.
5. The method according to claim 1, characterized in that, The step of generating the system variable file for the project using a template engine based on the target message includes: Under the preset control namespace, set the fault injection master switch variable, duration mode switch variable, frame count mode switch variable, duration variable, and frame count variable for the target message; Under the preset message namespace, a sub-namespace for the target message is created, and the tampering control variable, coefficient variable and offset variable of the target message are set in the sub-namespace; Under the preset root namespace, set the recording control variables for the target message; When the simulation architecture configuration information indicates that simulation nodes should be generated, the node control variables for each simulation node are set under the control namespace. Based on the set variables, a variable list is generated, and the variable list is deduplicated using a combination of namespace and variable name as the key to obtain the system variable file of the project.
6. The method according to claim 5, characterized in that, Also includes: When the duration mode switch variable is switched from the off state to the on state, the frame count mode switch variable is set to the off state; When the frame count mode switch variable switches from the off state to the on state, the duration mode switch variable is set to the off state; wherein, the duration mode switch variable and the frame count mode switch variable are mutually exclusive, and the duration mode switch variable and the frame count mode switch variable are respectively provided with an edge detection flag, the edge detection flag is used to trigger a mutual exclusion operation when the variable is detected to switch from the off state to the on state.
7. The method according to claim 6, characterized in that, Also includes: When the duration mode switch variable switches from the off state to the on state, a timer start flag is generated, and the timer is started when the first frame of the target message arrives; When the timer expires, the duration mode switch variable is set to the off state, and the duration mode flag is cleared; When the frame count mode switch variable is switched from the off state to the on state, the number of received frames of the target message is counted, and when the accumulated number of received frames reaches the preset frame count threshold, the frame count mode switch variable is set to the off state and the frame count mode flag is cleared.
8. The method according to claim 1, characterized in that, The step of selecting the corresponding project configuration file from the preset built-in template directory based on the simulation architecture configuration information includes: When the simulation architecture configuration information indicates that no simulation node is generated, the channel mode is determined to be dual-channel mode, and the project configuration file corresponding to the dual-channel mode is selected from the preset built-in template directory; When the simulation architecture configuration information indicates the generation of simulation nodes, the channel mode is determined to be a three-channel mode, and a simulation control script file is generated based on each simulation node; wherein, the simulation control script file contains node start control and node stop control logic, and the control variables in the simulation control script file are bound to the corresponding node control variables; Select the configuration file corresponding to the three-channel mode from the preset built-in template directory, and add the simulation control script file to the configuration file to obtain the project configuration file.
9. The method according to claim 1, characterized in that, Also includes: Merge the system variable file into the system variable configuration block of the project configuration file, and replace the path in the merged project configuration file with the actual project path; Scan all script files in the replaced project configuration file and create blank template files for any script files that have not yet been generated.
10. An automatic project generation system, characterized in that, include: The receiving unit is used to receive configuration parameters of the target project input by the user; wherein, the configuration parameters include at least the name of the target node, the network name where the target node is located, the verification algorithm type, the database file path, and the simulation architecture configuration information; The parsing unit is used to read the database file according to the database file path and parse the database file to obtain a parsed file; wherein the parsed file includes at least message information and verification information; The filtering unit is used to filter out the target packets corresponding to the target node from the packet information based on the name and the network name; The selection unit is used to select the verification algorithm corresponding to the verification algorithm type from the verification algorithm database, and generate verification code based on the verification algorithm; The file generation unit is used to generate script files, panel files, and system variable files for the project based on the target message through a template engine. The selection unit is used to select the corresponding project configuration file from the preset built-in template directory according to the simulation architecture configuration information, and associate the script file, the panel file, the system variable file and the verification code with the project configuration file to generate the project.