DOC PREVIEW
MSU CSE 470 - 10a-MoreDynamicModels
Course Cse 470-
Pages 6

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

110a-MoreDynamicModels1More Dynamic Modeling210a-MoreDynamicModelsReview of getting started:●Scenario making: gets us started thinking aboutevents.●Interface (high-level prototyping): helps us tothink about order of things. (happening in projects)●Event trace: helps to know what object is doingwhat action.●State Diagram creation tips.310a-MoreDynamicModelsDynamic Model - StateDiagram●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 oninstance variables, is valid.410a-MoreDynamicModelsStates Labeled with ConditionsSOPSE1start, errorSE2start, close,errorS0do/close:=tcloseS2start, closeS4close; heatS3start,close,heatstart_oven/start:=t; error:=topen_door/close:=fopen_door/close:=f close_doorstart_oven/start:=tclose_doorreset/close:=f; error:=fwarmup/heat:=tstart_cooking/start:=fdone/start:=f; heat:=fopen_door/close:=f; heat:=f(null)Microwave Oven510a-MoreDynamicModelsDynamic Models for E.S.●Dynamic Model for user buttons would be simplistic;modeling might not be needed.●Some environmental units might have behavior thatshould be modeled. (like an engine shifting through speeds)●For embedded systems - might only need one significantbehavior model (for controller.)●Complex models will be decomposed into more detailedbehavioral models.●Concurrency could be present within a model.onoffbuttonpushedbuttonpushed610a-MoreDynamicModelsHow dynamic model relates to objectmodel●One state diagram for each class (withimportant behavior.)●Each class has concurrent behavior.●Aggregation in the Object Model usuallyimplies concurrency in the Dynamic Model.2710a-MoreDynamicModelsExamples of Aggregation(5.17)●Object modelCarIgnitionTransmissionBrakeAcceleratorEach class here will need a concurrent state diagramHow to model concurrency within an objectrelease keyturn key to startIgnitionturn key off[Transmissionin Neutral]depress acceleratorrelease acceleratorAcceleratorTransmissionpush Rpush Npush Fpush NupshiftdownshiftupshiftdownshiftstopForwarddepress brakerelease brakeBrakeCaroffstartingonNeutralReversefirstsecond thirdonoffonoff910a-MoreDynamicModelsHow to hide complexity●Not have a ‘flat’ state diagram●Start abstract and then do subdiagrams.■use bull’s eye●Take one abstract state and expand it with stategeneralization.1010a-MoreDynamicModelsExample of nesting(and other syntax as well)coin in(value)cancel / refund coinsselect(item)[change<0][item empty][change=0][change>0]Example: lower-level state diagram for Dispense item activityDo/move armto correct rowDo/move are tocorrect columnDo/push itemoff shelfidleDo/add to balance(value)coin in(value)Do/test item present; make changeDo/dispensechangestop1110a-MoreDynamicModelsState GeneralizationForwardNeutral ReversePush NPush FPush NPush RNeutralReverseFirst Second ThirdUpshift Upshiftdownshift downshiftForwardPush FPush NPush NPush R1210a-MoreDynamicModelsNotation on Transitions and inStates●Do/ activity■takes some time.■associated with a state.●Guards■conditions - boolean■ [ guard ]●Actions :■instantaneous■associated with an event.■/actionState1do/ activity 1event1 (attribs) [condition1]/ action1You might need any orall of these for your project!State2do/ activity 231310a-MoreDynamicModelsChecking for completenessand consistency●Formal specifications do this better!■The mathematical format can allow automation of thesetypes of checks.●Every state should have a way in and out.■unless starting point or ending point.●Look for one object’s Dynamic Model sending anevent that doesn’t have any receiving transition inanother object’s DM.1410a-MoreDynamicModelsThings to watch out for●Think about input from concurrent objects atunexpected times.■ex. If more than one ATM machine is trying to accessthe same account at the same time.■User input when not planned. (OK to ignore, but makesure that is what is really wanted.)●Take your scenarios and see if they work!■Walk through seeing that all the object’soperations/messages has all the needed transitions.1510a-MoreDynamicModelsProducer-Consumer - Normal Scenarioconsumer producergetackdataack1610a-MoreDynamicModelsProducer-ConsumerState machine 1startack0waitstashdo/save bufstartfetchwaitsend(producer.get)ackdata(buf)get/send(consumer.ack)timeout/send(consumer.nak)timeoutackdata_ready/consumer.data(buf)consumerproducer1710a-MoreDynamicModelsBasic Class Diagramconsumer producerget, ackdata, ack, nak1810a-MoreDynamicModelsProducer-ConsumerState machine 2startack0waitstashdo/save bufstartfetchwaitsend(producer.get)ackdata(buf)get/send(consumer.ack)timeout/send(consumer.nak)timeoutackdata_ready/consumer.data(buf)consumerproducer/acknaknak410a-MoreDynamicModels19Dynamic Model Timing andExceptional Handlingstop2010a-MoreDynamicModelsTopics Covered:●Dynamic Model■Synchronization schemes■Exception Handling■Timing including safety critical issues.2110a-MoreDynamicModelsSynchronization●In concurrent processing, the actions of theobjects are rarely independent of each other.●One may need to stop and wait for anotherprocess to ‘catch up’ or get to a certain state.●Example: In a nuclear power plant, the modelwould need to reflect waiting for rods to be inplace before generating power.2210a-MoreDynamicModels(Very Simple) Power Plantidlecool heatdo/raise rodsGet_readydo/open valvespumpsdo/start pumpstimeout(1s)[water cold]op_temp/send(pumps_on)too_hot/insert rodspumps_onoff/insert rodsoff/close valves; pumps offstart2310a-MoreDynamicModelsSynchronization of Statesby status detectionA1A2 B2B1eventIN(A2)ABTransition between B1 and B2 will not fire until object A has entered state A2.2410a-MoreDynamicModelsSynchronization of Statesby a common eventStateA1StateA2StateB2StateB1Firing of the two transitions in the two models will happen at the same time.event1 event1A B52510a-MoreDynamicModelsSynchronization of Statesby common dataStateA1do: x:=0StateA2do: x:= 1StateB2StateB1ABeventWhen(x==1)Transition from State B1 to State B2 will not fire untilin State A2. (This assumes shared memory.)2610a-MoreDynamicModelsSynchronization of Statesby CommunicationStateA1StateA2StateB2StateB1ABevent/send(sync)sync2710a-MoreDynamicModelsException Handling●Events such as resets and


View Full Document

MSU CSE 470 - 10a-MoreDynamicModels

Download 10a-MoreDynamicModels
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view 10a-MoreDynamicModels and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view 10a-MoreDynamicModels 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?