Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
280 CHAPTER 11 Modeling Event-Based Behavior with State Machines The terminate pseudostate is always associated with the state of an entire state machine. If a terminate pseudostate is reached, then the behavior of the state machine terminates. A terminate pseudostate has the same effect as reaching the final states of all the state machine's regions. The termination of the state machine does not imply the destruction of its owning object, but it does mean that the object will not respond to events via its state machine. If a state machine or state contains a single region, it typically is not named, but if there are multiple regions, they can be named. A single region is represented by the area inside the frame of the state machine diagram. The notation for the concepts introduced thus far is as follows: n n n An initial pseudostate is shown as a filled circle. A final state is shown as a "bulls-eye"; that is, a filled circle surrounded by a larger hollow circle. A terminate pseudostate is shown as an X. 11.3.2 State A state represents some significant condition in the life of a block, typically because it represents some change in how the block responds to events and what behaviors it performs. This condition can be specified in terms of the values of selected properties of the block, but typically the condition is expressed in terms of an implicit state variable (or variables) corresponding to its regions. It is helpful to use the analogy that the block is controlled by a switch, in which each state corresponds to a switch position for the block, and the block can exhibit some specified behavior in each switch position. The state machine defines all valid switch positions (i.e., states) and transitions between switch positions (i.e., state transitions). If there are multiple regions, each region is controlled by its own switch with its switch positions corresponding to its nested states. The switch positions can be specified by a form of truth table, similar to how logic gates can be specified, in which the current states and transitions define the next state. Each state may have entry and exit behaviors that are performed whenever the state is entered or exited, respectively. In addition, the state may perform a do behavior that executes once the entry behavior has completed. The do behavior continues to execute until it completes or the state is exited. Although any SysML behavior can be used, typically entry and exit behaviors and do behaviors are activities or opaque behaviors. A state is represented by a round-cornered box containing its name. Entry and exit behaviors and do behaviors are described as text expressions preceded by the keywords entry , exit , or do and a forward slash. There is some flexibility in the content of the textual expression. The text expression typically is the name of the behavior, but when the behavior is an opaque behavior, the body of the opaque behavior can be used instead (refer to Chapter 7, Section 7.5 for a description of an opaque behavior). Figure 11.2 shows a simple state machine for the Surveillance System, with a single operating state in its single region. A transition from the region's initial pseudostate goes to the operating state. On entry, the Surveillance System displays the fact that it is operational on all operator consoles, and on exit, it displays a shutdown status. While the Surveillance System is in the operating state, it performs, via a do activity, its standard function of Monitor Site; that is, monitoring the building where it is installed for any unauthorized entry. When in the operating state, a Turn Off signal triggers a transition to the final state, and since there is a single region, the state machine terminates.