Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

28
Groep2 Max Aalderink Paul Gielen Wesley Hilhorst 30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor

Transcript of Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Page 1: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Groep2Max AalderinkPaul GielenWesley Hilhorst 30-06-2010Lars Stolwijk

2TPRJ8 Hartmonitor

Page 2: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Inleiding

De opdracht Middelen Tijdpad Resultaat

Page 3: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Inleiding – De opdracht

Hartmonitor Firma DSS (Driver Simulator Systems) & HTC Fysische gegevens voor training Loggen van gegevens ARM7-processor

Page 4: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Inleiding – Middelen

PSPad editor Ontwikkelomgeving voor de ARM7 Aangeleverd begin Requirements Architecture pRTOS Mkt.py als interface voor de hardware

Page 5: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Inleiding – Tijdpad

1e stadium Modelleren 2e stadium Modelleren + kennis maken ARM7 3e stadium Fine tuning modellen + programmeren 4e stadium Voltooien programmeren + eventuele

bijwerkingen modellen

Page 6: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Inleiding – Resultaat

Werkend product voldoet aan eisen Niet beste groepje Deadline verplaatst Veel tijd nodig voor modellen

Page 7: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Requirements Architecture

Use case 3 belangrijkste SeqD Constraints

Page 8: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

RA – Use case diagram

User

MonitorTraining Time

Monitor HeartRate

Select MonitorMode

«include»

«extend»

Page 9: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

RA – SeqD Monitor Heart Rate

IRS:InfraredSensor

LCD:LCDDisplay

HeartMonitorController:MonitorControlSystem

speaker:Speaker

led:LED

modeButton:Button

User

Start Monitor Training TimeMonitor Training Time

enable the LCDDisplay enableloop

if { reportBeat }

heartBeatreport heart beat

reportBeat

set timer MT for 100 ms setTimer( 100, MT )led on ontimer MT fires timeUpled off offdisplay current heart rate displayText( heartRate )if hr < TZ-low

beep for 100ms @ 250Hz

speakerOn( 100, 250 )

else

if hr > TZ-high

beep for 50ms @ 500Hz

speakerOn( 50, 500 )

end if

end if

end loop

if { reportBeat }

heartBeatreport heart beat

reportBeat

set timer MT for 100 ms setTimer( 100, MT )led on ontimer MT fires timeUpled off offdisplay current heart rate displayText( heartRate )if hr < TZ-low

beep for 100ms @ 250Hz

speakerOn( 100, 250 )

else

if hr > TZ-high

beep for 50ms @ 500Hz

speakerOn( 50, 500 )

end if

end if

heartBeatreport heart beat

reportBeat

set timer MT for 100 ms setTimer( 100, MT )led on ontimer MT fires timeUpled off offdisplay current heart rate displayText( heartRate )if hr < TZ-low

beep for 100ms @ 250Hz

speakerOn( 100, 250 )

else

beep for 100ms @ 250Hz

speakerOn( 100, 250 )

if hr > TZ-high

beep for 50ms @ 500Hz

speakerOn( 50, 500 )

end if

beep for 50ms @ 500Hz

speakerOn( 50, 500 )

calucate heart rate

Page 10: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

RA – SeqD Monitor Training Time

LCD:LCDDisplay

HeartMonitorController:MonitorControlSystem

modeButton:Button

loop

Display training timedisplayText( trainingTime )

set timer ttTimer 100mssetTimer( 100, ttTimer )

trainingTime += 100ms

Time uptimeUp

end loop { modeButton pushed }

Display training timedisplayText( trainingTime )

set timer ttTimer 100mssetTimer( 100, ttTimer )

trainingTime += 100ms

Time uptimeUp

pushreport modeButton down buttonDown

Page 11: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

RA – SeqD Select Monitor ModeLCD

:LCDDisplaymodeButton

:ButtonHeartMonitorController:MonitorControlSystem

setButton:Button

User

push

buttonDown

enable

