Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2000 Morgan Kaufman Overheads for Computers as Components Introduction zExample: model train controller.

Similar presentations


Presentation on theme: "© 2000 Morgan Kaufman Overheads for Computers as Components Introduction zExample: model train controller."— Presentation transcript:

1

2 © 2000 Morgan Kaufman Overheads for Computers as Components Introduction zExample: model train controller.

3 © 2000 Morgan Kaufman Overheads for Computers as Components Purposes of example zFollow a design through several levels of abstraction. zGain experience with UML.

4 © 2000 Morgan Kaufman Overheads for Computers as Components Model train setup Console: Throttle, Inertia, Estop, … power supply rcvrmotor ECC address: train # headercommand: speed, … Speed/acc control

5 © 2000 Morgan Kaufman Overheads for Computers as Components Requirements zConsole can control 8 trains on 1 track. zThrottle has at least 63 levels.  speed control levels zInertia control adjusts responsiveness with at least 8 levels.  acceleration zEmergency stop button. zError detection scheme on messages.

6 © 2000 Morgan Kaufman Overheads for Computers as Components Requirements form

7 © 2000 Morgan Kaufman Overheads for Computers as Components Conceptual specification zBefore we create a detailed specification, we will make an initial, simplified specification. yGives us practice in specification and UML. yGood idea in general to identify potential problems before investing too much effort in detail.

8 © 2000 Morgan Kaufman Overheads for Computers as Components Typical control sequence :console:train_rcvr set-inertia set-speed estop Time Data packets sent at any time

9 © 2000 Morgan Kaufman Overheads for Computers as Components Basic system commands

10 © 2000 Morgan Kaufman Overheads for Computers as Components Message classes set-inertia value: unsigned- integer set-speed value: integer estop Have common features: type, address to send data, # of bits, parity

11 © 2000 Morgan Kaufman Overheads for Computers as Components Command class command type: 3-bits address: 3-bits parity: 1-bit set-inertia type=001 value: 3-bits set-speed type=010 value: 7-bits estop type=000

12 © 2000 Morgan Kaufman Overheads for Computers as Components Major subsystem roles zConsole: yread state of front panel; yformat messages; ytransmit messages. zReceiver: yreceive message; yinterpret message; ycontrol the train.

13 © 2000 Morgan Kaufman Overheads for Computers as Components System structure modeling zSome classes define non-computer components. yDenoted by *name. zChoose important systems at this point to show basic relationships.

14 © 2000 Morgan Kaufman Overheads for Computers as Components Console system classes panelformattertransmitter knobs*sender* 1 1 1 1 11 1 1 Console 1

15 © 2000 Morgan Kaufman Overheads for Computers as Components Console class roles zpanel: describes analog knobs and interface hardware. zformatter: turns knob settings into bit streams. ztransmitter: sends data on track.

16 © 2000 Morgan Kaufman Overheads for Computers as Components Train system classes train set train receiver controller motor interface detector*pulser* 1 1..t 1 1 1 1 1 1 1 1 1 1

17 © 2000 Morgan Kaufman Overheads for Computers as Components Train class roles zreceiver: digitizes signal from track. zcontroller: interprets received commands and makes control decisions. zmotor interface: generates signals required by motor, e.g., to control SPEED, ACCELERATION

18 © 2000 Morgan Kaufman Overheads for Computers as Components Train speed control zMotor controlled by pulse width modulation: zSketching out the spec first helps us understand the basic relationships in the system. V + - duty cycle Fast/slow

19 © 2000 Morgan Kaufman Overheads for Computers as Components Detailed specification zWe can now fill in the details of the conceptual specification: ymore classes; ybehaviors.

20 © 2000 Morgan Kaufman Overheads for Computers as Components Console/train physical object classes knobs* train-knob: integer speed-knob inertia-knob emergency-stop: boolean pulser* pulse-width: unsigned- integer direction: boolean sender* send-bit( ) detector* read-bit( ) : integer

21 © 2000 Morgan Kaufman Overheads for Computers as Components Panel and motor interface classes panel train-number( ) : integer speed( ) : integer inertia( ) : integer estop( ) : boolean new-settings( ) motor-interface speed: integer int speed( ){ int spd; spd= inp(KNOBS_SPEED_PORT); return spd; } send_speed( )

22 © 2000 Morgan Kaufman Overheads for Computers as Components Transmitter and receiver classes transmitter send-speed(adrs: integer, speed: integer) send-inertia(adrs: integer, val: integer) send-estop(adrs: integer) receiver current: command new: boolean read-cmd() new-cmd() : boolean rcv-type(msg-type: command) rcv-speed(val: integer) rcv-inertia(val:integer) Read, detect, get parameter

23 © 2000 Morgan Kaufman Overheads for Computers as Components Class descriptions ztransmitter class has one behavior for each type of message sent. zreceiver function provides methods to: ydetect a new message; ydetermine its type; yread its parameters (estop has no parameters).

24 © 2000 Morgan Kaufman Overheads for Computers as Components Formatter class formatter current-train: integer current-speed[ntrains]: integer current-inertia[ntrains]: unsigned-integer current-estop[ntrains]: boolean send-command( ) panel-active( ) : boolean operate( ) Interfaces with transmitter Basic actions for the object: read, interpret, send msgs

25 © 2000 Morgan Kaufman Overheads for Computers as Components Formatter class description zFormatter class holds state for each train, setting for current train. zThe operate() operation repeatedly performs the basic formatting task.

26 © 2000 Morgan Kaufman Overheads for Computers as Components Control input sequence diagram :knobs:panel:formatter:transmitter change in speed/ inertia/estop change in train number change in control settings read panel panel settings panel-active send-command send-speed/ send-inertia/ send-estop read panel panel settings read panel panel settings change in train number operate( ) panel-active send-command

27 © 2000 Morgan Kaufman Overheads for Computers as Components Formatter operate behavior Idle (cyclic) send-command() panel-active() Yes No

28 © 2000 Morgan Kaufman Overheads for Computers as Components Panel-active behavior panel*:read-train() current-train = train-knob update-screen changed = true T panel*:read-speed() current-speed = throttle changed = true T F... F

29 © 2000 Morgan Kaufman Overheads for Computers as Components Controller class controller current-train: integer current-speed[ntrains]: integer current-direction[ntrains]: boolean current-inertia[ntrains]: unsigned-integer operate() issue-command() Called by receiver when it gets a new command: Interprets messages, issues a command

30 © 2000 Morgan Kaufman Overheads for Computers as Components Setting the speed zDon’t want to change speed instantaneously. zController should change speed gradually by sending several commands.

31 © 2000 Morgan Kaufman Overheads for Computers as Components Sequence diagram for set- speed command :receiver:controller:motor-interface:pulser* new-cmd cmd-type rcv-speed set-speedset-pulse operate() read_cmd()

32 © 2000 Morgan Kaufman Overheads for Computers as Components Controller operate behavior issue-command() receive-command() wait for a command from receiver

33 © 2000 Morgan Kaufman Overheads for Computers as Components Summary zSeparate specification and programming. ySmall mistakes are easier to fix in the spec. yBig mistakes in programming cost a lot of time. zYou can’t completely separate specification and architecture. yMake a few tasteful assumptions.

34 © 2000 Morgan Kaufman Overheads for Computers as Components Assignment #1 zChapter 1: Q1-3, Q1-4, Q1-5, Q1-9, Q1- 15


Download ppt "© 2000 Morgan Kaufman Overheads for Computers as Components Introduction zExample: model train controller."

Similar presentations


Ads by Google