A method and system for visually displaying simulation execution
Through the simulation execution engine of the state machine model semantics, the SysML state machine model is converted into an SCXML file to realize simulation execution and animation display, which solves the problem that the existing technology cannot intuitively display the operation of the SysML state machine model and improves the efficiency of the system design scheme. Executability and communication efficiency.
Patent Information
- Application Number
- CN202111419488.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-11-26
AI Technical Summary
The existing technology cannot intuitively display the operation of the SysML state machine model, which affects early requirements verification and stakeholder communication in system design.
Through the simulation execution engine of state machine model semantics, use the model converter to convert the SysML state machine model into SCXML files, and manage SCXML instances through the file parser and instance scheduler, combined with event transceivers and animation displays, to achieve simulation execution and animation show.
It provides a visual simulation verification environment to ensure the consistency of modeling data and simulation data, realizes the automated generation and formal testing and verification of system design solutions, and improves communication efficiency.
Smart Images

Figure CN114090185B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of simulation, relates to state machine simulation, and specifically relates to a method and system for visually displaying simulation execution. Background Art
[0002] MBSE has been applied to system design in most industrial system fields. Although a system model based on the SysML standard is introduced during system design, the system design and functional logic can be expressed through the state machine; however, when it comes to how to verify requirements and ensure the accuracy of the model, the static model cannot intuitively display the operation of the system, which is not conducive to communication with stakeholders and cannot verify requirements in the early stages of design.
[0003] SCXML is an event-based state machine language. It is the product of the combination of CCXML and Harel State Tables. The CCXML1.0 specification defines a state machine and event processing syntax as well as a series of call control elements. HarelState Table is a state machine notation proposed by David Harel in 1987, and later the state machine in UML adopted these notations. Harel State Tables provides a concise, semantically sound and powerful control structure. The SCXML standard can use XML syntax and Harel State Table semantics to describe the logical concepts of state and event transfer in CCXML. Summary of the invention
[0004] The technical problem solved by the present invention is to provide a method and system for visually displaying simulation execution, realize simulation execution and animation display of SysML state machine model through a simulation execution engine of state machine model semantics, and provide a visual simulation verification environment.
[0005] The present invention is achieved through the following technical solutions:
[0006] A method for visually displaying simulation execution includes the following operations:
[0007] 1) The model converter receives the simulation model provided by the SysML state machine and generates a standard SCXML file from the simulation model using the state diagram as a generation unit;
[0008] When generating SCXML files, the internal properties of the state diagram primitives and the sources and targets of the connecting lines in the primitives are converted into standard executable SCXML code;
[0009] 2) The file parser receives the SCXML file, parses its semantics using the methods and properties of the XmlReader class to generate an SCXML instance and assign values for reading by the simulation engine and instance scheduler;
[0010] 3) When the simulation of the state machine model is initiated, all SCXML instances of the model are managed by the instance scheduler, and the event transceiver also starts working;
[0011] The event transceiver responds to internal / external events, or processes internal trigger events;
[0012] When executing to the state instance in the SCXML instance, if its internal attributes contain a call event, the call event is sent through the event transceiver, and then the event transceiver notifies the instance scheduler to start the corresponding SCXML instance;
[0013] 4) When the SCXML instance started by the instance scheduler runs to the internal signal sending action, the event transceiver immediately sends a signal and calls FireEvents to notify all state machine instances. The event transceiver of each state machine instance will receive the signal event, and then determine whether to respond to the signal event based on its own current state and business needs;
[0014] When the event transceiver receives an event, it first determines whether the current event state is pending. If it is pending, it is added to the event queue according to business needs. If it is not pending, the EventStep method is executed to calculate the next state and the next transition of the current state, and then the animation display is notified according to the actions including exiting the current state, executing the next transition, and entering the next state.
[0015] 5) The animation display performs animation display by notifying the simulation animation interface through the received action.
[0016] Furthermore, when generating SCXML files, one state diagram generates one SCXML file;
[0017] Convert all graphics elements in the state diagram into elements in the SCXML file, where the state graphics elements generate the state elements of the SCXML file; the SCXML file is of XmlDocument class and the elements are XmlElement.
[0018] Furthermore, when generating the SCXML file, the internal attributes of the primitive are refined into triggers, conditions and target ends. Then, when converting into the SCXML file, the following correspondence is adopted: the trigger attribute in the primitive corresponds to event, the condition attribute corresponds to cond, and the target end attribute corresponds to target.
[0019] When parsing the SCXML file, the various attributes of the SCXML file are read through the GetAttribute method of the XmlReader class. After the attributes are read, the data is read line by line by judging the type of the current node; in the process of reading line by line, the name of the current node is judged to organize the various attributes of the SCXML class; then, by calling the UpdateSCXML method, various attributes including status, transition, action, and history connector are operated to generate an SCXML instance with complete attributes; the operations include initializing, assigning values, and sorting each attribute.
[0020] The instance scheduler sends a call event to other state machines through the target attribute of the send node on the entry behavior, Do behavior, exit behavior, and conversion action behavior of the state instance.
[0021] The event transceiver receives and responds to internal / external events through the TruggerEvents method, and processes internal triggering events through the FireEvents method.
[0022] Furthermore, when the animation is displayed, if the simulation animation interface receives an entry or exit notification, the corresponding primitive is found in the graphic display area of the simulation animation interface according to the ID of the current state in the SCXML instance, and the border of the primitive is set to the corresponding color, and the corresponding log of entering or exiting a state is output in the log area;
[0023] If the simulation animation interface receives a conversion notification, it finds the corresponding source and target graphics in the graphic display area of the simulation animation interface according to the source and target of the currently converted SCXML instance; then it finds a series of graphics in the specified path between the source and the target according to the cond and event of the current conversion, and sets the border of this graphics to the entry color and then to the exit color in the order from source to target to achieve the animation effect; at the same time, it also outputs the log of the transition from one state to another in the log area.
[0024] Furthermore, when the animation is displayed, if the current entering element is the initial state of the state diagram, the default conversion source and conversion line before the state are first set to the entry color; if the current entering element is a sub-state machine element, the sub-state machine instance of the instance scheduler is called to start the instance.
[0025] Furthermore, the animation display is also provided with an interval time setter to adjust the animation speed. When the graphic element is set to the entry color, the System.Threading.Thread.Sleep() method is called to pause the current form interface for a specified time.
[0026] Accordingly, the present invention also provides a system for visually displaying simulation execution, comprising:
[0027] A model converter receives the simulation model provided by the SysML state machine, converts the primitives into executable SCXML codes based on the internal properties of the primitives in the state diagram in the simulation model, and generates the simulation model into a standard SCXML file using the state diagram as a generation unit;
[0028] The file parser receives the SCXML file and parses it using the methods and properties of the XmlReader class, generating a fully attributed SCXML instance and assigning values to it for reading by the simulation engine and instance scheduler;
[0029] Instance scheduler, manages all generated SCXML instances, starts the corresponding state machine instance when the simulation is initiated; sends call events through nodes on state behaviors;
[0030] The event transceiver responds to internal or external events and notifies the animation display according to the exit of the current state, the execution of the next transition and the next state; when the event transceiver needs to send a signal, it will notify all state machine instances, and each state machine instance will determine whether it needs to respond to the signal event based on its current state and business needs;
[0031] The animation display notifies the simulation animation interface through the entry, exit, and conversion actions of the state instance in the SCXML instance to perform animation display.
[0032] Compared with the prior art, the present invention has the following beneficial technical effects:
[0033] The method and system for visually displaying simulation execution provided by the present invention perform simulation on a state machine diagram based on the W3C SCXML standard, and after completing SysML modeling in a system modeling tool, demonstrate the operation logic of the system by means of functional logic simulation based on SCXML; the present invention ensures the consistency of modeling data and simulation data, realizes the automatic generation of executable models of system design solutions, visualizes dynamic scenes, and performs formal testing and verification of the logic of the model. The present invention improves the situation that the system cannot be intuitively displayed in the form of documents, improves the communication efficiency with stakeholders, and solves the problem of adding simulation execution and animation display to the current SysML state machine model. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a system schematic diagram of the present invention.
[0035] Figure 2 It is a schematic diagram of the process of the present invention.
[0036] Figure 3 It is a schematic diagram of SysML state diagram.
[0037] Figure 4 This is the generated SCXML file diagram.
[0038] Figure 5 It is a simulation animation diagram. DETAILED DESCRIPTION
[0039] The present invention is further described in detail below in conjunction with the embodiments, which are intended to explain the present invention rather than to limit it.
[0040] See also Figure 1 , Figure 2 , a method for visually displaying simulation execution, comprising the following operations:
[0041] 1) The model converter receives the simulation model provided by the SysML state machine and generates a standard SCXML file from the simulation model using the state diagram as a generation unit;
[0042] When generating SCXML files, the internal properties of the state diagram primitives and the sources and targets of the connecting lines in the primitives are converted into standard executable SCXML code;
[0043] 2) The file parser receives the SCXML file, parses its semantics using the methods and properties of the XmlReader class to generate an SCXML instance and assign values for reading by the simulation engine and instance scheduler;
[0044] 3) When the simulation of the state machine model is initiated, all SCXML instances are managed by the instance scheduler, and the event transceiver also starts working; when a state instance in an SCXML instance is executed, if its internal attributes contain a call event, the call event is sent through the event transceiver, and then the event transceiver responds to the call event and notifies the instance scheduler to start the corresponding SCXML instance;
[0045] When the state machine instance started by the instance scheduler runs to the internal signal sending action, the event transceiver must immediately send a signal and call FireEvents to notify all state machine instances. The event transceiver of each state machine instance will receive the signal event and then determine whether to respond to the signal event based on its current state and business needs.
[0046] 4) Event transceivers respond to internal / external events or process internal trigger events;
[0047] When the event transceiver receives an event, it first determines whether the current event state is pending. If it is pending, it is added to the event queue according to business needs. If it is not pending, the EventStep method is executed to calculate the next state and the next transition of the current state, and then the animation display is notified according to the actions including exiting the current state, executing the next transition, and entering the next state.
[0048] 5) The animation display performs animation display by notifying the simulation animation interface through the received action.
[0049] Furthermore, when parsing the SCXML file, the various attributes of the SCXML file are read through the GetAttribute method of the XmlReader class. After the attributes are read, the data is read line by line by judging the type of the current node; in the process of reading line by line, the name of the current node is judged to organize the various attributes of the SCXML class; and then by calling the UpdateSCXML method, the various attributes including the state, transition, action, and history connector are operated to generate an SCXML instance with complete attributes; the operations include initializing, assigning values, and sorting each attribute.
[0050] During animation display, if the current entry element is the initial state of the state diagram, the default conversion source and conversion line before the state are set to the entry color; if the current entry element is a sub-state machine element, the sub-state machine instance of the instance scheduler is called to start the instance.
[0051] Furthermore, when the animation is displayed, if the simulation animation interface receives an entry or exit notification, the corresponding primitive is found in the graphic display area of the simulation animation interface according to the ID of the current state in the SCXML instance, and the border of the primitive is set to the corresponding color, and the corresponding log of entering or exiting a state is output in the log area;
[0052] If the simulation animation interface receives a conversion notification, it finds the corresponding source and target graphics in the graphic display area of the simulation animation interface according to the source and target of the currently converted SCXML instance; then it finds a series of graphics in the specified path between the source and the target according to the cond and event of the current conversion, and sets the border of this graphics to the entry color and then to the exit color in the order from source to target to achieve the animation effect; at the same time, it also outputs the log of the transition from one state to another in the log area.
[0053] Accordingly, see Figure 1 The present invention provides a system for visually displaying simulation execution, comprising:
[0054] A model converter receives the simulation model provided by the SysML state machine, converts the primitives into executable SCXML codes based on the internal properties of the primitives in the state diagram in the simulation model, and generates the simulation model into a standard SCXML file using the state diagram as a generation unit;
[0055] The file parser receives the SCXML file and parses it using the methods and properties of the XmlReader class, generating a fully attributed SCXML instance and assigning values to it for reading by the simulation engine and instance scheduler;
[0056] Instance scheduler, manages all generated SCXML instances, starts the corresponding state machine instance when the simulation is initiated; sends call events through nodes on state behaviors;
[0057] The event transceiver responds to internal or external events and notifies the animation display according to the exit of the current state, the execution of the next transition and the next state; when the event transceiver needs to send a signal, it will notify all state machine instances, and each state machine instance will determine whether it needs to respond to the signal event based on its current state and business needs;
[0058] The animation display notifies the simulation animation interface through the entry, exit, and conversion actions of the state instance in the SCXML instance to perform animation display.
[0059] Each module and its operation are described below.
[0060] The model converter generates the SysML state machine model into a standard SCXML file to support further analysis and conversion. One state diagram generates one SCXML file. When generating SCXML, based on the primitives of the state diagram, the internal properties of the primitives and the source and target of the connection are analyzed and converted into standard, executable SCXML code. Different types of primitives correspond to different elements of the generated SCXML.
[0061] The state element will generate the state element of the SCXML file, such as<state id=“s”> , and finally convert all the graphics elements in the state diagram into elements in the SCXML file; the SCXML file is the XmlDocument class and the element is the XmlElement.
[0062] Taking the state graph as an example, the following are the rules for converting the state graph into SCXML code:
[0063] For an example where state s can jump to state s1 and state s2 when triggered by e1 and e2 respectively, the code of the generated SCXML file is as follows:
[0064]
[0065] Among them, the "trigger" attribute of the conversion corresponds to event, the "condition" attribute corresponds to "cond", and the "target" attribute corresponds to target.
[0066] The file parser is supported by SCXML files, which allows the simulation engine to read and parse the semantics of SCXML files, and reads SCXML files using the methods and properties of the XmlReader class. Specifically, the various attributes of the SCXML file are read through the GetAttribute method and assigned to the SCXML instance class. After the attributes are read, the data is read line by line by judging the value of NodeType (the type of the current node). In the process of reading line by line, the name of the current node (NodeName such as "state", "transition", "onentry", "final", etc.) is judged to organize the various attributes of the SCXML class, and then the initialization, assignment, sorting and other operations of the state, transition, historical connector and other attributes are implemented by calling the UpdateSCXML method of the file parser, and finally a SCXML instance with complete attributes is generated and provided to the instance scheduler.
[0067] The instance scheduler manages all SCXML instances (state machine instances) and starts the corresponding state machine instances. In the state entry behavior, Do behavior, exit behavior, and transition action behavior, call events are sent to other state machines through the target attribute of the send node.
[0068] Taking the state entry behavior primitive as an example, a description of the SCXML instance called for the sub-state machine is given.
[0069] For the entry behavior of the shutdown state, another state machine is called, and the generated SCXML code is as follows:
[0070]
[0071]
[0072] Among them, the attribute of the called object type ("Statemachine") corresponds to Type, the "Calling object" attribute corresponds to "event", and the "State diagram of the called object" attribute corresponds to target.
[0073] Event transceivers can respond to internal or external events, or they can trigger events from within. The TruggerEvents method is responsible for receiving events, while the FireEvents method is responsible for triggering events.
[0074] When the event transceiver receives an event, it will first determine whether the current state is suspended. If it is suspended, it will determine whether it needs to be added to the event queue for later processing based on business needs. If it is not a suspended state, it will execute the EventStep method to calculate the next state and next transition of the current state, and then notify the animation display based on actions such as exiting the current state, executing the next transition, and entering the next state.
[0075] When the event transceiver needs to send a signal (for example, when executing the signal sending element), it will notify all state machine instances by calling the FireEvents method. Each state machine instance determines whether it needs to respond to the signal event based on its current state and business needs.
[0076] The animation display notifies the simulation animation interface through actions such as entering, exiting, and switching states to perform animation display.
[0077] When the simulation animation interface receives an entry or exit notification of an event state, it will find the corresponding graphic element in the graphic display area of the simulation animation interface according to the ID of the current state, set the border of the graphic element to the corresponding color, and output the corresponding log of entering or exiting a state in the log area.
[0078] If the current entry element is the initial state of the state diagram, the default conversion source and conversion line before the state are set to the entry color; if the current entry element is a sub-state machine element, the sub-state machine instance of the instance scheduler will be called to start the instance.
[0079] When the simulation animation interface receives a conversion notification, it will find the corresponding source and target primitives in the graphic display area of the simulation animation interface according to the current conversion source and target, and then find a series of primitives in the specified path between the source and target according to the current conversion cond and event, and set the border of this primitive to the entry color first and then to the exit color in the order from source to target, so as to achieve the animation effect. At the same time, the log of the conversion from one state to another will be output in the log area.
[0080] The animation display can also adjust the animation speed. Specifically, you can set an interval time (unit: milliseconds). When the graphic element is set to enter the color, it will call the System.Threading.Thread.Sleep() method to pause the current form interface for a specified time.
[0081] Specific examples are given below.
[0082] The transmission control unit of a car is a typical industrial system. The transmission control unit receives the driver's shift command and controls the gearbox shift. In this case, dynamic simulation based on the SCXML standard is implemented for the SysML state machine model of the transmission control unit.
[0083] Create a SysML state machine model of the car's transmission control unit, such as Figure 3 shown.
[0084] Generate SCXML file based on the transmission control unit state machine model, according to Figure 3 The state diagram and primitives are converted into Figure 4 SCXML files and elements in .
[0085] The SCXML file converted into this state diagram is as follows:
[0086] <?xml version="1.0"?>
[0087] <scxml xmlns="http: / / www.w3.org / 2005 / 07 / scxml"version="1.0"
[0088] initial="339aded6-d0a1-429e-8f3c-d395a1da39dc@@P">
[0089]
[0090] Then, for the state (named P) primitive, generate the elements in the SCXML file as follows:
[0091]
[0092]
[0093] According to the same rules, Figure 3 All the primitives in the state diagram are converted into SCXML files.
[0094] Initiate simulation of the transmission control unit state machine, and display the simulation execution process and animation, such as Figure 5 shown.
[0095] During driving, by switching the R gear to the N gear, Figure 5 The gear shifting process is shown in the form of animation. First, the state machine is currently in the R state, and the R state icon is displayed in red. When an external trigger N is received, it switches to the N state through conversion. At this time, the R state and the conversion line are set to green, representing the executed path, and the N state is set to red, representing the current state.
[0096] The above embodiments are preferred examples for implementing the present invention, and the present invention is not limited to the above embodiments. Any non-essential additions and substitutions made by those skilled in the art based on the technical features of the technical solution of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for visually displaying simulation execution, characterized in that: The following operations are included: 1) The model converter receives the simulation model provided by the SysML state machine and generates a standard SCXML file from the simulation model using the state diagram as a generation unit; When generating SCXML files, the internal properties of the state diagram primitives and the sources and targets of the connecting lines in the primitives are converted into standard executable SCXML code; 2) The file parser receives the SCXML file, parses its semantics using the methods and properties of the XmlReader class to generate an SCXML instance and assign values for reading by the simulation engine and instance scheduler; 3) When the simulation of the state machine model is initiated, all SCXML instances of the model are managed by the instance scheduler, and the event transceiver also starts working; The event transceiver responds to internal / external events, or processes internal trigger events; When executing to the state instance in the SCXML instance, if its internal attributes contain a call event, the call event is sent through the event transceiver, and then the event transceiver notifies the instance scheduler to start the corresponding SCXML instance; 4) When the SCXML instance started by the instance scheduler runs to the internal signal sending action, the event transceiver immediately sends a signal and calls FireEvents to notify all state machine instances. The event transceiver of each state machine instance will receive the signal event, and then determine whether to respond to the signal event based on its own current state and business needs; When the event transceiver receives an event, it first determines whether the current event state is pending. If it is pending, it is added to the event queue according to business needs. If it is not pending, the EventStep method is executed to calculate the next state and the next transition of the current state, and then the animation display is notified according to the actions including exiting the current state, executing the next transition, and entering the next state. 5) The animation display performs animation display by notifying the simulation animation interface through the received action.
2. The method for visually displaying simulation execution as claimed in claim 1, characterized in that: When generating SCXML files, one state diagram generates one SCXML file; Convert all graphics elements in the state diagram into elements in the SCXML file, where the state graphics elements generate the state elements of the SCXML file; the SCXML file is of XmlDocument class and the elements are XmlElement.
3. The method for visually displaying simulation execution as claimed in claim 1, characterized in that: When generating an SCXML file, the internal attributes of the primitive are refined into triggers, conditions, and targets. Then, when converting into an SCXML file, the following correspondence is adopted: the trigger attribute in the primitive corresponds to event, the condition attribute corresponds to cond, and the target attribute corresponds to target.
4. The method for visually displaying simulation execution as claimed in claim 1, characterized in that: When parsing the SCXML file, the various attributes of the SCXML file are read through the GetAttribute method of the XmlReader class. After the attributes are read, the data is read line by line by judging the type of the current node; in the process of reading line by line, the name of the current node is judged to organize the various attributes of the SCXML class; then, by calling the UpdateSCXML method, various attributes including status, transition, action, and history connector are operated to generate an SCXML instance with complete attributes; the operations include initializing, assigning values, and sorting each attribute.
5. The method for visually displaying simulation execution according to claim 1, characterized in that: The instance scheduler sends a call event to other state machines through the target attribute of the send node on the entry behavior, Do behavior, exit behavior, and conversion action behavior of the state instance.
6. The method for visually displaying simulation execution as claimed in claim 1, characterized in that: The event transceiver receives and responds to internal / external events through the TruggerEvents method, and processes internal triggering events through the FireEvents method.
7. The method for visually displaying simulation execution according to claim 1, characterized in that: When the animation is displayed, if the simulation animation interface receives an entry or exit notification, the corresponding primitive is found in the graphic display area of the simulation animation interface according to the ID of the current state in the SCXML instance, and the border of the primitive is set to the corresponding color. At the same time, the corresponding log of entering or exiting a state is output in the log area; If the simulation animation interface receives a conversion notification, it finds the corresponding source and target graphics in the graphic display area of the simulation animation interface according to the source and target of the currently converted SCXML instance; then it finds a series of graphics in the specified path between the source and the target according to the cond and event of the current conversion, and sets the border of this graphics to the entry color and then to the exit color in the order from source to target to achieve the animation effect; at the same time, it also outputs the log of the transition from one state to another in the log area.
8. The method for visually displaying simulation execution as claimed in claim 1, characterized in that: During animation display, if the current entry element is the initial state of the state diagram, the default conversion source and conversion line before the state are set to the entry color; if the current entry element is a sub-state machine element, the sub-state machine instance of the instance scheduler is called to start the instance.
9. The method for visually displaying simulation execution according to claim 1, characterized in that: The animation display also has an interval time setter to adjust the animation speed. When the graphic element is set to the entry color, the System.Threading.Thread.Sleep() method is called to pause the current form interface for a specified time.
10. A system for visually displaying simulation execution, characterized in that: include: A model converter receives the simulation model provided by the SysML state machine, converts the primitives into executable SCXML codes based on the internal properties of the primitives in the state diagram in the simulation model, and generates the simulation model into a standard SCXML file using the state diagram as a generation unit; The file parser receives the SCXML file and parses it using the methods and properties of the XmlReader class, generating a fully attributed SCXML instance and assigning values to it for reading by the simulation engine and instance scheduler; Instance scheduler, manages all generated SCXML instances, starts the corresponding state machine instance when the simulation is initiated; sends call events through nodes on state behaviors; The event transceiver responds to internal or external events and notifies the animation display according to the exit of the current state, the execution of the next transition and the next state; when the event transceiver needs to send a signal, it will notify all state machine instances, and each state machine instance will determine whether it needs to respond to the signal event based on its current state and business needs; The animation display notifies the simulation animation interface through the entry, exit, and conversion actions of the state instance in the SCXML instance to perform animation display.
Citation Information
Patent Citations
Graphics engine reset and recovery in a multiple graphics context execution environment
CN110956570A
Ai design analysis and recommendations
CN112558929A
