TinyOS学习笔记(2)
Module of Sense Application
SenseM.nc
------------------------------------------------
|module SenseM {
| }
| uses {
| interface Timer;
| interface ADC;
| interface StdControl as ADCControl;
| interface Leds;
| }
|}
------------------------------------------------
◆提供StdControl接口
◆使用Timer、ADC、StdControl、Leds接口
◇nesC程序中可以使用同一个接口的多个实例
●interface StdControl as ADCControl
●ADCControl是StdControl的实例
◇不提供实例名,则实例名与接口名相同
●interface ADC相当于interface ADC as ADC
Configuration of Sense Application
Sense.nc
--------------------------------------------------
|configuration Sense {
| // this module does not provide any interface
|}
|implementation
|{
| components Main, SenseM, LedsC, TimerC, Photo;
|
| Main.StdControl -> SenseM;
| Main.StdControl -> TimerC;
|
| SenseM.ADC -> Photo;
| SenseM.ADCControl -> Photo;
| SenseM.Leds -> LedsC;
| SenseM.Timer -> TimerC.Timer[unique("Timer")];
|}
--------------------------------------------------
◆不提供任何接口
◆使用Main、SenseM、LedsC、TimerC、Photo模块
◆连接Main.StdControl接口到SenseM.StdControl和TimerC.StdControl
◆连接SenseM.ADC接口到Photo.ADC
◆连接SenseM.ADCControl到Photo.StdControl
◆参数化接口
◇组件可以使用相同接口的不同实例,并分别为其命名
provides {
interface StdControl as fooControl;
interface StdControl as barControl;
}
◇参数化接口允许组件通过运行时或编译时参数值使用多个该接口的实例
provides interface Timer[uint8_t id];
◇每个Timer可以有256实例,每个实例对应一个8位数字
◇unique、uniqueCount函数
●产生一个唯一的8位数字与参数关联。
●unique("Timer")是产生一个唯一的数字与Timer串关联;unique("Timer")与unique("MyTimer")可能产生相同的数;
●uniqueCount返回与参数关联的数的个数
SenseM.nc
------------------------------------------------
|module SenseM {
| provides
{
| interface
StdControl;
| }
| uses {
| interface Timer;
| interface ADC;
| interface StdControl as ADCControl;
| interface Leds;
| }
|}
------------------------------------------------
◆提供StdControl接口
◆使用Timer、ADC、StdControl、Leds接口
◇nesC程序中可以使用同一个接口的多个实例
●interface StdControl as ADCControl
●ADCControl是StdControl的实例
◇不提供实例名,则实例名与接口名相同
●interface ADC相当于interface ADC as ADC
Configuration of Sense Application
Sense.nc
--------------------------------------------------
|configuration Sense {
| // this module does not provide any interface
|}
|implementation
|{
| components Main, SenseM, LedsC, TimerC, Photo;
|
| Main.StdControl -> SenseM;
| Main.StdControl -> TimerC;
|
| SenseM.ADC -> Photo;
| SenseM.ADCControl -> Photo;
| SenseM.Leds -> LedsC;
| SenseM.Timer -> TimerC.Timer[unique("Timer")];
|}
--------------------------------------------------
◆不提供任何接口
◆使用Main、SenseM、LedsC、TimerC、Photo模块
◆连接Main.StdControl接口到SenseM.StdControl和TimerC.StdControl
◆连接SenseM.ADC接口到Photo.ADC
◆连接SenseM.ADCControl到Photo.StdControl
◆参数化接口
◇组件可以使用相同接口的不同实例,并分别为其命名
provides {
interface StdControl as fooControl;
interface StdControl as barControl;
}
◇参数化接口允许组件通过运行时或编译时参数值使用多个该接口的实例
provides interface Timer[uint8_t id];
◇每个Timer可以有256实例,每个实例对应一个8位数字
◇unique、uniqueCount函数
●产生一个唯一的8位数字与参数关联。
●unique("Timer")是产生一个唯一的数字与Timer串关联;unique("Timer")与unique("MyTimer")可能产生相同的数;
●uniqueCount返回与参数关联的数的个数
浙公网安备 33010602011771号