More Dynamic Modeling - PowerPoint PPT Presentation

About This Presentation
Title:

More Dynamic Modeling

Description:

Event trace: helps to know what object is doing what action. State Diagram creation tips. ... Car. Ignition. Transmission. Brake. Accelerator ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 33
Provided by: drbillm
Learn more at: http://www.cse.msu.edu
Category:
Tags: dynamic | modeling | more

less

Transcript and Presenter's Notes

Title: More Dynamic Modeling


1
More Dynamic Modeling
2
Review of getting started
  • Scenario making gets us started thinking about
    events.
  • Interface (high-level prototyping) helps us to
    think about order of things. (happening in
    projects)
  • Event trace helps to know what object is doing
    what action.
  • State Diagram creation tips.

3
Dynamic Model - State Diagram
  • Graphical representation of a finite state
    machine.
  • Changing states - transitioning on events.
  • Events - external stimuli and internal messages
  • ex. button pushed timer complete tub full.
  • ex. complete event sent by state
  • In each state, a set of predicates based on
    instance variables, is valid.

4
States Labeled with Conditions
Microwave Oven
SOP
open_door/closef heatf
(null)
start_oven/startt errort
open_door/closef
close_door
SE1 start, error
S4 close heat
S0 do/closet close
done/startf heatf
close_door
start_cooking/startf
start_oven/startt
open_door/closef
S2 start, close
SE2 start, close, error
S3 start,close, heat
reset/closef errorf
warmup/heatt
5
Dynamic Models for E.S.
  • Dynamic Model for user buttons would be
    simplistic modeling might not be needed.
  • Some environmental units might have behavior that
    should be modeled. (like an engine shifting
    through speeds)
  • For embedded systems - might only need one
    significant behavior model (for controller.)
  • Complex models will be decomposed into more
    detailed behavioral models.
  • Concurrency could be present within a model.

button
pushed
on
off
button
pushed
6
How dynamic model relates to object model
  • One state diagram for each class (with important
    behavior.)
  • Each class has concurrent behavior.
  • Aggregation in the Object Model usually implies
    concurrency in the Dynamic Model.

7
Examples of Aggregation (5.17)
  • Object model

Car
Ignition
Transmission
Brake
Accelerator
Each class here will need a concurrent state
diagram
8
How to model concurrency within an object
Car
turn key to start
Ignition
Transmission
release key
in Neutral
off
on
starting
turn key off
Transmission
push R
Reverse
Neutral
push N
push F
push N
Forward
upshift
upshift
stop
second
third
first
downshift
downshift
Accelerator
Brake
depress accelerator
depress brake
on
off
on
release accelerator
off
release brake
9
How to hide complexity
  • Not have a flat state diagram
  • Start abstract and then do subdiagrams.
  • use bulls eye
  • Take one abstract state and expand it with state
    generalization.

10
Example of nesting(and other syntax as well)
coin in(value)
coin in(value)
Do/add to balance(value)
idle
cancel / refund coins
select(item)
changelt0
item empty
Do/test item present make change
change0
changegt0
Example lower-level state diagram for Dispense
item activity
Do/dispense change
Do/move arm to correct row
Do/move are to correct column
Do/push item off shelf
stop
11
State Generalization
Push R
Neutral
Reverse
Push N
Push N
Push F
Forward
Push R
Reverse
Neutral
Push N
Push N
Push F
Forward
Upshift
Upshift
First
Second
Third
downshift
downshift
12
Notation on Transitions and in States
  • Do/ activity
  • takes some time.
  • associated with a state.
  • Guards
  • conditions - boolean
  • guard
  • Actions
  • instantaneous
  • associated with an event.
  • /action

event1 (attribs) condition1/ action1
State1 do/ activity 1
You might need any or all of these for your
project!
State2 do/ activity 2
13
Checking for completeness and consistency
  • Formal specifications do this better!
  • The mathematical format can allow automation of
    these types of checks.
  • Every state should have a way in and out.
  • unless starting point or ending point.
  • Look for one objects Dynamic Model sending an
    event that doesnt have any receiving transition
    in another objects DM.