setTimer( 2000, ttBTN )

releasereport modeButton up buttonUp

cancel timer BTN cancelTimer( ttBTN )set display mode to HR

monitor heart rate Monitor Heart Rate

loop

setButton pushed pushreport setButton down buttonDown

switch display mode

display datadisplayText

end loop { modeButton pushed }...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

timeUp( ttBTN )

disable

enable

setTimer( 2000, ttBTN )

releasereport modeButton up buttonUp

cancel timer BTN cancelTimer( ttBTN )set display mode to HR

monitor heart rate Monitor Heart Rate

loop

setButton pushed pushreport setButton down buttonDown

switch display mode

display datadisplayText

end loop { modeButton pushed }...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

timeUp( ttBTN )

releasereport modeButton up buttonUp

cancel timer BTN cancelTimer( ttBTN )set display mode to HR

monitor heart rate Monitor Heart Rate

loop

setButton pushed pushreport setButton down buttonDown

switch display mode

display datadisplayText

end loop { modeButton pushed }...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

cancel timer BTN cancelTimer( ttBTN )set display mode to HR

monitor heart rate Monitor Heart Rate

loop

setButton pushed pushreport setButton down buttonDown

switch display mode

display datadisplayText

end loop { modeButton pushed }...

setButton pushed pushreport setButton down buttonDown

switch display mode

display datadisplayText

switch display mode

display datadisplayText

push

buttonDown

push

buttonDown

displayText

push

buttonDown

displayTextdisplayText

push

buttonDown

timeUp( ttBTN )timeUp( ttBTN )

disable

Stop monitor

LCD:LCDDisplay

modeButton:Button

HeartMonitorController:MonitorControlSystem

setButton:Button

User

push

buttonDown

enable

setTimer( 2000, ttBTN )

release

buttonUp

cancelTimer( ttBTN )

Monitor Heart Rate

push

buttonDown

displayText...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

timeUp( ttBTN )

disable

enable

setTimer( 2000, ttBTN )

release

buttonUp

cancelTimer( ttBTN )

Monitor Heart Rate

push

buttonDown

displayText...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

timeUp( ttBTN )

release

buttonUp

cancelTimer( ttBTN )

Monitor Heart Rate

push

buttonDown

displayText...

push

buttonDown

push

buttonDown

displayText

push

buttonDown

cancelTimer( ttBTN )

Monitor Heart Rate

push

buttonDown

displayText...

push

buttonDown

displayTextdisplayText

push

buttonDown

push

buttonDown

displayText

push

buttonDown

displayTextdisplayText

push

buttonDown

timeUp( ttBTN )timeUp( ttBTN )

disable

Page 12: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

RA - Constraints

Constrainttype Identificatie Beschrijving Meetwaarde Verificatie Waarden

Nauwkeurigheid

Hartfrequentie Aantal kloppingen die opgevangen moeten worden.

Gehaalde kloppingen per minuut in %

Analyse van eigen ontwerp en software

Doel – 98%Best – 100%Slecht – minder dan 98%

Trainingstijd De gemeten afwijking tussen begin en eindperiode.

Seconden Met een geijkte stopwatch

Doel – 10Best – 0Slecht – minder dan 10

Signaalsterkte De sterkte van de geluidssignalen die worden gegeven

Afstand in meters

Luisteren of het geluidssignaal hoorbaar is

Doel – 5Best – 10Slecht – minder dan 3

Page 13: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Software Architecture

Class Diagram Concurrency Diagram STD’s Task Interaction SeqD’s

Page 14: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – Class Diagram

RTOS

cTimer{Abstract}

cEventFlagGroup

cChanneltype T, short SIZEtype T, short SIZE

cTask{Abstract}

cTimer{Abstract}

cEventFlagGroup

cChanneltype T, short SIZEtype T, short SIZE

cTask{Abstract}

«Interface»TimerListener

timeOut (in src : Timer) : void

«control»HeartRateController

