State machine graphical modeling packaging method, device and equipment and storage medium
By acquiring event description files, performing logical analysis and graphical encapsulation, we have achieved graphical modeling of multi-layered nested state machines. This solves the problem of insufficient expressiveness of the Modelica standard in hierarchical state machine modeling and improves the readability and maintainability of the model.
Patent Information
- Application Number
- CN202511716541.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-27
AI Technical Summary
The existing Modelica standard has insufficient expressive power in the modeling and simulation of multi-level state machines, especially in supporting advanced semantics such as hierarchical states, concurrent states, and historical nodes, which limits the ability to build and simulate complex control models.
By acquiring event description files, performing logical analysis to extract state machine structure, obtaining hierarchical nesting information, performing planar view modeling and graphical encapsulation processing, we can achieve graphical modeling of multi-layered nested state machines and reduce model complexity.
It improves the readability and maintainability of the model, solves the problem of graphical modeling of complex multi-layered nested finite state machines, and enhances the design efficiency and user experience of the model.
Smart Images

Figure CN121579104A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of software modeling and packaging technology, and particularly relates to a state machine graphical modeling and packaging method, device, equipment and storage medium. BACKGROUND
[0002] In the Modelica-based multi-domain unified modeling technology, the finite state machine is a key model for describing discrete control logic. The traditional finite state machine theory abstracts the behavior logic as a set of finite states and responds to external events through state transitions, but its single-layer flat structure is difficult to meet the hierarchical needs of complex systems.
[0003] In practical applications, control logic usually has a clear hierarchical relationship and needs to nest multiple sub-scene processing schemes in a large running scene, and the single-layer state machine modeling method faces the limitation of insufficient expressiveness in such complex scenes. Although the existing Modelica3.5 standard introduces state machine semantics to provide a basis for logic modeling, its state machine function still mainly stays at the level of graphical construction of basic states and transitions.
[0004] However, these platforms have obvious deficiencies in supporting hierarchical states, concurrent states, historical nodes and other advanced semantics, and lack effective support for multi-level and modular modeling of complex state machines, which restricts the ability to build and simulate complex control models in a unified modeling environment. Therefore, the current technology cannot meet the modeling and simulation needs of complex hierarchical state machines. SUMMARY
[0005] The present application provides a state machine graphical modeling and packaging method, device, equipment and storage medium to realize multi-layer nested state machine graphical modeling, effectively reduce the complexity of the model, and improve the readability and maintainability of the model.
[0006] According to an aspect of the present application, a state machine graphical modeling and packaging method is provided. The method comprises:
[0007] obtaining an event description file of an event implementation logic to be modeled and packaged;
[0008] performing logical analysis on the event description file, extracting a state machine structure, and obtaining hierarchical nesting information of a finite state machine in the event description file, wherein the hierarchical nesting information comprises at least one parent state machine, and the parent state machine comprises a child state machine;
[0009] performing planar view modeling processing according to the hierarchical nesting information, and obtaining a state view model corresponding to the finite state machine in the event description file, wherein the state view model displays the display information of all event states in a planar display form;
[0010] perform graph encapsulation processing on the sub-state machines in the state view model to obtain an event modeling encapsulation view corresponding to the to-be-modeled encapsulation event.
[0011] According to another aspect of the present application, a state machine graphical modeling encapsulation apparatus is provided. The apparatus comprises:
[0012] A description file obtaining module is configured to obtain an event description file of to-be-modeled encapsulation event implementation logic;
[0013] A nested information determining module is configured to perform logical analysis on the event description file, extract a state machine structure, and obtain hierarchical nested information corresponding to a finite state machine in the event description file, wherein the hierarchical nested information comprises at least one parent state machine, and the parent state machine comprises a sub-state machine;
[0014] A view model constructing module is configured to perform planar view modeling processing according to the hierarchical nested information to obtain a state view model corresponding to the finite state machine in the event description file, wherein the state view model displays display information of all event states in a planar display form;
[0015] An event view determining module is configured to perform graph encapsulation processing on the sub-state machines in the state view model to obtain an event modeling encapsulation view corresponding to the to-be-modeled encapsulation event.
[0016] According to another aspect of the present application, an electronic device is provided, which comprises:
[0017] at least one processor; and
[0018] a memory in communication connection with the at least one processor; wherein
[0019] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the state machine graphical modeling encapsulation method according to any one of the embodiments of the present application.
[0020] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to implement the state machine graphical modeling encapsulation method according to any one of the embodiments of the present application when executed by the processor.
[0021] The technical scheme of the embodiment of the application is: an event description file of a to-be-modeled packaging event is acquired; the event description file is logically analyzed to extract a state machine structure and obtain hierarchical nesting information corresponding to a finite state machine in the event description file; a flat view modeling process is performed according to the hierarchical nesting information to obtain a state view model corresponding to the finite state machine in the event description file; and a sub-state machine in the state view model is graphically packaged to obtain an event modeling packaging view corresponding to the to-be-modeled packaging event. The problem of graphical modeling of a complex multi-layer state-nested finite state machine is solved, the complexity of the model is effectively reduced, and the readability and maintainability of the model are improved.
[0022] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the application, nor is it used to limit the scope of the application. Other features of the application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiments description. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0024] Figure 1 is a flow chart of a state machine graphical modeling packaging method provided by the embodiment of the application;
[0025] Figure 2 is a schematic diagram of a state view model provided by the embodiment of the application;
[0026] Figure 3 is a schematic diagram of an event modeling packaging view provided by the embodiment of the application;
[0027] Figure 4 is a schematic diagram of another state view model provided by the embodiment of the application;
[0028] Figure 5 is a schematic diagram of another event modeling packaging view provided by the embodiment of the application;
[0029] Figure 6 is a structural diagram of a state machine graphical modeling packaging device provided by the embodiment of the application;
[0030] Figure 7 is a structural schematic diagram of an electronic device for implementing the state machine graphical modeling packaging method of the embodiment of the application. DETAILED DESCRIPTION
[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] Figure 1 This is a flowchart illustrating a graphical state machine modeling encapsulation method provided in an embodiment of the present invention. This embodiment is applicable to the graphical modeling of complex, multi-layered nested finite state machines. The method can be executed by a graphical state machine modeling encapsulation device, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0034] S101. Obtain the event description file of the event implementation logic to be modeled and encapsulated;
[0035] It should be noted that state machine graphical modeling is a visual modeling method that constructs the abstract logic of the events to be modeled into a visible graphical logic model. For example, the events to be modeled can be simple electric fan operation logic events and smart coffee machine operation logic events, or complex chip operation logic events, etc.
[0036] The modeling and encapsulation of the events to be modeled is achieved through finite state machines. A finite state machine is a mathematical model used to describe the behavioral logic of an object. Its core idea is that an object is always in one of a finite, predefined set of states. Based on external inputs or events, the object transitions from one state to another, or simultaneously produces an output. For example, water has three states: solid, liquid, and gas. The transition from solid to liquid is triggered by a heating event. Graphical modeling of finite state machines uses standardized graphical symbols to intuitively display states, events, and transitions, allowing users to understand the complex state logic of the events to be modeled.
[0037] The event description file can be a standard Modelica source file, which includes descriptive text information and descriptive annotation information. A Modelica source file is a plain text file with the .mo extension that contains model code written in the Modelica language. Modelica source files are the source files for building Modelica models and are used to achieve highly graphical state machine modeling.
[0038] S102. Perform logical analysis on the event description file, extract the state machine structure, and obtain the hierarchical nesting information corresponding to the finite state machine in the event description file.
[0039] The hierarchical nesting information describes the multi-level state nesting of the event description file during complex runtime logic. The hierarchical nesting information includes at least one parent state machine, which includes child state machines.
[0040] Let's illustrate this with an example of multi-level state nesting. For instance, consider modeling a smart coffee machine. Its states include power off, standby, preparation, brewing, and error. State transitions include: pressing the power button in the power off state to enter standby; inserting a coffee capsule in standby to enter preparation, then pressing the power button back to power off; pressing the start button in preparation to enter brewing; completing brewing in brewing and returning to standby; and entering an error state if an error occurs (e.g., lack of water, data error) in any state. Since errors can occur in standby, preparation, and brewing states, transitioning to the error state would require drawing many lines from multiple states (standby, preparation, brewing) to the error state. Multiple error events would make the circuitry extremely complex and difficult to maintain. Therefore, multi-level state nesting is needed to solve these problems.
[0041] The core idea of multi-level nested states is that a large state contains smaller states. The large state is called the parent state, and it can contain several smaller states (called child states), similar to a large folder (parent state) containing files and other folders (child states).
[0042] The states of the smart coffee machine are redefined using a multi-layered nested structure. Parent states include a power-off parent state, a power-on parent state, and an error parent state. The power-on parent state includes standby, preparation, and brewing sub-states (the brewing sub-state itself is a parent state, including heating, water pouring, extraction, and completion sub-states). Error transitions are defined for each parent state; when a temperature error occurs, the transition is to the temperature error sub-state within the error parent state. A transition line is drawn between the power-on and error parent states, replacing the numerous individual transition lines connecting the states, thus achieving the multi-layered nested state structure.
[0043] Specifically, the event description file is logically analyzed to determine the running logic of the event to be modeled and encapsulated in the event description file, as well as the relationship between each state structure. By extracting the state machine structure, the hierarchical nesting information corresponding to the finite state machine can be obtained.
[0044] For example, the step of performing logical analysis on the event description file, extracting the state machine structure, and obtaining the hierarchical nesting information corresponding to each state machine in the event description file includes: performing logical analysis on the event description file to determine the event logic information of each state machine in the event description file.
[0045] The event logic information is parsed to obtain the nested information corresponding to each state machine in the event description file.
[0046] Specifically, the event description file is logically analyzed to determine the event logic information of each state machine it contains. It should be noted that the event logic information includes event states, event conditions, and event transitions. For example, in the state changes of water, event states include solid, liquid, and gaseous states; event transitions include solid-liquid-gas transitions; and event conditions are endothermic and exothermic. For instance, the event transition from solid to liquid is triggered by the heating event condition. By analyzing and interpreting the nesting relationships between parent and child states in the event logic information, hierarchical nesting information can be obtained. Furthermore, this invention supports constructing a tree-structured data model based on hierarchical nesting information to visualize the nesting relationships.
[0047] S103. Perform planar view modeling processing based on the hierarchical nesting information to obtain the state view model corresponding to the finite state machine in the event description file.
[0048] The state view model displays all event state information in a flat, planar format.
[0049] It needs to be explained that in a multi-level nested state structure, when editing a deeply nested state machine, one must click to enter the corresponding parent state in order to edit the child states within the parent state. It is not possible to intuitively view all the states in the encapsulated event to be modeled. To avoid frequent switching between interfaces at different state levels, the view needs to be flattened so that composite states can be directly displayed on their parent canvas, expanding to show the entire sub-state diagram inside, thereby improving design efficiency and user experience.
[0050] Specifically, based on the hierarchical nesting information, the correspondence between each state is determined, and this correspondence is drawn directly on the canvas. This allows direct viewing of the child states within the parent state and their transition relationships, thereby obtaining the state view model corresponding to the finite state machine in the event description file.
[0051] For example, the hierarchical nesting information is processed into a planar view model to obtain a state view model corresponding to the finite state machine in the event description file, including:
[0052] The hierarchical nesting information is parsed to determine the state machine nesting relationship between parent and child state machines. For each state machine nesting relationship, the relative position coordinates of each parent state machine and its child state machine on the canvas are determined based on the state machine nesting relationship. For each parent state machine, based on the absolute position coordinates of the parent state machine on the canvas and the relative position coordinates of the parent state machine and its child state machine on the canvas, planar view modeling is performed to obtain the state view model corresponding to the finite state machines in the event description file.
[0053] Specifically, the dependency relationships between parent and child state machines in the event description file are read and parsed to determine the complete parent-child dependency tree. Then, based on the parent-child dependency tree, the nesting relationship of state machines is determined. For example, if the parsing shows that "state A is the parent state machine of states A1 and A2, and states A1 and A2 are child state machines", this is denoted as a nesting relationship of state machines.
[0054] Based on the nested state machine relationships, the parent and child state machines are graphically represented, and their relative position coordinates are determined. In this graphical representation, each parent state machine is treated as an independent canvas (or container). Within the parent state machine's canvas, the position of its child state machines is defined by relative position coordinates. For example, the origin (0,0) of the relative position coordinates is typically the top-left corner of the parent state machine's canvas. As another example, the starting position of child state machine B1 can be defined as (50,100) on the inner canvas of its parent state machine B.
[0055] It should be noted that the absolute position coordinates of the parent state machine on the canvas can be set as needed, or they can be determined by deploying it in a preset default position. After determining the absolute position coordinates of the parent state machine and the relative position coordinates of the parent state machine and its child state machines on the canvas, the absolute position coordinates of each child state machine on the top-level canvas can be calculated by simple vector addition. Then, based on the absolute position coordinates of the parent and child state machines, planar view modeling is performed to obtain the state view model corresponding to the finite state machines in the event description file.
[0056] It is worth noting that after determining the absolute coordinates of the sub-state machine, if the sub-state machine itself is also a parent state machine (and contains deeper nested sub-states), then the absolute coordinates of the sub-state machine need to be used as a new reference to continue the same planar view modeling process for the sub-state machines of that sub-state machine. This process is iterated and recursively repeated until all levels of nested states have been processed.
[0057] Through recursive coordinate transformation, all state machines are transformed onto the same canvas, resulting in a state view model. This state view model no longer contains complex parent-child nesting relationships, placing all graphical elements on the same planar layer, thus enabling the graphics rendering engine to directly and efficiently draw a planar view of the entire state machine.
[0058] Figure 2 This is a schematic diagram of a state view model provided in an embodiment of the present invention. Figure 2 As shown, the state view model can directly present a planar view of the entire state machine. In this planar view, there are parent state machine A and parent state machine B. Parent state machine B includes child state machine Normal and child state machine Press.
[0059] S104. Perform graphical encapsulation processing on the sub-state machines in the state view model to obtain the event modeling encapsulation view corresponding to the event to be modeled and encapsulated.
[0060] It needs to be explained that the state view model can directly present the child states and their transition relationships within each parent state on a flat canvas. However, all state details are laid out on a flat map. Although the information is complete, the interface is too cluttered in actual use.
[0061] Based on this, the embodiments of the present invention perform graphical encapsulation processing on the sub-state machines in the state view model, retaining the important information of the parent state machine and its internal sub-state machines in the state view model, and encapsulating the remaining information of the internal sub-state machines, thereby achieving a balance between information density and clarity, and obtaining the event modeling encapsulation view corresponding to the event to be modeled and encapsulated.
[0062] For example, the step of graphically encapsulating the sub-state machines in the state view model to obtain the event modeling encapsulation view corresponding to the event to be modeled includes: parsing the state view model to determine all target sub-state machines contained in the top-level parent state machine in the state view model; performing drawing transformation processing on the target sub-state machines in the state view model based on a preset drawing strategy to obtain an initial encapsulation graphic; and drawing the path of the state machine transition corresponding to the initial encapsulation graphic according to the state transition relationship between the target sub-state machines to obtain the event modeling encapsulation view.
[0063] Specifically, in the technical solution of this invention, the graphical encapsulation process encapsulates all state machines except the top-level parent state machine in the hierarchical nesting to reduce the information density of the model. Based on this, the top-level parent state machine is parsed and filtered from the state view model, and all state machines inside each top-level parent state machine are determined as target child state machines.
[0064] After determining the target sub-state machine, the target sub-state machine in the state view model is drawn and converted into a specific graphical style to obtain the initial encapsulated graphic. After the target sub-state machine is drawn, the state transition relationships between the target sub-state machines in the original hierarchical nesting need to be reconnected. Based on the absolute coordinates of the two state graphics in the initial encapsulated graphic, the connection path is automatically calculated according to the state transition relationship. Once all state machine transitions have been drawn, a clear visual connection is established between the state graphics, allowing for a clear understanding of the logical flow, thus obtaining the event modeling encapsulated view. The modeling encapsulated view can intuitively present the top-level parent state machine and its internal logical behavior. It should be noted that the drawn connection path may be a simple straight line, or it may be a polygonal line with corners or a Bézier curve to avoid passing through other graphics.
[0065] For example, the step of performing drawing transformation processing on the target sub-state machine based on a preset drawing strategy to obtain an initial encapsulation graphic includes: replacing the state graphics of the target sub-state machine in the state view model with the state graphics of the target sub-state machine based on the preset drawing strategy to obtain a first encapsulation image; and deleting the relevant data information of the target sub-state machine in the first encapsulation image to obtain the initial encapsulation graphic.
[0066] The preset drawing strategy defines the visual representation rules of the state machine. This strategy can include the graphical form of the state machine and layout adjustments. The graphical form includes the shape (e.g., rounded rectangle), size, color, and border style of the drawn state machine. Layout adjustments ensure that state graphics do not overlap and are aligned to the grid, thus optimizing the visual effect.
[0067] Specifically, based on the type of the target sub-state machine, a state graphic of the same type is selected to replace the target sub-state machine, and the positional distribution of the state graphics is adjusted. Once all target sub-state machines have been replaced by encapsulated graphics, the resulting visual product is the first encapsulated image. For example, a blue rounded rectangle with a width of 80 and a height of 40 is drawn at canvas coordinates (100, 150), with the running states marked inside, to realize the drawing process of the target sub-state machine. The first encapsulated image is typically a container graphic, with its direct sub-states outlined within it. The first encapsulated image can also use different colors and border styles to highlight its expandable composite states.
[0068] The relevant data information associated with the first encapsulation image is removed or hidden. Overly complex and deep details in the first encapsulation image are stripped away, leaving only the core visual elements necessary to express the logic of the current level, resulting in a more concise and clear initial encapsulation graphic.
[0069] For example, the step of drawing the path of the corresponding state machine transition in the initial encapsulation diagram according to the state transition relationship between the target sub-state machines to obtain the event modeling encapsulation view includes:
[0070] The event description file is subjected to state transition analysis to determine the transition line segment information of cross-sub-state machine transitions in different views; based on the state transition information, the corresponding state machine transitions in the initial encapsulation diagram are drawn to obtain the event modeling encapsulation view.
[0071] The transfer segment information includes a transfer declaration, a starting object, a target object, and path information, wherein the path information includes starting coordinates, inflection point coordinates, and ending coordinates.
[0072] Specifically, the event description file is deeply parsed, traversing all the analyzed state transition information. For each piece of information in the state transition information, the corresponding starter object and target object can be found on the initial encapsulated graph. The graphics rendering engine then uses the starter object and target object in the path information, based on the specific type of the cross-sub-state machine.
[0073] Draw the corresponding line segments. Figure 3 A schematic diagram of the event modeling encapsulation view provided in an embodiment of the present invention, such as... Figure 3 As shown, when parent state machine A transitions to child state machine Normal within parent state machine B, the path drawing includes the line segment between parent state machine A and parent state machine B, as well as the line segment within parent state machine B that points to child state machine Normal. For example, text labels are typically added near the connection lines to display the event name parsed from the transition declaration.
[0074] Once all state machine transitions have completed their path drawing based on their respective transition segment information, the originally isolated initial encapsulated graphics are organically integrated by connecting the lines to form a complete workflow diagram, thus obtaining the event modeling encapsulated view. The event modeling encapsulated view not only clearly shows the layout of the states but also intuitively presents the transition logic and triggering conditions between states.
[0075] Figure 4 This is a schematic diagram of another state view model provided in an embodiment of the present invention. Figure 5 This is a schematic diagram of another event modeling encapsulated view provided in an embodiment of the present invention. The event modeling encapsulated view is an encapsulated state view model, such as... Figure 4 As shown, the parent state machine Fueling_Mode includes the child state machines Running and Fuel_Disabled. The Running child state machine is itself a parent state machine, which includes the Low_Emissions and Rich_Mixture child state machines. The Low_Emissions and Rich_Mixture child state machines further include other sub-state machines at deeper levels. Figure 4 The displayed state view model contains excessive information density, resulting in an overly cluttered interface. For example... Figure 5 As shown, the event modeling encapsulation view outlines the composite states of each sub-state machine, achieving an optimal balance between information density and clarity in its visual representation. This approach reveals the main internal structure of the model while avoiding the clutter caused by displaying all the details.
[0076] The technical solution of this invention involves obtaining an event description file containing the logic of an encapsulated event to be modeled. The event description file is then logically analyzed to extract the state machine structure, obtaining the hierarchical nesting information corresponding to the finite state machines in the event description file. Based on this hierarchical nesting information, planar view modeling is performed to obtain a state view model corresponding to the finite state machines in the event description file. Finally, the sub-state machines in the state view model are graphically encapsulated to obtain an event modeling encapsulation view corresponding to the event to be modeled. This solves the problem of graphical modeling of complex, multi-layered nested finite state machines, effectively reducing model complexity and improving model readability and maintainability.
[0077] Figure 6 This is a schematic diagram of a state machine graphical modeling and encapsulation device provided in an embodiment of the present invention. Figure 6 As shown, the device includes:
[0078] The description file acquisition module 301 is used to acquire the event description file of the event implementation logic to be modeled;
[0079] Nested information determination module 302 is used to perform logical analysis on the event description file, extract the state machine structure, and obtain the hierarchical nesting information corresponding to the finite state machines in the event description file, wherein the hierarchical nesting information includes at least one parent state machine, and the parent state machine includes a child state machine.
[0080] The view model construction module 303 is used to perform planar view modeling processing based on the hierarchical nesting information to obtain the state view model corresponding to the finite state machine in the event description file. The state view model displays the display information of all event states in a planar display format.
[0081] The event view determination module 304 is used to perform graphical encapsulation processing on the sub-state machines in the state view model to obtain the event modeling encapsulation view corresponding to the event to be modeled and encapsulated.
[0082] The technical solution of this invention involves obtaining an event description file containing the logic of an encapsulated event to be modeled. The event description file is then logically analyzed to extract the state machine structure, obtaining the hierarchical nesting information corresponding to the finite state machines in the event description file. Based on this hierarchical nesting information, planar view modeling is performed to obtain a state view model corresponding to the finite state machines in the event description file. Finally, the sub-state machines in the state view model are graphically encapsulated to obtain an event modeling encapsulation view corresponding to the event to be modeled. This solves the problem of graphical modeling of complex, multi-layered nested finite state machines, effectively reducing model complexity and improving model readability and maintainability.
[0083] Optionally, the event description file is a standard Modelica source file, and the event description file includes descriptive text information and descriptive annotation information.
[0084] Optionally, the nested information determination module 302 is used for:
[0085] The event description file is logically analyzed to determine the event logic information of each state machine in the event description file, wherein the event logic information includes event state, event condition and event transition;
[0086] The event logic information is parsed to obtain the nested information corresponding to each state machine in the event description file.
[0087] Optionally, the view model building module 303 is used for:
[0088] The hierarchical nesting information is parsed and processed to determine the state machine nesting relationship between the parent state machine and the child state machine in the hierarchical nesting information.
[0089] For each nested state machine relationship, determine the relative position coordinates of each parent state machine and its child state machine on the canvas according to the nested state machine relationship;
[0090] For each parent state machine, based on the absolute position coordinates of the parent state machine on the canvas and the relative position coordinates of the parent state machine and its child state machines on the canvas, planar view modeling is performed to obtain the state view model corresponding to the finite state machines in the event description file.
[0091] Optionally, the event view determination module 304 includes:
[0092] The sub-state machine determination unit is used to parse the state view model and determine all target sub-state machines contained in the top-level parent state machine in the state view model.
[0093] An encapsulated graphics drawing unit is used to perform drawing transformation processing on the target sub-state machine in the state view model based on a preset drawing strategy to obtain an initial encapsulated graphics.
[0094] The event view determination unit is used to draw the path of the corresponding state machine transition in the initial encapsulation diagram according to the state transition relationship between the target sub-state machines, and obtain the event modeling encapsulation view.
[0095] Optionally, the graphics drawing unit is encapsulated for:
[0096] Based on a preset drawing strategy, the state graphics of the target sub-state machine in the state view model are replaced to obtain the first encapsulated image;
[0097] The data information related to the target sub-state machine in the first encapsulation image is deleted to obtain the initial encapsulation pattern.
[0098] Optionally, the event view determination unit is used for:
[0099] The event description file is subjected to state transition analysis to determine the transition line segment information of the cross sub-state machine transition in different views. The transition line segment information includes transition declaration, starting object, target object and path information. The path information includes starting coordinates, inflection point coordinates and ending coordinates.
[0100] Based on the state transition information, the corresponding state machine transitions in the initial encapsulation diagram are drawn to obtain the event modeling encapsulation view.
[0101] The state machine graphical modeling and encapsulation device provided in the embodiments of the present invention can execute the state machine graphical modeling and encapsulation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0102] Figure 7 A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0103] like Figure 7 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0104] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0105] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the state machine graphical modeling encapsulation method.
[0106] In some embodiments, the state machine graphical modeling encapsulation method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the state machine graphical modeling encapsulation method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the state machine graphical modeling encapsulation method by any other suitable means (e.g., by means of firmware).
[0107] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0108] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0109] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0110] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0111] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0112] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0113] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0114] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A graphical modeling and encapsulation method for state machines, characterized in that, include: Obtain the event description file containing the encapsulated event implementation logic to be modeled; Logical analysis is performed on the event description file to extract the state machine structure and obtain the hierarchical nesting information corresponding to the finite state machines in the event description file. The hierarchical nesting information includes at least one parent state machine, and the parent state machine includes child state machines. Based on the hierarchical nesting information, planar view modeling is performed to obtain the state view model corresponding to the finite state machine in the event description file. The state view model displays the display information of all event states in a planar display format. The sub-state machines in the state view model are graphically encapsulated to obtain the event modeling encapsulation view corresponding to the event to be modeled.
2. The method according to claim 1, characterized in that, The event description file is a standard Modelica source file, and the event description file includes descriptive text information and descriptive annotation information.
3. The method according to claim 1, characterized in that, The step of performing logical analysis on the event description file, extracting the state machine structure, and obtaining the hierarchical nesting information corresponding to each state machine in the event description file includes: The event description file is logically analyzed to determine the event logic information of each state machine in the event description file, wherein the event logic information includes event state, event condition and event transition; The event logic information is parsed to obtain the nested information corresponding to each state machine in the event description file.
4. The method according to claim 1, characterized in that, The hierarchical nesting information is processed into a planar view model to obtain the state view model corresponding to the finite state machine in the event description file, including: The hierarchical nesting information is parsed and processed to determine the state machine nesting relationship between the parent state machine and the child state machine in the hierarchical nesting information. For each nested state machine relationship, determine the relative position coordinates of each parent state machine and its child state machine on the canvas according to the nested state machine relationship; For each parent state machine, based on the absolute position coordinates of the parent state machine on the canvas and the relative position coordinates of the parent state machine and its child state machines on the canvas, planar view modeling is performed to obtain the state view model corresponding to the finite state machines in the event description file.
5. The method according to claim 1, characterized in that, The step of graphically encapsulating the sub-state machines in the state view model to obtain the event modeling encapsulation view corresponding to the event to be modeled includes: The state view model is parsed to determine all target child state machines contained in the top-level parent state machine in the state view model; Based on a preset drawing strategy, the target sub-state machine in the state view model is drawn and transformed to obtain the initial encapsulated graphic. Based on the state transition relationships between the target sub-state machines, the corresponding state machine transitions in the initial encapsulation diagram are drawn to obtain the event modeling encapsulation view.
6. The method according to claim 5, characterized in that, The step of performing drawing transformation processing on the target sub-state machine based on a preset drawing strategy to obtain the initial encapsulated graphic includes: Based on a preset drawing strategy, the state graphics of the target sub-state machine in the state view model are replaced to obtain the first encapsulated image; The data information related to the target sub-state machine in the first encapsulation image is deleted to obtain the initial encapsulation pattern.
7. The method according to claim 5, characterized in that, The step of drawing the path of the corresponding state machine transition in the initial encapsulation diagram according to the state transition relationship between the target sub-state machines to obtain the event modeling encapsulation view includes: The event description file is subjected to state transition analysis to determine the transition line segment information of the cross sub-state machine transition in different views. The transition line segment information includes transition declaration, starting object, target object and path information. The path information includes starting coordinates, inflection point coordinates and ending coordinates. Based on the state transition information, the corresponding state machine transitions in the initial encapsulation diagram are drawn to obtain the event modeling encapsulation view.
8. A graphical modeling and encapsulation device for state machines, characterized in that, include: The description file acquisition module is used to acquire the event description file that encapsulates the event implementation logic to be modeled; The nesting information determination module is used to perform logical analysis on the event description file, extract the state machine structure, and obtain the hierarchical nesting information corresponding to the finite state machines in the event description file, wherein the hierarchical nesting information includes at least one parent state machine, and the parent state machine includes a child state machine. The view model construction module is used to perform planar view modeling processing based on the hierarchical nesting information to obtain the state view model corresponding to the finite state machine in the event description file. The state view model displays the display information of all event states in a planar display format. The event view determination module is used to perform graphical encapsulation processing on the sub-state machines in the state view model to obtain the event modeling encapsulation view corresponding to the event to be modeled and encapsulated.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the state machine graphical modeling encapsulation method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the state machine graphical modeling and encapsulation method according to any one of claims 1-7.