• 沒有找到結果。

ECCaddress

在文檔中 Scotch Road (頁 80-111)

Embedded System Design - NTHU EOS Lab 80 Module-1 Embedded Computing

Model train setup

console

power supply

rcvr motor

ECC

Embedded System Design - NTHU EOS Lab 81 Module-1 Embedded Computing

Step-1: Requirements (1/2)

 Console can control 8 trains on 1 track

 Throttle has at least 63 levels

 Inertia control adjusts responsiveness with at least 8 levels (加速度)

 Emergency stop button

 Error detection scheme on messages

Embedded System Design - NTHU EOS Lab 82 Module-1 Embedded Computing

Step-1: Requirements Form (2/2)

name model train controller

purpose control speed of <= 8 model trains inputs throttle, inertia, emergency stop,

train #

outputs train control signals

functions set engine speed w. inertia;

emergency stop

performance can update train speed at least 10 times/sec

manufacturing cost $50

power wall powered

physical size/weight

console comfortable for 2 hands; < 2

lbs.

Embedded System Design - NTHU EOS Lab 83 Module-1 Embedded Computing

Step-2: Conceptual Specification

 Before we create a detailed specification, we will make an initial, simplified

specification

 Gives us practice in specification and UML.

 Good idea in general to identify potential

problems before investing too much effort in

detail

Embedded System Design - NTHU EOS Lab 84 Module-1 Embedded Computing

Basic System Commands

command name parameters

set-speed speed

(positive/negative) set-inertia inertia-value

(non-negative)

estop none

Embedded System Design - NTHU EOS Lab 85 Module-1 Embedded Computing

UML Sequence Diagram

:console :train_rcvr

set-inertia set-speed

set-speed

set-speed

estop

Embedded System Design - NTHU EOS Lab 86 Module-1 Embedded Computing

Class Diagram

command

set-inertia

value: unsigned-integer set-speed

value: integer

estop

Embedded System Design - NTHU EOS Lab 87 Module-1 Embedded Computing

Subsystem Collaboration Diagram

Shows relationship between console and receiver (ignores role of track):

 One console can control up to 8 receivers

:console :receiver

1..n: command

Embedded System Design - NTHU EOS Lab 88 Module-1 Embedded Computing

System Structure Modeling

 Some classes define non-computer components

 Denote by *name

 Choose important systems at this point to

show basic relationships

Embedded System Design - NTHU EOS Lab 89 Module-1 Embedded Computing

Major Subsystem Roles

 Console:

 read state of front panel

 format messages

 transmit messages

 Train:

 receive message

 interpret message

 control the train

Embedded System Design - NTHU EOS Lab 90 Module-1 Embedded Computing

Console System Class Diagram

console

panel formatter transmitter

Knobs* sender*

1 1

1 1 1

1

1 1 1

1

Embedded System Design - NTHU EOS Lab 91 Module-1 Embedded Computing

Console class roles

 panel: describes analog knobs and interface hardware

 formatter: turns knob settings into bit streams

 transmitter: sends data on track

Embedded System Design - NTHU EOS Lab 92 Module-1 Embedded Computing

Train System Class Diagram

train set

train receiver

controller

motor interface

detector* pulser*

1 1..t

1

1

1 1 1 1

1 1

1 1

Embedded System Design - NTHU EOS Lab 93 Module-1 Embedded Computing

Train class roles

 receiver: digitizes signal from track

 controller: interprets received commands and makes control decisions

 motor interface: generates signals

required by motor

Embedded System Design - NTHU EOS Lab 94 Module-1 Embedded Computing

Detailed Specification

 We can now fill in the details of the conceptual specification:

 more classes

 behaviors

 Sketching out the spec first helps us

understand the basic relationships in the

system

Embedded System Design - NTHU EOS Lab 95 Module-1 Embedded Computing

Console Physical Object Classes

knobs*

train-knob: integer speed-knob: integer

inertia-knob: unsigned-integer emergency-stop: boolean

pulser*

pulse-width: unsigned-integer direction: boolean

sender*

send-bit()

detector*

read-bit() : integer

Embedded System Design - NTHU EOS Lab 96 Module-1 Embedded Computing

Panel and Motor Interface Classes

panel

train-number() : integer speed() : integer

inertia() : integer estop() : boolean new-settings()

motor-interface

speed: integer

Embedded System Design - NTHU EOS Lab 97 Module-1 Embedded Computing

Class Descriptions

 panel class defines the controls

 new-settings() behavior reads the controls

 motor-interface class defines the motor

speed held as state

Embedded System Design - NTHU EOS Lab 98 Module-1 Embedded Computing

Transmitter and Receiver Classes

transmitter

send-speed(adrs: integer, speed: integer)

send-inertia(adrs: integer, val: integer)

set-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)

Embedded System Design - NTHU EOS Lab 99 Module-1 Embedded Computing

Class Descriptions

 transmitter class has one behavior for each type of message sent

 receiver function provides methods to:

 detect a new message

 determine its type

 read its parameters (estop has no parameters)

Embedded System Design - NTHU EOS Lab 100 Module-1 Embedded Computing

Formatter Class

formatter

current-train: integer

current-speed[ntrains]: integer current-inertia[ntrains]:

unsigned-integer

current-estop[ntrains]: boolean send-command()

panel-active() : boolean

update-panel()

Embedded System Design - NTHU EOS Lab 101 Module-1 Embedded Computing

Formatter Class Description

 Formatter class holds state for each train, setting for current train

 The operate() operation performs the

basic formatting task

Embedded System Design - NTHU EOS Lab 102 Module-1 Embedded Computing

Control Input Cases

 Use a soft panel to show current panel settings for each train

 Changing train number:

 must change soft panel settings to reflect current train’s speed, etc.

 Controlling throttle/inertia/estop:

 read panel, check for changes, perform

command

Embedded System Design - NTHU EOS Lab 103 Module-1 Embedded Computing

Control Input Sequence Diagram

:knobs :panel :formatter :transmitter

ch an g e in s p ee d / in er ti a/ es to p ch an g e in tr ai n n u m b er

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

set-knobs

new-settings

Embedded System Design - NTHU EOS Lab 104 Module-1 Embedded Computing

Formatter Operate Behavior

idle

update-panel()

send-command() panel-active() new train number

other

Embedded System Design - NTHU EOS Lab 105 Module-1 Embedded Computing

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

...

Embedded System Design - NTHU EOS Lab 106 Module-1 Embedded Computing

Controller Class

controller

current-speed: integer

current-inertia: unsigned-integer

set-speed(integer)

set-inertia(integer)

new-speed(integer)

Embedded System Design - NTHU EOS Lab 107 Module-1 Embedded Computing

Setting the Speed

 Don’t want to change speed instantaneously

 Controller should change speed gradually

by sending several commands

Embedded System Design - NTHU EOS Lab 108 Module-1 Embedded Computing

Set-Speed Sequence Diagram

:receiver :controller :motor-interface :pulser*

new-cmd cmd-type

rcv-speed new-speed set-pulse

set-pulse

set-pulse

set-pulse

set-pulse

Embedded System Design - NTHU EOS Lab 109 Module-1 Embedded Computing

Refined Command Classes

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

Embedded System Design - NTHU EOS Lab 110 Module-1 Embedded Computing

Summary

 Separate specification and programming

 Small mistakes are easier to fix in the spec

 Big mistakes in programming cost a lot of time

 You can’t completely separate specification and architecture

 Make a few tasteful assumptions

在文檔中 Scotch Road (頁 80-111)

相關文件