State : int

max : int

cur : int

hbCounter : int

previousTime : int

ledt : int

retreivedTZTime : int

avg : float

runUpdate : bool

top : char

run () : void

reportHeartBeat () : void

calculateTime () : void

timeOut (in timer : Timer) : void

changeDisplayMode (in mode : int) : void

stopMonitoring () : void

abort () : void

deleteData () : void

init () : void

update () : void

timeout () : void

setShowState () : void

setRunState () : void

calcAVG () : float

calculateHeartRate () : int

hrToStr () : String

«control»DisplayModeController

state : int

counter : int

running : bool

getCurrentDisplayMode () : int

run () : void

buttonDown (in b : Button) : void

timeout (in t : Timer) : void

buttonUp (in b : Button) : void

update ()

setHRC ()

«Interface»SensorListener

reportHeartBeat (in src : InfraredSensor) : void«control»

TrainingTimeController

time : int

tzTime : int

tzBoundLow : int

tzBoundHigh : int

cont : bool

intTz : bool

tzTimer : Timer

run () : void

getCurrentTime () : long

abort () : void

resetCurrentTime () : void

updateCurrentTime (in time : int) : void

timeout (in t : Timer) : void

init () : void

update () : void

getInBounds () : int

resetTZTime () : void

getTZTime () : int

updateTZTime () : void

«boundary»Button

key : int

downSeen : int

upSeen : int

last : int

setListener (in cl : ButtonListener) : void

updateState () : void

removeListener () : void

«boundary»LCDDisplay

enable () : void

setText (in row : int, in data : String) : void

disable () : void

gotoRowCol () : void

displayChar () : void

clear () : void

«boundary»InfraredSensor

state : bool

setListener (in cl : SensorListener) : void

updateState () : void

removeListener () : void

«boundary»Speaker

low () : void

high () : void

«boundary»LED

on () : void

off () : void

«auxiliary»Timer

setTimer (in ms : int, in cl : TimerListener) : void

cancel () : void

«Interface»ButtonListener

buttonDown (in b : Button) : void

buttonUp (in b : Button) : void

«control»ButtonEvent

init () : void

update () : void

«control»SpeakerSwitch

Status : int

nrTicks : int

maxTicks : int

timeTicks : int

switchOn (in freq : int, in ms : int) : void

switchOff () : void

init () : void

update () : void

«control»IREventDetection

init () : void

update () : void

«control»DisplayController

enable () : void

disable () : void

displayTime (in time : int) : void

displayData (in data : String) : void

init () : void

update () : void

timeToStr () : String

11

1

1

theLEDTimer

1

1

11

theHeartRateController

1

1

theIRSensor

11

theLCDDisplay

1

1

theSpeaker11theLED

1

1

theModeButton1

1

theSetButton

*1

1

1

theButtonTimer

1

1

theSpeakerTimer

1

1

theLCDDisplay*

1 HRTFlags

*

1

1

1

theSpeaker

1

1

theLCDDisplay

1

1

theIRSensor

11

theSetButton

theModeButton 1

1

theModeButton theSetButton

*1 MSTFlags

«implement»

«implement»

«implement»

«implement»

«implement»

Page 15: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – Concurrency Diagram

MSTFlags HRTFlags

ButtonEvent-Task

SpeakerSwit-chTask

TrainingTim-eTask

IREventTask

ModeSelecti-onTask

HeartRateT-ask

DTChannel

:pRTOS

wait()wait()

read()read()

write()write()write()write()

set()set()

set( timerFno )set( timerFno )

wait()wait()

set( betFNo )set( betFNo )

set( timerFno )set( timerFno )

Alle tak en zullen om de beurt geactiveerd worden door het RTOS

Page 16: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – STD ButtonEvent

Waiting for interupt

E ntry/b lock

Unblocked

/[nr == 0]theSetButton->updateState()

u p d a te /

/t im erInterupt/unb lock ();

/ in it / [n r = 0 ]

