Strategy code generation method and device, electronic equipment and readable storage medium

The method of generating policy code in formal statements solves the complex and time-consuming problem of ECU policy development, and achieves more efficient and accurate policy code generation and debugging.

CN119396369AActive Publication Date: 2025-02-07CHINA FAW CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411279943.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-02-07
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

In the field of software development, the development process of electronic control unit (ECU) strategies is complicated and time-consuming, and relies on developers to write code, resulting in inefficiency, error-prone and difficulty in debugging.

Method used

Provides a policy code generation method, which automatically generates policy code by obtaining predefined formal statements, receiving input data and generating formal code, expanding formal rule code, filling in concept details, and automatically generating policy code for use by ECU.

Benefits of technology

It reduces the difficulty of strategy development, improves efficiency, simplifies the debugging process, and improves the accuracy and acquisition efficiency of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396369A_ABST
    Figure CN119396369A_ABST
Patent Text Reader

Abstract

The invention provides a strategy code generation method and device, electronic equipment and a readable storage medium, and the method comprises the steps: obtaining a predefined formalized statement which defines all concept details used for strategy execution; receiving input data of the formalized statement, and generating a corresponding formalized code based on the input data and the formalized statement; on the basis of the formalized code, generating an inclusion relation between concept details; expanding formalized rule codes in the formalized codes to obtain rule expansion codes; and filling the concept details based on the inclusion relation between the rule expansion code and the concept details to obtain a strategy code. According to the method, developers can be allowed to intuitively describe the strategy by utilizing the formalized grammar, and the strategy code is automatically generated to be used by the ECU, so that the strategy development difficulty is lower, the efficiency is improved, the debugging is simpler and more convenient, and the accuracy is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a strategy code generation method, device, electronic device and readable storage medium. Background Art

[0002] In the field of software development, the strategy development for electronic control units (ECUs) often relies on developers to write a lot of code by hand. However, in practice, it is found that this process is not only complicated and time-consuming, but also requires developers to have high programming skills and embedded software development experience. Therefore, handwritten code inevitably brings problems such as low efficiency, easy errors and difficult debugging. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a strategy code generation method, device, electronic device and readable storage medium, which can allow developers to use formal syntax to intuitively describe the strategy and automatically generate strategy code for use by ECU, thereby making strategy development less difficult, more efficient, easier to debug and more accurate.

[0004] The first aspect of the present application provides a policy code generation method, comprising:

[0005] Obtaining a predefined formal statement that defines all conceptual details for policy execution;

[0006] receiving input data of the formal statement, and generating corresponding formal code based on the input data and the formal statement;

[0007] Based on the formalized code, generating inclusion relations between the concept details;

[0008] Expanding the formalized rule code in the formalized code to obtain a rule expansion code;

[0009] Based on the inclusion relationship between the rule expansion code and the concept details, the concept details are filled to obtain the strategy code.

[0010] In the above implementation process, the method can receive data input by developers based on formal statements and automatically generate corresponding policy codes, so that developers no longer need to directly write policy codes, which is conducive to improving the efficiency and quality of obtaining policy codes.

[0011] Furthermore, the concept details are filled based on the inclusion relationship between the rule expansion code and the concept details to obtain the strategy code, including:

[0012] Based on the inclusion relationship between the concept details, obtaining the attribute tuple corresponding to the rule expansion code;

[0013] Substituting the attribute tuple into the precondition and calculation expression in the rule expansion code to obtain an intermediate code;

[0014] A function emission sequence is generated in the intermediate code when the result of the calculation expression is true, and a strategy code is obtained.

[0015] In the above implementation process, the method can perform corresponding code filling based on the preconditions, calculation expressions and function emission sequences included in the rules, thereby declaring the detailed structure of the strategy code and refining the process of obtaining the strategy code.

[0016] Furthermore, the method further comprises:

[0017] Get all the conceptual details for policy execution;

[0018] Formal statements are defined based on preprocessor macro definition commands and the concept details.

[0019] In the above implementation process, the method can predefine the formal statements based on the preprocessing macro definition command, so that the developer can directly input data with the formal statements during use.

[0020] Furthermore, the concept details include one or more of a conceptualized signal name, a signal identification value, a period, a timeout threshold, a mathematical maximum value, a mathematical minimum value, a logical maximum value, a logical minimum value, a signal initial value, an error value, a rule set, a mapping table, a signal maximum enumeration value, a function, a function identification value, a code block, a code block identification value, and a data structure.

[0021] In the above implementation process, the method defines a large number of conceptual details, which can be used for corresponding definitions in formal statements, so that developers can more easily use formal statements to develop policy codes.

[0022] Furthermore, the method further comprises:

