Jumat, 22 Juni 2018

Sponsored Links

UML_img_587.jpg
src: www.site.uottawa.ca

UML's state machine , also known as UML statechart , is a significant significant improvement of the limited mathematical concepts of automobiles in computer science applications as stated in Unified Modeling Language (UML) notation.

The concept behind it is about regulating the way devices, computer programs, or other processes (often technically) work in such a way that the entity or each sub-entity is always in one of a number of possible states and where there is a definitional-defined transition between these countries.

The UML state machine is an object-based variant of Harel statechart, adapted and extended by UML. , The purpose of the UML state machine is to overcome the main limitations of traditional finite state machines while retaining their key benefits. UML statecharts introduce new concepts from hierarchical nesting states and orthogonal regions, while extending the idea of ​​action. The UML state machine has the characteristics of a Mealy engine and a Moore engine. They support actions that depend on the circumstances of triggering systems and events, such as in the Mealy machine, as well as incoming and outgoing actions, which are related to circumstances rather than transitions, as in Moore machines.

The term "UML state machine" can refer to two types of state machines: state machine behavior and protocol state machine . The behavior status engine can be used to model the behavior of individual entities (eg, instance classes). The protocol state machine is used to express protocols of use and can be used to define the legal use scenarios of classifiers, interfaces, and ports.


Video UML state machine



Ground state machine concept