/[nr++ == 2]/nr = 0;b lock ();

/[nr == 1]theModeButton->updateState()...

Page 17: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – STD DisplayController

Running

State1

Write Channel

displayData/cc->write(di);

State2

enabled

/theLCDDisplay->enable();theLCDDisplay->clear();resume();

Writing On Channel

/cc -> read();

Context Switch

Getting DisplayItem

/di = cc->getItem();

Flushing

/theLCDDisplay->displayChar(di.text[index++]);

State1

Write Channel

displayData/cc->write(di);

Write Channel

displayData/cc->write(di);

State2

enabled

/theLCDDisplay->enable();theLCDDisplay->clear();resume();

Writing On Channel

/cc -> read();

Context Switch

Getting DisplayItem

/di = cc->getItem();

Flushing

/theLCDDisplay->displayChar(di.text[index++]);

enabled

/theLCDDisplay->enable();theLCDDisplay->clear();resume();

Writing On Channel

/cc -> read();

Context Switch

Getting DisplayItem

/di = cc->getItem();

Flushing

/theLCDDisplay->displayChar(di.text[index++]);

Suspend

Entry/suspend();in i t /

enable/theLCDDisplay->enable();theLCDDisplay->clear();resume(); ...

disab le/theLCDDisplay-> disab le();

/

e n a b le / u p d a te /

/unb loc k

u p d a te //index = 0;theLCDDisplay->gotoRowCol(di.row,0);

u p d a te /[ index > = di. len]/

Page 18: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – STD IREventDetection

Waiting for interupt

Flushing

Monitoring

Waiting for interupt

Flushing

/ unblock ();/ update[ theIRSensor-> updateState()];

// init

/block ();

Page 19: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – STD SpeakerSwitch

Off

/theSpeak er->low();suspend();

On

Blocking High

/nrTick s = 0;theSpeak er->high();tick eTick s -= 1;b lock ();

Unblocking High

Unblocking Low

Blocking Low

/nrTick s = 0;theSpeak er->low();timeTick s -= 1;b lock ();

Beeping

Blocking High

/nrTick s = 0;theSpeak er->high();tick eTick s -= 1;b lock ();

Unblocking High

Unblocking Low

Blocking Low

/nrTick s = 0;theSpeak er->low();timeTick s -= 1;b lock ();

in i t /

switchOn[[ms > 0]]/maxTick s = CLK_FREQ / (2*hz);timeTick s = CLK_FREQ * ms / 1000;

u p d a te /

t im erInterrupt/unb loc k ();

update/nrT ic k s + = 1

[e ls e ] / [nrT ic k s = = m axT ic k s ]/

t im erInterrupt/unb loc k ();

update/nrT ic k s + = 1

[e ls e ] /[nrT ic k s = = m axT ic k s ]/

[ t im eT ic k s = = 0] /

Page 20: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – STD TrainingTimeController

Waiting to get unblocked

Updating

Running

Waiting to get unblocked

Updating

Waiting

in it /s us pend();

ab ort /s us pend();

run/resetTime();resume();

/

/u n b lo c kupdate/updateTime(100);b lock ();

Page 21: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD DisplayTask

DTChannel:cChannel

theDisplayCtrl:DisplayController

theLCDDisplay:LCDDisplay

theTrainingTimeCtrl:TrainingTimeController

theHeartRateCtrl:HeartRateController

theDisplayModeCtrl:DisplayModeController

init

disable

suspend

enable

resumeenable

clear

update

read

block

disable

disable

else alt

if { display the time }

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

end if

task updated by RTOSupdate

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

end alt

end loop {disabled}

end loop

suspend

enable

resumeenable

clear

resumeenable

clear

update

read

block

disable

disable

else alt

if { display the time }

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

end if

task updated by RTOSupdate

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

end alt

end loop {disabled}

read

block

disable

disable

else alt

if { display the time }

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

end if

task updated by RTOSupdate

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

