80 likes | 198 Vues
This overview explores state diagrams as a critical component of software engineering, illustrating how they capture the sequence of states within a system. State diagrams represent the system's history and processing logic. Transitions between states are depicted by events, optional data, and conditions. This guide also highlights various applications of state diagrams, including TCP protocol handling, firmware generation, and the HexAtom MIDI music generator. Gain insights into how these diagrams can model complex systems effectively.
E N D
CSC 354 – Software Engineering, Spring 2013, Week 8 UML Distilled, Chapter 10 State Diagrams
State Diagram • A State Diagram is a diagram that shows a sequence of states of a system, where a state shows values of the primary variables that store the history and encode the logic of the system’s processing. • A directional transition from one state to another shows the event triggering the transition, along with additional, optional data – arguments, guard condition & activity are optional. • event(arguments) [guard condition] / activity • event (typical but optional) shows incoming stimulus (method call, message from external system, etc.), arguments are event data, guard condition tests whether to process event, activity is the output of the state machine. You need at least 1 of these fields.
HexAtom commands ADD "a\\s*(\\d+)\\s*([nsx][ew]?)\\s*(\\d+)\\s*(@\\s*(-)?\\d+\\s*,\\s*(-)?\\d+)?” DIAM "d\\s*(\\d+)” TEMPO "t\\s*((\\d+)|(\\d*\\.\\d+)|(\\d+\\.\\d*))” PROBABILITY "((pcd)|(pde)|(pdf)|(pfi)|(pft)|(pfu)|(pmt)|(pst)|(pxu)|(paz))" + "\\s*(\\d+)(-\\d+)?\\s*=" + \\s*((\\d+)|(\\d*\\.\\d+)|(\\d+\\.\\d*)) QUERY "q\\s*((d|t|f|(p\\s*\\d*))*)” FAKE "f\\s*((\\d*\\.?\\d+)|(\\d+\\.?\\d*))"
Interpreter helper methods • After using a java.util.regex.Match object to extract parameters from the string, the interpreter invokes one of the following helper methods to do the actual work. • helpAddAtom • helpChangeDiameter • helpChangeTempo • helpProbCommand • helpQueryCommand • Fake sets the probabilityToFake directly.
Other applications of state diagrams • TCP protocol establishment & termination • http://en.wikipedia.org/wiki/Transmission_Control_Protocol • Other protocol handlers, including generation of firmware for hardware devices. • The MIDI music generator in HexAtom is a state machine that accepts changes in game state and translate them to timed changes in musical state. • Typically, software that you can think of as a machine is a candidate for modeling using a state diagram.