A method and device for automatically generating a state machine model based on a demand matrix

By constructing a requirement matrix and automatically generating a state machine model, the problems of errors introduced by manual development and high time consumption are solved, and efficient and accurate state machine model design is achieved.

CN119829900BActive Publication Date: 2026-04-28XIAN FLIGHT SELF CONTROL INST OF AVIC
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAN FLIGHT SELF CONTROL INST OF AVIC
Filing Date
2024-12-24
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

When using model-based system design methods in engineering, manually developing state machine models is prone to introducing errors and requires a lot of time when there are many state transitions.

Method used

By constructing a requirement matrix, including a list of interface information, a list of state behaviors, a state transition condition matrix, and a priority matrix, a state machine model is automatically generated, and model elements are injected according to pre-defined modeling standards.

Benefits of technology

This reduces the workload of manual labor, improves the efficiency and quality of state machine model design, and ensures the accuracy and reliability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829900B_ABST
    Figure CN119829900B_ABST
Patent Text Reader

Abstract

The application provides a demand matrix-based automatic generation method and device for a state machine model, which comprises the following steps: step 1: constructing a demand matrix according to the demand information and performing formulaic description in the demand matrix; the demand matrix comprises an interface information list, a state behavior list, a state transition condition matrix and a priority matrix; step 2: generating a blank model file, then extracting the interface information in the demand matrix, converting the interface information into a state machine model interface framework and automatically injecting the interface information into the blank model file; step 3: extracting state information in the state behavior list, according to the type of each state and state behavior, injecting model elements into each state according to a pre-set modeling standard and writing corresponding content; step 4: extracting transition information in the state transition condition matrix and priority information of each state transition in the priority matrix, and injecting model elements into each state transition and transition condition according to the pre-set modeling standard.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer science, specifically to a method and apparatus for automatically generating state machine models based on a demand matrix. Background Technology

[0002] In model-based system development, model design is a crucial step. A requirement-based model can be used for early simulation verification and later code generation; the correctness of the model has a significant impact on the efficiency and quality of the entire project.

[0003] However, when using model-based system design methods in engineering, on the one hand, developing state machine models manually during the research and development process can introduce human-induced errors, and on the other hand, the state machine model itself contains a lot of information, especially when there are many state transitions, so manual development requires a lot of time. Summary of the Invention

[0004] The purpose of this invention is to provide an automatic state machine model generation technology based on a demand matrix, which can be used to generate state machine models that meet project requirements; this reduces the workload of model designers and increases the efficiency and quality of model design.

[0005] Firstly, this application provides a method for automatically generating a state machine model based on a demand matrix, the method comprising:

[0006] Step 1: Based on the use cases and requirements of the state machine model, obtain the requirement information of the state machine model; construct a requirement matrix according to the requirement information, and describe it in a formulaic way in the requirement matrix; the requirement matrix includes an interface information list, a state behavior list, a state transition condition matrix, and a priority matrix;

[0007] Step 2: Generate a blank model file, then extract the interface information from the requirement matrix, convert the interface information into a state machine model interface framework, and automatically inject it into the blank model file;

[0008] Step 3: Extract the state information from the state behavior list. Based on the type and behavior of each state, inject model elements and write the corresponding content for each state according to the pre-set modeling standards.

[0009] Step 4: Extract the migration information from the state transition condition matrix and the priority information of each state transition from the priority matrix, and inject model elements into each state transition and transition condition according to the pre-set modeling criteria.

[0010] Furthermore, the interface information list is the interface information content of the model.

[0011] Furthermore, the state behavior list contains state behavior information, which is a description of the set of assignment operations performed in each state when the system transitions to that state.

[0012] Furthermore, the state transition condition matrix contains state transition information and is a description of the set of conditions that must be met when transitioning between states.

[0013] Furthermore, the priority matrix contains priority information, which is a description of the set of priorities for each state to migrate to other states when each state is transitioning.

[0014] Furthermore, the state machine model is a graphical model of a visual functional module flow diagram designed according to requirements in the system design process based on model development, and the state machine model interface framework includes information on all input and output ports.

[0015] Furthermore, step 3 includes:

[0016] If the state information in the state behavior list contains a state behavior, then inject the same-named state element graph into the state machine model, and write the state behavior and state number into the state element graph of the state machine model.