end alt

disable

disabledisable

else alt

if { display the time }

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

end if

task updated by RTOSupdate

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

if { display the time }

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

end if

set given time to displaydisplayTime( time )

di = DisplayItem(timeString)

write the channel

write( di )

{3ms}unblock task unblock

else if { display the data }

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

di = DisplayItem(dataString)

set given data to displaydisplayData( data )

write the channel

write( di )

{3ms}unblock task unblock

task updated by RTOSupdate

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

get item from channeldata = getItem

display given data or time on LCD displaysetText( row, data )

DTChannel:cChannel

theDisplayCtrl:DisplayController

theLCDDisplay:LCDDisplay

theTrainingTimeCtrl:TrainingTimeController

theHeartRateCtrl:HeartRateController

theDisplayModeCtrl:DisplayModeController

init

disable

suspend

enable

resumeenableclear

updateread

block

disable

disable

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

update data = getItem

setText( row, data )

suspend

enable

resumeenableclear

resumeenableclear

updateread

block

disable

disable

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

update data = getItem

setText( row, data )

read

block

disable

disable

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

update data = getItem

setText( row, data )

disable

disabledisable

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

update data = getItem

setText( row, data )

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

displayTime( time )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

displayData( data )write( di )

{3ms}

unblock

update data = getItem

setText( row, data )

data = getItem

setText( row, data )

Page 22: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD HeartRateTask

theHeartRateCtrl:HeartRateController

theTrainingTimeCtrl:TrainingTimeController

theDisplayModeCtrl:DisplayModeController

HRTflags:cEventFlagGroup

theMSTTimer:Timer

theLED:LED

theDisplayCtrl:DisplayController

theSpeakerSwitchCtrl:SpeakerSwitch

start and initialize task initstate = RUNNING

run theHeartRateCtrl runrun theTrainingTimeCtrl runloop

wait on a flag to be set waitblock blocka flag was set by some task set( flagNo )... which unblock s the task unblocktask updated by RTOS update

get the flag setflagFno = getFlagNo

if{ flagNo == beatFNo && state = RUNNING};

setTimer( 50 )set led on oncalculate cur, avg, max, hr, in-Tz calculateTime

get display mode getCurrentDisplayModeif{ mode == data }

write data to display displayData( data )else alt

write time to display displayTime( time )end alt

if{beat is lower then trainingszone}

beep 250hz for 100ms switchOn( 250, 100 )else if{beat is higher then trainingszone}

beep 500hz for 50ms switchOn( 500, 50 )

getCurrentTimewait

getCurrentTimecalculateTime

wait

set( 50 )off

displayData( data )wait

wait on a flag to be set waitblock blocka flag was set by some task set( flagNo )... which unblock s the task unblocktask updated by RTOS update

get the flag setflagFno = getFlagNo

if{ flagNo == beatFNo && state = RUNNING};

setTimer( 50 )set led on oncalculate cur, avg, max, hr, in-Tz calculateTime

get display mode getCurrentDisplayModeif{ mode == data }

write data to display displayData( data )else alt

write time to display displayTime( time )end alt

if{beat is lower then trainingszone}

beep 250hz for 100ms switchOn( 250, 100 )else if{beat is higher then trainingszone}

beep 500hz for 50ms switchOn( 500, 50 )

getCurrentTimewait

getCurrentTimecalculateTime

wait

set( 50 )off

displayData( data )wait

get the flag setflagFno = getFlagNo

if{ flagNo == beatFNo && state = RUNNING};

setTimer( 50 )set led on oncalculate cur, avg, max, hr, in-Tz calculateTime

get display mode getCurrentDisplayModeif{ mode == data }

write data to display displayData( data )else alt

write time to display displayTime( time )end alt

if{beat is lower then trainingszone}

beep 250hz for 100ms switchOn( 250, 100 )else if{beat is higher then trainingszone}

beep 500hz for 50ms switchOn( 500, 50 )