Many event-driven software systems mean that they are constantly awaiting the occurrence of some external or internal events such as mouse clicks, keystrokes, check marks, or packet data arrivals. After recognizing the event, the system reacts by performing appropriate calculations that may include manipulating hardware or generating "soft" events that trigger other internal software components. (That's why an event-driven system is an alternative called reactive system .) After the event handling is complete, the system returns to wait for the next event.

The response to an event generally depends on the event type and on the internal state of the system and may include a status change that leads to transition status . Country patterns, states, and transitions among these countries can be abstracted and represented as finite-state machine (FSM).

The concept of FSM is important in programming that is triggered by the event because it makes the event that handles explicitly depending on the event type and on the system state. When used correctly, the state machine can drastically reduce the number of execution paths through the code, simplifying the conditions tested at each branching point, and simplifying the transition between different execution modes. Instead, using event-driven programming without the underlying FSM model can cause the programmer to produce error-prone, difficult to expand and overly complex application code.

Basic UML status diagram

UML maintains a common form of traditional state diagram. UML state diagram is a directed graph in which the node shows the state and the connector shows the state transition. For example, Figure 1 shows a UML state diagram that corresponds to the machine's state of the computer keyboard. In UML, the status is represented as a rounded rectangle labeled with the state name. Transitions, represented as arrows, are labeled with trigger events that are optionally followed by a list of executed actions. Initial transition comes from a dense circle and determines the default status when the system first starts. Each state diagram must have such a transition, which should not be labeled, since it is not triggered by an event. The initial transition can have an associated action.

Events

The event is something that happens that affects the system. Strictly speaking, in the UML specification, the term event refers to the type of event rather than to the concrete example of the event. For example, Keystroke is an event for a keyboard, but each key press is not an event, but a concrete event of a Keystroke event. Another interesting event for the keyboard may be Power-on, but turning power on tomorrow at 10:05:36 will be an example of a Power-on event.

Events can connect parameters , allowing event events to convey not only the occurrence of some interesting events but also quantitative information about the event. For example, a Keystroke event generated by pressing a key on the computer keyboard has associated parameters that pass the character scanning code as well as the status of the Shift, Ctrl, and Alt keys.

Instance instances outperform the instantaneous events that produce them and possibly convey these events to one or more state machines. Once generated, the event instance passes through a processing life cycle that can comprise up to three stages. First, the received event instance is received and pending processing (e.g., Placed in the event queue). Then, the event instance is sent to the state machine, which at the time becomes the current event. Finally, is consumed when the state machine finishes processing the event instance. Instance of the consumed event is no longer available for processing.

State

A state captures the relevant aspects of the system history very efficiently. For example, when you press a key on the keyboard, the generated character code will be either uppercase or lowercase characters, depending on whether Caps Lock is on. Therefore, keyboard behavior can be divided into two states: the "default" status and the "caps_locked" status. (Most keyboards include LEDs indicating that the keyboard is "caps_locked".) Keyboard behavior depends only on a particular aspect of its history, ie whether the Caps Lock key has been pressed, but not, for example, how many and precisely which other key has been pressed previous. A country may obscure all possible (but irrelevant) sequences of events and only capture the relevant ones.

To relate this concept to programming, this means that instead of recording event history in many variables, banners, and convoluted logic, you are dependent primarily on a state variable that can only assume a finite number. of a priori specified value (for example, two values ​​in the case of a keyboard). The state variable value defines the current system state at a given time. The concept of state reduces the problem of identifying the execution context in the code to test only state variables, rather than many variables, thereby eliminating many conditional logic.

Advanced status

One possible interpretation of the state for a software system is that each state represents a set of valid values ​​that differ from the overall program memory. Even for simple programs with only a few basic variables, this interpretation leads to a number of astronomical states. For example, a single 32-bit integer may contribute more than 4 billion different countries. Obviously, this interpretation is not practical, so program variables are usually separated from the state. In contrast, the complete state of the system (called extended state ) is a combination of qualitative (state) and quantitative aspects (expanded state variables). In this interpretation, variable change does not necessarily imply a qualitative change in the behavior of the system and therefore does not lead to state change.

State machines equipped with variables are called expanded state machine and UML state machines fall into this category. Expanded state machines can apply the underlying formalism to a much more complex problem than practical without including additional status variables. For example, suppose the behavior of the keyboard depends on the number of characters typed so far and after, say, 1,000 keystrokes, broken keyboard and enter the final state. To model this behavior in a state machine without memory, you need to introduce 1,000 statuses (for example, pressing a key in a stroke123 state will lead to a stroke124 state, and so on), which is obviously an impractical proposition. Alternatively, you could build an extended state machine with a down-key key_count variable. The counter will be initialized to 1,000 and subtracted by each keystroke without changing the state. When counter reaches zero, state machine will enter final state.

The state diagram of Figure 2 is an example of an extended state machine, where the complete state of the system (called extended state) is a combination of qualitative aspects - "state" - and quantitative aspects - expanded state variables (such as down-counter key_count ).

The obvious advantage of an extended state machine is its flexibility. For example, extending the life of a "cheap keyboard" from 1,000 to 10,000 keystrokes would not complicate an extended state machine at all. The only modifications required will change the initialization value of the key_count down-counter in the initial transition.

The versatility of this expanded state machine comes at a price, however, because of the complex coupling between the "qualitative" and "quantitative" aspects of an expanded state. The coupling takes place through the guard conditions attached to the transition, as shown in Figure 2.

Guard conditions

The guard conditions (or just guard) are dynamically evaluated Boolean expressions based on extended status variable values ​​and event parameters. The guard conditions affect the state machine behavior by allowing actions or transitions only when they evaluate TRUE and disable it when they evaluate to FALSE. In UML notation, the guard conditions are displayed in square brackets (eg, [key_count == 0] in Figure 2).

The need for guards is a direct consequence of the addition of memory variables extended to the state machine formalism. Used sparingly, state variables are extended and guards form powerful mechanisms that can simplify the design. But do not let the fancy name ("guard") and concise UML notation fool you. When you actually encode an expanded state machine, the guard becomes the same IF and ELSE you want to remove using the state machine in the first place. Too many of them, and you will find yourself back to the starting point ("spaghetti code"), where the guards effectively take over the handling of all relevant conditions in the system.

Indeed, variable misuse and an expanded state guard are the main mechanisms of architectural decay in designs based on state machines. Usually, in daily battles, it seems very tempting, especially for new programmers to certify machine formalism, to add additional status variables and other guard conditions (other IF or MORE) rather than exit from related behavior to new qualitative aspects of the system - country. From experience in the trenches, the possibility of decaying the architecture is directly proportional to the overhead (actual or perceived) involved in adding or removing states (related to the actual strategy used to implement UML state machines.)

One of the major challenges of becoming an effective state machine designer is to develop a sense in which parts of behavior should be caught as a "qualitative" ("country") aspect and which elements are better left as "quantitative" aspects (expanded state variables). In general, you should actively look for opportunities to capture the event history (what happens) as the "status" of the system, rather than storing this information in the expanded status variables. For example, a state machine representing pocket calculator behavior might use an additional DecimalFlag status variable to remember that the user entered a decimal point to avoid entering multiple decimal places within the same number. However, a better solution would be to observe that entering a decimal point really leads to a different state of "entering the learning_part_some_number", where the calculator ignores the decimal points. This solution is superior for a number of reasons. The lower reason is that it removes one additional state variable and needs to initialize and test it. A more important reason is that state-based solutions are stronger because context information is used very locally (only in this particular circumstance) and discarded so irrelevant. After the numbers are entered correctly, it is not essential for the operation of the next calculator if the number has a decimal point. The state machine moves to another state and automatically "forgets" the previous context. Additional status variables DecimalFlag , on the other hand, "lie around" are way past time when information becomes irrelevant (and possibly out of date!). Worse, you should not forget to reset DecimalFlag before entering another number or the flag will misrepresent that the user has entered a decimal point, but maybe this happens in the context of the previous number .

Capturing behavior as a qualitative "state" also has flaws and limitations. First, the state and transition topology in the state machine must be static and fixed at compile time, which can be overly restrictive and inflexible. Sure, you can easily find "state machines" that will modify themselves at runtime (this is what often happens when you try to re-code "spaghetti code" as a state machine). However, it's like writing a self-modifying code, which was done in the early days of programming but was quickly dismissed as a generally bad idea. Consequently, the "state" can only capture the static aspects of a behavior known as a priori and is unlikely to change in the future.

For example, it's okay to capture decimal point entries in the calculator as a separate state "enters_purchases_part_part_", since numbers can only have one fractional part, known as a priori and will not change in the future. However, applying a "cheap keyboard" without an expanded state variable and guard conditions is practically impossible. This example shows the major disadvantages of qualitative "status", which can not store too much information (such as varying number of keystrokes). Extended variables and state guards are thus a mechanism for adding additional runtime flexibility to state machines.

Actions and transitions

When an instance event is sent, the state machine responds by performing action , such as changing a variable, running I/O, executing a function, generating another event instance, or changing to another state. Any parameter values ​​associated with an event are currently available for all actions that are directly caused by the event.

Switching from one state to another is called transition status , and the event that causes it to be called triggering event, or simply trigger . In the keyboard example, if the keyboard is in the "default" state when the CapsLock key is pressed, the keyboard will enter the "caps_locked" state. However, if the keyboard is already "caps_locked", pressing CapsLock will cause a different transition - from "caps_locked" to "default" status. In both cases, pressing CapsLock is a trigger event.

In an extended state machine, the transition can have a guard, meaning that the transition can be "enabled" only if the guard evaluates to TRUE. A country can have many transitions in response to the same trigger, as long as they have a non-overlapping guard; However, this situation may create problems in the order of guard evaluation when triggers are common. The UML specification intentionally does not specify a particular sequence; instead, UML puts a load on the designer to design the guard in such a way that their evaluation order does not matter. Practically, this means that the guard expression should have no side effects, at least nothing will change the evaluation of other guards who have the same triggers.

Run-to-completion execution model

All state machine formalisms, including UML state machines, universally assume that state machines complete the processing of each event before they can begin processing the next event. This execution model is called run to completion , or RTC.

In the RTC model, the system processes events in discrete, indivisible RTC steps. New incoming events can not interrupt the processing of current events and must be stored (usually in the event queue) until the state machine becomes inactive. This semantics completely avoids the problem of internal concurrency in one state machine. The RTC model also addresses the conceptual problem of transition-related processing actions, where the state machine is not in a well-defined state (between two states) during the duration of the action. During processing of events, the system is unresponsive (so it can not be observed), so the uncertain state during that time has no practical meaning.

Note, however, that RTC does not mean that the state machine has to monopolize the CPU until RTC steps are completed. The preemption restriction applies only to the context of the task of a state machine that is already busy processing the event. In a multitasking environment, other tasks (not related to the task context of the busy state machine) can run, possibly preceding the state machine being executed. As long as other state machines do not share variables or other resources with each other, there is no danger of concurrency.

The main advantage of RTC processing is simplicity. The biggest disadvantage is that the state machine's responsiveness is determined by its longest RTC step. Achieving short RTC steps can often significantly complicate real-time design.

Maps UML state machine



UML extensions to traditional FSM formalism

Although traditional FSM is an excellent tool for solving smaller problems, it is generally well known that they tend to become out of control, even for systems that are quite involved. Because of the phenomenon known as state and transition boom , the traditional FSM complexity tends to grow faster than the complexity of the system it describes. This occurs because the traditional state machine's formalism leads to repetition. For example, if you're trying to describe the behavior of a simple pocket calculator with traditional FSM, you'll soon see that many events (eg, Delete Button or Off is pressed) are handled identically in many states. The conventional FSM shown in the figure below does not have the means to capture such similarity and requires repetition of the same actions and transitions in many states. What is missing in a traditional state machine is a mechanism for factoring common behavior to share it with many states.

UML's state machine completely overcomes the shortcomings of this conventional FSM. They provide a number of features to eliminate repetition so that the complexity of the UML state machine is no longer explosive but tends to faithfully represent the complexity of the reactive system it describes. Obviously, these features are very attractive to software developers, because only those who make the whole state machine approach really apply to real life problems.

Hierarchical nested status

The most important innovation of the UML state machine over traditional FSM is the introduction of hierarchically nested states (that's why statecharts is also called country hierarchical engine , or HSM s). The semantics associated with nesting states are as follows (see Figure 3): If a system is in a nesting state, such as a "result" (called substate ), it is also (implicitly) in the country around " in "(called superstate ). This state machine will try to handle every event in the context of the substate, which is conceptually at the lower level of the hierarchy. However, if the substate "result" does not specify how to handle the event, the event is not discarded secretly as in a traditional "flat" state machine; instead, are automatically handled at a higher level context than the "in" superstate. This is what the system is in the "outcome" of the state as well as "active". Of course, nesting states is not limited to one level only, and the simple rules of event processing apply recursively to every nesting level.

Countries containing other countries are called composite countries ; on the contrary, declaring without an internal structure is called simple state . Nested statuses are called direct substrate when not in other countries; otherwise it is referred to as a transitive nested substrate .

Because the internal structure of the composite state can become all-encompassing, every hierarchical state machine can be seen as an internal structure of some composite level (higher level). Conceptually convenient to define a composite state as the final root of the state machine hierarchy. In the UML specification, each state machine has top state (the abstract root of each state machine hierarchy), which contains all the other elements of the state machine as a whole. The graphics rendering of this all-enclosed up state is optional.

As you can see, the semantic decomposition of a hierarchical state is designed to facilitate the reuse of behavior. Substrate (nested status) only need to determine the difference from superstate (contains state). Substate can easily inherit the general behavior of its superstate by simply ignoring the commonly handled events, which are then automatically handled by the higher level. In other words, hierarchical state nesting allows programming by distinction .

The most frequently emphasized state hierarchy aspect is abstraction - a long and powerful technique for dealing with complexity. Instead of discussing all aspects of complex systems at the same time, it is often possible to ignore (in abstractly) some parts of the system. Hierarchical status is the ideal mechanism for hiding internal details because the designer can easily zoom out or zoom in to hide or display nested states.

However, composite states not only hide complexity; they also actively reduce it through the powerful mechanism of hierarchical event processing. Without such reuse, even moderate increases in system complexity can lead to explosive increases in the number of countries and transitions. For example, a hierarchical state machine representing a pocket calculator (Figure 3) avoids the Delete and Dead transitions in most states. Avoiding repetition allows the growth of HSMs to remain proportional to growth in system complexity. As the modeled system grows, the opportunities for reuse also increase and thus potentially negate the increase in the number of disproportionate and transitional nations typical of traditional FSM.

Orthogonal Region

Analysis with hierarchical state decomposition can include the application of 'exclusive-OR' operations for each particular country. For example, if the system is on "on" superstate (Figure 3), it may be a case that is also in either "operand1" substate OR "operand2" substate OR substance "opEntered" OR "result" substate. This will lead to the superstate description "in" as 'OR-state'.

UML statistics also introduce complement AND-decomposition. Such decomposition means that the composite state may contain two or more orthogonal regions (orthogonal means compatible and independent in this context) and that in such composite states requires to be in all orthogonal regions simultaneously.

Orthogonal regions overcome the problems that often occur in combinatorial enhancement in the number of circumstances when the behavior of a fragmented system becomes independent parts, which are simultaneously active. For example, in addition to the main keypad, the computer keyboard has an independent numeric keypad. From the previous discussion, remember the two key status keys that have been identified: "default" and "caps_locked" (see Figure 1). Numeric keypads can also be in two conditions - "numbers" and "arrows" - depending on whether Num Lock is on. The complete state space of the keyboard in standard decomposition is a Cartesian product of two components (main keypad and numeric keypad) and consists of four states: "default numbers," "arrow-default," "caps_locked-numbers," and "caps_locked-arrows. "However, this would be an unnatural representation because the behavior of the numeric keypad does not depend on the state of the main keypad and vice versa. The use of orthogonal regions allows mixing of independent behaviors as Cartesian products should be avoided and, conversely, for them to remain separate, as shown in Figure 4.

Note that if orthogonal regions are entirely independent of each other, their combined complexity is merely an additive, which means that the number of independent states needed to model the system is only the summation of klm... , where k, l , m,... shows the number of OR-states in each orthogonal region. However, the common case of mutual reciprocity, on the other hand, produces multiplicity complexities, so in general, the number of countries needed is the product of the k ÃÆ'â € "l ÃÆ'â €" m ÃÆ'â € "... .

In most real-life situations, the orthogonal region will only be approximately orthogonal (ie not really independent). Therefore, UML statecharts provide a number of ways for orthogonal regions to communicate and synchronize their behavior. Among the rich set of mechanisms (sometimes complicated), perhaps the most important feature is that orthogonal regions can coordinate their behavior by sending instances of events to each other.

Although orthogonal regions imply the independence of execution (allowing more or less concurrency), the UML specification does not require that separate execution threads be assigned to each orthogonal region (though this can be done if desired). In fact, most commonly, orthogonal regions execute in the same thread. The UML specification only requires that the designer not rely on a particular order for events to be delivered to the relevant orthogonal areas.

In and out of action

Each state in a statechart UML can have an optional entry entry, which is executed while logged in, as well as an optional exit action, which is executed after exit from the state. Outgoing entries and actions relate to states instead of transitions. Regardless of how a country is entered or exited, all incoming and outgoing actions will be executed. Due to these characteristics, statechart behaves like a Moore machine. UML notation for state incoming and outgoing actions is to place reserved (or "exit") "entries" under the name compartment, followed by forward slashes and a list of arbitrary actions (see Figure 5).

The value of incoming and outgoing actions is that they provide a means for initialization and cleaning guarantees , much like class constructors and destructor in object-oriented programming. For example, consider the "door_open" state of Figure 5, which corresponds to the oven toaster behavior when the door is open. This condition has important crucial safety requirements: Always switch off the heater when the door is open. Also, when the door opens, the internal lights that illuminate the oven should be lit.

Of course, the behavior can be modeled by adding appropriate actions (turning off the heater and turning on the lights) to any transition path that leads to the "door_open" state (the user can open the door anytime during "roasting" or "roasting" or when the oven is not used at all). It should not be forgotten to turn off the internal lights with every transition leaving the "door_open" state. However, such a solution would lead to repetition of action in many transitions. More importantly, such an approach leaves design errors in subsequent amendments to behavior (for example, subsequent programmers working on new features, such as top browning, may forget to disable heaters in transition to "door_open").

Outbound and outward actions allow the adoption of desired behavior in a safer, simpler, and more intuitive way. As shown in Figure 5, it can be determined that the action out of "heating" turns off the heater, the act of going into "door_open" lights up the oven light, and the action out of "door_open" turns off the light. Use of incoming and outgoing measures is better for placing actions on transition because it avoids repetitive coding and improves functionality by eliminating security hazards; (Heater when door opens). The semantics of outbound action ensure that, regardless of the transition path, the heater will be disabled when the toaster is not in a "warm-up" state.

Because an entry action is executed automatically every time an associated state is entered, they often specify an operating condition or a state identity, greatly as the class constructor determines the identity of the object being constructed. For example, the "heating" state identity is determined by the fact that the heater is turned on. This condition should be set before entering the substrate of "warm-up" because the act of getting into the substrate of "heating," such as "grilling," depends on the proper initialization of the "warming" superstate and only makes a difference from this initialization. As a result, the sequence of action execution must always move from the outermost state to the top-down state.

Not surprisingly, this sequence is analogous to the order in which the class constructor is invoked. Classroom development always begins at the root of the class hierarchy and follows all the inheritance levels to the classes used. Execution of the exit action, which corresponds to the destructor request, results in a bottom-up sequence.

Internal transitions

Very commonly, an event only causes some internal action to take place but does not lead to a change of state (state transition). In this case, all actions performed consist of internal transitions . For example, when one type on a keyboard, it responds by generating different character codes. However, unless the Caps Lock key is pressed, the keyboard state does not change (no transition status occurs). In UML, this situation should be modeled with an internal transition, as shown in Figure 6. UML notation for internal transitions follows the common syntax used for exit (or incoming) actions, except as a substitute for word entries (or out) internal transitions labeled with trigger events (for example, see internal transitions triggered by the ANY_KEY event in Figure 6).

In the absence of inbound and outbound actions, internal transitions will be identical to self-transition (the transition where the target country is the same as the source country). In fact, in the classic Mealy machine, actions are exclusively attributed to state transitions, so the only way to carry out action without changing circumstances is through self-transition (described as loop directed at Figure 1 from the top of this article). However, with the inbound and outbound actions, as in the UML statistics, the self-transition involves the execution of outgoing and incoming actions and therefore very different from the internal transition.

Unlike the self transition, no incoming or outgoing action has ever been executed as a result of internal transitions, even if internal transitions are inherited from a higher level of hierarchy than the current active state. Internal transitions are inherited from the superstate at each level of the stacking action as if they were defined directly in the currently active country.

The order of transition execution

State nests combined with incoming and outgoing measures significantly complicate the state transitional semantics in HSM compared to traditional FSMs. When confronted with hierarchically nested states and orthogonal territories, the simple term current state can be very confusing. In HSM, more than one country can be active at once. If the state machine is in a leaf state contained in a composite state (which may be contained in a higher level composite state, etc.), all composite states that either directly or transitive contain leaf states also active. Furthermore, since some composite states in this hierarchy may have orthogonal regions, the current active state is actually represented by a state tree that begins with a single peak state at the root to the simple state of the individual on the leaf. The UML specification refers to a state tree like this as a state configuration.

At UML, the state transition can directly connect two countries. These two statuses, which may be consolidated, are defined as the main primary and primary target of a transition. Figure 7 shows a simple transitional example and explains the role of the state in the transition. The UML specification specifies that taking state transitions involves executing the following actions in the following order (see Section 15.3.14 in the OMG Unified Modeling Language (OMG UML), Infrastructure Version 2.2 ):

  1. Evaluate the guard conditions associated with the transition and perform the following steps only if the guard evaluates to TRUE.
  2. Exits the source state configuration.
  3. Perform transition-related actions.
  4. Enter the target status configuration.

The sequence of transitions is easily interpreted in the simple case of the primary source and the primary target being nested at the same level. For example, the T1 transition shown in Figure 7 causes guard evaluation g (); followed by a sequence of actions: a (); b (); t (); c (); d (); and e () ; assuming that the guard g () evaluates to TRUE.

However, in the case of common sources and target countries nesting at different levels of the country hierarchy, it may not be immediately clear how much level of buildup needs to be released. The UML specification specifies that the transition involves the exit of all nesting states from the current active state (which may be a direct or transitive substrate of the primary source state) to, but excluding, the most common ancestor (LCA) of the main source state and the main target countries. As the name suggests, LCA is the lowest composite state that is also a superstate of both source and target state. As mentioned before, the execution sequence of exit actions is always from the deepest nesting status (current active state) up the hierarchy to the LCA but without leaving the LCA. For example, LCA (s1, s2) of state "s1" and "s2" shown in Figure 7 is the state of "s."

Entering the target status setting starts from the level at which the outbound action is interrupted (ie, from within the LCA). As mentioned earlier, the entry action must run from the highest level to the state hierarchy level to the primary target country. If the primary target country is a composite, the UML semantics set to "drill" into the submachine recursively using the local initial transition. The target status configuration is actually entered only after facing the state of the leaf that does not have an initial transition.

Local transition versus external

Before UML 2, the only transitional semantics used are external transitions , where the main source of the transition is always out and the main target of the transition is always included. UML 2 maintains the semantics of "external transition" for backward compatibility, but introduces a new transition type called local transitions (see Section 15.3.15 in Unified Modeling Language (UML), Infrastructure Version 2.2 ). For many transition topologies, external and local transitions are actually identical. However, local transitions do not cause exit and reentry to the primary source state if the primary targeting country is a substrate of the primary source. Additionally, local state transitions do not result in exit and reentry into the primary target country if the primary target is the supersector of the primary source country.

Figure 8 contrasts local (a) and external (b) transitions. In the top row, you see the primary source case containing the primary target. Local transitions do not cause exit from the source, while external transitions cause exit and re-entry to the source. In the bottom row of Figure 8, you see the main target case containing the primary source. Local transitions do not cause target entry, whereas external transitions lead to exit and reenter the target.

Event restrictions

Sometimes an event arrives at a very uncomfortable time, when a state machine is in a state that can not handle the event. In many cases, the nature of the event is such that it can be suspended (within limits) until the system enters another state, where it is better prepared to handle the original event.

UML state machine provides a special mechanism for delaying events in the state. In each state, you can include the [event list]/suspension clause. If an event in the list of state-suspended events currently occurs, the event will be saved (suspended) for processing in the future until a country is entered that does not include the event in a suspended event list. After entering such a state, UML's state machine will automatically remember any stored events that are no longer suspended and will then consume or discard this event. It is possible for a superstate to have a transition defined on an event suspended by a substate. Consistent with other areas in the UML state machine specification, the substate takes precedence over superstate, the event will be suspended and the transition for the superstate will not be executed. In the case of orthogonal regions in which an orthogonal region maintains an event and the other consumes the event, the consumer takes precedence and the event is consumed and not suspended.

statechart - UML State machine with nested states and do Activity ...
src: i.stack.imgur.com


UML state machine limitations

Harel statecharts, which are the precursors of the UML state machine, have been created as "visual formalism for complex systems", so from their inception, they have been closely related to graphical representations in the form of state diagrams. However, it is important to understand that the UML state machine concept goes beyond certain notation, graphics or textual. The UML specification makes this distinction evident by separating the state machine semantics from the notation.

However, UML statistical notation is not fully visual. Trivial state machines require a large amount of textual information (eg action specifications and guards). The exact syntax of action and guard expression is not defined in the UML specification, so many people use structured English or, more formally, expressions in implementation languages ​​such as C, C, or Java. In practice, this means UML's static notation depends heavily on a particular programming language.

However, most semantic statecharts are highly biased toward graphical notation. For example, state diagrams do not represent the processing sequence, be it a guard evaluation sequence or a sequence of delivery events to an orthogonal region. The UML specification avoids this problem by putting a load on the designer to not rely on a particular sequence. However, it is the case that when the UML state machine is actually implemented, there is full control over the execution command, thus raising the criticism that UML semantics may not need to be limiting. Similarly, statechart diagrams require a lot of piping equipment (pseudostates, like joints, forks, intersections, selection points, etc.) to represent graphical flow controls. In other words, these graphical notation elements do not add much value in representing control flows compared to regular structured code.

UML notation and semantics are really geared for computerized UML tools. The UML state machine, as represented in the tool, is not just a state diagram, but a mixture of graphical and textual representations that precisely capture state topologies and actions. Users of this tool can get multiple complementary views of the same state machine, both visual and textual, while the resulting code is just one of the many views available.

UML State Diagrams
src: www.btutor.com


External links

  • The latest UML specification by Object Management Group (OMG)
  • UML 2 State Machine Diagram
  • QM status engine modeling and code generation tool for deep embedded systems
  • North State Framework C and C # UML State Machine Framework.
  • Sinelabore C/C/Java code generator from UML country diagram
  • Improve Meta State C engine framework of a very strong Finite State framework.
  • ThingML Country UML Machine with textual syntax and compiler targeting C, Arduino, Java, and JavaScript.
  • yasmine C UML State Machine framework (supports C 11 or C 03 with Boost)

Creating a State Diagram - YouTube
src: i.ytimg.com


References

Source of the article : Wikipedia

Comments
0 Comments