[0023] receiving an input signal, the input signal comprising a corresponding signal identifier, a signal value, and a signal timestamp;

[0024] matching a signal object corresponding to the signal identifier;

[0025] Determine whether the signal timestamp is before the update timestamp of the signal object;

[0026] When the signal timestamp is before the update timestamp of the signal object, a data processing error indication is returned.

[0027] In the above implementation process, the method proposes a signal verification process before the policy code is called, which can make the call of the policy code effective and reasonable.

[0028] Furthermore, the method further comprises:

[0029] When the signal timestamp is not before the update timestamp of the signal object, determining whether the signal value is the same as the current value of the signal object;

[0030] When the signal value is the same as the current value of the signal object, the update timestamp of the signal object is updated based on the signal timestamp, and a data processing success indication is returned.

[0031] In the above implementation process, the method can automatically eliminate the interference of historical signals and directly update the data when the value has not changed, thereby avoiding invalid calls to the strategy code.

[0032] Furthermore, the method further comprises:

[0033] When the signal value is different from the current value of the signal object, recording the current value of the signal object;

[0034] updating a current value of the signal object based on the signal value;

[0035] An update timestamp of the signal object is updated based on the signal timestamp.

[0036] In the above implementation process, the method can update the signal when the signal value changes, and further trigger the use of the strategy code.

[0037] Furthermore, the method further comprises:

[0038] Determining whether the signal value belongs to the same class as the current value of the signal object;

[0039] When the signal value and the current value of the signal object do not belong to the same category, the signal timestamp is recorded as a signal change timestamp.

[0040] In the above implementation process, the method can further perform the same type judgment on the signal value, and automatically record the change timestamp when the type changes, so as to be used in other subsequent processes.

[0041] Furthermore, the method further comprises:

[0042] Acquire a strategy code corresponding to the signal object; the strategy code includes at least a first rule;

[0043] Determine whether the precondition of the first rule is met;

[0044] When the precondition of the first rule is met, verify whether the expression statement of the first rule is established;

[0045] When the expression statement of the first rule is established, the corresponding function emission sequence is triggered.

[0046] In the above implementation process, the method can determine whether to trigger the corresponding function emission sequence by judging the precondition and the expression statement, thereby ensuring the correct application of the function emission sequence.

[0047] Furthermore, when the policy code further includes a second rule, after the corresponding function emission sequence is triggered, or when the expression statement of the first rule does not hold, it further includes:

[0048] Determine whether to continue rule evaluation;

[0049] When continuing rule evaluation, determining whether the precondition of the second rule is satisfied;

[0050] When the precondition of the second rule is met, verify whether the expression statement of the second rule is established;

[0051] When the expression statement of the second rule is established, the corresponding function emission sequence is triggered.

[0052] In the above implementation process, the method can automatically determine whether to evaluate the next rule when facing multiple rules, thereby realizing the correct application of the policy code of multiple rules.

[0053] Furthermore, after stimulating the corresponding function emission sequence, the method further includes:

[0054] Returns an indication of successful data processing.

[0055] In the above implementation process, the method can give corresponding instructions to enable the device or user to understand the current data processing status.

[0056] A second aspect of the present application provides a strategy code generation device, the strategy code generation device comprising:

[0057] A first acquisition unit, configured to acquire a predefined formal statement, wherein the formal statement defines all conceptual details for policy execution;

[0058] A first generating unit, configured to receive input data of the formalized statement, and generate corresponding formalized code based on the input data and the formalized statement;

[0059] A second generating unit, configured to generate, based on the formalized code, an inclusion relationship between the concept details;

[0060] An expansion unit, used for expanding the formal rule code in the formal code to obtain a rule expansion code;

[0061] The third generating unit is used to fill the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the strategy code.

[0062] Furthermore, the third generating unit includes:

[0063] An acquisition subunit, used for acquiring an attribute tuple corresponding to the rule expansion code based on the inclusion relationship between the concept details;

[0064] A substitution subunit, used for substituting the attribute tuple into the precondition and calculation expression in the rule expansion code to obtain an intermediate code;

[0065] A generating subunit is used to generate a function emission sequence in the intermediate code when the result of the calculation expression is true, so as to obtain a strategy code.

[0066] Furthermore, the strategy code generating device further comprises:

[0067] The first acquisition unit is further used to acquire all concept details for policy execution;

[0068] A definition unit is used to define a formal statement based on a preprocessing macro definition command and the concept details.

[0069] Furthermore, the concept details include one or more of a conceptualized signal name, a signal identification value, a period, a timeout threshold, a mathematical maximum value, a mathematical minimum value, a logical maximum value, a logical minimum value, a signal initial value, an error value, a rule set, a mapping table, a signal maximum enumeration value, a function, a function identification value, a code block, a code block identification value, and a data structure.