getCurrentTimewait

setTimer( 50 )set led on oncalculate cur, avg, max, hr, in-Tz calculateTime

get display mode getCurrentDisplayModeif{ mode == data }

write data to display displayData( data )else alt

write time to display displayTime( time )end alt

write data to display displayData( data )else alt

write time to display displayTime( time )write time to display displayTime( time )

if{beat is lower then trainingszone}

beep 250hz for 100ms switchOn( 250, 100 )else if{beat is higher then trainingszone}

beep 500hz for 50ms switchOn( 500, 50 )

beep 250hz for 100ms switchOn( 250, 100 )else if{beat is higher then trainingszone}

beep 500hz for 50ms switchOn( 500, 50 )beep 500hz for 50ms switchOn( 500, 50 )

getCurrentTimewait

getCurrentTimecalculateTime

wait

getCurrentTimecalculateTime

wait

set( 50 )off

displayData( data )wait

set( 50 )off

displayData( data )wait

stopMonitoring

abort

Page 23: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD ModeSelectionTasktheDisplayModeCtrl

:DisplayModeControllertheHeartRateCtrl

:HeartRateControllerMSTflags

:cEventFlagGrouptheSetButton

:ButtontheModeButton

:ButtontheButtonTimer

:TimertheDisplayCtrl

:DisplayController

init

setListener( this )

setListener( this )

setHRC( this )

setListener( this )

setListener( this )

setHRC( this )

wait

block

set( flagNo )

unblock

update

flagNo = getFlagNo

set( flagNo )

unblock

update

block

enable

run

deleteData

stopMonitoring

...

disable

abort

setRunState

setShowState

run

wait

wait

block

set( flagNo )

unblock

update

flagNo = getFlagNo

set( flagNo )

unblock

update

block

unblock

update

block

update

blockblock

enable

run

deleteData

stopMonitoring

...

disable

abort

setRunState

setShowState

run

enable

run

deleteData

stopMonitoring

...

disable

abort

enable

run

deleteData

enable

run

deleteData

stopMonitoringstopMonitoring

...

disable

abort

disable

abort

setRunState

setShowState

setRunStatesetRunState

setShowStatesetShowState

runrunrun

wait

theDisplayModeCtrl:DisplayModeController

theHeartRateCtrl:HeartRateController

MSTflags:cEventFlagGroup

theSetButton:Button

theModeButton:Button

theButtonTimer:Timer

theDisplayCtrl:DisplayController

init

setListener( this )

setListener( this )

setHRC( this )

setListener( this )

setListener( this )

setHRC( this )

wait

block

set( flagNo )

unblock

update

flagNo = getFlagNo

set( flagNo )

unblock

update

blockif { status == INIT }

status = STB

if {flagNo == modeButtonDown}

if { status == STB }

enable displayController enablestart heartrate monitor rundelete the data

deleteDatarunning = true

status = RUNNING

end alt

if { status == RUNNING }

stop monitoringstopMonitoring

status = SHOWING

end alt

if { status == SHOWING }...

disable DisplayController disableabort heartrateController abort

end alt

end if

if {flagNo == setButtonDown}

if { status == RUNNING }

set run state setRunStateend alt

if { status == SHOWING }

setShowState

run

wait

wait

block

set( flagNo )

unblock

update

flagNo = getFlagNo

set( flagNo )

unblock

update

block

unblock

update

block

update

blockblockif { status == INIT }

status = STB

if {flagNo == modeButtonDown}

if { status == STB }

enable displayController enablestart heartrate monitor rundelete the data

deleteDatarunning = true

status = RUNNING

end alt

if { status == RUNNING }

stop monitoringstopMonitoring

status = SHOWING

end alt

if { status == SHOWING }...

disable DisplayController disableabort heartrateController abort

end alt

end if

if {flagNo == setButtonDown}

if { status == RUNNING }

set run state setRunStateend alt

if { status == SHOWING }

setShowState

run