[0017] If the state information in the state behavior list does not have a state behavior and is not a node, then inject the same state element graph into the state machine model and write the state number into the state element graph.

[0018] If the state information in the state behavior list is a node, then inject a node element graph into the state machine model.

[0019] Furthermore, step 4 includes:

[0020] If a priority matrix exists in the demand matrix, the transition information in the state transition condition matrix is ​​converted into model elements according to the priority order in the priority matrix, and injected into the model according to the pre-set modeling standards. The model transition elements also follow the priority order.

[0021] If there is no priority matrix in the demand matrix, but there is an unconditional transition in the state transition condition matrix, then the transition information is converted into model elements in the order from left to right in the state transition condition matrix with the unconditional transition at the end, and injected into the model according to the pre-set modeling standards. The model transition elements also follow the order from left to right in the state transition condition matrix with the unconditional transition at the end.

[0022] If no unconditional transition exists, the transition information is converted into model elements in the order from left to right in the state transition condition matrix, and injected into the model according to the pre-set modeling criteria. The model transition elements also follow the priority order from left to right in the state transition condition matrix.

[0023] Secondly, this application provides an automatic state machine model generation device based on a demand matrix, which is applied to the above-mentioned automatic state machine model generation method based on a demand matrix.

[0024] This invention provides a method and apparatus for automatically generating state machine models based on a demand matrix. Based on the usage scenarios and requirements of the state machine model, it obtains the demand information for the state machine model and forms a corresponding demand matrix. A blank model file is generated, and the interface information of the model in the demand matrix is ​​extracted, converted into a state machine model interface framework, and automatically injected into the blank model file. State behavior information is extracted from the demand matrix, and according to the type and behavior of each state, model elements are injected into the state machine model for each state, along with corresponding state behaviors and state numbers. State transition information and priority information are extracted from the demand matrix, and according to the priority of each state transition in the priority information, model elements and transition conditions are injected into the state machine model for each state transition. Modeling standards must be followed when injecting model elements. This invention reduces workload, automatically generates state machine models based on a demand matrix, improves the efficiency and accuracy of model design, and has strong versatility, improving the quality and reliability of the model.

[0025] The advantages of this invention are:

[0026] 1. Based on the needs of the project and engineering, obtain model requirement information and form a corresponding requirement matrix;

[0027] 2. Extract state machine model information from the requirement matrix, automatically convert it into state machine model content, and inject it into the model file according to the modeling standards. This saves the manual work of designing state machine models according to requirements and ensures the accuracy of the state machine model.

[0028] 3. It automatically generates state machine models that meet the requirements, saving manpower and improving the efficiency and quality of state machine model design. Attached Figure Description

[0029] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0030] Figure 1 This is a flowchart of a method for automatically generating a state machine model based on a demand matrix, as described in this invention.

[0031] Figure 2This is a flowchart of a method for automatically generating a state machine model based on a no-priority demand matrix, as described in this invention.

[0032] Figure 3 This is a flowchart of a method for automatically generating a state machine model based on a priority demand matrix, as described in this invention.

[0033] Figure 4 This is the top-level diagram of the state machine model automatically generated in Example 2.

[0034] Figure 5 This is the internal diagram of the state machine model automatically generated in Example 2.

[0035] Figure 6 This is the top-level diagram of the state machine model automatically generated in Example 3.

[0036] Figure 7 This is the internal diagram of the state machine model automatically generated in Example 3. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0038] The features and illustrative embodiments of various aspects of the present invention will now be described in detail. Numerous specific details are set forth in the following detailed description to provide a thorough understanding of the invention. However, it will be apparent to those skilled in the art that the invention may be practiced without requiring some of these specific details. The following description of embodiments is merely intended to provide a better understanding of the invention by illustrating examples of the invention. The invention is by no means limited to any specific setups and methods set forth below, but covers any improvements, substitutions, and modifications to structures, methods, and devices without departing from the spirit of the invention. Well-known structures and techniques are not shown in the drawings and the following description to avoid unnecessarily obscuring the invention.

[0039] It should be noted that, unless otherwise specified, the embodiments of the present invention and the features thereof can be combined with each other, and the various embodiments can be referenced and cited in each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0040] Example 1

[0041] like Figure 1As shown, this application provides a method for automatically generating a state machine model based on a demand matrix, the method including:

[0042] Step 1: Based on the use cases and requirements of the state machine model, obtain the requirement information of the state machine model; construct a requirement matrix according to the requirement information, and describe it in a formula; wherein, the requirement matrix includes an interface information list, a state behavior list, a state transition condition matrix, and a priority matrix.

[0043] Among them, the state machine model is a graphical model of the visual functional module flow diagram designed according to requirements in the system design process based on model development, such as the Simulink model.

[0044] Specifically, the interface information list contains the interface information of the model, including the input / output categories of the ports, port names, and data types.

[0045] The demand matrix describes the elements of the state transition system M, M = (S, T, A). Here, S is the set of all states, T is the set of state transition conditions, and A is the set of state behaviors.

[0046] S = {S1, S2, S3, ..., Sn}, where S1 is the initial state.

[0047] The state behavior list contains state behavior information and describes the set of assignment operations performed in each state when the system transitions to that state; that is, it describes the elements S and A of the state transition system M. A is the set of all state behaviors {A1, A2, A3, ..., An}, where Ai is the state behavior of state Si, which must consist of one or more assignment statements. If Si has no state behavior, then Ai is empty. The state behavior list should be a 2*n table, where the first row is the header of each column, the first column is the state name, i.e., S; the second column is the behavior of each state, i.e., A.

[0048] The state transition condition matrix contains state transition information and is a description of the set of conditions that must be met when transitioning between states, that is, a description of the elements T of the state transition system M.

[0049]

[0050] Here, Tij represents the transition condition that must be satisfied when migrating from Si to Sj. This condition must be a logical expression. A true logical expression indicates that the transition condition is met, and a state transition can occur; a false logical expression indicates that the transition condition is not met, and a transition cannot occur. If there is no transition from Si to Sj, Tij is empty; if the transition from Si to Sj is unconditional, Tij is 1, i.e., always true. When the set S of M has n elements, the state transition condition matrix is ​​a (n+1)*(n+1) table, where the first element of the intersection of the first row and the first column is empty. Afterwards, the elements in the first row and the first column, starting from the second element, are S1, S2, S3, ..., Sn. The element that intersects the first column (Si) of the matrix with the first row (Sj) of the matrix is ​​Tij, which represents the transition condition that must be satisfied when migrating from Si to Sj.

[0051] The priority matrix contains priority information and describes the set of priorities for each state when transitioning to other states. When a state satisfies the transition conditions of multiple states, the transition with the higher priority is executed, and other transitions are not executed. The priority matrix needs to be referenced to the state transition condition matrix; its priority is only considered when a transition condition Tij exists. The priority matrix is ​​a (n+1)*(n+1) table, with the same format as the state transition condition matrix, except that the transition condition Tij is replaced with priority numbers. The highest priority is 1, the second highest is 2, and so on.

[0052] In the above statement, 0 <i≤n,0<j≤n,i≠j。

[0053] Step 2: Generate a blank model file, then extract the interface information from the requirement matrix, convert the interface information into a state machine model interface framework, and automatically inject it into the blank model file;

[0054] Specifically, the state machine model interface framework includes information on all input and output ports, such as the names and types of all ports, and is arranged in the expected style.

[0055] Step 3: Extract the state information from the state behavior list. Based on the type and behavior of each state, inject model elements and write the corresponding content for each state according to the pre-set modeling standards.

[0056] Specifically, step 3 includes:

[0057] If the state information in the state behavior list contains a state behavior, then inject the same-named state element graph into the state machine model, and write the state behavior and state number into the state element graph of the state machine model.

[0058] If the state information in the state behavior list does not have a state behavior and is not a node, then inject the same state element graph into the state machine model and write the state number into the state element graph.

[0059] If the state information in the state behavior list is a node, then inject a node element graph into the state machine model.

[0060] Among them, modeling standards are the specifications that need to be followed when automatically generating models. They are usually derived from the constraints of the model's operating environment, including but not limited to: determining the source of modeling elements, modules cannot overlap, states cannot overlap, signal lines cannot overlap with modules or states, and transition conditions need to be near transition lines, etc.

[0061] The state number is a number, usually starting from 1 and incrementing, with each state having a different number. The state number can be an output variable, unaffected by any input, only outputting different values ​​in different states, for use in later model debugging and validation.