[0070] Furthermore, the strategy code generating device further comprises:

[0071] A receiving unit, configured to receive an input signal, wherein the input signal includes a corresponding signal identifier, a signal value, and a signal timestamp;

[0072] A matching unit, configured to match a signal object corresponding to the signal identifier;

[0073] A first judging unit, configured to judge whether the signal timestamp is before the update timestamp of the signal object;

[0074] An indication unit is used to return a data processing error indication when the signal timestamp is before the update timestamp of the signal object.

[0075] Furthermore, the strategy code generating device further comprises:

[0076] a second judging unit, configured to judge whether the signal value is the same as the current value of the signal object when the signal timestamp is not before the update timestamp of the signal object;

[0077] An updating unit is used to update the update timestamp of the signal object based on the signal timestamp when the signal value is the same as the current value of the signal object, and return an indication of successful data processing.

[0078] Furthermore, the strategy code generating device further comprises:

[0079] a recording unit, configured to record the current value of the signal object when the signal value is different from the current value of the signal object;

[0080] The updating unit is further configured to update the current value of the signal object based on the signal value;

[0081] The updating unit is further configured to update the update timestamp of the signal object based on the signal timestamp.

[0082] Furthermore, the strategy code generating device further comprises:

[0083] a third judging unit, configured to judge whether the signal value belongs to the same category as the current value of the signal object;

[0084] The recording unit is further configured to record the signal timestamp as a signal change timestamp when the signal value and the current value of the signal object do not belong to the same category.

[0085] Furthermore, the strategy code generating device further comprises:

[0086] A second acquisition unit, configured to acquire a strategy code corresponding to the signal object; the strategy code at least includes a first rule;

[0087] A fourth judgment unit, used to judge whether a precondition of the first rule is met;

[0088] A verification unit, configured to verify whether the expression statement of the first rule is established when the precondition of the first rule is met;

[0089] The triggering unit is used to trigger the corresponding function emission sequence when the expression statement of the first rule is established.

[0090] Further, when the policy code further includes a second rule, the policy code generating device further includes:

[0091] a fifth judgment unit, configured to judge whether to continue rule evaluation after the triggering unit triggers the corresponding function emission sequence or when the expression statement of the first rule does not hold;

[0092] The fourth judgment unit is further used to judge whether the precondition of the second rule is satisfied when continuing the rule evaluation;

[0093] The verification unit is further configured to verify whether the expression statement of the second rule is established when the precondition of the second rule is met;

[0094] The triggering unit is further used to trigger a corresponding function emission sequence when the expression statement of the second rule is established.

[0095] Furthermore, the indication unit is also used to return a data processing success indication after the excitation unit excites the corresponding function emission sequence.

[0096] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the policy code generation method described in any one of the first aspects of the present application.

[0097] A fourth aspect of the present application provides a computer-readable storage medium storing computer program instructions, wherein when the computer program instructions are read and executed by a processor, the policy code generation method described in any one of the first aspect of the present application is executed.

[0098] The beneficial effects of the present application are as follows: the method and device allow developers to use formal statements to describe the strategy and give text output, and then interpret the strategy into C language strategy code through the code generation mechanism for use by the ECU. Among them, the use of formal statements can avoid the efficiency and accuracy problems caused by a large amount of handwritten strategy code, and can also reduce the development difficulty of developers based on more intuitive descriptions. Therefore, the method and device can reduce the difficulty of obtaining and debugging strategy codes, and can also improve the efficiency and accuracy of obtaining strategy codes. BRIEF DESCRIPTION OF THE DRAWINGS

[0099] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0100] Figure 1 A schematic diagram of a process flow of a strategy code generation method provided in an embodiment of the present application;

[0101] Figure 2 A schematic diagram of the quantitative relationship between conceptual details provided in an embodiment of the present application;

[0102] Figure 3 A flowchart of another strategy code generation method provided in an embodiment of the present application;

[0103] Figure 4 A flowchart of another strategy code generation method provided in an embodiment of the present application;

[0104] Figure 5 A schematic diagram of the structure of a strategy code generation device provided in an embodiment of the present application;

[0105] Figure 6 A schematic diagram of the structure of another strategy code generation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0106] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0107] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0108] Example 1

[0109] Please see Figure 1 , Figure 1 A schematic diagram of a process flow of a strategy code generation method provided in this embodiment. The strategy code generation method includes:

[0110] S101. Obtain a predefined formal statement, which defines all conceptual details for policy execution.

