<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- Documentation of Creating a State Automaton. --> <html> <head> <link rel="stylesheet" type="text/css" href="../layout/stylesheet.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Creating a State Automaton using AutoFOCUS3 (AF3)</title> </head> <body> <div class="header"> <div class="box"> <div class="navbar"> <!--a href="https://www.fortiss.org/" align="left"> <img src="fortiss-logo.png" width="90px" height="20px" align="left"> </a--> <div class="dropdown"> <button class="btn" id="hamburger"> <label for="hamburger" class="hamburger"> <span class="hamburgerLine"></span> <span class="hamburgerLine"></span> <span class="hamburgerLine"></span> </label> </button> <div class="dropdown-content"> <a href="../getting_started.html"> Main Page</a> <a href="../requirements/MIRA.requirements.html">Requirements Engineering</a> <a href="#">Deployment and Code Generation</a> <a href="#">Design Space Exploration (DSE)</a> <a href="#">Assurance Case Modeling</a> <a href="#">Further Resources</a> </div> </div> <div class="dropdown"> <button class="dropbtn">Modeling and Simulation <i class="triangle"></i></button> <div class="dropdown-content"> <a href="model_element_attributes.html">Introduction to Graphical Modeling Interface</a> <a href="component_architecture.html">Component Architecture Modeling</a> <a href="data_dictionary.html">Data Dictionary: Types and Functions</a> <a href="code_specification.html">Behavior Modeling -> Code Specifications</a> <a href="hierarchical_state_automaton.html">Behavior Modeling -> Hierarchical State Automata</a> <a href="mode_automaton.html">Behavior Modeling -> Mode Automata</a> <a href="simulation_with_af3.html">Simulation -> Simulation</a> <a href="operatorpanels.html">Simulation -> Operator Panels</a> <a href="operatorpanels_advanced.html">Simulation -> Advanced interface</a> <a href="cosimulation_with_af3.html">Simulation -> Co-Simulation and FMI Support</a> <a href="refactoring.html">Refactoring</a> <a href="model_markers_view.html">On-the-fly Checks</a> </div> </div> <div class="topnav-right"> <a href="mailto:af_user@lists.fortiss.org?subject=Reporting 'state_automaton.html' Documentation Problem!&body= Dear Af3 team, I am reporting an issue related to 'modelling and simulation'. {Please specify the problem precisely here.}.">Report a Problem?</a> </div> </div> </head> </div> </div> <div class="box"> <button onclick="topFunction()" id="upBtn" title="Go to top">Top</button> <h2>Creating a State Automaton</h2> <p>Beside the usage of <a href="code_specification.html"><i>Code Specifications</i></a>, there is also the possibility to define the behavior of components in a graphical State Automaton Diagram.</p> <h4>Drawing States and Transitions</h4> <p>Once you have added a state automaton to your component and opened it, you might drag&drop a state from the right Model Elements View to your diagram. In the same way you can add ports to your states.</p> <p>To move a state, pick the state somewhere in the middle and move it. Same for ports, just pick them and move around the border of the state. To resize a state, pick the lower, the right, or the lower-right point of its bounding-box and then move it.</p> <p>In order to create transitions between two states, press the <b><alt>-Key</b> on your keyboard and drag the transitions from one port to another port of different I/O-kind (i.e., Entry/Exit). If you drag from one state to another state, new ports will be created automatically and the transition will be created between the new ports. Invalid transitions (e.g., between two Output/Exit-Ports) are avoided by disabling the dragging.</p> <p>You should declare one state as initial. This can be done in the <i>Properties View</i> after you selected a state. This state is marked with a little black dot. If you forget to declare a state as initial, or if you declare more than one state as initial, this is detected by AutoFOCUS after you have saved the project. In this cases, an Error marker will be shown in the <a href="model_markers_view.html">Model Markers View</a>.</p> <p> In the <i>Properties View</i>, you can edit the names of selected states, transitions and ports. You can also specify comments.</p> <p> You can change the route of transitions by selecting it, pick the point shown in the middle and move it. Afterwards, two new points are shown between the moved middle point and the two ports. By moving these points, you can further define the route more precisely.</p> <img src="./pictures/StateAutomaton1.png"> <p> <i>Note:</i> Dragging&dropping a state <i>inside</i> a state, yields a <a href="hierarchical_state_automaton.html">Hierarchical State Automaton</a>.</p> <h4>Data State Variables</h4> <p> Data State Variables (DSVs) are internal variables that can be accessed in all states of the corresponding state automaton. To add such a variable to a state automaton, click the <i>Data State</i> tab in your State Automaton View. Press the Add-Button to add a DSV.</p> <img src="./pictures/DataStateVariables1.png"> <p>You may give a variable name, a type of the variable and an initial value. Valid types are <i>int</i>, <i>double</i> and <i>boolean</i>. Invalid types are detected and an error message is given.</p> <img src="./pictures/DataStateVariables2.png"> <h4>Defining Guards and Actions</h4> <p>If the component is in a state that has multiple outgoing transitions, it has to be specified which transition is used at the next step. This is done by specifying <i>Guards</i> of transitions. If no Guard of an outgoing transition is fulfilled, the state keeps active. If multiple outgoing transition guards would be fulfilled, this would result in a non-deterministic behavior. AutoFOCUS provides a <a href="non_determinism_analysis.html">Non-determinism analysis</a> to detect this.</p> <p>If a guard is fulfilled and the transition is fired, a defined <i>Action</i> is executed. There can be multiple Actions separated by '<tt>;</tt>'.</p> <img src="./pictures/StateAutomaton.GuardsAndActions.png"> <p>If you have created a complex transition and want to reuse it again as another transition, you may use the copy&paste buttons in the properties view of a transition. Press <i>copy</i> for a transition, then create a new transition somewhere and finally press <i>paste</i> in this new transition. All settings of the copied transition (Guards and Actions) will be inserted into the new transition.</p> <p>It is also possible to define <i>Idle actions</i> at states. These actions are fired in every simulation step, if the state is active and no outgoing transition guard is fulfilled. For valid syntax, please look at the above example screen shot. E.g., Green() is a Enumeration Member defined in the <a href="data_dictionary.html">Data Dictionary</a>. Of course, syntax checking is also provided for guards and actions. </p> </div> <script src="../layout/jsscript/topBtn.js"> </script> </body> </html>