[0062] Step 4: Extract the transition information from the state transition condition matrix and the priority information of each state transition from the priority matrix, and inject model elements into each state transition and transition condition according to the pre-set modeling criteria.

[0063] Specifically, step 4 includes:

[0064] If a priority matrix exists in the demand matrix, the transition information in the state transition condition matrix is ​​converted into model elements according to the priority order in the priority matrix, and injected into the model according to the pre-defined modeling standards. The model transition elements also follow the priority order. If a priority matrix does not exist in the demand matrix, but unconditional transitions exist in the state transition condition matrix, the transition information is converted into model elements according to the left-to-right order in the state transition condition matrix, with unconditional transitions at the end. The model transition elements also follow the left-to-right order in the state transition condition matrix, with unconditional transitions at the end. If no unconditional transitions exist, the transition information is converted into model elements according to the left-to-right order in the state transition condition matrix, and injected into the model according to the pre-defined modeling standards. The model transition elements also follow the left-to-right priority order in the state transition condition matrix.

[0065] In summary, this invention relates to an automatic generation method for state machine models based on a demand matrix. The method includes: obtaining state machine model requirement information based on the usage scenario and requirements of the state machine model, forming a corresponding requirement matrix; generating a blank model file, extracting the interface information of the model from the requirement matrix, converting it into a state machine model interface framework, and automatically injecting it into the blank model file; extracting state behavior information from the requirement matrix, injecting model elements into the state machine model for each state according to its type and behavior, and writing corresponding state behaviors and state numbers; extracting state transition information and priority information from the requirement matrix, injecting model elements and transition conditions into the state machine model for each state transition according to the priority of each state transition in the priority information; and adhering to pre-defined modeling standards when injecting model elements. This invention reduces workload, automatically generates state machine models based on a demand matrix, improves the efficiency and accuracy of model design, has strong versatility, and improves the quality and reliability of the model.

[0066] Example 2

[0067] like Figure 2 As shown, this application embodiment takes a demand matrix without priority as an example to provide a method for automatically generating a state machine model based on the demand matrix. The method includes:

[0068] Step 1: Based on the use cases and requirements of the model, obtain the state machine model requirement information and form the corresponding requirement matrix.

[0069] The requirement matrix includes the following list of interface information:

[0070]

[0071] The demand matrix contains the following list of state behaviors:

[0072]

[0073] The demand matrix includes the following state transition condition matrix:

[0074]

[0075] The demand matrix does not include priority information.

[0076] Step 2: Generate a blank SLX model file and extract the interface information. This state machine model has 3 input ports and 3 output ports, all of which are Boolean type. Insert the corresponding ports into the blank model according to this information, with the input on the left and the output on the right.

[0077] Step 3: Based on the state behavior list, the model has 4 states. For each state, determine if a state behavior exists, and inject a state element graphic into the model for that state. Write the state behavior and state number into the state graphic. During injection, the initial state is placed in the top left corner, the second state to the right of the initial state, the third state below the initial state, and the fourth state in the bottom right corner, ensuring no overlap between states. This completes the injection of model element graphics for all states.

[0078] Step 4: Extract information from the state transition condition matrix. Since there is no priority matrix and no unconditional transition, inject model elements according to the transition of each state from left to right in the state transition matrix, and write the transition conditions on the transition graph.

[0079] Step 5: During the model element injection process in Steps 3 and 4, modeling standards must be followed. State elements cannot overlap, information within a state element cannot be outside the state element's graphic, transition elements cannot cross state elements, and transition conditions cannot overlap with other elements. The automatically generated state machine model is as follows: Figure 4 and Figure 5 As shown.

[0080] Example 3

[0081] like Figure 3 As shown in the illustration, this application provides a method for automatically generating a state machine model based on a priority-based demand matrix, using such a matrix as an example. The method includes:

[0082] Step 1: Based on the use cases and requirements of the model, obtain the state machine model requirement information and form the corresponding requirement matrix.

[0083] The requirements matrix includes the following list of interfaces:

[0084]

[0085] The demand matrix contains the following list of state behaviors:

[0086]

[0087] The demand matrix includes the following state transition condition matrix:

[0088]

[0089] The priority matrix included in the demand matrix is ​​as follows:

[0090]

[0091] Step 2: Generate a blank SLX model file and extract the interface information. The model has 4 Boolean type input ports and 2 int32 type output ports. Insert the corresponding ports into the blank model according to this information, with the input on the left and the output on the right.