[0111] In this embodiment, all concept details refer to all relevant contents defined by developers through formal statements, including configuration conditions, signal names, signal values, resolutions, function names, tuples, rules, etc. These concept details are the basis for policy execution, through which the execution conditions, execution process, and execution results of a policy can be fully described.

[0112] S102: Receive input data of a formal statement, and generate corresponding formal code based on the input data and the formal statement.

[0113] S103. Generate inclusion relationships between concept details based on formalized codes.

[0114] In this embodiment, the inclusion relationship between concept details refers to the inclusion or being included relationship between various defined concepts (such as signals, functions, rules, etc.). For example, a rule may contain multiple signals as preconditions, a rule may trigger multiple functions, and so on. This member inclusion relationship describes the logical connection and dependency between different concepts and is an important part of the policy execution logic.

[0115] Please see Figure 2 , Figure 2 A schematic diagram of the quantitative relationship between concept details is given.

[0116] S104. Expand the formal rule code in the formal code to obtain a rule expansion code.

[0117] S105 , filling in the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the strategy code.

[0118] In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0119] In this embodiment, the execution subject of the method may also be a smart device such as a smart phone, a tablet computer, etc., which is not limited in this embodiment.

[0120] It can be seen that the implementation of the strategy code generation method described in this embodiment can allow developers to use formal syntax to intuitively describe the strategy and automatically generate strategy code for use by ECU, thereby making strategy development easier, more efficient, easier to debug, and more accurate.

[0121] Example 2

[0122] Please see Figure 3 , Figure 3 A schematic diagram of a process flow of a strategy code generation method provided in this embodiment. The strategy code generation method includes:

[0123] S201. Obtain all conceptual details for policy execution.

[0124] In this embodiment, the conceptual details include one or more of a conceptualized signal name, a signal identification value, a period, a timeout threshold, a mathematical maximum value, a mathematical minimum value, a logical maximum value, a logical minimum value, a signal initial value, an error value, a rule set, a mapping table, a signal maximum enumeration value, a function, a function identification value, a code block, a code block identification value, and a data structure.

[0125] In this embodiment, the concept details may also include configuration conditions, which are used to indicate the premise for executing the strategy; that is, a specific vehicle model is a prerequisite for executing a specific strategy;

[0126] The signal name in the concept details is used to identify internal original signals, external original signals, internal high-order data, external high-order signals, etc.;

[0127] In the concept details, signal values ​​(all values ​​related to signals) are used to represent the values ​​corresponding to all signals, integers, enumerations;

[0128] The concept details may also include resolution, which is used to indicate the type precision of the signal value; wherein, signal value = original data * resolution;

[0129] The concept details may also include a function name, which is used to indicate the function associated with the result generated after the policy is executed;

[0130] Concept details can also include tuples containing a set of attribute values ​​for a custom concept that can be used by rules.

[0131] In this embodiment, the rule is a description form of the strategy, wherein the strategy code is a specific code related to the rule. At the same time, the strategy code is applied to the pipeline: wherein the pipeline refers to the pipeline code for executing the rule, which has a fixed logic, and the variation is described by the signal name and the configuration condition (the corresponding content can be found in Example 3).

[0132] S202: Define formal statements based on preprocessing macro definition commands and concept details.

[0133] For example, the definition of a formal statement can be found in the following code:

[0134]

[0135]

[0136]

[0137] S203: Obtain a predefined formal statement, which defines all conceptual details for policy execution.

[0138] S204: Receive input data of the formal statement, and generate corresponding formal code based on the input data and the formal statement.

[0139] For example, the formal code could look like this:

[0140] ①FUNC_EOL(ACC,{LOW,DISABLE},{MID,ENABLE},{HIGH,ENABLE})

[0141] This formal code defines the configuration conditions of the strategy, specifically that the advanced cruise control function has three vehicle configurations: high, medium and low. At this time, the strategy is only equipped on high-end and medium-end vehicles. It can be seen that this statement can select the vehicle configuration file through the code engineering build system to complete the support of multiple vehicle models in the same project. Among them, ACC stands for "AdaptiveCruise Control", which is an adaptive cruise control system.

[0142] ②VAL_DEF(AIRBAG_ON,1)

[0143] This formal code defines the signal value type definition, specifically defining that the value is 1 when the airbag fault warning function is activated.

[0144] ③SIG_DEF(AIRBAG,AIRBAG_OFF,100,1000,AIRBAG_LOGIC_MIN,AIRBAG_LOGIC_MAX,AIRBAG_FLASH,COMMON_VBAD)

[0145] The formal code defines the airbag fault signal, specifically defines the signal name, internal analog initial signal value, period, timeout, mathematical maximum value, mathematical minimum value, logical maximum value, logical minimum value, initial signal value, and error value.

