La lecture en ligne est gratuite
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
Télécharger Lire

tutorial

22 pages
1)structuretheseA04]).WiSottomSimworkulationdesFconsumptionramewmoorkphOvThiserviewnoJohanneenGlaserclimateandototypDanielulated.Wre-ebcon-erwJulyserial1,ulation.2008moAbstractulationThetPasAofWiSreacSimhomeulationnoFfunction,ramewnoorkelopmenfacilitateecicationsarctheplemensimhiteulationdesignofinwirelessansensorers,nettowkorks.in-Thitsain-Fig.cludesduletheimplemen-indesternalnicationstructureulated.oftintheyMotesensorpressurenoasdes(e.g.asswasellsasptheasnetawtoporkdol-connectingatthem.tation.Thisdesignodoveeotherrvtheide-ewTdo3cumendtcksdescribC,esytheADbasicon.principlesisofitheeryframetypwandorkeacandesgivbedesignsPaorkshorttheinosedtropductiontheofter-itsthestructure.wAcommlargeetpartareofwidethisstartsdosensorcumethene04])tviaisandtaktrolensystemsbtertainmeny[GSSaintutorialofincludingiscovirtualding.examplesthatwhictiminghwguidewyunicationoufailuretoethetheusagewnofmthe(seeframewdesignofunctionalrimplemek.b1tsWirelessrenedSensormoNetnwreectingorksimWirelessOnsensorphnettswandorksa(WSN)fromareFiguremainlydouseddologyinorkbuildingWSNautomation,iscarfunctionalineteriaorroutingdevices,tioncon-atainerterfacetracvking ...
Voir plus Voir moins

Vous aimerez aussi

1)
structure
these
A
04]).
WiS
ottom
Sim
work
ulation
des
F
consumption
ramew
mo
ork
ph
Ov
This
erview
no
Johann
een
Glaser
climate
and
ototyp
Daniel
ulated.
W
re-
eb
con-
er
w
July
serial
1,
ulation.
2008
mo
Abstract
ulation
The
t
P
as
A
of
WiS
reac
Sim
home
ulation
no
F
function,
ramew
no
ork
elopmen
facilitate
ecication
s
arc
the
plemen
sim
hite
ulation
design
of
in
wireless
an
sensor
ers,
net
to
w
k
orks.
in-
Thi
t
s
a
in-
Fig.
cludes
dule
the
implemen-
in
des
ternal
nication
structure
ulated.
of
tin
the
yMote
sensor
pressure
no
as
des
(e.g.
as
s
w
as
ell
s
as
p
the
as
net
a
w
top
ork
dol-
connecting
at
them.
tation.
This
design
o
do
v
e
e
other
rv
the
i
de-
ew
T
do
3
cumen
d
t
cks
describ
C,
es
y
the
AD
basic
on.
principles
is
of
i
the
ery
frame
typ
w
and
ork
eac
and
es
giv
b
e
design
s
P
a
ork
short
the
in
osed
tro
p
duction
the
of
ter-
its
the
structure.
w
A
comm
large
et
part
are
of
wide
this
starts
do
sensor
cume
the
n
e04])
t
via
is
and
tak
trol
en
systems
b
tertainmen
y
[GSS
a
in
tutorial
of
including
is
co
virtual
ding
.
examples
that
whic
timing
h
w
guide
w
y
unication
ou
failure
to
e
the
the
usage
wn
of
m
the
(see
framew
design
o
functional
r
impleme
k.
b
1
ts
Wireless
rened
Sensor
mo
Net
n
w
reecting
orks
im
Wireless
On
sensor
ph
net
ts
w
and
orks
a
(WSN)
from
are
Figure
mainly
do
used
dology
in
ork
building
WSN
automation,
is
car
functional
in
e
teri
a
or
routing
devices,
tion
con-
a
tainer
terface
trac
v
king,
and
bridge
h
and
c
vulcan
mapp
main
dul
t
the
e
or
nance
blo
and
mo
monitori
is
n
its
g
standardize
as
F
w
of
ell
t
as
eral
geological
tations
surv
prepared.
eillance.
of
The
optimization
no
with
des
WiS
comprise
rame-
sensors
depicted
for
A
e.g.
eginning
tem
is
p
one
erature,
ta-
h
mo
umidit
e
y
1
,
in
insolation,
nal
str
of
ai
no
n
as
gauge
ell
and
the
so
u-
on.
b
All
w
no
them
des
sim
comm
The
unicate
range
with
utilisation
eac
at
h
y
other
no
via
(e.g.
a
Tin
n
[Ro
ad-ho
and
c
hes
mult
tire
i
monitoring
-hop
car
net
con
w
to
ork
complex
.
as
This
en
means
t
that
Sindrion
the
dule
pac
The
k
ternal
ets
tructure
are
a
routed
de
from
built
no
a
de
pr
to
e
no
Thi
de
means
and
its
the
the
routing
and
information
o
accrues
er
during
as
the
ell
ne
comm
t
and
w
de
ork
s
op
r
eration.
sim
Sp
With
ecial
true
MA
do
C
dev
and
t
routing
etho
proto
ogy
cols
Fig.
w
the
ere
starts
dev
a
elop
sp
ed
and
for
n
this
Guided
purp
y
ose.
quiremen
The
the
proba-
is
bly
via
b
hitectural
est
dels
kno
w
wn
to
is
dels
IEEE
th
802.15.4
actual
ZigBee
-
(
tation.
[
the
H
hand,
P
ysical
03],
strain
[IEE03]),
eect
but
functional
ev
arc
en
ctur
more
l
sp
signs
ecialized
b
proto
up.
cols
1:
ex-
op
ist
wn
(e.g.
metho
CSMA-MPS
.
[MB04
W
]).
o
The
The
main
no
dev
e
elopmen
split
t
to
target
blo
is
lik
the
a
lo
ysical,
w
MA
p
a
o
and
w
applica-
er
la
consumption
er,
of
CPU,
ev
in
ery
,
no
con
de
ert-
to
timer
supply
so
them
Eac
with
of
energy
blo
sca
ks
v
then
enging
ed
or
mo
from
es
a
n
single
sim
battery
F
,
ev-
y
functional
et
c
with
its
long
dule
lifetimes
e
as
dened.
long
comprises
as
name
10
the
y
d
ears.
terfaces.
2
or
Sim
h
ulation
the
F
dule
ramew
yp
ork
sev
The
dieren
P
implemen
A
can
WiS
e
Sim
The
ulation
ow
F
the
rame
and
w
of
ork
WSN
assists
the
y
A
ou
Sim
in
F
the
w
dev
is
elopmen
in
t
2.
and
t
esp
b
ecial
the
ly
de
the
comp
optimization
from
of
mo
WSN
implemen
no
tion
des
er
and
dule
net
yp
w
from
ork
mo
proto
cols.
The
+
+of
strategie
xygen
2:
b
Rene
ramew
men
but
t
.
cycles.
b
tations
w
library
mostly
.
crosoft
Then
total
the
yp
mo
proto
dules
baseband.
are
unit.
congured
of
(e.g.,
Structure
clo
discrete
c
requires
k
or
frequency
cated
of
to
the
p
CPU,
mo
resolution
the
of
s
the
es
ADC).
w
In
sp
the
are
next
also
step
an
the
dules,
mo
dio
del
dep
is
ork
s
the
i
ork
m
ev
u-
hines
lated
e
and
are
the
de
results
of
are
emen
ev
this
aluated.
applying
Based
Exc
on
one
the
dieren
sim
a
ulation
ADC.
results
dieren
the
of
individual
y
mo
hardw
dels
analog
are
x
rened,
C
i.e.
ted
their
dedicated
b
of
eha
ˆ
viour
e.g.
is
the
imple-
Par
men
ing,
ted
rate
in
F
m
the
ore
P
detail
The
and
d
more
sim
accurately
The
.
with
A
The
d-
to
ditionally
ulator
the
compile
mo
the
dules'
conf
functions
w
are
ersion
altered
the
to
Figure
approac
er-
h
in
to
l
the
impro
design
of
goals.
de.
The
ization
conguration
b
of
follo
the
.
mo
the
dels
implementation
ma
dule
y
i.e.
b
selection
e
,
mo
e,
died
an
to
example
o
ho
and
MA
then
ˆ
the
d
sim
functions
ulation
the
is
w
p
and
erformed
digital
again.
RF
Al
or
ternativ
mple
ely
ic
the
col
comp
impleme
osition
soft
of
as
the
are
total
com
no
oth
de
ossible
m
sc
a
mo
y
resolution
b
o
e
coun
c
CPU.
hanged,
of
if
the
the
p
curren
and
t
a
sel
5
ection
ork
of
Fig.
mo
structure
dule
of
implemen
WiS
tations
are
do
-
es
bas
not
the
meet
en
the
system
design
programming
goals.
del
These
ter-
cyclic
he
impro
C
v
ramew
emen
follo
ts
OMNeT++
of
t
the
and
mo
T
dels
Unix
are
ou
called
compiler
r
Aut
enement
and
cycles
On
and
the
are
Studio
the
or
main
Please
trac
guide
k
2
to
no
enhance
p
the
formance,
dev
the
elopmen
teraction
t.
them
When
eads
these
an
renemen
v
t
t
cycles
the
are
no
completed,
All
the
optim
nal
is
outcome
erformed
c
y
omprises
the
ˆ
wing
the
s
function
ˆ
a
hange
n
actual
d
dule
ˆ
for
the
mo
arc
t
hitecture
e,
of
a
the
t
no
from
de,
library
as
e.g.
w
dual-slop
e
a
ll
or
as
SAR
ˆ
Another
the
i
implemen
c
tation
osing
and
t
ˆ
C
the
cols.
p
Partitioning
o
mo
w
ul
er
and/or
sp
b
ecication
dividing
of
task
ev
et
ery
een
sub-mo
are
dule.
soft-
4
are,
Optimization
and
Sev
or
eral
and
strategies
F
for
e
the
a
optimization
a
of
ec
the
MA
wire-
proto
less
could
sensor
e
system
n
are
in
a
w
v
or
ailable.
a
First
hardw
of
acceleration
all
A
a
bination
system
b
level
is
optimization
p
is
.
p
The
erformed.
ale
This
a
in-
dule,
cludes
the
the
of
no
ADC
de
r
comp
register
osition
t
and
a
ev
ˆ
en
ameterization
mo
mo
dica-
e.g.
tions
tim-
of
transmission
the
o
whole
er
system
bit
b
of
eha
ra-
vior
transmitter.
lik
The
e
ramew
c
5.1
ho
In
osing
3
dieren
basic
t
and
net
endencies
w
the
ork
A
la
F
y
ork
out
depicted.
or
frame
application
w
patterns.
is
The
e
system
on
l
OMNeT++
ev
ev
el
t
optimization
ulation
guides
and
y
C++
ou
language.
to
mo
an
programmer
adequate
in
system
acts
arc
t
hitecture.
framew
In
and
paralle
++.
l
F
cr
ork
oss-layer
the
optimization
wing
is
ols:
p
discrete
er-
en
formed.
sim
This
3.3
means
Do
that
1.4.7.
more
o
than
on
one
mac
net
y
w
need
ork
GCC
la
4.0
y
4.1,
er
o
is
2.60a
mo
Automak
died
1.9.6.
at
Windo
a
s
time.
Mi-
Probably
Visual
eac
v
h
7
of
8
these
required.
c
consult
hanges
installation
alone
lo
w
at
ould
degrade
the

https://clara.tuwien.ac.at/pawis/sim:docues
implem
a
3:
one
Structure
dules
of
ule.
the
run
P
e
A
ens
WiS
Fig.
F
o
ramew
and
ork.
one
5.2
are
Discrete
ultithreadi
Ev
o
en
erything
t
unctional
Sim
erf
ulator
can
Since
o
the
a
P
k
A
Eac
WiS
ed
Sim
b
ulation
task
F
.
ramew
ted
ork
has
is
tion
based
o
on
oin
the
suc
OMNeT++
of
Descrete
b
Ev
F
en
subroutine
t
im
Sim
Note
ulation
after
System,
terfaces
w
ed.
e
ait
ha
a
v
Figure
e
b
to
mo
discuss
a
ho
5.3.2
w
eral
its
ted
ev
The
en
but
t
oncurr
pro-
is
cessing
This
is
era-
w
e
orking.
oin
Basically
to
e
means
v
ed
ery
later
mo
these
dule
ulation
can
een
generate
oin
new
am
events
ulation
whic
trol
h
t
are
ted
stored
al
in
These
the
green
so
functional
called
a
F
to
utur
v
e
starts
Event
nished,
List
means
(FEL).
p
The
when
sim
some
ulation
de-
k
on
ernel
men
st
trigger
e
ws
adily
inside
pic
w
ks
so
the
of
earliest
i
ev
ted
en
class
t
orders.
(whic
asks
h
dule
has
c
the
imple-
seman
ev
t
n
i
within
c
sequen
of
task
a
ning
message
n
transp
ery
ort
ted
e
metho
d
is
from
co
net-
e
w
so
ork
y
no
dene
de
whe
to
passes
no
sim
de)
ernel.
from
the
this
is
FEL.
this
The
t
c
on
urr
A
e
ld
n
the
t
elapses.
sim
et
ulation
w
time,
yield
whic
hap-
h
the
is
instan
st
i
o
5.3.3
r
terfaces
e
w
d
w
in
o
a
e
v
so
ariable,
c
is
n
then
es
set
similar
to
(see
this
ws
ev
Ev
en
terface
t's
ted
time
so
and
in
the
other
ev
the
en
cation
t
in
is
task
de-
task
liv
in
ered
returns.
to
functional
the
not
destination
tly
mo
l
dule.
v
The
dditionally
destination
oin
mo
dule
dule
a
ma
dep
y
mo
i
is
ts
b
e
hanism
lf
parallel
insert
red
new
Fig.
ev
T
en
dule
ts
trol
in
mo
to
Figure
the
on.
FEL.
h
As
these
so
dules
on
s
as
en
this
as
task
C++
has
deriv
nished,
from
the
.
sim
T
ulation
Within
k
mo
ernel
sev
again
tasks
consults
an
the
e
FEL
men
and
and
tak
en
es
i
the
parallel.
earliest
execution
ev
one
en
is
t.
tial
The
all
sim
s
ulation
run-
time
c
therefore
e
do
tly
es
Ev
not
task
corre-
implemen
late
as
to
class
w
d.
all
concurrency
clo
implemen
c
as
k
op
time,
tiv
b
m
ecause
ng,
it
ev
is
r
only
task
dened
to
b
p
y
ts
the
r
ev
it
en
execution
ts
the
generated
ula-
during
k
sim
That
ulation.
that
F
program
or
w
sim
stopp
ulations
at
with
p
large
in
temp
and
oral
c
distance
tin
b
there.
et
t
w
yie
een
p
the
ts
ev
sim
en
time
ts,
Ev
sim
b
ulation
w
time
t
will
o
elapse
h
faster
p
than
ts
the
p
w
in
all
s
clo
e
c
t
k
s
time.
m
Con
time.
trary
F
,
In
sim
Con
ulations
o
with
transitions
dense
et
temp
een
oral
w
resolution,
mo
where
ar
the
implemen
sim
as
ulati
called
on
un
k
tion
ernel
I
has
t
to
ac
execute
.
man
are
y
to
ev
calls
en
the
ts
arro
and
in
their
4).
han-
ery
dlers,
in
the
is
sim
plemen
ulati
as
on
task,
time
it
ma
run
y
parallel
b
the
e
tasks.
slo
that
w
in
er
o
than
of
the
functional
w
terface
all
this
clo
and
c
the
k
has
t
the
i
v
me.
cation
5.3
That
Basic
that
Con
in
ce
are
p
running
t
ermanen
s
but
5.3.1
n
Mo
y
dularization
in
The
ok
wireless
A
sensor
at
no
p
de
ts
is
mo
split
can
up
ne
in
w
to
condition
mo
ending
dules,
another
e.g.
d-
a
This
C
comple
PU
ted
,
y
the
mec
net
to
w
a
ork
tas
proto
(see
col
arro
la
in
y
4).
ers
4:
(applica-
asks
tion,
mo
routing,
s
MA
con
C,
o
ph
across
ysical),
dule
a
3
timer
and
PawisModulector.
an
w
CPU
n
The
ors,
submo
C++
dules
in
of
.
a
and
sensor
are
no
easily
de
e
are
w
usually
calls.
ei-
c
ther
e
implemen
y
ted
of
as
h
rmwar
th
e
w
(soft
y
w
-
are),
ondition
i
with
.e.
lo
are
con
executed
h
b
i
y
analog-
a
(ISR)
CPU,
ery
or
maps
as
ng
de
p
dic
no
ate
d-
d
certain
har
exit
dwar
b
e
i
.
simple
Ev-
.
ery
as
mo
l
dule
ance
ca
ha
n
en
ha
dule).
v
Ev
e
the
sev
whic
eral
ak
tas
time
ks,
y
and
instan
the
implemen
can
co
b
some
e
m
mixed
priority
soft
of
w
(as
are
its
and
an
hardw
ec
a
ISR.
r
p
e
All
tasks
onment
(e.g.
surrounding
the
ob
RF
...
transceiv
uation
er
to
hardw
1
are
These
plus
of
its
not
driv
ould
er).
time
It
y
is
a
im-
lo
p
a
ortan
h
t
b
to
op
note
it
that
y
soft
but
w
time.
are
lo
tasks
ded-
can
for
not
ag
run
dedic
in
e
parallel,
and
since
dela
the
er
CPU
the
is
w
only
execution
a
This
v
CPU
ailable
op
once.
in
Therefore
++
the
et
con
in
trol
time
o
in
w
v
is
the
transferred
u-
from
s
one
(e.g.
mo
..
dule
inter-
to
v
another
servic
(think
thing
of
Rs
subroutine
the
call
o
and
mo
return
in
here)
n
instead
the
of
appropriate
triggered
hec
ev
con-
en
n
ts.
the
T
consumption)
o
En
mo
are
del
ons
the
the
p
including
o
c
w
themselv
er
w
and
heaters,
time
en
consumption
erties
of
5.3.8))
soft
lo
w
ait
are
en
tasks
rm
the
d-
ideal
calls
case
oin
is
coroutine.
a
s
CPU
w
sim
it
ulator
for
whic
jump
h
Ho
is
a
fed
in
b
One
y
is
the
a
actual
This
rm
deled
w
to
are
that
op
de-
co
ust
des.
mo
Un-
actual
fortunately
y
this
de
is
o
v
only
ery
sim
time
host
consuming.
esn't
There-
sim
fore
complica
in
dela
the
ma
P
e
A
break
W
w
i
certain
S
(i.e.,
framew
b
ork
or
the
timer
CPU
can
sim
emen
ulation
he
is
metho
split
more
in
utilize
to
o
t
des
w
This
o
to
parts.
p
The
mo
functional
halts
t
til
a
o
s
l
ks
up
of
h
the
ues
rm
Note
w
e
are
and
are
ery
writ-
d
ten
place
in
een
pure
virtually
C++
same
co
i.e.
de
5.3.6
inside
rupts
of
handling
the
in
task
steps.
metho
i
d
deled
itself.
troller
The
interrupt
timing
exist.
and
come
p
mo
o
timer,
w
v
er
They
c
ed
ons
ve
um
e
p
has
ti
an
on
r
part
Ev
is
the
then
I
del
s
egated
ized
to
mo
the
ed
CPU
e).
mo
w
dule.
can
It
for
only
v
rep
the
orts
source
its
terrupt
p
mo
o
to
w
terrupt
er
tor,
c
its
ons
then
umptio
to
n
curr
(on
run
b
task
ehalf
y
of
w
the
in-
real
later.
mo
ronmen
dule)
de
and
at
dela
t
ys
the
execution
This
f
w
o
no
r
he
the
the
esti-
Besides
mated
e
pro
also
cessing
lik
time.
ls,
This
in
delegation
t
is
within
real-
t.
ized
global
as
the
5.3.4
onen
p
Sec.
er
al-
c
w
entage
w
inte
for
ger
setup
terface.
ts.
p
In
er
w
c
mo
ent-
1
age
is
o
are
at
p
in
ts
p
the
er
ules
c
i
entage
is
memory
allo
ac
ed,
c
ecause
ess
w
scripting
stand
p
a
er
ondrous
c
in
entage
.
ow
w
c
s
ontr
dela
ol
programmed
the
soft
dur
are?
ation
w
with
y
.
a
This
del
call
y
is
op.
one
is
of
mo
the
with
exit
call
p
thing
oin
Note
ts
suc
o
a
f
la
task
m
coroutines.
not
These
e
requests
deled
include
an
the
lo
estimated
in
execu-
our
tion
co
time
since
of
w
the
u
rm
d
w
load
are
our
co
ula
de
tion
on
CPU
the
do
CPU.
adv
No
the
w
ulation
think
More
that
t
the
d
CPU
y
of
ops
a
y
g
v
iv
a
en
icated
no
c
de
to
should
ait
b
a
e
ev
r
t
e
a
-
set
placed
y
during
ISR
the
a
optimization
ated
pro
mo
cess
This
(e.g.,
b
use
impl
an
ted
ARM
t
instead
ery-
of
Ev
an
ds.
MSP430)
en
or
sophisticated
c
ys
hange
lo
the
p
conguration
w
(e.g.,
mo
use
of
a
CPU.
faster
sets
crystal).
CPU
This
a
w
w
ould
o
also
er
require
de
to
h
mo
the
dify
un
all
an
execution
terrupt
time
ccurs.
estimates
wil
in
w
all
e
mo
the
dules
whic
of
then
the
tin
no
its
de.
eration.
T
that
o
only
allo
lapses
ws
dened.
for
are
a
Ev
CPU
C
exc
co
hange
e
without
ou
the
b
need
w
to
suc
adapt
calls
other
runs
mo
the
dules
time
the
t,
execution
no
time
elapses.
estimates
I
are
ter
referred
The
to
terrupt
the
is
so
ted
called
se
norm
eral
CPU
W
.
th
This
n
is
mo
an
micro
i
n
maginary
n
but
merous
w
sour
ell
es
dened
The
CPU
e
implemen
from
tation
other
(regarding
dules
its
a
p
an
erformance).
digital-con
The
erter,
a
.).
ctual
are
CPU
app
mo
to
del
rupt
scales
ctors
its
Ev
pro
ry
cessing
ector
ti
a
me
and
and
interrupt
p
e
o
outine
w
assigned.
er
ery-
consumption
except
ac-
registration
cording
the
to
S
its
i
individual
r
prop
al-
erties
within
and
CPU
dep
dule
end-
describ
ing
ab
on
v
the
Ev
p
(soft
ercen
are)
tages
dule
of
register
execution
ISR
t
an
yp
terrupt
es.
e
The
When
framew
i
ork
terrupt
user
triggers
has
in
to
request,
implemen
CPU
t
dule
the
it
CPU
the
mo
in
dule
v
as
-
a
c
C++
ks
class
priorit
de
and
r
transfers
i
trol
v
the
ed
The
from
e
d
tly
and
ni
o
CPU
v
(read:
e
dela
rr
and
i
o
de
er
sev
is
eral
terrupted
virtual
nished
metho
5.3.7
ds.
vi
See
t
Sec.
no
6.5
s
for
placed
details.
3D
5.3.5
osi
Timing
i
Mo
within
deling
Envir
time
.
dela
manages
ys
outer
is
orld
dieren
all
t
des
i
t
n
ir
rm
and
w
RF
are
hannel.
and
the
hardw
d
are
s
mo
es
dules.
other
In
jects
hardw
e
are
al
mo
o
dules
trees,
just
terferers,
use
ligh
a
sources,
e
reside
dur
the
ation
vironmen
ongur
A
call.
ditionally
There
prop
are
(e.g.
the
atten
c
exp
and
t
and
(see
calls
4
whic
ev
requireCpu()
requireCpuUntil() requireCpuOrUntil()
wait()
requireCpu()
requireCpu( ,
, ,
, )
Cpu
wait( )
waitUntil() waitOrUntil() b
wait()in
data
a
5:
an
The
y
En
to
vironmen
of
t
er
with
and
functions,
in
ob-
the
jects
explicitly
and
with
se
hierarc
n
trix
sor
o
no
(4)
des
ely
5.3.8
results
Air
ultiplication
The
unication.
A
terface,
i
tennas
r
w
is
p
a
s
s
the
ub
er
comp
no
onen
r
t
ery
of
.
the
The
en
and
vironmen
of
t
p
to
du-
handle
transmitter
the
from
RF
scaling
c
vironmen
hannels,
setup
whic
wn
h
y
are
of
dened
are
b
et
y
ery
the
This
no
calcu-
de
noise
placemen
is
t
are
and
(
the
dule.
obstacles
e
b
to
e
the
t
its
w
sim
een
its
them.
Sim
The
.
RF
.
signal
s
is
is
s
ectors
ub
hold
ject
p
to
des,
w
calculation
a
is
v
eration
e
ends
propagation
sense
phe-
only
nomenons
is
lik
d
e
to
atten
adjac
uation,
terface
reection,
data
refraction,
actual
scattering
This
and
sim
fading
to
(m
b
ulti-path
c
propagation)
t
from
supp
the
tenna
transmitter
adja-
to
additional
the
ery
receiv
are
er.
is
Theory
transmitted
The
the
curren
The
t
to
implemen
and
tation
er.
of
error
the
BER
Air
and
only
index
handles
d
atten
y
uation
enables
e
ply
ects,
Calculating
b
uation
ecause
no
the
ery
other
giv
eec
ency
ts
o
w
gisters
ould
startup
require
A
an
o
enormous
sim
complex-
n
it
e
y
5.3.9
in
.
the
.
sim
.
ulator.
scrib
F
tation
or
Implemen
free
coun
space
the
propagation
the
the
rom
receipien
trans-
t
e
p
w
o
at.
w
ec-
er
Then
is
receiv
dened
w
b
written
y
matrix
Figure
for
cal
the
i
Since
tr
mak
elec
a
t
activ
dieren
v
e
h
v
feren
a
a
h
matrix
can
(5)
consumer
single
ery
eration.
Ev
matrix
ule.
dened
d-
the
mo
to
supply
-
the
or
y
vironmen
b
is
vided
used
pro
w
is
as
oltage
(5).
v
simple
supply
can
The
calculated
.
external
equals
sim
er
The
(1)
en
where
Air
w
isotropic
o
uniform
p
No
consumed
for
The
matrix,
.
v
Meter
uations
Power
een
tral
of
is
no
the
orted.
an
no
tenna
of
gain
k
of
the
the
con-
transmitter
e
in
w
the
de
direc
the
tion
ratio
to
o
the
receiv
receiv
o
er
rom
and
the
cen
o
the
ed.
to
a
orted
o
rep
p
nally
the
is
of
and
no
tree
e
is
of
the
h
an
a
tenna
This
gain
mo
of
sup-
the
).
receiv
th
er
atten
in
from
the
y
dire
de
ction
ev
to
other
the
de
transmitter.
es
supply
adjac
is
ma-
the
w
w
p
a
at
v
e
e-
it
length,
ulation
the
t
is
consumption.
the
w
distance
p
b
ulates
et
task
w
Ev
een
ulatio
the
r
t
w
w
P
o
6.10.
no
.
des
.
and
Sec.
up
.
is
.
the
.
atten
ed
uation
de-
exp
i
onen
implemen
t.
tation
The
calculated.
latte
t
r
error
is
Let
usually
v
2
bit
for
BER
ideal
the
free
F
space
the
propagation,
mitted
but
receiv
for
d
indo
o
or
er
en
all
vironmen
no
ts
resp
higher
tiv
v
.
alues
the
lik
of
e
ed
3.5
o
are
er
more
easily
appropriate.
b
Alternativ
the
ely
op
the
m
receiv
lation
ed
mo
p
on
o
(5)
w
the
er
only
can
e
b
when
e
single
calcu-
is
lated
e,
b
one
y
alue
di
dep
v
whic
i
dif-
ding
t
the
zero
transmit
n
p
the
o
m
w
in
er
reduces
b
a
y
column
the
op
sur-
The
face
ency
of
is
a
precisely
sphere
in-
propagates
from
This
en
.
t
supply
the
(replacing
com
the
m
exp
F
onen
an
t
en
b
t
y
SNR
er
calculated.
)
is
with
during
radius
net
equaling
ork
the
ulation
distance
sho
of
in
the
Due
receiv
this
er
in
and
the
transmitter
also
w
e
.
b
This
an
dilute
RF
d
hannel

ulation
p
ol.
o
curren
w
implem
er
tation
densit
the
y
only
is
orts
then
an
m
with
ultipl
an
ied
gain.
b
obstacles
y
considered
the
the
an
cency
tenna
though
area
gi
o
en
p
atten
the
b
of
w
the
ev
receiv
pair
er.
t
to
o
orted
des
rep
supp
and
Ev
de)
receiving
co
de
C++
notied
our
a
y
pac
y
et
(b
via
calculated
Air.
is
notication
(2)
tains
The
receiv
atten
r
uation
o
from
er.
the
no
transmitter
then
sumption
lates
to
signal
re-
noise
ceiv
(SNR)
er
its
con-
wn
is
the
giv
ed
en
p
b
w
y
F
actual
thi
the
SNR
ulation
bit
sim
rati
During
(BER)
distribution.
deriv
r
The
e
is
w
function
(3)
5
where
.
i j i;j2
1; 2;:::;n
0 1
A A A1;1 1;2 1;n
B CA A A2;1 2;2 2;nB C
A =B C
@ A
A A An;1 n;2 n;n
! !
P PTx Rx
n
! !
P =APRx Tx
!
PTx
A
A
!P = P G (’ )Rx Tx Tx Tx;Rx
2
! bG (’ ) dRx Rx;Tx
4
!G (’ )Tx Tx;Rx
!G (’ )Rx Rx;Tx

d
b
24d
b
d
ARx
1 bP =P d ARx Tx Rx
4
j
i
P = UI
P URx;i
A =i;j
PTx;jstarts
6
v
eha
s
vior.
p
i.e.
te
the
of
curren
the
t
the
b
second
dep
ou
ends
w
in
tro
dier-
Application
en
via
t
timer
w
Ev
a
the
ys
Its
on
b
the
as
supply
fr
v
.
oltage.
are
Curren
t
tly
i
three
main
kinds
pure
of
LED
p
(except
ower
w
r
in
ep
Figure
orters
ted
are
refer
pro
use
vided
the
but
the
y
lass
ou
s
are
class
free
i
to
t
dene
sources,
new
to
ones.
is
ˆ
ou
examples.
sim
:
the
some
another
for
dules
on
the
Read
wing
.
nni
The
whic
curren
mo
t
Timer
do
ok
es
terfaces.
not
supplie
dep
er
end
o
on
in
the
ication
supply
terrupt
v
of
oltage.
l
ˆ
class
dules).
F
:
t.
mo
ha
other
macro
(of
In
items
other
.
is
The
cl
supply
the
curren
r
t
In
is
3)
prop
the
ortional
class
to
b
the
metho
supply
1:
v
WiS
oltage,
oered
t
p
ypically
all
as
ou
for
all
a
mo
resistor.
ds
ˆ
err
tered
on
:
rst
-
description
s
viron-
regi
the
ously
is
i
6.1
v
sho
e
Fig.
.
is
A
fol-
constan
to
t
is
curren
in
t
dule
plus
is
a
w
supply
This
v
to
oltage
t
dep
in
endan
their
t
functional
p
mo
or-
App)
tion.
b
ˆ
o
Dene
LDO
y
regula
our
).
o
issue
wn
whic
rep
the
orter
gram
b
ISR
y
rou-
deriving
Mo
from
LED
the
mo
pr
is
base
a
class.
ed
This
A
can
ork
im-
L
plemen
Inside
t
y
an
e
y
sp
non-linear
class
curren
ent
t
h
c
and
haracteris-
ternal
tics
param
y
a
ou
of
need.
s,
The
i
p
t
o
the
w
m
er
dules.
supply
cl
mo
(see
dule
ou
calculates
to
its
acro
output
.
v
con
oltage
y
dep
v
ending
ables
on
as
the
e.
output
declaration
curren
P
t,
dule
t
to
he
.
r
w
e
fac
-
our
fore
e
dieren
v
t
in
source
dule
b
cuted
eha
and
viors
are
are
virtual
p
h
ossible
o
to
de.
o.
called
This
of
results
all
in
cuted
a
the
simple
of
electrical
En
net
men
w
and
or
Air
k.
example
A
in
t
duced.
an
Mo
y
As
p
wn
oin
n
t
6
in
system
a
built
h
the
a
lo
r
mo
dw
The
are
program
task
ru
y
ng
ou
the
ca
mo
n
(App)
set
h
a
a
new
soft
p
are
o
dule.
w
i
er
connected
rep
the
orter
and
and
he
its
to
c
v
harac
e
t
functions
e
their
ristics.
in
The
All
previous
dules
rep
the
orter
are
is
d
then
y
replaced
p
b
w
y
source
a
(lo
new
drop-out
o
t
n
r
e
The
.
can
The
an
rep
terrupt
orter
h
handles
terrupts
all
appl
supply
pro-
v
and
oltage
the
c
(in
hange
service
s
tine).
according
6:
to
dules
its
the
prop
example.
erties
ery
automatic
du
ally
e
.
implemen
Note
as
that
C++
only
deriv
tasks
from
whic
P
h
WiS
sim
ramew
ula
class
t
(see
e
s
dedi-
1).
cated
of
hardw
class
are
ou
consume
v
p
to
o
a
w
ecial
er
can
on
ou
their
ar
o
y
wn.
whic
T
declares
asks
constructor
whic
some
h
in
sim
stu.
ulate
rst
soft
eter
w
alw
are
ys
tasks
name
just
the
use
as
the
the
the
parameter
metho
s
d.
paren
The
c
CPU
and
mo
thi
dule
d
will
ust
re-
e
p
.
ort
the
its
as
p
denition
o
Lst.
w
y
er
ha
c
e
ons
add
umpti
m
on
mo
and
other
t
The
he
can
additional
tain
info
man
for
mem
whic
er
h
ar
task
-
it
and
i
ds
s
y
executing
lik
co
Listing
de.
Class
6
of
Example
he
In
A
this
mo
section
Led
w
om
e
.
will
.
discuss
.
the
er
implemen
o
tation
es,
of
r
a
in
simple
y
application
gister
doing
r
some
e
pro
ha
cessing
y
in
Therefore
a
s
CPU
mo
and
for
blinking
exe-
a
then
LED
dules,
in
There
parallel.
t
This
o
will
metho
demonstrate
whic
all
y
imp
can
ortan
v
t
i
concepts
They
of
automatically
the
up
P
start
A
the
WiS
ulation.
F
is
ramew
exe-
ork.
for
F
or
dules:
I
ConstantReporter I = Iconst
UResistiveReporter I =
R
ULinearReporter I =I +const R
PawisModule
PowerReporter
Module_Class_Members( , , 0)
0
Define_Module( )
led.h
#include <memory> <base/paModule.h>
#include "ledReporter.h"
requireCPU()
using namespace pawis;
class Led : public PawisModule {
private:
bool m_bState;
std::auto_ptr<PowerSourceAdapter>
m_pPowerAdapter;
void set(TaskControl &pa_oControl);
virtual void onStartup(); void onInit();
public:
Module_Class_Members(Led, PawisModule, 0)
};
onStartup()
onInit()
onStartup()
onInit()a
ound
mo
The
example
NED
b
File
as
The
our
mo
y
dule
NED
instan
This
tiation
y
and
one
connections
n
b
the
e-
whic
t
class.
w
send-
e
ated
en
source
eac
declarations
h
ust
other
A
are
autogenerated
describ
of
ed
ork
i
no
n
terop
the
Listing
so
application
called
ted
NED
sp
le
from
.
gates).
This
can
is
le
a
to
text
h
le
p
used
o
b
ed
y
w
the
the
under-
other
lying
no
OMNeT++
mo
framew
Y
ork
t
to
no
setup
ting
the
can
whole
of
net
n
w
de
ork
et
.
kinds
A
e
NED
C++
le
b
denes
a
t
b
hre
for
e
tation
t
wis
yp
h
es
la
of
through
ob
h
jects
6.1.2
whic
The
h
trans
are
the
setup
(pro
within
OMNeT++)
a
a
hierarc
with
h
ds
y
tains
.
C++
The
the
highest
oun
lev
and
el
It
is
e
the
w
network
y
whic
source
h
w
w
is
e
comp
use
ule
to
Lst.
connect
can
the
more
individ-
yp
ual
w
no
The
des.
dule
It
net
is
with
de
an
clared
b
in
s
a
Simply
blo
that
c
dule
k
ts
of
y
6.1.1
e
name
n
elds.
no
top
NED
mo
the
dule
le
header
to
(see
the
Lst.
is
2).
ple
See
y
also
easily
Sec.
Messages
5.3.7
h
ho
header
w
cludes
to
h
build
ramew
complex
P
net
deriv
w
class,
orks.
er
The
h
next
corresp
lo
messages
w
b
er
unicate
lev
Mo
el
the
are
le.
c
NED
omp
is
ound
l
mo
with
dules
to
de-
ol
clared
vided
with
y
the
whic
name
creates
...
C++
access
le
blo
the
c
ostx
ks.
.
They
con
com
aut
bine
-generated
other
class
comp
for
ound
describ
or
comp
simple
d
mo
dules
d-
net-
ules
orks.
and
m
s
b
e
compiled
t
same
their
a
parameters
as
and
metho
in
C++
terconnec
les.
t.
net
Simple
ork
mo
de
dules
built
are
a
the
ound
l
d-
o
(see
w
in
est
2).
lev
ou
el
dene
in
or
the
dieren
NED
t
hierarc
es
h
net
y
ork
.
des.
These
comp
are
mo
the
represen
only
the
items
w
whic
(here
h
)
ac-
instanciate
tually
y
im
um
p
er
l
the
emen
e
t
des.
functionalit
e
y
sure
.
y
Therefore
mo
they
co
are
implemen
the
in
only
erabilit
items
b
whic
w
h
en
ha
diere
v
t
e
of
individual
des.
C+
2:
+
l
co
for
de
LED
pro
from
v
.
i
a
ded
in
b
OMNeT++
y
y
the
translated
programmer.
h
That
le
means
sim
that
writing
y
b
ou
implemen
will
e
concen
can
trate
er.
on
la
the
eac
i
elds
mplemen
ecic
t
the
a
in-
t
implemen
i
Eac
on
ork
of
F
simple
a
mo
the
dules.
ed
T
is
o
whic
structure
message
y
requires
our
y
net
abstraction
w
Eac
ork
onding
no
the
des
(
y
ing
ou
y
dene
other
comp
eac
ound
commm
mo
dules
dules
Messages
i
7
n
our
simple Timer
gates:
in: App_in;
out: App_out;
endsimple
simple Ldo
endsimple
simple Battery
network
endsimple
: endnetwork
simple Config
parameters:
module endmodule ConfigFile: string;
endsimple
module LedNode
parameters:
NodeId : const;
submodules:
cpu : SimpleCpu;
led : Led;
app : App;
timer : Timer;
ldo : Ldo;
battery : Battery;
connections:nedtool
app.Led_out --> led.App_in;
app.Led_in <-- led.App_out;_n.cpp
app.Timer_out --> timer.App_in;
app.Timer_in <-- timer.App_out;
endmodule
module LedNetwork
submodules:
LedNode config : Config
parameters:
ConfigFile = "";
ln1: LedNodeLedNetwork
parameters:
NodeId = 1;
endmodule
network lednet : LedNetwork
endnetwork
Led.ned
simple SimpleCpu
endsimple
simple Led
gates:
in: App_in;
out: App_out;
endsimple
BaseMessage
simple App
gates:
in: Timer_in;
.msgin: Led_in;
opp_msgcout: Timer_out;
out: Led_out;
endsimpleariables
i
Its
T
ariables
asks
a
Ev
of
ery
ou
mo
m
dule
and
is
d
built
t
of
means
tasks
(e.g.
.
are
Eac
i
h
unique
of
whic
these
is
tasks
f
is
func-
implemen
t
ted

as
b
a
The
metho
or
d
our
inside
tasks
of
can
the
h
mo
same
d-
a
ule's
stac
class.
ery
Their
stac
name
default
can
started
b
run
e
3)
c
ar
hosen
and
freel
a
y
are
bu
resp
t
with
they
func-
m
alw
us
and
t
k
accept
con
exactly
running
one
y
parameter
one
of
e
the
are
t
ou
yp
em
e
dule
6.2
the
.
p
The
is
return
.
t
ables
y
task
p
declare
e
d.
is
o
task.
T
(see
functions
a
addi-
and
ur
wing
k
in
o
Lst.
that
3).
eginning
The
metho
sho
name
parameter
ams
holds
call.
an
e
ob
cre-
ject
the
whic
to
h
second
is
to
a
and
unique
They
represen
are
tation
The
of
k
the
and
task.
call
It
c
con
task
tains
de
the
blo
status
a
and
an
con
erter,
text
softwar
of
the
the
routing
task
of
as
col).
w
dule
ell
ha
as
man
some
mix
task-related
soft
metho
as
ds
All
lik
the
e
er
from
the
(see
instance
b
shared
elo
.
w).
ev
T
when
asks
metho
are
ni
virtually
time
r
or
unning
i
in
h
parallel
ev
as
use
de-
,
scrib
cal
ed
the
in
that
Sec.
has
5.
stac
3.2.
is
Their
set
e
size,
x
,
e
oer
cution
parameter.
lea
alue
v
n
es
A
at
b
certain
t
(dened)
t
p
T
oin
jus
ts
the
(yie
are
ld).
the
The
(see
sim
the
ulation
task
k
p
ernel
for
then
out
hands
that
o
can
v
an
er
ytime
con
new
trol
parameter
to
d
other
to
tasks.
prop
The
e).
execution
third
of
oin
the
ob
task
for
is
pa-
then
ely
con
b
tin

ued
in
where
in
it
ond
w
a
as
is
i
in
n
describ
terrupted.
w.
P
es
oin
ys
ts
whic
where
the
the
in
execution
e
is
tly
transf
do
e
c
rr
(e.g.
e
t
d
mer,
to
AD
other
v
tasks
...)
are
some
ˆ
e
App
on
delay
CPU
)
the
ˆ
la
dule
er
pr
y
e
proto
dic
Within
ate
mo
)
y
ˆ
can
mo
v
delay
as
,
y
pr
and
e
hardw
dic
and
ate
w
)
tasks
ˆ
y
WiS
need.
ˆ
tasks
A
access
ˆ
m
P
it.
ˆ
v
the
of
and
mo
of
class
with
whic
v
are
ari-
amongst
ous
tasks
com
This
binations
s
of
en
parameter
ossible
t
the
yp
task
e
d
s
run
(see
ng
Sec.
ultiple
6.3.2).
s
Please
F
see
v
the
r
Do
-
x
whic
ygen
are
do
to
cumen
ery
tation
instance
of
the
tation
k
for
i.e.
detail
lo
s
v
and
within
the
metho
exact
Note
paramete
ev
r
task
lists
its
of
wn
these
k,
metho
h
ds.
limited.
Within
o
ev
the
ery
k
task
the
y
of
ou
nishing)
can
(e.g.
ha
an
v
tional
e
Its
lo
v
ops,
c
Implemen
re
and
tly
3:
32kB.
conditions,
tas
..
can
.
e
Note
in
that
w
y
dieren
ou
w
m
ys.
ust
asks
include
should
yield
t
p
from
oin
b
ts
on
as
started
describ
rom
ed
ondition
ab
d
o
Lst.
v
using
e
c
or
y
return
metho
from
an
the
ar
metho
in
d
p
after
ams
p
ait
erforming
Note
the
this
desired
tion
job.
b
Other-
used
wise
ywhere
y
an
our
to
C++
ate
metho
tasks.
d
rst
will
is
nev
metho
er
(using
giv
macro
e
cast
bac
the
k
er
con-
yp
trol
The
to
and
the
parameters
sim
p
ulation
ters
k
w
ernel
jec
(this
s
is
input
wh
output
y
rameters,
w
ectiv
e
.
call
can
this
e
co
not
op
and
erativ
discussed
e
detail
m
functional
ultitasking).
terfaces.
When
sec
the
kind
metho
t
d
s
exits
creation
(e.g.
using
with
tional
Listing
terfaces
),
is
the
ed
tas
elo
k
A
is
to
nished.
is
Ev
a
ery
non-blo
task
king
m
h
o
that
dels
started
either
runs
a
parallel
de
indep
dic
n
ate
n
d
.
har
starter
dwar
8
e
b
startTask() registerIsr()
registerFunctionalInterface()
TaskControl& void
App::myMain() App::onTimer()
onInit()
startTask( , ,
, )
invoke()
ParameterList
0
startTask()
wait(
waitUntil(
waitOrUntil(
app.cpp
requireCpu()
#include "app.h"
requireCpuUntil()
Define_Module(App);
requireCpuOrUntil()
void App::onInit() {
invoke() invokeReturn() // init member variables
// ...
// register ISRs
registerIsr(CAST_TASK(App::onTimer), 17,
"timer_isr");
TaskControl // schedule initial task
startTask("main",CAST_TASK(App::myMain),0,0);
}if
switch
void App::onTimer(TaskControl &pa_oControl) {
// do our internal work
m_bLedState = !m_bLedState;
// set the LED
pa_oControl.requireCpu(0.5, 0.0, 0.2, 0.3,
return 0.001f);invoke("Led", "set", m_bLedState);
// setup new timer event
pa_oControl.requireCpu(0.5, 0.0, 0.3, 0.2,
0.005f);invoke("Timer", "start",
(unsigned int)(20));
++m_nCounter;
}
// predicate function for requireCpuOrUntil()
bool App::done() {
// test an external condition,t
o
w
.
w
from
reserv
Timer
param-
dule
caller
mo
.
WiS
the
A
v
P
are
the
.
of
x
tation
b
Implemen
terface
4:
of
Listing
the
.
inter-
erloaded
in
v
eral
o
for
an
don'
with
the
called
in
again
its
is
e,
4)
is
Lst.
arameters
(see
c
liseconds
plies
mil
e
in
ob
y
e
dela
parameter
the
that
ecifying
p
sp
out
an
are
requires
of
h
f
whic
resp
,
return
enience
functions
v
e
con
or
or
cumen
F
functional
terface.
ed
in
task
functional
whic
another
this
of
and
cation
That
o
blo
v
the
in
also
next
parameters
the
The
for
cation
reused
t
e
the
b
v
can
Alternativ
t
b
jec
with
ob
template
The
cation
es.
n
yp
are
t
of
parameter
e
templated
ams
with
ar
ds
(see
metho
3).
erloaded
ultiple
v
v
o
for
the
binations
6.3
ters
F
ll
unctional
o
In
yp
t
alues.
erfaces
v
The
y
Timer
ha
as
setup
w
list.
ell
please
as
xygen
the
of
LED
er
oer
terface
a
o
functional
another
in
a
terface
created
eac
d
h
is
whic
cuted.
h
d
is
to
used
of
b
tin
y
that
the
a
Application
king
(red
calls
arro
6.3.3
ws
task
i
ws
n
sup-
Fig.
a
6,
in
metho
functional
d
v
or
caller
in
parameter
L
e
s
one
t.
o
1
tioned
and
v
f
is
in
a
Lst.
t
4).
created
6.3.1
parameter(s)
Setup
is
The
value
functional
d.
in
v
terface
the
m
is
ust
sumed,
b
parame
e
This
registered
o
in
d
t
fac
(and
e
not
ar
in
in
an
p
)
ams
with
'ing
relev
for
name
Lst.
not
There
metho
m
d
o
is
erloaded
multiInvokable
ersions
This
onsible
(see
sev
Lst.
com
4).
o
The
parame-
rst
as
parameter
e
is
as
a
meth-
string
ds
with
t
the
ed
name
v
of
This
the
con
in
enience
terface
that
(referred
ou
to
t
b
v
y
to
other
a
mo
eter
dules).
F
The
details
second
consult
parame
Do
t
do
e
tation
r
is
is
Whenev
a
a
casted
in
p
is
oin
v
ter
k
to
from
the
h
task
dule,
metho
new
d.
is
The
and
third
metho
parameter
(here
tells
)
the
e
framew
e
ork,
When
if
metho
this
returns,
functional
returns
in
o
terface
execution
is
the
i
con
n
ues.
tended
means
to
calle
b
alw
e
ys
in
c
v
(see
ok
oth
ed
of
m
).
ultiple
P
times
The
in
to
paralle
sho
l.
ho
When
to
se
ply
t
to
to
fun
.
tional
the
terface.
framew
rst
ork
in
do
in
es
o
additional
to
sanit
sup-
y
one
c
of
hec
yp
ks
the
to
Here
w
of
arn
ab
the
v
user
men
of
o
m
erloaded
ultiple
ersions
in
from
v
used.
o
ely
c
transferred
ations.
jec
6.3.2
could
I
e
n
and
v
he
o
added
cat
the
ion
typ
Other
parameters
mo
the
dules
metho
can
When
then
in
in
o
v
returns
ok
input
e
list
the
co
functional
-
in-
i.e.
terface
added
with
ters
the
cleared.
metho
means
d
the
memory
wnership
mo
9
dule
m
// e.g. ADC has finished conversion invoke()
if (m_nCounter > 2) {
return true; invoke()
}
return false;
}
void App::myMain(TaskControl &pa_oControl) {
App::onTimer()
// ...
// start the LED toggling
Led.setonTimer(pa_oControl);
bool// Before Start waiting 50ms or the predicate
invoke()pa_oControl.requireCpuOrUntil(0.1f,0.0f,0.0f,
0.9f, 0.05, CAST_PREDICATE(App::done));
// main program running infinitely ParameterList
while (true) {
pa_oControl.setCpuState( add< >( )
new SimpleCpu::CpuState(
SimpleCpu::CpuState::pmSleep));
pa_oControl.requireCpu(/ ... /, 1.0e-6);* *
}
}
delete
invoke()
ParameterList
Timer.start
unsigned intset()
startTimer()
invoke()
timer.cpp
onStartup() onInit() #include "timer.h"
registerFunctionalInterface( , ,
) / ... /* *
void Timer::onStartup() {
// register the functional interface
registerFunctionalInterface("start",
CAST_TASK(Timer::startTimer), false);
}
false
void Timer::onInit() {
// setup interrupt source
m_oTimerSource.setName("timer");
// register our interrupt source
registerIntSource(m_oTimerSource);
// Create power source adapter and reporter
invoke( , m_pPowerAdapter.reset(new PowerSourceAdapter(
getContext().findPowerSource("ldo"),, , ) onTimer() *
LdoPowerSource::src3V3, 0, true));
m_pPowerAdapter->setReporter(invoke()
new LinearReporter( this));*invokeReturn<typename>()
// Initial consumption
m_pPowerAdapter->
getReporter<LinearReporter>()->
set(0.0f, / infinite /);* *
TaskControl }
void Timer::countTimer(TaskControl &pa_oControl) {
Timer::startTimer() // start the timertion
where
whic
the
predicate
when
trigger
gh
ol
hi
ow
go
y
will
tasks
5
ait
nr.
the
bit
the
the
set
where
has
ort
With
p
oth,
input
oin
8-bit
6.4.3
ital
separate
dig
terface
a
.
is
p
e.
d
k
second
li
start
ok
o
lo
long
could
to
de
mo
co
there
are
across
w
king
rm
e
h
Soft
suc
tly
w
5.3.3
ho
is
ws
from
sho
ts
5
m
Lst.
func-
condition.
5.3.4
exit
ilar
second
used,
as
the
used
call
is
LED's
timeout
t
certain
time
a
run
hangs
entage
innite
ac
oid
e
v
activ
a
to
o
is
T
reside
.
where
)
cla
...
v
transmission,
t
nished
oundaries.
has
,
PHY
means
the
er
hed,
they
reac
task
is
In
alue
is
v
ed
ter
As
coun
w
a
y
(e.g.
y
condition
rst
external
a
an
The
for
t
aiting
sets
w
a
is
b
h
i
c
describ
whi
is
task
c
a
entage
del
memory
mo
entage
to
d
w
ct.
ho
s
The
wice.
implemen
eort
tation
deled,
of
the
a
is
f
exec
unc
b
t
CPU
i
certain
onal
dic
in
p
t
er
e
p
rf
This
a
aluated
ce
com
is
The
sho
return
wn
and
in
tin
Lst.
Usually
4.
has
The
the
(previously
l
regis-
is
tered)
deriv
metho
s
d
the
ws
tioned
is
can
executed
en
up
dule
on
that
the
and
in
blo
v
whic
o
sim
cation
elapses
of
are
the
There-
functional
yield
in
within
terface
d.
sho
are
.
w
This
dela
extracts
deled
the
already
rst
Sec.
parameter
rigg
(
in
example
task
)
for
from
satised
the
task.
parameter
deled
list
w
held
The
b
is
y
and
the
to
The
the
ob
task
jec
f
t
onal
and
n
stores
class
it
er
to
i
a
is
mem
the
b
used
e
the
r
CPU
v
in
ariable.
CPU
It
ulated
is
p
imp
inte-
ortan
er
t
at
that
c
the
c
t
er
yp
c
e
dur
(supplie
d
d
ob
as
the
a
in
template
3
parameter)
used
m
t
ust
w
exactly
set
ma
is
t
t
c
mo
h
of
t
mer.
o
for
the
to-
one
ti
sup-
principally
plied
fore
to
F
the
whic
acc
til
or
conditi
di
end,
ng
er
).
ger
.
c
Secondly
pr
a
entage
new
ess
task
c
i
ontr
s
is
created
v
with
as
3,
as
.
is
It
e.
will
function
run
to
in
a
p
stop
a
also
r
con
al
ue
lel
.
(and
the
therefore
function
indep
to
enden
within
tly)
same
t
du
o
e
the
it
functional
used.
in-
a
terface
ed
task
s
whic
from
h
(e.g.
allo
a
ws
ailable
the
)
metho
ou
d
implemen
to
predic
return
function
immediately
mo
.
b
6.4
Note
Timing
b
6.4.1
m
H
already
ar
are
dw
c
ar
functions
e
h
tasks
that
As
ula-
stated
time
i
whenev
n
they
Sec.
us
5.3.5
d.
hardw
fore
are
are
task
p
s
ts
mo
the
del
metho
time
6.4.2
dela
w
ys
tasks
with
soft
the
are
metho
a
ds
y
Lst.
mo
delay
dieren
(see
as
,
describ
tion
in
pr
5.3.5.
e
T
dic
er
ate
stated
function
Sec.
func-
one
and
can
tion
ait
delay
a
i
condition
pr
b
e
another
dic
This
ate
mo
function
b
ond
t
.
o
The
tasks.
rst

function
task
dela
started
ys
As
execution
uses
for
function.
a
w
constan
for
t
trigger.
amoun
second
t
implemen
of
a
time,
unc
the
i
second
in
function
a
dela
d
ys
a
execution
me
un
b
til
v
a
r
certain
able
condition
h
(tested
queried
b
y
y
predicate
the
tion
predicate
w
function)
th
is
the
fullled.
6.5
The
As
third
ed
form
Sec.
returns
the
after
usage
a
sim
constan
with
t
to
dela
er
y
entage
or
ger
un
p
ti
c
l
o
the
sim-
condition
er
is
entage
true,
ac-
whic
ess
he
p
v
c
er
ow
happ
ontr
ens
is
r
ation
st.
metho
In
from
the
metho
task
je
me
In
t
metho
ho
function
d
L
c
t.
in
this
Lst.
is
4
t
the
A
timer
rst
dela
soft
y
are
is
to
realized
the
with
state
the
mo
and
and
metho
he
d.
call
The
dels
parameter
setup
of
the
y
i
(and
ate
dela
useful
is
tasks
a
the
so
tal
called
u
pr
on
e
is
di-
determinable
c
e-
ate
its
fun
.
c
or
ti
tasks
on
h
whic
un
h
a
tells
external
the
on
sim
their
ula
the
t
p
i
c
on
inte
k
e
ernel
er
whether
entage
the
at
(mo
p
deled)
c
job
memory
has
c
nished
ol
or
er
not
entage
(see
c
bined
10
).
ate
m_pPowerAdapter->getReporter<LinearReporter>(). true false
set(2.2e-3, 1.5e6); wait(Or)Until()
// show that we are running
setFillColor("#FF0000");
// wait for the delay TaskControl::Predicate
pa_oControl.wait(m_tDelay);
TaskControl::ModulePredicate
// timer has run off
m_pPowerAdapter->getReporter<LinearReporter>().
set(1.2e-3, 1.5e6);
wait() wait(Or)Until()// show that the timer ran off
setFillColor("#00FF00");
// issue an interrupt request
pa_oControl.intRequest(m_oTimerSource);
}
void Timer::startTimer(TaskControl &pa_oControl) {
// get the delay parameter and calc the seconds
m_tDelay = pa_oControl.inParams()->
get<unsigned int>(0) / 1000.0f;
// start parallel task doing the delay
startTask(CAST_TASK(Timer::countTimer), 0, 0);
}
onInit() waitUntil()Timer::startTimer()
Timer.set 0
TaskControl&
waitUntil()
invoke()
requireCpu(
startTask()
, ,
, , )
TaskControl&
App::onTimer()
requireCpu()
wait( ) waitUntil( )
waitOrUntil( , ) requireCpuUntil( ,
, ,
, )
waitUntil()
requireCpuOrUntil()
Timer::countTimer() App::myMain()
wait()
wait(Or)Until()
requireCpu(Or)Until()
App::done() P1IN
wait(Or)Until()

Un pour Un
Permettre à tous d'accéder à la lecture
Pour chaque accès à la bibliothèque, YouScribe donne un accès à une personne dans le besoin