14
Things to watch out for
  • Think about input from concurrent objects at
    unexpected times.
  • ex. If more than one ATM machine is trying to
    access the same account at the same time.
  • User input when not planned. (OK to ignore, but
    make sure that is what is really wanted.)
  • Take your scenarios and see if they work!
  • Walk through seeing that all the objects
    operations/messages has all the needed
    transitions.

15
Producer-Consumer - Normal Scenario
consumer
producer
get
ack
data
ack
16
Producer-ConsumerState machine 1
consumer
producer
start
start
send(producer.get)
get/send(consumer.ack)
ack0
timeout/ send(consumer.nak)
ack
fetch
wait
data_ready/ consumer.data(buf)
data(buf)
wait
ack
timeout
stash do/save buf
17
Basic Class Diagram
consumer
producer
get, ack
data, ack, nak
18
Producer-ConsumerState machine 2
consumer
producer
start
start
send(producer.get)
nak
get/send(consumer.ack)
ack0
timeout/ send(consumer.nak)
ack
fetch
nak
wait
data_ready/ consumer.data(buf)
data(buf)
wait
ack
timeout
stash do/save buf
/ack
19
Dynamic Model Timing and Exceptional Handling
stop
20
Topics Covered
  • Dynamic Model
  • Synchronization schemes
  • Exception Handling
  • Timing including safety critical issues.

21
Synchronization
  • In concurrent processing, the actions of the
    objects are rarely independent of each other.
  • One may need to stop and wait for another process
    to catch up or get to a certain state.
  • Example In a nuclear power plant, the model
    would need to reflect waiting for rods to be in
    place before generating power.

22
(Very Simple) Power Plant
idle
start
cool
heat do/raise rods
op_temp/send(pumps_on)
timeout(1s)water cold
too_hot/insert rods
off/insert rods
off/ close valves pumps off
pumps do/start pumps
Get_readydo/open valves
pumps_on
23
Synchronization of Statesby status detection
B
A
A1
B1
event
IN(A2)
A2
B2
Transition between B1 and B2 will not fire until
object A has entered state A2.
24
Synchronization of Statesby a common event
A
B
StateA1
StateB1
event1
event1
StateB2
StateA2
Firing of the two transitions in the two models
will happen at the same time.
25
Synchronization of Statesby common data
A
B
StateA1 do x0
StateB1
event
When(x1)
StateA2 do x 1
StateB2
Transition from State B1 to State B2 will not
fire until in State A2. (This assumes shared
memory.)
26
Synchronization of Statesby Communication
A
B
StateA1
StateB1
event/send(sync)
sync
StateA2
StateB2
27
Exception Handling
  • Events such as resets and hardware interrupts
    must be handled.
  • These are called Exceptions.
  • Needed if user can exit a sequence of states at
    anytime.

28
Examples of exception handling
  • Possible to modeling exiting all the substates of
    a superstate in UML.
  • Ex. Pushing the N (neutral button) in any of the
    forward states of a transmission.
  • 3 ways to exit normal completion, direct
    transition, and exception.

normal exiting by completion using a final state.
Good modularity.
Superstate
event1
event
substate1
substate2
some_event
exception_event
normal exit but violates data hiding
29
Timing Issues in Dynamic Model
  • Sometimes the firing of a transition is time
    dependent, especially in embedded systems.
  • Real-time systems might have transitions that are
    tied to a real-time clock.
  • States might time-out after a certain length of
    time.
  • Transitions might need to be stalled for a
    certain length of time.

30
Timing (Safety critical)
  • Safety critical real-time solutions
  • example
  • transition out of boiler on state after being
    in this state for 1 hour, even if one expects a
    transition on when(temperaturegtexpected).

Boiler
when(temperature gt expected)
On
Off
timeout(1h)
31
Delays in Dynamic Model
  • Sometimes a transition should not be fired for a
    certain amount of time.
  • This timing constraint can be modeled using
    timeout and an extra state
  • ex.
  • 10 seconds since the exit from state A
  • This will delay the transition to State B for 10
    seconds.

timeout(10s)
event
State A
Hold
State B
32
More Timing Issues in D. M.
  • For a real-time system, the event might refer to
    a real-time clock
  • example
  • changing a traffic signal from day operation to
    night operation at 10 p.m.

Day superstate
Night superstate
2200_hours
0600_hours
Write a Comment
User Comments (0)
About PowerShow.com