[0146] ④RULE_DEF(RULE_AIRBAG_HIT,PRE_COND, <statement>,<FUNC_CASE_NAME> ,…)

[0147] The formal code defines the rules, including the rule name, precondition, expression statement (rules can be nested and referenced), and rule triggering object. Among them, "..." is a variable-length parameter that can contain multiple FUNC_CASE_NAMEs to trigger multiple function objects.

[0148] ⑤CUSTOM_DEF(AIRBAG_HITCH_ATTR,AIRBAG_HITCH,…)

[0149] The formal code defines a user-defined concept, specifically an airbag attribute type, and a concept variable for this type, followed by variable-length attribute parameter values. These variable-length parameters need to be used by expression statements in user-defined rules.

[0150] ⑥RES_DEF(RES_XXX,1 / 10 / 100)

[0151] This formal code defines a numerical resolution type for use in function definitions.

[0152] ⑦FUNC_DEF(AIRBAG_ON,SIG_A,VAL_A,RES_AAA)

[0153] The formal code defines the function, which gives the name and the secondary signal output involved in the function.

[0154] S205. Generate inclusion relationships between concept details based on the formalized code.

[0155] S206: Expand the formal rule code in the formal code to obtain a rule expansion code.

[0156] S207. Based on the inclusion relationship between the concept details, obtain the attribute tuple corresponding to the rule expansion code.

[0157] In this embodiment, the attribute tuple refers to a custom concept containing attribute values, which is used for use by rules. In the formal description, the attribute tuple can be used to further fill in the concept details and promote the generation of policy codes.

[0158] S208. Substitute the attribute tuple into the precondition and calculation expression in the rule expansion code to obtain the intermediate code.

[0159] S209. Generate a function emission sequence in the intermediate code when the result of the calculation expression is true, and obtain a strategy code.

[0160] For example, this method can first define all concept details through formal statements, and then generate relevant formal codes such as signal type, value type, configuration condition, resolution, etc. on this basis, and further form the inclusion relationship between concept members. At this time, according to the RULE definition, the preconditions, calculation expressions, etc. are expanded, and based on the above inclusion relationship, the attribute tuple RULE expression is substituted in sequence, and then the function emission sequence when the expression is TURE is generated, so as to obtain the complete strategy code.

[0161] In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0162] In this embodiment, the execution subject of the method may also be a smart device such as a smart phone, a tablet computer, etc., which is not limited in this embodiment.

[0163] It can be seen that the implementation of the strategy code generation method described in this embodiment can refine the process of formal statement definition and the process of association and reference between definitions, and can apply formal language methods to the strategy code generation process, so that developers can use formal syntax to intuitively describe the strategy and automatically generate strategy code for ECU use, thereby making strategy development easier, more efficient, easier to debug, and more accurate.

[0164] Example 3

[0165] Please see Figure 4 , Figure 4 A schematic diagram of a process flow of a strategy code generation method provided in this embodiment. The strategy code generation method includes:

[0166] S301. Receive an input signal, where the input signal includes a corresponding signal identifier, a signal value, and a signal timestamp.

[0167] S302: Match a signal object corresponding to the signal identifier.

[0168] S303, determine whether the signal timestamp is before the update timestamp of the signal object, if so, execute step S304; if not, execute step S305.

[0169] S304: Return a data processing error indication and end this process.

[0170] S305, determine whether the signal value is the same as the current value of the signal object, if so, execute step S306; if not, execute step S307.

[0171] S306: Update the update timestamp of the signal object based on the signal timestamp, return a data processing success indication, and then end this process.

[0172] S307. Record the current value of the signal object.

[0173] As an optional implementation, the method further includes:

[0174] Determine whether the signal value belongs to the same class as the current value of the signal object;

[0175] When the signal value and the current value of the signal object do not belong to the same category, the signal timestamp is recorded as the signal change timestamp.

[0176] S308. Update the current value of the signal object based on the signal value.

[0177] S309: Update the update timestamp of the signal object based on the signal timestamp.

[0178] S310. Obtain a strategy code corresponding to a signal object; the strategy code includes at least a first rule.

[0179] In this embodiment, the generated policy code can be added to the pipeline processing process shown in this embodiment.

[0180] S311, determine whether the precondition of the first rule is met, if so, execute step S312; if not, end this process.

[0181] S312: Verify whether the expression statement of the first rule is valid. If so, execute step S313; if not, end this process.

[0182] S313, stimulating the corresponding functional emission sequence.

[0183] As an optional implementation, when the policy code further includes a second rule, after stimulating the corresponding function emission sequence, or when the expression statement of the first rule does not hold, it further includes:

[0184] Determine whether to continue rule evaluation;

[0185] When continuing rule evaluation, determine whether the precondition of the second rule is satisfied;