status = STB

if {flagNo == modeButtonDown}

if { status == STB }

enable displayController enablestart heartrate monitor rundelete the data

deleteDatarunning = true

status = RUNNING

end alt

if { status == RUNNING }

stop monitoringstopMonitoring

status = SHOWING

end alt

if { status == SHOWING }...

disable DisplayController disableabort heartrateController abort

end alt

end if

if { status == STB }

enable displayController enablestart heartrate monitor rundelete the data

deleteDatarunning = true

status = RUNNING

end alt

enable displayController enablestart heartrate monitor rundelete the data

deleteDatarunning = true

status = RUNNING

if { status == RUNNING }

stop monitoringstopMonitoring

status = SHOWING

end alt

stop monitoringstopMonitoring

status = SHOWING

if { status == SHOWING }...

disable DisplayController disableabort heartrateController abort

end alt

disable DisplayController disableabort heartrateController abort

if {flagNo == setButtonDown}

if { status == RUNNING }

set run state setRunStateend alt

if { status == SHOWING }

setShowState

if { status == RUNNING }

set run state setRunStateend alt

set run state setRunState

if { status == SHOWING }

setShowStatesetShowState

runrunrun

wait

Gaat naar volgende display modus

Page 24: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD TrainingTimeTask

theTrainingTimeCtrl:TrainingTimeController

theDisplayCtrl:DisplayController

theHeartRateCtrl:HeartRateController

start and initialize the taskinit

set static tzRange

task suspends itself...suspend

run the task run... resumes the task... resume

time == 0; resetCurrentTime

send time to DisplaydisplayTime( time )

... resumes the task... resume

time == 0; resetCurrentTime

send time to DisplaydisplayTime( time )

loop

interupt from timer timerInterruptunblock the task unblocktask updated by RTOS

updatetime += 100 updateCurrentTime( time )

send time to Display displayTime( time )task block s itself...

blockend loop(abort)

interupt from timer timerInterruptunblock the task unblocktask updated by RTOS

updatetime += 100 updateCurrentTime( time )

send time to Display displayTime( time )task block s itself...

block

time += 100 updateCurrentTime( time )

send time to Display displayTime( time )task block s itself...

block

Page 25: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD ButtonEvent

theButtonEventCtrl:ButtonEvent

MSTflags:cEventFlagGroup

aListener:ButtonListener

theModeButton:Button

theSetButton:Button

initialize theButtonEventCtrl initloop

task block s itselfblock

interrupt from timertimerInterrupt

... unblock s the taskunblock

task resume by RTOSupdate

update button state updateStateget state

getState( theSetButton )if{should report down}

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

end if

task block s itself block

timerInterrupt timerInterrupt

...unblock s the task unblocktask resumed by RTOS update

update button state updateStateget state

getState( theModeButton )if{should report down}

report button down buttonDown( theModeButton )upon which a flag is set

set( btnModeDown )

buttonUp( theModeButton )

set( btnModeUp )

task block s itselfblock

interrupt from timertimerInterrupt

... unblock s the taskunblock

task resume by RTOSupdate

update button state updateStateget state

getState( theSetButton )if{should report down}

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

end if

update button state updateStateget state

getState( theSetButton )if{should report down}

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

end if

get stategetState( theSetButton )

if{should report down}

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

end if

if{should report down}

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

end if

report button down

buttonDown( theSetButton )

upon which a flag is set

set( btnSetDown )

task block s itself block

timerInterrupt timerInterrupt

...unblock s the task unblocktask resumed by RTOS update

update button state updateStateget state

getState( theModeButton )if{should report down}

report button down buttonDown( theModeButton )upon which a flag is set

set( btnModeDown )

buttonUp( theModeButton )

set( btnModeUp )

update button state updateStateget state

getState( theModeButton )if{should report down}

report button down buttonDown( theModeButton )upon which a flag is set

set( btnModeDown )

buttonUp( theModeButton )

set( btnModeUp )