[0092] Step 3: Based on the state behavior list, the model has 6 states. Check each state sequentially to see if it has a state behavior. If a state behavior exists, inject a state element graphic into the model for that state, writing the state behavior and state number into the graphic. If no state behavior exists, it is a node, and inject a node element graphic into that state. During injection, the order is: initial state at the top left corner, second state to the right of the initial state, third state to the right of the second state, fourth state below the initial state, fifth state to the right of the fourth state, and sixth state at the bottom right corner, ensuring no overlap between states. This completes the injection of model element graphics for all states.

[0093] Step 4: Extract information from the state transition condition matrix. Since priority information exists, inject the corresponding state transitions into the model elements according to the order of priority numbers in the priority matrix, and write the transition conditions onto the transition graph. All transitions for each state in the model also follow the order in the priority matrix.

[0094] Step 5: During the model element injection process in Steps 3 and 4, modeling standards must be followed. State elements cannot overlap, information within a state element cannot be outside the state element's graphic, transition elements cannot cross state elements, and transition conditions cannot overlap with other elements. The automatically generated state machine model is as follows: Figure 6 and Figure 7 As shown.

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and these modifications or substitutions should be covered within the protection scope of the present invention.

Claims

1. A method for automatically generating a state machine model based on a demand matrix, characterized in that, The methods include: Step 1: Based on the use cases and requirements of the state machine model, obtain the requirement information of the state machine model; construct a requirement matrix according to the requirement information, and describe it in a formulaic way in the requirement matrix; the requirement matrix includes an interface information list, a state behavior list, a state transition condition matrix, and a priority matrix; Step 2: Generate a blank model file, then extract the interface information from the requirement matrix, convert the interface information into a state machine model interface framework, and automatically inject it into the blank model file; Step 3: Extract the state information from the state behavior list. Based on the type and behavior of each state, inject model elements into each state according to the pre-set modeling standards and write the corresponding content. Step 4: Extract the transition information from the state transition condition matrix and the priority information of each state transition from the priority matrix, and inject model elements into each state transition and transition condition according to the pre-set modeling criteria. Step 3 includes: If the state information in the state behavior list contains a state behavior, then inject the same-named state element graph into the state machine model, and write the state behavior and state number into the state element graph of the state machine model. If the state information in the state behavior list does not have a state behavior and is not a node, then inject the same state element graph into the state machine model and write the state number into the state element graph. If the state information in the state behavior list is a node, then inject a node element graph into the state machine model; Step 4 includes: If a priority matrix exists in the demand matrix, the transition information in the state transition condition matrix is ​​converted into model elements according to the priority order in the priority matrix, and injected into the model according to the pre-set modeling standards. The model transition elements also follow the priority order. If there is no priority matrix in the demand matrix, but there is an unconditional transition in the state transition condition matrix, then the transition information is converted into model elements in the order from left to right in the state transition condition matrix with the unconditional transition at the end, and injected into the model according to the pre-set modeling standards. The model transition elements also follow the order from left to right in the state transition condition matrix with the unconditional transition at the end. If no unconditional transition exists, the transition information is converted into model elements in the order from left to right in the state transition condition matrix, and injected into the model according to the pre-set modeling criteria. The model transition elements also follow the priority order from left to right in the state transition condition matrix.

2. The method according to claim 1, characterized in that, The interface information list contains the interface information of the model.

3. The method according to claim 1, characterized in that, The state behavior list contains state behavior information, which is a description of the set of assignment operations performed in each state when the system transitions to that state.

4. The method according to claim 1, characterized in that, The state transition condition matrix contains state transition information and is a description of the set of conditions that must be met when transitioning between states.

5. The method according to claim 1, characterized in that, The priority matrix contains priority information and is a description of the set of priorities for each state when it transitions to other states.

6. The method according to claim 1, characterized in that, The state machine model is a graphical model of a visual functional module flow diagram designed according to requirements in the system design process based on model development. The state machine model interface framework includes information on all input and output ports.

7. An automatic state machine model generation device based on a demand matrix, characterized in that, The device is applied to the automatic generation method of state machine model based on demand matrix as described in claim 1.

Citation Information

Patent Citations

  • Construction method, operation method and operation device of state machine model and storage medium

    CN118760485A