[0186] When the precondition of the second rule is met, verify whether the expression statement of the second rule is established;

[0187] When the expression statement of the second rule is established, the corresponding function emission sequence is triggered.

[0188] S314. Return an indication of successful data processing.

[0189] For example, the following pseudo code shows the key processing process in this embodiment:

[0190] / / Pipeline processing procedure

[0191] ret_t deal(id_t id, val_t val, time_t ts) {

[0192] signal_t* psig = lut_find(id);

[0193] do {

[0194] if (ts < update(psig)) {

[0195] return RET_NOK;

[0196] }

[0197] if (val == get_val(psig)) {

[0198] ts_update(psig, ts);

[0199] return RET_OK;

[0200] } else {

[0201] old_val(psig, get_val(psig));

[0202] }

[0203] bool_t same_class = val_same_range(psig, val);

[0204] set_val(psig, val);

[0205] ts_update(psig, ts);

[0206] if (FALSE == same_class) {

[0207] ts_since(psig, ts);

[0208] }

[0209] } while (0);

[0210] rule_t* const* rules = get_rules(psig);

[0211] for (int idx = 0; NULL!= rules[idx]; ++idx) {

[0212] if(NULL!=rules[idx]->eval){

[0213] rule_ret_t ret_eval=rules[idx]->eval();

[0214] if(RULE_EVAL_RET_TRUE_NEXT==ret_eval){

[0215] rules[idx]->emit();

[0216] continue;

[0217] }else if(RULE_EVAL_RET_TRUE_STOP==ret_eval){

[0218] rules[idx]->emit();

[0219] break;

[0220] }else if(RULE_EVAL_RET_FALSE_NEXT==ret_eval){

[0221] continue;

[0222] }else if(RULE_EVAL_RET_FALSE_STOP==ret_eval){

[0223] break;

[0224] }

[0225] }else{

[0226] break;

[0227] }

[0228] }

[0229] return RET_OK

[0230] It can be seen that this method can complete the whole process of automatic execution of the strategy code triggered by an external signal and emission of a second-order signal through the three steps of signal generation-rule triggering-function emission.

[0231] In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0232] In this embodiment, the execution subject of the method may also be a smart device such as a smart phone, a tablet computer, etc., which is not limited in this embodiment.

[0233] It can be seen that the implementation of the strategy code generation method described in this embodiment can detect the received data based on the pipeline method, and automatically call the strategy code to apply the strategy when the conditions are met, so that the strategy code can be applied in the vehicle.

[0234] Example 4

[0235] Please see Figure 5 , Figure 5 FIG. 1 is a schematic diagram of the structure of a strategy code generating device provided in this embodiment. Figure 5 As shown, the strategy code generating device includes:

[0236] A first acquisition unit 410 is used to acquire a predefined formal statement, where the formal statement defines all conceptual details for policy execution;

[0237] A first generating unit 420, configured to receive input data of a formal statement and generate corresponding formal codes based on the input data and the formal statement;

[0238] A second generating unit 430 is used to generate an inclusion relationship between concept details based on the formalized code;

[0239] An expansion unit 440 is used to expand the formal rule code in the formal code to obtain a rule expansion code;

[0240] The third generating unit 450 is used to fill the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the policy code.

[0241] In this embodiment, the explanation of the strategy code generating device can refer to the description in Embodiment 1, Embodiment 2 or Embodiment 3, which will not be elaborated in this embodiment.

[0242] It can be seen that the implementation of the strategy code generation device described in this embodiment can allow developers to use formal syntax to intuitively describe strategies and automatically generate strategy codes for use by ECUs, thereby making strategy development less difficult, more efficient, easier to debug, and more accurate.

[0243] Example 5

[0244] Please see Figure 6 , Figure 6 FIG. 1 is a schematic diagram of the structure of a strategy code generating device provided in this embodiment. Figure 6 As shown, the strategy code generating device includes:

[0245] A first acquisition unit 410 is used to acquire a predefined formal statement, where the formal statement defines all conceptual details for policy execution;

[0246] A first generating unit 420, configured to receive input data of a formal statement and generate corresponding formal codes based on the input data and the formal statement;

[0247] A second generating unit 430 is used to generate an inclusion relationship between concept details based on the formalized code;

[0248] An expansion unit 440 is used to expand the formal rule code in the formal code to obtain a rule expansion code;

[0249] The third generating unit 450 is used to fill the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the policy code.

[0250] As an optional implementation manner, the third generating unit 450 includes:

[0251] An acquisition subunit 451 is used to acquire an attribute tuple corresponding to the rule expansion code based on the inclusion relationship between the concept details;