get stategetState( theModeButton )

if{should report down}

report button down buttonDown( theModeButton )upon which a flag is set

set( btnModeDown )

buttonUp( theModeButton )

set( btnModeUp )

report button down buttonDown( theModeButton )upon which a flag is set

set( btnModeDown )

buttonUp( theModeButton )

set( btnModeUp )

buttonUp( theModeButton )

set( btnModeUp )

Page 26: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD IREventTask

theIREventCtrl:IREventDetection

theInfraredSensor:InfraredSensor

HRTflags:cEventFlagGroup

theSensorListener:SensorListener

start and initialize the taskinit

loop

task block s itselfblock

interrupt from timertimerInterrupt

...unblock s the task unblocktask resumed by RTOS... update

poll infraredSensor updateStateget state

getStateif (should report beat)

report heartbeat reportHeartBeatupon which a flag is set

set( IREvent )

end if

end loop

task block s itselfblock

interrupt from timertimerInterrupt

...unblock s the task unblocktask resumed by RTOS... update

poll infraredSensor updateStateget state

getStateif (should report beat)

report heartbeat reportHeartBeatupon which a flag is set

set( IREvent )

end if

poll infraredSensor updateStateget state

getStateif (should report beat)

report heartbeat reportHeartBeatupon which a flag is set

set( IREvent )

end if

get stategetState

if (should report beat)

report heartbeat reportHeartBeatupon which a flag is set

set( IREvent )

end if

report heartbeat reportHeartBeatupon which a flag is set

set( IREvent )

Page 27: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

SA – SeqD SpeakerSwitchTask

theSpeakerSwitchCtrl:SpeakerSwitch

theSpeaker:Speaker

init

low

suspend

switchOn( freq, ms )

resumeupdate

high

block

timerInterruptunblock

update

high

low

block

terminate

low

suspend

switchOn( freq, ms )

resumeresumeupdate

high

block

high

block

timerInterruptunblock

update

high

low

block

timerInterruptunblock

update

high

low

block

high

low

high

lowlow

blockblock

terminate

theSpeakerSwitchCtrl:SpeakerSwitch

theSpeaker:Speaker

init

low

suspend

switchOn( freq, ms )

resumeupdate

high

blockloop

interrupt from timertimerInterrupt

...unblock s the task unblocktask resumed by RTOS update

if{status == LOW}

speak er high highelse

speak er low lowend if

if{++nrTick s == maxTick s}

flip status; nrTick s = 0

end if

if{--nrTick s > 0}

task block s itselfblock

end if

end loop {timeTick s == 0 OR...

... speak er switched off} terminateend loop

low

suspend

switchOn( freq, ms )

resumeresumeupdate

high

block

high

blockloop

interrupt from timertimerInterrupt

...unblock s the task unblocktask resumed by RTOS update

if{status == LOW}

speak er high highelse

speak er low lowend if

if{++nrTick s == maxTick s}

flip status; nrTick s = 0

end if

if{--nrTick s > 0}

task block s itselfblock

end if

end loop {timeTick s == 0 OR...

interrupt from timertimerInterrupt

...unblock s the task unblocktask resumed by RTOS update

if{status == LOW}

speak er high highelse

speak er low lowend if

if{++nrTick s == maxTick s}

flip status; nrTick s = 0

end if

if{--nrTick s > 0}

task block s itselfblock

end if

if{status == LOW}

speak er high highelse

speak er low lowend if

speak er high highelse

speak er low lowspeak er low low

if{++nrTick s == maxTick s}

flip status; nrTick s = 0

end if

flip status; nrTick s = 0

if{--nrTick s > 0}

task block s itselfblock

end if

task block s itselfblock

... speak er switched off} terminateExecuted in the context of another task

Page 28: Groep2 Max Aalderink Paul Gielen Wesley Hilhorst30-06-2010 Lars Stolwijk 2TPRJ8 Hartmonitor.

Demonstratie