A method for changing a model for generating source code
By applying conversion and configuration rules between block diagram models, modifications and adaptations between models are automatically processed, solving the difficulties of manual modifications and adaptations in large-scale development projects, and improving the efficiency and automation of code generation.
Patent Information
- Application Number
- CN201910920527.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-09-28
- Filing Date
- 2019-09-27
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2039-09-27
AI Technical Summary
In large-scale development projects involving multiple developers and different enterprises, there are difficulties in modifying, transferring and adapting between block diagram models, especially during the code generation process between different versions, which requires a heavy workload of manual modification and adaptation. , and it is difficult for existing technology to automatically handle differences in complex structures and multi-level models.
Modify and transfer between block diagrams by applying conversion rules and configuration rules, including modification of identification blocks, addition or deletion of extension blocks, adjustment of parameters, comparison and editing using the graphical user interface, automatic processing of semantic layer differences, and Store and optimize rules through a database to reduce manual adaptation work.
It realizes automatic modification transmission and adaptation between block diagram models, reduces the manual workload in the code generation process, and improves efficiency. Especially in the code generation process between models with multiple versions and complex structures, it significantly reduces Burden of manual modification and adaptation.
Smart Images

Figure CN110968308B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a modification of an executable model, in particular a block diagram, and the generation of source code for programming a control device from the block diagram. Background Art
[0002] Control devices are used in many applications to detect physical quantities of processes and / or to act on processes with the aid of connected actuators; for example, this may involve anti-lock control of braking processes. The time constants that determine the dynamic behavior of the process often result in cycle times of 1 ms or less, so that real-time capabilities of the control device are required. For cost reasons, control devices often have microcontrollers with little memory and limited computing power, so that the size and efficiency of the executable code are very important.
[0003] In order to speed up the design of control devices, control strategies are often developed based on models in a computing environment such as MATLAB / Simulink. Therefore, the behavior of the process and / or regulator or generally the control device can first be simulated and it can be checked whether the desired characteristics exist. These models can be block diagrams in particular, which include blocks that perform operations such as calculations, wherein the blocks can, for example, calculate an output signal from multiple input signals. Usually, the block diagram is executed periodically, wherein all blocks are permanently kept in the memory and each block is executed once per time step. In particular, the block can apply one or more operations to the input signal from the previous step in order to generate the output signal of the current step. In addition to the sub-models that are executed periodically, in order to describe approximately time-continuous behavior, the block diagram can also include a sub-model for describing discrete behavior, in which multiple states and transition conditions are defined.
[0004] With the aid of a code generator, source code for programming the control device can be generated directly from these models. For example, from the document "Production Quality Code Generation from Simulink Block Diagrams" by H. Hanselmann et al., Proceedings of the 1999 International Conference on Computer-Aided Control System Design, Kohala Coast, Hawaii, a code generator for generating source code with production quality is known. In this case, the generated production code can be adapted by additional annotations to the blocks or block variables. In particular, models that were originally created for calculations with high-precision floating-point variables can be equipped with a setting for scaling (Skalierung), whereby the control device can perform calculations with fixed-point numbers in order to achieve a significant reduction in the calculation cost with a slight loss in accuracy.
[0005] In the field of edge computing (in which the large amount of data that appears must be analyzed efficiently), data flow-oriented programming languages have also been put into use during this period. Thus, a method is known from US2017 / 0277521A1, in which multiple data streams are identified in a development environment, and a series of functions should be applied to the multiple data streams. The input data stream exists as a queue with multiple elements, which should be combined into a common output data stream by a "merge" function, for example. The designed program is translated into optimized platform-specific instructions in a secondary translation tool. In this case, the conversion functions applied to each data stream and the "merge" function are translated and combined into a deterministic finite automaton. Through this optimization, it is not necessary to provide a buffer for the intermediate level of the "merge" function, so that efficient splicing of data streams can be achieved. Changes to the program can be made in a graphical user interface containing a visualization component, and the auxiliary tools for distributed development are not disclosed in this document.
[0006] In larger development projects, different areas of development are often carried out by several people, who may also work at different companies. Function developers who create and improve models can usually work with floating point numbers. Function models that have been created can also be used in different projects and adapted in terms of functionality. The additional annotations required for porting to control devices are usually implemented by a specialist in code generation, to whom the model is handed over in the corresponding project phase. For this step, there is usually only a few days at their disposal, during which a large number of manual modifications must be made. The problem becomes more acute if the project includes several phases in which code generation is to be performed; additional annotations are often manual work, even if the underlying model remains essentially unchanged.
[0007] For texts arranged in rows with a large number of words each, such as source code in a high-level language, there are comparison programs that can often also implement three-way comparisons. This three-way comparison is helpful, especially when multiple different versions of the text are created based on an initial version, for example, by two programmings working in parallel on the source code. The more complex structure of block diagrams or general graphic models (in terms of text) makes comparisons between models difficult. In order to improve manual operability, US2018 / 0060457 A1 proposes: filtering the comparison results between block diagrams or post-processing the results with the help of scripts. In particular, in hierarchical block diagrams that include a large number of different levels, transmission modifications are only possible in a very limited way. From US 8151244 B2, a method for "merging" or splicing graphic programs is known, in which a common original program is considered. However, it is necessary in this regard that the model uses the same version of the development environment and does not have different additional annotations, so that modifications in the functional model cannot be automatically transferred to the annotated model for code generation. Summary of the invention
[0008] Against this background, it is an object of the present invention to further improve the prior art and in particular to support the transfer of modifications between different model types.
[0009] This object is achieved by a method according to the invention for transferring changes between block diagrams, by a computer program product according to the invention and by a computer system according to the invention.
[0010] Therefore, a method for transmitting modifications between block diagrams is provided. The block diagram comprises a periodically calculated model consisting of blocks connected by signals, wherein the basic model comprises one or more basic blocks, wherein the basic blocks have one or more basic parameters, wherein the extended model comprises one or more basic blocks and at least one extended block, wherein the extended block has at least one additional extended parameter, in particular one or more parameters for code generation. A first block diagram comprises a first version of the basic model, a second block diagram comprises an extended model generated from the first version of the basic model, wherein a third block diagram comprises a second version of the basic model, wherein the first version is older than the second version. According to the invention, the method comprises the following steps:
[0011] applying a plurality of transformation rules to the first block graph in order to obtain a first intermediate model, wherein the transformation rules comprise criteria for identifying blocks and modifications to be applied to the identified blocks, wherein at least one extended block is added and / or at least one basic block is deleted,
[0012] Compare the second block diagram with the first intermediate model,
[0013] determining at least one configuration rule from the comparison, wherein the configuration rule comprises a rule for identifying a block or a parameter and a modification to be applied to at least one parameter, in particular an extended parameter,
[0014] applying the plurality of transformation rules to the third block diagram to obtain a second intermediate model, and
[0015] Applying the at least one configuration rule to the second intermediate model in order to obtain a fourth block diagram. Suitably, the fourth block diagram comprises an extended model of the second version and is in particular prepared for code generation.
[0016] If two or more blocks are connected by signals, this is expediently represented in the model by signal lines, and signals or data can be transferred between the connected blocks; in this case, in particular, the first block outputs one value or, by definition, a plurality of associated values, while the second block receives these multiple associated values and takes them into account when determining one or more associated output values of the second block. Signals can contain scalar variables and / or structured data types such as arrays, as is the case, for example, in buses. Unlike signals, the parameters of blocks remain fixed during model execution or code generation; these parameters serve in particular to define the properties of blocks or the generated code and are therefore usually only modified during modeling.
[0017] The present invention is based on the consideration that a direct three-way merge does not make sense for models with different semantic layers, i.e., where there is at least one basic model and at least one extended model. Instead, the differences between models with different semantic layers but the same version are considered separately from the differences between different versions of the models. In the transition from one semantic layer to another, a basic block can in particular be replaced by an extended block; a basic block can also be replaced by one or more blocks, at least one of which is an extended block. In this case, the functionality performed by the basic model and the extended model is usually largely the same. Certain differences between the calculated signal values may, for example, be caused by the use of fixed-point data types in the extended model. If, for example, the user has added a set of blocks, significant functional differences may occur between different versions of the model.
[0018] The processing of the individual blocks and / or the separated groups of blocks is expediently expressed as a transformation rule, which comprises a criterion for identifying the blocks and a modification to be applied to the identified blocks, wherein at least one extended block is added and / or at least one basic block is deleted. According to another concept, the transformation rule can usually be fixedly predetermined, because the basic block can always be replaced by the same extended block or the same group of blocks regardless of the position of the basic block. For example, the transformation rule can indicate that the basic port of the output signal is replaced by the corresponding extended port; this is generally applicable and can therefore be easily automated. Expediently, for each block of the basic model, it is checked whether the identification rule is met, and if so, the predetermined modification is applied in each case.
[0019] Additional attributes or at least one extended parameter may in particular include settings for code generation, such as scaling, value range, variable type or data type. For example, the scaling of an extended block is also related to the scaling of adjacent extended blocks, i.e., local environments, and, if necessary, the operations of adjacent extended blocks, i.e., local environments. According to another conception, the configuration rules may therefore be context-dependent, and are therefore suitably determined by comparing two models of the same version. By converting the basic model of the first or old version into an intermediate model corresponding to the extended model in terms of the semantic layer, a suitable comparison basis is provided so that as many modifications as possible in these context-dependent modifications can be automatically undertaken. The user does not have to do so much manual adaptation to prepare the model of the new version for code generation.
[0020] If the model goes through several different versions, the configuration rules determined in the past can usually continue to be applied, so that the manual effort for creating corresponding extended models with the increase of model versions is significantly reduced. Therefore, by storing the learned rules or by a learning mechanism, the user can be relieved even more significantly.
[0021] In principle, there may also be more than two semantic levels if, for example, an additional block library always includes blocks with one or more further parameters. The transition from a "simple" annotation of a model for code generation to a fully annotated model (e.g. for code generation adapted to AUTOSAR) can also be considered or processed as a transition between semantic levels. A stepwise adaptation can then take place, wherein the conversion rules preferably always include a transition between a first semantic level and a next semantic level, wherein the corresponding extended block has one or more extended parameters from a predefined set of extended parameters of this level.
[0022] Preferably, determining the configuration rules comprises: displaying the difference between the second block diagram and the first intermediate model and receiving user input, wherein the user can edit, enable or discard the configuration rules derived from the difference, and wherein the edited or enabled configuration rules are stored. In particular, the difference can be displayed in a graphical user interface, wherein the user enables, adapts or discards the determined configuration rules. Therefore, expediently, a plurality of individual configuration rules are determined based on the comparison of the two block diagrams, wherein the individual configuration rules respectively relate to individual blocks or groups of individual blocks.
[0023] Particularly preferably, the transformation rules and / or configuration rules are stored in a database and an operator interface is provided to the user in which the transformation rules and / or configuration rules can be defined and / or edited, whereupon the new or modified rules are stored in the database. The transformation rules can be designed in different ways, for example as a script in a scripting environment, which can control the model editor. It can also be provided that versions are assigned to the transformation rules and that the application of the transformation rules to basic or extended models with a predetermined version and / or a predetermined creation time is restricted, for example in order to take into account modifications within the semantic layer.
[0024] Particularly preferably, two or more stored configuration rules are compared on common points in order to obtain a common configuration rule, and the common configuration rule is displayed in an operation interface that enables editing, activation or discarding of the common configuration rule, wherein the common configuration rule is stored in the case of editing or activation. Preferably, priorities can be assigned to the configuration rules, so that, for example, the common configuration rule is applied first and only the special configuration rules are used to handle situations that are not covered. The assignment of priorities can be performed by the user or automatically, for example automatically depending on the degree of commonality of the configuration rules.
[0025] Preferably, the block diagram is defined hierarchically, wherein a block in a higher layer can include a plurality of lower-level blocks, wherein the lower-level blocks are assigned to the blocks in the higher layer and the blocks are identified based on a block type that describes the functionality and / or based on a model path that describes the position of the block in the hierarchical model and / or based on the block name. If the block includes a mask for defining the diagram, the block type can also be determined based on the mask type (e.g. TL_CustomCode).
[0026] Preferably, after applying the configuration rules, at least one plausibility condition is checked, wherein if it is not met, an error message is output and / or a graphical user interface for modifying parameters, in particular for extending parameters, is displayed. The annotated extension model is advantageously checked for plausibility according to a predetermined set of rules and possibly existing user rules. In the event of an error, the user can adapt the parameters in the graphical user interface so that, in other words, critical positions are automatically addressed. The plausibility conditions can be predetermined or expressed by the user, wherein both general plausibility conditions, i.e., those that are always checked, and special plausibility conditions, i.e., those that are assigned to specific configuration rules, can be defined or checked.
[0027] For the case of hierarchically defined block diagrams, in which a block in a higher level may include multiple blocks in lower levels, where the blocks in lower levels are assigned to blocks in higher levels, it is advantageous to equate the blocks of one block diagram with the blocks of the other block diagram before the comparison between the two block diagrams. That is, from the perspective of the comparison program, the two blocks are the same block. This equating describes the relative layout between the two models and avoids multiple misleading error reports when, for example, additional levels are added. The user can specify the layout or the blocks to be equated in the graphical user interface. It can also be provided that the assignment is saved in the form of rules, in which the relationship is applied before the comparison of the models. It can also be provided that for different levels or separate areas such as subsystems, the inherent relationship between the two blocks is respectively described in order to specify the relative position for the corresponding layers.
[0028] Preferably, for a rule for adding a block to a block diagram, wherein the added block is connected to at least one previously existing block via a signal, according to an additional rule, the value of at least one parameter of the added block is selected as a function of one or more parameter values of adjacent blocks in the signal flow, in particular of the immediately preceding block and / or the immediately succeeding block. Suitably, the rule is a conversion rule and the additional rule is a configuration rule. For example, for a newly added block, the scaling of the signal can be determined as a function of adjacent blocks in the signal flow, in particular above the arranged block; signal characteristics or labels or markings can also be used in general.
[0029] Preferably, a previously defined block providing functionality from a library can be added to the block diagram, wherein the defined block providing functionality can exist multiple times in the block diagram, and at least one defined block is assigned one or more conversion rules. Suitably, the one or more conversion rules are stored in the block library as additional information. The conversion rules can also include: in the case of multiple instances of a block in the block diagram, defining a common function for these instances and defining a data structure with block variables for each instance, wherein depending on the block to be executed, the corresponding data structure is assigned to the function.
[0030] Preferably, the rules include: if in the modified block diagram, an intermediate block among the three blocks of the original block diagram arranged sequentially in the signal flow is missing or deleted, and the intermediate block has a scaling of the output signal that is different from that of the blocks upstream of the signal flow, and the blocks downstream of the signal flow should inherit or adopt the scaling according to the settings, then the scaling block is automatically added.
[0031] Preferably, the method additionally comprises generating source code from the fourth block diagram.
[0032] The invention also relates to a method for transmitting modifications between block diagrams, the block diagrams comprising a cyclically calculated model consisting of blocks connected by signals, wherein a basic model comprises one or more basic blocks, wherein a basic block has one or more basic parameters, wherein an extended model comprises one or more basic blocks and at least one extended block, wherein the extended block has at least one additional extended parameter, in particular one or more parameters for code generation, wherein a first block diagram comprises a first version of the extended model, wherein a second block diagram comprises a first version of the basic model, wherein a third block diagram comprises a second version of the extended model, and wherein the first version is lower, that is to say older, than the second version, the method comprising the following steps:
[0033] applying at least one inverted transformation rule to the third block diagram in order to obtain a first intermediate model, wherein the transformation rule comprises a criterion for identifying blocks and modifications to be applied to the identified blocks, wherein at least one extension block is added and / or at least one basic block is deleted according to the transformation rule, wherein the inverted transformation rule undoes the modifications to the assigned transformation rule,
[0034] comparing the first intermediate model with the second block diagram in order to determine basic blocks and / or basic parameters that are modified,
[0035] transferring the determined modifications to the first block diagram in order to obtain a second intermediate model, and
[0036] Applying at least one transformation rule to the second intermediate model to obtain a fourth block diagram.
[0037] In this form, the method according to the present invention can transfer modifications to the new version of the extended model to the old version of the extended model, wherein modifications within the semantic layer may also occur between different versions. In the example of the invention, the version of the code generator or the entire tool chain is usually kept unchanged. Here, according to the method of the invention, for example, a patch created later can be applied to an old model version, which was created with an old tool chain or an old version of the code generator. Due to the approach via the basic model, a new copy of incompatible language tools of the new version is avoided. Preferably, a distinction is made between the transformation rules of different versions, wherein one or more language tools are applied or avoided in the rules depending on the version.
[0038] The invention further relates to a method for configuring a control device, wherein the control device comprises at least one computing unit and preferably has at least one sensor and / or at least one actuator in order to detect data of a physical process and / or to influence the physical process, the method comprising the following steps:
[0039] a. creating a fourth block diagram using a method for transmitting a modification according to the present invention,
[0040] b. Generate source code from the fourth block diagram,
[0041] c. compiling the source code for the computing unit to generate executable code,
[0042] d. transfer executable code to the control device, and
[0043] e. Saving the executable code in a non-volatile memory of the control device and / or executing the executable code by a computing unit of the control device.
[0044] The invention further relates to a computer program product having a computer-readable storage medium on which instructions are embedded which, when executed by a processor, cause the processor to be set up to carry out the method according to the invention for transmitting modifications.
[0045] The invention furthermore relates to a computer system comprising a human-machine interface, a non-volatile memory and a processor, wherein the processor is set up to execute the method according to the invention for transmitting modifications. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The invention will be further described below with reference to the accompanying drawings. In this case, identical parts are provided with the same reference numerals. The embodiments shown are very schematic and not to scale.
[0047] in:
[0048] Figure 1 A preferred embodiment of a computer system is shown;
[0049] Figure 2 A schematic diagram showing software components preferably present on a computer system;
[0050] Figure 3 shows the general scheme for generating source code;
[0051] Figure 4 A schematic diagram showing a comparison between two block diagrams;
[0052] Figure 5 Schematic diagrams showing different embodiments of the model;
[0053] Figure 6 a schematic diagram showing a transformed form of the model;
[0054] Figure 7 A schematic diagram of two hierarchical models is shown; and
[0055] Figure 8 A schematic diagram of an exemplary operation interface is shown. DETAILED DESCRIPTION
[0056] Figure 1 A preferred embodiment of a computer system PC is shown. The computer system has: a processor CPU, which can be implemented as a multi-core processor in particular; a working memory RAM; and a bus controller BC. Preferably, the computer system PC is designed to be directly manually operated by a user, wherein the display DIS is preferably connected via a graphics card GPU and the keyboard KEY and mouse MOU are connected via a peripheral interface HMI. In principle, the man-machine interface of the computer system PC can also be constructed as a touch interface. The computer system also includes: a non-volatile data storage HDD, which can be implemented as a hard disk and / or a solid state disk in particular; and an interface NET, in particular a network interface. The control device ES can be connected via the interface NET. In principle, one or more arbitrary interfaces, in particular wired interfaces, can exist on the computer system PC and can be used for connection with the control device ES respectively. Suitably, a network interface according to the Ethernet standard can be used; the interface NET can also be implemented wirelessly, such as in particular as a WLAN interface or as an interface according to a standard such as Bluetooth.
[0057] The control device ES can be implemented as a series control device or as an evaluation board for a target platform. Suitably, the control device comprises: an interface NET for connecting to a computer system PC; a microcontroller MCR having an architecture different from the processor of the computer system; a working memory RAM; and a non-volatile memory NVM. For the embodiment of the present invention, the control device ES which can be suitably used for the testing of the model is not required.
[0058] In principle, the computer system can also be designed as a client-server system, in which one or more software components are executed on an external server.
[0059] exist Figure 2 In , the scheme of software components which are preferably installed on a computer system PC is shown. These software components use the mechanisms of the operating system OS, for example to access a non-volatile memory HDD or to establish a connection with an external computer via a network interface NET.
[0060] The technical computing environment TCE is capable of generating models and generating source code from these models. In the modeling environment MOD, models of dynamic systems can preferably be created via a graphical user interface. In this case, block diagrams can be involved in particular, which include multiple blocks and describe the time behavior and / or internal states of the dynamic system. At least some of these blocks are connected by signals, i.e., directional connections for exchanging data, which can be scalar or combined. Blocks can be atomic, i.e., provide a predefined functionality in one step. If the block diagram is hierarchical, multiple blocks at the lower level can describe the structure of the blocks at the upper level. Preferably, atomic blocks can also include multiple blocks at the lower level. Combined blocks can be subsystems in particular; subsystems can have additional characteristics, such as the implementation of individual functions and / or the triggering of the implementation of subsystems by dedicated signals. Specific blocks can be arranged in subsystems in order to further specify the characteristics of the subsystems in detail. The computing environment TCE preferably includes one or more libraries, from which blocks or modules can be selected for modeling. In the scripting environment MAT, instructions can be entered interactively or via batch files to perform calculations or adjust the model. The computing environment TCE also comprises a simulation environment SIM which is set up to interpret or execute the block diagrams in order to examine the time behavior of the system. Preferably, these calculations are performed on one or more cores of a microprocessor CPU of the computer system using high-precision floating point numbers.
[0061] From the created model, source code can be generated by means of a code generator PCG, preferably in the programming language C. Advantageously, in the definition data set DDT, additional information is formed into the model, in particular into block variables. Advantageously, these block variables are assigned value ranges and / or scaling in order to support the calculation of the model with fixed-point instructions. The desired properties of the source code, for example, compliance with standards such as MISRA, are also determined. can be set or saved in a definition data set DDT. Suitably, each block variable is assigned a predetermined variable type and one or more desired characteristics, such as the admissibility of optimizations such as variable integration, are set. The code generator PCG preferably analyzes the settings of the definition data set DDT and takes these settings into account when generating the source code. The definition data set DDT can have a tree structure or be saved as a simple file in the memory of the computer system; optionally, it can be provided that the definition data are saved in a dedicated database system. The definition data set may have a program interface and / or an import / export function. The technical computing environment TCE also includes a converter CNV, which converts the model with the parameters important for code generation into an intermediate form suitable for comparison.
[0062] The computer system PC has a compiler COM and a linker, which are suitably set up to generate binary files that can be executed on the control device ES and / or the computer system PC. In principle, there can be multiple compilers, especially cross compilers for different target platforms, in order to support control devices or evaluation boards ES with different processor architectures. In addition, there is a comparison program MOC, which receives two models in an intermediate form and determines and preferably displays the differences. In addition, configuration rules can be determined or derived from one or more determined differences. Preferably, the comparison program includes a graphical user interface, in which the user can see and then edit, confirm or discard the derived configuration rules. In addition, there can also be a version control system VCS, which stores different versions of block diagrams and / or generated intermediate forms in a database.
[0063] Figure 3 The general scheme for generating source code with the aid of a code generator is shown. The method can be implemented completely by a processor of a preferred embodiment of a computer system PC; however, the method can also be configured to be implemented in a client-server environment with an operating computer and one or more servers connected via a network, wherein in particular the computationally intensive steps are performed on these servers.
[0064] In the first step S1, i.e. conversion, the selected model consisting of one or more blocks of the block diagram BLD is converted into an intermediate diagram IR, which preferably includes one or more hierarchical graphs. In this case, it may be a data flow diagram, a control flow diagram or a tree structure in particular. In addition to the block diagram BLD, it is appropriate that additional information from the definition data set DDT is also taken into account when generating the intermediate diagram or has an impact on the intermediate diagram. This may also include the following situations, in which elements or characteristics of elements or settings important for code generation, such as data types of variables, are generated based on the information in the definition data set DDT.
[0065] In the second step S2, i.e., optimization, the hierarchical graph is optimized in order to reduce the number of required variables and / or memory usage, such as stack occupancy and / or the number of operations or processor instructions and / or the execution time of the source code. The optimization may include a plurality of intermediate steps in which other intermediate diagrams are generated between the model / block diagram and the source code / program text. In particular, it may be provided that in each intermediate step, a set of the original hierarchical graphs is converted into another set of modified hierarchical graphs, wherein one or more optimization rules are applied. Different strategies may be applied during the optimization, such as "Constant folding" or the removal of "Dead Code". It may also be provided that some optimizations have already been applied within the scope of the conversion of step S1, in particular when these optimizations can be performed more simply on the block diagram diagram.
[0066] In the third step S3, i.e., translation, the optimized intermediate graphical representation IR or optimized hierarchical graph obtained by all the executed intermediate steps is translated into a source code PCO of a textual programming language, such as, in particular, C code. In this step, further optimization can also be performed, in particular, so that the generated instructions are a subset of the instructions included in principle by the language and / or the generated control structure is a subset of the control structure included in principle by the language. This can just meet the defined rules. Optionally or supplementally, it can be provided that additional information, such as the relationship between the program line and the block of the block diagram BLD, is generated and in particular, this additional information is integrated into the source code in the form of annotations to improve the readability of the source code PCO and / or simplify debugging.
[0067] During or after code generation, information about the current block diagram or results of the code generation, such as alarms, can be stored in a definition data set. This information can be used, for example, to influence the compilation of the generated source code or to provide meta information for other tools, such as calibration information in the ASAP2 format or information for generating intermediate layers according to the AUTOSAR standard. In an alternative embodiment, it can be provided that a code in a hardware description language or a configuration of a programmable hardware module is generated from the block diagram.
[0068] Figure 4 A comparison between two block diagrams is schematically shown. In this case, in a first step, the first block diagram under consideration is opened in the model editor MOD of the technical computing environment TCE1 and converted into an intermediate form INF1 with a converter CNV. This intermediate form is particularly suitable for comparison and includes current parameter values, which are adapted under the script environment MAT. The script environment MAT can be used for automated manipulation of the model editor MOD and the converter; in addition, it can also be provided that the comparison results are filtered, modified or supplemented by means of filter scripts. Immediately or in parallel, in a second step, the second block diagram under consideration is opened in the model editor MOD of the technical computing environment TCE2 and converted into an intermediate form INF2 with a converter CNV, wherein the script environment MAT can perform manipulation and / or filtering. In sequential processing, TCE1 and TCE2 can represent the same technical computing environment, while the intermediate forms INF1 and INF2 are at least temporarily stored in a file system or a database. In parallel execution, two independent instances (Instanz) TCE1, TCE2 of the technical computing environment are opened.
[0069] The two intermediate forms are supplied to a comparison program MOC which generates a list with the differences DIFF. Preferably, the comparison program also comprises a component which determines the configuration rules as a function of the differences between the first and second block diagrams. Thus, a plurality of configuration rules can be derived from the comparison of the two block diagrams (depending on the number of differences). The configuration rules obtained can be stored in a database, wherein preferably a check is performed to see whether the corresponding configuration rules already exist so that no new storage should be performed.
[0070] exist Figure 5 , schematically shows the following situation, in which modifications on the basic model should be transferred to the extended model. In particular, the basic model can be a Simulink model and the extended model can be a TargetLink model.
[0071] The old version of the basic model B1.0, the extended model E1.0 and the new version of the basic model B 2.0 are shown. The basic model B1.0 includes: an input port In1; a gain block Gain, which amplifies the input signal by k times (or perhaps attenuates it, when k<1); and an output port Out1. In the extended model E1.0, the input and output ports are replaced by corresponding ports with additional parameters (indicated by two diagonal lines in the port). The gain (Gain) block is also replaced by a corresponding extended block (indicated by a double line). For the output port, two extended parameters are exemplarily described, that is, the desired data type Int8 of the output variable and the desired scaling 2 -13 The new version of the basic model B 2.0 includes a saturation block Saturation, which limits the output signal of the gain block to a predetermined interval. For code generation, the new version of the extended model E 2.0 is required.
[0072] Differences between the old basic model B1.0 and the revised basic model B 2.0 can be determined by comparing the two models using the comparison program MOC. In order to prevent a large number of so-called differences from occurring, it is generally advisable that the models are "aligned" in this case, i.e. a block defined by the user in the old basic model B1.0 corresponds to a block in the new basic model B 2.0 or is identical to this block. This applies in particular to extensive models with a plurality of levels and a plurality of individual blocks.
[0073] The difference between the extended model E1.0 and the original basic model B1.0 can be divided into: general conversion, such as replacing the output ports of the basic form by output ports in the extended diagram; and special configuration, such as the selection of a certain scaling on the output port. Therefore, the conversion rules TV can be distinguished from the configuration rules KV. If only the conversion rules are applied to the basic model, an intermediate model E1.0* or E 2.0* is formed, which contains extended blocks but is not suitable for code generation due to the lack of suitable properties. Suitable properties or extended parameters are usually context-dependent and therefore change with the placement of the corresponding block in the model and / or adjacent blocks or parameters of these adjacent blocks. In contrast, once defined conversions can usually be applied to basic blocks of a predetermined type without modification.
[0074] Figure 6 Schematically shows the Figure 5The transformed form of the new model of the situation outlined in . The input ports of the new basic model B 2.0 have been replaced by corresponding extended ports with additional parameters by means of transformation rules. The values of the additional parameters can be adapted by the following configuration rules, which are determined by a comparison of the (extended) input ports in the transformed basic model B1.0, i.e. the intermediate model E1.0*, with the extended input ports in the extended model E1.0 or have been determined by a comparison of the (extended) input ports in the transformed basic model B1.0, i.e. the intermediate model E1.0*, with the extended input ports in the extended model E1.0. The gain blocks have been replaced by extended gain blocks using another transformation rule. The values for the additional parameters can be adapted by means of configuration rules which are determined by a comparison of the (extended) gain blocks in the intermediate model E1.0* with the extended gain blocks in the extended model E1.0 or have been determined by a comparison of the (extended) gain blocks in the intermediate model E1.0* with the extended gain blocks in the extended model E1.0. Similarly, the output ports can also be transferred to the new extended model E 2.0 by means of general conversion rules and position-dependent configuration rules. The values for the data type Int8 and the values for scaling at the output ports 2 are shown by way of example. -13 .
[0075] The saturation blocks in the new basic model B 2.0 have been replaced by extended saturation blocks by means of conversion rules (indicated by the double lines above and below). The values Dt for the data type and the values Sk for the scaling cannot be determined by comparing the extended model E1.0 with the intermediate model E1.0*, since the saturation blocks are not present in the basic model B1.0. Therefore, directly applicable location-specific configuration rules are not available.
[0076] In the present case, in which a new block (saturation block) is added between the front block (gain block) and the rear block (output port), it is advantageous to obtain possible values for the extension parameter from consideration of adjacent blocks; general or adaptive configuration rules may be mentioned. For example, the value of the extension parameter of the output port to be extended can be used here. In an optional processing method, the values of the front block and the rear block can be compared, wherein, in the case of agreement, a common value can be used for the block to be added. Whether one processing method is more suitable or another processing method is more suitable may be different for each individual extension parameter. Therefore, the comparison program preferably includes an operating interface in which the user can choose between different possibilities. The selected processing method is then preferably stored as a new configuration rule.
[0077] Figure 7Schematic diagrams of two hierarchical models to be compared are shown. On the left is a first block diagram with a first level E1 and a second level E2. On the right is a second block diagram with three levels E1, E2 and E3.
[0078] In level E1, the first block diagram includes a definition block D1 and four blocks B1, B2, B4, B5 connected by signals. Block B4 is a hierarchical block, the functionality of which is defined by a number of blocks in the lower level E2. For simplicity, it is assumed that blocks B1, B2, B5 are simple blocks without lower levels; however, in principle, other hierarchical blocks may also exist, which would then be implemented in separate lower levels.
[0079] In the lower level E2, the first block diagram comprises an input port P21, an output port P22 and three signal-connected blocks B21, B2, B23, which perform calculation operations.
[0080] In the first level E1, the second block diagram includes a definition block D1 and five blocks B1, B2, B3, B4, B5 connected by signals. Compared with the first block diagram, an additional block (B3) is added between B2 and B5. As explained above, the value of the expansion parameter for the converted block can be determined by comparing the previous block with the next block. However, for example, it may also happen that the newly added block makes the previous value of the next block invalid. If block B3 is a gain block with a large gain, the previous data type of the signal entering B5 may also overflow. Therefore, it is appropriate to suggest a "worst case" scaling for the subsequent blocks after adding the blocks that are problematic in this regard. Specifically, for example, an 8-bit wide integer variable may be replaced by a 16-bit wide integer variable. Preferably, the suggested modification is presented to the user in a graphical user interface so that the user can confirm, edit or discard the modification. In addition, it can also be provided that a list with such suggestions or key positions is presented in the modified model. As a result, the user can specifically allow jumping to the corresponding position and select the appropriate processing method respectively.
[0081] For simplicity, it is assumed in the present case that only the block B4 of the first level of the second block diagram is a hierarchical block. The second level comprises an input port P21, a block B21 and an output port P22. Block B21 is a hierarchical block, the implementation of which is modeled by other blocks of the third level E3 at the lower level. The third level E3 comprises: an input port P31; three blocks B31, B32, B33; and an output port P32. In a direct comparison of the first block diagram with the second block diagram, all blocks below the respective first level will be presented as differences. This can be advantageous; for example when the block B4 on the left has been replaced by a semantically completely different block. However, it can also be misleading that, for example, the layer E2 of the first block diagram is consistent with the layer B3 of the second block diagram, where the additional level has been added as space for later expansion (such as pre-filtering of the input signal). A direct comparison will result in a large number of misleading differences. In this case, it is expedient to make the left block B4 identical to the right block B21, since the underlying structurally consistent modeling can then be checked for parameter deviations. The user advantageously makes this decision, and the decision can be stored, for example, as a separate rule to be executed before the comparison.
[0082] Figure 8 An exemplary user interface is schematically shown, which enables editing of conversion and / or configuration rules. In principle, a rule comprises a filter, ie a condition to be checked or a pattern to be checked for consistency, and an action, ie a modification to be applied when the condition is met or the pattern is consistent.
[0083] The configuration rules determined by the comparison between the extended model and the assigned intermediate model are usually first of all specific or location-related. In the case of a hierarchical model, the location can be stated, for example, in the form of a block path, which includes upper subsystems or levels. Preferably, after a large number of configuration rules have been determined and saved in the database, it is checked whether multiple individual configuration rules can be used universally. In addition, the user can pre-set priorities, wherein basic preferences for universal configuration rules can also be specified. Optionally, it can also be specified that after the universal configuration rule is identified and saved, one, more or all of the individual configuration rules covered by it are deleted from the database or marked as invalid. Similar to the conversion rules, the universal configuration rules can contain filtering based on block type; however, it can also be specified that the existence of a certain environment, that is, the blocks defined as the front block and / or the back block are used as filtering criteria.
[0084] In the illustrated user interface, the left side shows the "Filter" section in which the user can enter a filter. For this purpose, the field "Pfad (path)" and the assigned input field as well as the field "Blocktyp (block type)" with the assigned input field are provided. In principle, other fields or characteristics can also be used for filtering. In the example shown, the user can therefore specify filtering only on a specific path or only on a specific block type. In addition, it is also conceivable that the user expresses combined criteria such as "the path contains a specific subsystem" and "the block type has a specific value".
[0085] In the illustrated user interface, the "Action" section is shown on the right, in which the user specifies the action to be performed or the modification to be applied when a condition is met or at all locations where the condition is met. For this purpose, the field "Typ", the field "Name" and the field "Classification" are provided, each with an assigned input field. Accordingly, the modifications to be applied can include: setting the block type to the value specified under "Typ" and / or setting the block name to the value specified under "Name" and / or setting the variable classification to the value specified under "Classification". In principle, other, unspecified modifications or execution actions can also be applied.
[0086] In the user interface shown, the " In the "Plausibility" section, the user can specify the conditions that are to be checked after applying the changes. For this purpose, the fields "Parameter", "Min.Wert" and "Max.Wert" are provided with assigned input fields. In addition (not shown), it is also possible for the user to specify whether a general warning should be displayed or the corresponding position in the model if the plausibility conditions are not met, or whether the applied changes should be undone in the event of a lack of plausibility.
[0087] The method or corresponding system according to the invention enables the user to gradually build up a set of configuration rules or conversion rules. In particular, when codes are to be generated from a plurality of successive versions of a basic model, the adaptation effort is significantly reduced as the number of versions increases.
Claims
1. A method for transmitting modifications between block diagrams, the block diagrams comprising a periodically calculated model consisting of blocks connected by signals, wherein: The basic model includes one or more basic blocks, wherein the basic block has one or more basic parameters, wherein the extended model includes one or more basic blocks and at least one extended block, wherein the extended block has at least one additional extended parameter, wherein the extended parameter is one or more parameters for code generation, wherein the first block diagram includes a first version of the basic model, wherein the second block diagram includes an extended model generated from the first version of the basic model, wherein the third block diagram includes a second version of the basic model, and wherein the first version is older than the second version, the method comprising the following steps: • applying a plurality of transformation rules to the first block diagram in order to obtain a first intermediate model, wherein the transformation rules comprise criteria for identifying blocks and modifications to be applied to the identified blocks, wherein at least one extended block is added and / or at least one basic block is deleted, • Compare the second block diagram with the first intermediate model, • determining from said comparison at least one configuration rule, wherein the configuration rule comprises a rule for identifying a block or a parameter and a modification to be applied on at least one parameter, • applying the plurality of transformation rules to the third block diagram to obtain a second intermediate model, and • Applying the at least one configuration rule to the second intermediate model to obtain a fourth block diagram.
2. The method according to claim 1, It is characterized in that Determining the configuration rules includes: displaying the differences between the second block diagram and the first intermediate model and receiving user input, wherein the user can edit, enable or discard the configuration rules derived from the differences, and wherein the edited or enabled configuration rules are stored.
3. The method according to claim 1 or 2, It is characterized in that The conversion rules and / or configuration rules are stored in a database, and an operation interface is provided to the user, in which the conversion rules and / or configuration rules can be defined and / or edited, and then the new or modified rules are stored in the database.
4. The method according to claim 3, It is characterized in that Two or more stored configuration rules are compared on common points to obtain a common configuration rule; and the common configuration rule is displayed in an operation interface, and the operation interface enables editing, enabling or discarding the common configuration rule, wherein in the case of editing or enabling, the common configuration rule is stored.
5. The method according to claim 1 or 2, It is characterized in that The block diagram is defined hierarchically, wherein a block in a higher layer can include multiple lower-layer blocks, and the lower-layer blocks are assigned to the blocks in the higher layer; and the blocks are identified based on a block type that describes the functionality and / or based on a model path that describes the location of the block in the hierarchical model and / or based on the block name.
6. The method according to claim 1 or 2, It is characterized in that After the configuration rules have been applied, at least one plausibility condition is checked, wherein, if it is not met, an error message is output and / or a graphical user interface is displayed for modifying parameters.
7. The method according to claim 1 or 2, It is characterized in that The block diagrams are defined hierarchically, wherein a block in a higher layer can include a plurality of lower layer blocks, wherein the lower layer blocks are assigned to the higher layer blocks, and before comparison between the two block diagrams, blocks of one block diagram are equated with blocks of another block diagram.
8. The method according to claim 1 or 2, It is characterized in that For the rule of adding a block to a block diagram, the added block is connected to at least one previously existing block via a signal, and according to an additional rule, the value of at least one parameter of the added block is selected depending on one or more parameter values of adjacent blocks in the signal flow.
9. The method according to claim 1 or 2, It is characterized in that Predefined blocks providing functionality from a library can be added to the block diagram, wherein defined blocks with the same functionality can exist multiple times in the block diagram; and at least one predefined block is assigned one or more conversion rules.
10. The method according to claim 1 or 2, It is characterized in that The rules include: if in the modified block diagram, the middle block of the three blocks arranged sequentially in the signal flow of the original block diagram is missing or the middle block is deleted, and the scaling of the output signal by the middle block is different from that of the block upstream of the signal flow, and the block downstream of the signal flow should inherit or adopt the scaling according to the setting, then the scaling block is automatically added.
11. The method according to claim 1 or 2, characterized in that: Source code is generated from the fourth block diagram.
12. The method according to claim 1 or 2, It is characterized in that Configuration rules include rules for identifying blocks or parameters and modifications to be applied on extended parameters.
13. The method according to claim 6, It is characterized in that If not met, an error message is output and / or a graphical user interface for modifying the extended parameters is displayed.
14. The method according to claim 8, It is characterized in that The adjacent blocks include an immediately preceding block and / or an immediately succeeding block.
15. A method for transmitting modifications between block diagrams, the block diagrams comprising a periodically calculated model consisting of blocks connected by signals, wherein: The basic model includes one or more basic blocks, wherein the basic block has one or more basic parameters, wherein the extended model includes one or more basic blocks and at least one extended block, wherein the extended block has at least one additional extended parameter, wherein the extended parameter is one or more parameters for code generation, wherein a first block diagram includes a first version of the extended model, a second block diagram includes a first version of the basic model, a third block diagram includes a second version of the extended model, and wherein the first version is older than the second version, and the method includes the following steps: • applying at least one inverted transformation rule to the third block diagram in order to obtain a first intermediate model, wherein the transformation rule comprises a criterion for identifying blocks and modifications to be applied to the identified blocks, wherein at least one extension block is added and / or at least one basic block is deleted according to the transformation rule, wherein the inverted transformation rule undoes the modifications to the assigned transformation rule, • comparing the first intermediate model with the second block diagram in order to determine the basic blocks and / or basic parameters that are modified, • transferring the determined modifications to the first block diagram in order to obtain a second intermediate model, and • Apply at least one transformation rule to the second intermediate model to obtain a fourth block diagram.
16. A method for configuring a control device, wherein: The control device comprises at least one computing unit, and the method comprises the following steps: a. Using a method according to one of claims 1 to 15 to create a fourth block diagram, b. generating source code from the fourth block diagram, c. compiling the source code for the computing unit to generate executable code, d. transmitting the executable code to the control device, and e. Saving the executable code in a non-volatile memory of the control device and / or executing the executable code by a computing unit of the control device.
17. The method according to claim 16, characterized in that The control device comprises at least one sensor and / or at least one actuator in order to detect data of a physical process and / or to influence the physical process. 18 . A computer program product having a computer-readable storage medium on which instructions are stored which, when executed by a processor, cause the processor to be set up to carry out the method according to claim 1 .
19. A computer system comprising a human-machine interface, a non-volatile memory and a processor, wherein: The processor is set up to carry out the method according to one of claims 1 to 17 .