[0252] The substitution subunit 452 is used to substitute the attribute tuple into the precondition and calculation expression in the rule expansion code to obtain the intermediate code;

[0253] The generating subunit 453 is used to generate a function emission sequence in the intermediate code when the result of the calculation expression is true, so as to obtain a strategy code.

[0254] As an optional implementation, the strategy code generating device further includes:

[0255] The first acquisition unit 410 is further used to acquire all concept details for policy execution;

[0256] The definition unit 460 is used to define a formal statement based on the preprocessing macro definition command and the concept details.

[0257] In this embodiment, the conceptual details include one or more of a conceptualized signal name, a signal identification value, a period, a timeout threshold, a mathematical maximum value, a mathematical minimum value, a logical maximum value, a logical minimum value, a signal initial value, an error value, a rule set, a mapping table, a signal maximum enumeration value, a function, a function identification value, a code block, a code block identification value, and a data structure.

[0258] As an optional implementation, the strategy code generating device further includes:

[0259] The receiving unit 470 is used to receive an input signal, wherein the input signal includes a corresponding signal identifier, a signal value and a signal timestamp;

[0260] A matching unit 480, configured to match a signal object corresponding to a signal identifier;

[0261] A first determination unit 490, configured to determine whether the signal timestamp is before the update timestamp of the signal object;

[0262] The indication unit 500 is used to return a data processing error indication when the signal timestamp is before the update timestamp of the signal object.

[0263] As an optional implementation, the strategy code generating device further includes:

[0264] A second determination unit 510, configured to determine whether the signal value is the same as the current value of the signal object when the signal timestamp is not before the update timestamp of the signal object;

[0265] The updating unit 520 is configured to update the update timestamp of the signal object based on the signal timestamp when the signal value is the same as the current value of the signal object, and return a data processing success indication.

[0266] As an optional implementation, the strategy code generating device further includes:

[0267] a recording unit 530, configured to record the current value of the signal object when the signal value is different from the current value of the signal object;

[0268] The updating unit 520 is further configured to update the current value of the signal object based on the signal value;

[0269] The updating unit 520 is further configured to update the update timestamp of the signal object based on the signal timestamp.

[0270] As an optional implementation, the strategy code generating device further includes:

[0271] A third determination unit 540, used to determine whether the signal value belongs to the same category as the current value of the signal object;

[0272] The recording unit 530 is further configured to record the signal timestamp as a signal change timestamp when the signal value and the current value of the signal object do not belong to the same category.

[0273] As an optional implementation, the strategy code generating device further includes:

[0274] A second acquisition unit 550 is used to acquire a strategy code corresponding to the signal object; the strategy code includes at least a first rule;

[0275] A fourth judgment unit 560, configured to judge whether a precondition of the first rule is satisfied;

[0276] A verification unit 570, configured to verify whether the expression statement of the first rule is established when the precondition of the first rule is satisfied;

[0277] The triggering unit 580 is used to trigger the corresponding function emission sequence when the expression statement of the first rule is established.

[0278] As an optional implementation manner, when the policy code further includes a second rule, the policy code generating device further includes:

[0279] A fifth judgment unit 590, used to judge whether to continue rule evaluation after the triggering unit 580 triggers the corresponding function emission sequence or when the expression statement of the first rule is not established;

[0280] The fourth judgment unit 560 is further used to judge whether the precondition of the second rule is satisfied when continuing the rule evaluation;

[0281] The verification unit 570 is further used to verify whether the expression statement of the second rule is established when the precondition of the second rule is met;

[0282] The triggering unit 580 is also used to trigger the corresponding function emission sequence when the expression statement of the second rule is established.

[0283] As an optional implementation, the indication unit 500 is further configured to return a data processing success indication after the excitation unit 580 excites the corresponding function emission sequence.

[0284] In this embodiment, the explanation of the strategy code generating device can refer to the description in Embodiment 1, Embodiment 2 or Embodiment 3, which will not be elaborated in this embodiment.

[0285] It can be seen that the implementation of the strategy code generation device described in this embodiment can allow developers to use formal syntax to intuitively describe strategies and automatically generate strategy codes for use by ECUs, thereby making strategy development less difficult, more efficient, easier to debug, and more accurate.

[0286] An embodiment of the present application provides an electronic device, including a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the policy code generation method in embodiment 1, embodiment 2 or embodiment 3 of the present application.

[0287] An embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the policy code generation method in Embodiment 1, Embodiment 2 or Embodiment 3 of the present application is executed.

[0288] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0289] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0290] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0291] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0292] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0293] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.< / statement>

Claims

1. A strategy code generation method, characterized in that: include: Obtaining a predefined formal statement that defines all conceptual details for policy execution; receiving input data of the formal statement, and generating corresponding formal code based on the input data and the formal statement; Based on the formalized code, generating inclusion relations between the concept details; Expanding the formalized rule code in the formalized code to obtain a rule expansion code; Based on the inclusion relationship between the rule expansion code and the concept details, the concept details are filled to obtain the strategy code.

2. The strategy code generation method according to claim 1, characterized in that: The step of filling the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the strategy code includes: Based on the inclusion relationship between the concept details, obtaining the attribute tuple corresponding to the rule expansion code; Substituting the attribute tuple into the precondition and calculation expression in the rule expansion code to obtain an intermediate code; A function emission sequence is generated in the intermediate code when the result of the calculation expression is true, and a strategy code is obtained.

3. The strategy code generation method according to claim 1, characterized in that: The method further comprises: Get all the conceptual details for policy execution; Formal statements are defined based on preprocessor macro definition commands and the concept details.

4. The strategy code generation method according to claim 1, characterized in that: The concept details include one or more of a conceptualized signal name, a signal identification value, a period, a timeout threshold, a mathematical maximum value, a mathematical minimum value, a logical maximum value, a logical minimum value, a signal initial value, an error value, a rule set, a mapping table, a signal maximum enumeration value, a function, a function identification value, a code block, a code block identification value, and a data structure.

5. The strategy code generation method according to claim 1, characterized in that: The method further comprises: receiving an input signal, the input signal comprising a corresponding signal identifier, a signal value, and a signal timestamp; matching a signal object corresponding to the signal identifier; Determine whether the signal timestamp is before the update timestamp of the signal object; When the signal timestamp is before the update timestamp of the signal object, a data processing error indication is returned.

6. The strategy code generation method according to claim 5, characterized in that: The method further comprises: When the signal timestamp is not before the update timestamp of the signal object, determining whether the signal value is the same as the current value of the signal object; When the signal value is the same as the current value of the signal object, the update timestamp of the signal object is updated based on the signal timestamp, and a data processing success indication is returned.

7. The strategy code generation method according to claim 6, characterized in that: The method further comprises: When the signal value is different from the current value of the signal object, recording the current value of the signal object; updating a current value of the signal object based on the signal value; An update timestamp of the signal object is updated based on the signal timestamp.

8. The strategy code generation method according to claim 7, characterized in that: The method further comprises: Determining whether the signal value belongs to the same class as the current value of the signal object; When the signal value and the current value of the signal object do not belong to the same category, the signal timestamp is recorded as a signal change timestamp.

9. The strategy code generation method according to claim 7, characterized in that: The method further comprises: Acquire a strategy code corresponding to the signal object; the strategy code includes at least a first rule; Determine whether the precondition of the first rule is met; When the precondition of the first rule is met, verify whether the expression statement of the first rule is established; When the expression statement of the first rule is established, the corresponding function emission sequence is triggered.

10. The strategy code generation method according to claim 9, characterized in that: When the policy code further includes a second rule, after the corresponding function emission sequence is triggered, or when the expression statement of the first rule does not hold, it further includes: Determine whether to continue rule evaluation; When continuing rule evaluation, determining whether the precondition of the second rule is satisfied; When the precondition of the second rule is met, verify whether the expression statement of the second rule is established; When the expression statement of the second rule is established, the corresponding function emission sequence is triggered.

11. The strategy code generation method according to claim 9, characterized in that: After the corresponding function emission sequence is triggered, the method further includes: Returns an indication of successful data processing.

12. A strategy code generating device, characterized in that: The strategy code generating device comprises: A first acquisition unit, configured to acquire a predefined formal statement, wherein the formal statement defines all conceptual details for policy execution; A first generating unit, configured to receive input data of the formalized statement, and generate corresponding formalized code based on the input data and the formalized statement; A second generating unit, configured to generate an inclusion relationship between the concept details based on the formalized code; An expansion unit, used for expanding the formal rule code in the formal code to obtain a rule expansion code; The third generating unit is used to fill the concept details based on the inclusion relationship between the rule expansion code and the concept details to obtain the strategy code.

13. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the policy code generation method according to any one of claims 1 to 11.

14. A readable storage medium, characterized in that: The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the strategy code generation method according to any one of claims 1 to 11 is executed.

Citation Information

Patent Citations

  • Method and device for efficiency control in formalized code generation

    CN103226488A

  • Carrier rocket test data interpretation method and system based on formalized description

    CN109582692A

  • Formal description method of matrix code generation technology based on Coq

    CN114154114A

  • Efficient formalized code construction method aiming at complex data processing requirements

    CN117591087A

  • Arithmetic enhancement of c-like smart contracts for verifiable computation

    WO2019092545A1