[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rwth/mobnets/SensorMeter
SensorMeterC.nc, NONE, 1.1 SensorMeterM.nc, NONE, 1.1
Krisakorn Rerkrai
krerkrai at users.sourceforge.net
Wed Jan 16 13:51:14 PST 2008
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rwth/mobnets/RemoteLU
Makefile, NONE, 1.1 RemoteLuC.nc, NONE, 1.1 RemoteLuM.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/rwth/mobnets/ULLA
AMTypes.h, NONE, 1.1 Attribute.h, NONE, 1.1 CommandInf.nc,
NONE, 1.1 CommandProcessorC.nc, NONE, 1.1 CommandProcessorM.nc,
NONE, 1.1 Condition.nc, NONE, 1.1 ConditionM.nc, NONE,
1.1 EventProcessorC.nc, NONE, 1.1 EventProcessorM.nc, NONE,
1.1 GetInfoIf.nc, NONE, 1.1 InfoRequest.nc, NONE, 1.1 LLAC.nc,
NONE, 1.1 LLAM.nc, NONE, 1.1 LinkEstimation.nc, NONE,
1.1 LinkProviderIf.nc, NONE, 1.1 Lu.h, NONE, 1.1 MemAlloc.h,
NONE, 1.1 MemAlloc.nc, NONE, 1.1 NotificationTimerC.nc, NONE,
1.1 NotificationTimerM.nc, NONE, 1.1 ProcessCmd.nc, NONE,
1.1 ProcessData.nc, NONE, 1.1 QauAdapterC.nc, NONE,
1.1 QauAdapterM.nc, NONE, 1.1 Query.nc, NONE,
1.1 QueryAssemblerC.nc, NONE, 1.1 QueryAssemblerM.nc, NONE,
1.1 QueryM.nc, NONE, 1.1 QueryProcessor.h, NONE,
1.1 QueryProcessorC.nc, NONE, 1.1 QueryProcessorM.nc, NONE,
1.1 RNTimer.nc, NONE, 1.1 ReadFromStorage.nc, NONE,
1.1 ReceivePacket.nc, NONE, 1.1 RequestUpdate.nc, NONE,
1.1 ScanLinks.h, NONE, 1.1 ScanMsg.h, NONE, 1.1 Sensing.nc,
NONE, 1.1 SensorMeterC.nc, NONE, 1.1 SensorMeterM.nc, NONE,
1.1 StorageIf.nc, NONE, 1.1 TestLinkUser.nc, NONE,
1.1 Transceiver.nc, NONE, 1.1 TransceiverM.nc, NONE,
1.1 ULLAStorageC.nc, NONE, 1.1 ULLAStorageM.nc, NONE,
1.1 UQLCmdMsg.h, NONE, 1.1 UcpIf.nc, NONE, 1.1 UllaAllocC.nc,
NONE, 1.1 UllaAllocM.nc, NONE, 1.1 UllaCoreC.nc, NONE,
1.1 UllaCoreM.nc, NONE, 1.1 UllaLinkProviderC.nc, NONE,
1.1 UllaLinkProviderM.nc, NONE, 1.1 UllaQuery.h, NONE,
1.1 UllaStorage.h, NONE, 1.1 UqpIf.nc, NONE,
1.1 WriteToStorage.nc, NONE, 1.1 msg_type.h, NONE, 1.1 ulla.h,
NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/rwth/mobnets/SensorMeter
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30191
Added Files:
SensorMeterC.nc SensorMeterM.nc
Log Message:
--- NEW FILE: SensorMeterC.nc ---
/*
* Copyright (c) 2007, RWTH Aachen University
*/
/**
*
* Sensor Meter - senses the physical world e.g. light, temperature, etc.
* It is used for the SmartHome Monitoring application.
*
<p>
* @author Krisakorn Rerkrai <kre at mobnets.rwth-aachen.de>
**/
#ifndef OSCOPE
#define OSCOPE
#endif
configuration SensorMeterC {
provides {
interface StdControl;
interface RequestUpdate;
}
}
implementation {
components
Main
, SensorMeterM
, EventProcessorC
#ifdef ULLA_STORAGE
, StorageC
#endif
, TimerC
, LedsC
#ifdef OSCOPE
, OscopeC
#endif
#ifdef TELOS_SENSOR
, HumidityC
, HamamatsuC
, InternalTempC
, InternalVoltageC
#endif
//, GenericComm as Comm
;
Main.StdControl -> SensorMeterM;
Main.StdControl -> TimerC;
//Main.StdControl -> Comm;
#ifdef OSCOPE
Main.StdControl -> OscopeC;
#endif
#ifdef TELOS_SENSOR
Main.StdControl -> HamamatsuC;
Main.StdControl -> InternalTempC;
Main.StdControl -> InternalVoltageC;
#endif
StdControl = SensorMeterM;
SensorMeterM.Timer -> TimerC.Timer[unique("Timer")];
SensorMeterM.Leds -> LedsC;
RequestUpdate = SensorMeterM;
SensorMeterM.AttributeEvent -> EventProcessorC.ProcessEvent[0];
SensorMeterM.LinkEvent -> EventProcessorC.ProcessEvent[1];
SensorMeterM.CompleteCmdEvent -> EventProcessorC.ProcessEvent[2];
#ifdef ULLA_STORAGE
SensorMeterM.WriteToStorage -> StorageC;
#endif
#ifdef TELOS_SENSOR
/* Sensors */
SensorMeterM.HumidityControl -> HumidityC;
SensorMeterM.Humidity -> HumidityC.Humidity;
SensorMeterM.Temperature -> HumidityC.Temperature;
SensorMeterM.TSR -> HamamatsuC.TSR;
SensorMeterM.PAR -> HamamatsuC.PAR;
SensorMeterM.InternalTemperature -> InternalTempC;
SensorMeterM.InternalVoltage -> InternalVoltageC;
SensorMeterM.HumidityError -> HumidityC.HumidityError;
SensorMeterM.TemperatureError -> HumidityC.TemperatureError;
#endif
#ifdef OSCOPE
SensorMeterM.OHumidity -> OscopeC.Oscope[0];
SensorMeterM.OTemperature -> OscopeC.Oscope[1];
SensorMeterM.OTSR -> OscopeC.Oscope[2];
SensorMeterM.OPAR -> OscopeC.Oscope[3];
SensorMeterM.OInternalTemperature -> OscopeC.Oscope[4];
SensorMeterM.OInternalVoltage -> OscopeC.Oscope[5];
#endif
}
--- NEW FILE: SensorMeterM.nc ---
/*
* Copyright (c) 2007, RWTH Aachen University
*/
/**
*
* Implementation of SersorMeterC.nc
<p>
* @author Krisakorn Rerkrai <kre at mobnets.rwth-aachen.de>
**/
includes UQLCmdMsg;
includes UllaQuery;
module SensorMeterM {
provides {
interface StdControl;
interface RequestUpdate;
interface GetInfoIf;
}
uses {
interface Timer;
interface Leds;
interface ProcessCmd as AttributeEvent;
interface ProcessCmd as LinkEvent;
interface ProcessCmd as CompleteCmdEvent;
//interface Condition;
#ifdef ULLA_STORAGE
interface WriteToStorage;
#endif
#ifdef TELOS_SENSOR
/* Sensors */
interface SplitControl as HumidityControl;
interface ADC as Humidity;
interface ADC as Temperature;
interface ADC as TSR;
interface ADC as PAR;
interface ADC as InternalTemperature;
interface ADC as InternalVoltage;
interface ADCError as HumidityError;
interface ADCError as TemperatureError;
#endif
#ifdef OSCOPE
interface Oscope as OHumidity;
interface Oscope as OTemperature;
interface Oscope as OTSR;
interface Oscope as OPAR;
interface Oscope as OInternalTemperature;
interface Oscope as OInternalVoltage;
#endif
}
}
/*
* Module Implementation
*/
implementation
{
enum {
OSCOPE_DELAY = 10,
};
norace uint16_t humidity, temperature, tsr, par, itemp, ivolt;
norace uint8_t state;
norace uint16_t numSamples;
norace uint16_t timeInterval;
norace uint8_t actionIndex;
// module scoped variables
TOS_MsgPtr msg;
int8_t pending;
QueryPtr query;
ResultTuple rt;
ResultTuplePtr rtp;
/* task declaration */
task void getHumidity();
task void getTemperature();
task void getTSR();
task void getPAR();
task void getInternalTemperature();
task void getInternalVoltage();
/* function declaration */
//result_t addToResultTuple(ResultTuplePtr result);
task void SimDataReady();
void CheckCounter();
command result_t StdControl.init() {
atomic {
//state = HUMIDITY;
rtp = &rt;
actionIndex = 0;
}
//call Leds.init();
//call Leds.set(0);
#ifdef TELOS_SENSOR
call HumidityControl.init();
#endif
return (SUCCESS);
}
#ifdef TELOS_SENSOR
event result_t HumidityControl.initDone() {
return SUCCESS;
}
#endif
/* start the sensorcontrol component */
command result_t StdControl.start() {
#ifdef TELOS_SENSOR
call HumidityControl.start();
#endif
return SUCCESS;
}
#ifdef TELOS_SENSOR
event result_t HumidityControl.startDone() {
call HumidityError.enable();
call TemperatureError.enable();
//call Timer.start( TIMER_ONE_SHOT, 250 );
return SUCCESS;
}
#endif
/* stop the sensorcontrol component */
command result_t StdControl.stop() {
#ifdef TELOS_SENSOR
call HumidityControl.stop();
#endif
call Timer.stop();
return SUCCESS;
}
#ifdef TELOS_SENSOR
event result_t HumidityControl.stopDone() {
call HumidityError.disable();
call TemperatureError.disable();
return SUCCESS;
}
#endif
// fill in the result tuple when dataReady, and signal receiveTuple
command result_t RequestUpdate.execute(QueryPtr pq) {
dbg(DBG_USR1, "Request update starts\n");
atomic {
query = pq;
actionIndex = 0;
state = pq->fields[actionIndex];
numSamples = pq->nsamples;
timeInterval = pq->interval;
//rtp->qid = pq->qid;
rtp->numFields = pq->numFields;
rtp->numConds = pq->numConds;
}
call Timer.start( TIMER_ONE_SHOT, OSCOPE_DELAY );
return SUCCESS;
}
event result_t Timer.fired() {
//call Leds.yellowToggle();
dbg(DBG_USR1, "Timer fired\n");
// set a timeout in case a task post fails (rare)
//call Timer.start(TIMER_ONE_SHOT, 100);
switch(state) {
case HUMIDITY:
post getHumidity();
break;
case TEMPERATURE:
post getTemperature();
break;
case TSRSENSOR:
post getTSR();
break;
case PARSENSOR:
post getPAR();
break;
case INT_TEMP:
post getInternalTemperature();
break;
case INT_VOLT:
post getInternalVoltage();
break;
case LED_ON:
call Leds.yellowOn();
break;
case LED_OFF:
call Leds.yellowOff();
break;
//default:
// call Timer.start(TIMER_ONE_SHOT, 10);
} // switch case
return SUCCESS;
}
default event ResultTuplePtr RequestUpdate.receiveTuple(ResultTuplePtr rtr) {
return rtr;
}
event result_t AttributeEvent.done(TOS_MsgPtr pmsg, result_t status) {
return SUCCESS;
}
event result_t LinkEvent.done(TOS_MsgPtr pmsg, result_t status) {
return SUCCESS;
}
event result_t CompleteCmdEvent.done(TOS_MsgPtr pmsg, result_t status) {
return SUCCESS;
}
/*------------------------------- Put data ------------------------------------*/
task void putHumidity() {
#ifdef OSCOPE
call OHumidity.put(humidity);
#endif
// fill in tuple here
rtp->fields[actionIndex] = HUMIDITY;
rtp->data[actionIndex] = humidity;
//call Leds.yellowToggle();
CheckCounter();
}
task void putTemperature() {
#ifdef OSCOPE
call OTemperature.put(temperature);
#endif
rtp->fields[actionIndex] = TEMPERATURE;
rtp->data[actionIndex] = temperature;
//call Leds.greenToggle();
CheckCounter();
}
task void putTSR() {
#ifdef OSCOPE
call OTSR.put(tsr);
//call Leds.greenToggle();
#endif
rtp->fields[actionIndex] = TSRSENSOR;
rtp->data[actionIndex] = tsr;
CheckCounter();
}
task void putPAR() {
#ifdef OSCOPE
call OPAR.put(par);
#endif
rtp->fields[actionIndex] = PARSENSOR;
rtp->dummy = 0xFF;
rtp->data[actionIndex] = par;
CheckCounter();
}
task void putIntTemp() {
#ifdef OSCOPE
call OInternalTemperature.put(itemp);
#endif
rtp->fields[actionIndex] = INT_TEMP;
rtp->data[actionIndex] = itemp;
CheckCounter();
}
task void putIntVoltage() {
#ifdef OSCOPE
call OInternalVoltage.put(ivolt);
#endif
rtp->fields[actionIndex] = INT_VOLT;
rtp->data[actionIndex] = ivolt;
CheckCounter();
}
task void getHumidity() {
#ifdef TELOS_SENSOR
call Humidity.getData();
#else
post SimDataReady();
#endif
}
task void getTemperature() {
#ifdef TELOS_SENSOR
call Temperature.getData();
#else
post SimDataReady();
#endif
}
task void getTSR() {
#ifdef TELOS_SENSOR
call TSR.getData();
#else
post SimDataReady();
#endif
}
task void getPAR() {
#ifdef TELOS_SENSOR
call PAR.getData();
#else
post SimDataReady();
#endif
}
task void getInternalTemperature() {
#ifdef TELOS_SENSOR
call InternalTemperature.getData();
#else
post SimDataReady();
#endif
}
task void getInternalVoltage() {
#ifdef TELOS_SENSOR
call InternalVoltage.getData();
#else
post SimDataReady();
#endif
}
#ifdef TELOS_SENSOR
async event result_t Humidity.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
humidity = data;
post putHumidity();
return SUCCESS;
}
event result_t HumidityError.error(uint8_t token) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
humidity = 0;
post putHumidity();
return SUCCESS;
}
async event result_t Temperature.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
temperature = data;
post putTemperature();
//state = TSRSENSOR;
return SUCCESS;
}
event result_t TemperatureError.error(uint8_t token) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
temperature = 0;
post putTemperature();
return SUCCESS;
}
async event result_t TSR.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
tsr = data;
post putTSR();
return SUCCESS;
}
async event result_t PAR.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
par = data;
post putPAR();
return SUCCESS;
}
async event result_t InternalTemperature.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
itemp = data;
post putIntTemp();
return SUCCESS;
}
async event result_t InternalVoltage.dataReady(uint16_t data) {
//struct QueryMsg *query = (struct QueryMsg *) msg->data;
ivolt = data;
post putIntVoltage();
return SUCCESS;
}
#endif
/*------------------------------- Simulation Results ---------------------------*/
#ifdef PC_PLATFORM
task void SimDataReady() {
dbg(DBG_USR1, "Simulate Data\n");
switch(state) {
case HUMIDITY:
dbg(DBG_USR1, "Simulate HUMIDITY %d\n", actionIndex);
humidity = 10;
post putHumidity();
break;
case TEMPERATURE:
dbg(DBG_USR1, "Simulate TEMPERATURE %d\n", actionIndex);
temperature = 11;
post putTemperature();
break;
case TSRSENSOR:
dbg(DBG_USR1, "Simulate TSRSENSOR %d\n", actionIndex);
tsr = 12;
post putTSR();
break;
case PARSENSOR:
dbg(DBG_USR1, "Simulate PARSENSOR %d\n", actionIndex);
par = 13;
post putPAR();
break;
case INT_TEMP:
dbg(DBG_USR1, "Simulate INT_TEMP %d\n", actionIndex);
itemp = 14;
post putIntTemp();
break;
case INT_VOLT:
dbg(DBG_USR1, "Simulate INT_VOLT %d\n", actionIndex);
ivolt = 15;
post putIntVoltage();
break;
}
//post SimDataReady();
}
#endif
void CheckCounter() {
dbg(DBG_USR1, "CheckCounter actionIndex=%d numF=%d\n", actionIndex,rtp->numFields);
actionIndex++;
if (actionIndex >= rtp->numFields) {
rtp->qid = (uint8_t)numSamples;
dbg(DBG_USR1, "QID = %d\n", numSamples);
// send results back to UQP
signal RequestUpdate.receiveTuple(rtp);
actionIndex = 0;
numSamples--;
}
state = query->fields[actionIndex];
if (numSamples > 0) {
if (actionIndex == 0) {
dbg(DBG_USR1, "***start next interval\n");
call Timer.start(TIMER_ONE_SHOT, timeInterval);
}
else {
dbg(DBG_USR1, "---go to next attribute\n");
call Timer.start(TIMER_ONE_SHOT, OSCOPE_DELAY);
}
}
}
/*------------------------------- Result Tuple ---------------------------------*/
/*------------------------------- ULLA Storage ---------------------------------*/
#ifdef ULLA_STORAGE
event result_t WriteToStorage.writeDone(uint8_t *data, uint32_t bytes, result_t ok) {
dbg(DBG_USR1,"WriteToStorage write done\n");
return SUCCESS;
}
#endif
} // end of implementation
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rwth/mobnets/RemoteLU
Makefile, NONE, 1.1 RemoteLuC.nc, NONE, 1.1 RemoteLuM.nc, NONE, 1.1
- Next message: [Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/rwth/mobnets/ULLA
AMTypes.h, NONE, 1.1 Attribute.h, NONE, 1.1 CommandInf.nc,
NONE, 1.1 CommandProcessorC.nc, NONE, 1.1 CommandProcessorM.nc,
NONE, 1.1 Condition.nc, NONE, 1.1 ConditionM.nc, NONE,
1.1 EventProcessorC.nc, NONE, 1.1 EventProcessorM.nc, NONE,
1.1 GetInfoIf.nc, NONE, 1.1 InfoRequest.nc, NONE, 1.1 LLAC.nc,
NONE, 1.1 LLAM.nc, NONE, 1.1 LinkEstimation.nc, NONE,
1.1 LinkProviderIf.nc, NONE, 1.1 Lu.h, NONE, 1.1 MemAlloc.h,
NONE, 1.1 MemAlloc.nc, NONE, 1.1 NotificationTimerC.nc, NONE,
1.1 NotificationTimerM.nc, NONE, 1.1 ProcessCmd.nc, NONE,
1.1 ProcessData.nc, NONE, 1.1 QauAdapterC.nc, NONE,
1.1 QauAdapterM.nc, NONE, 1.1 Query.nc, NONE,
1.1 QueryAssemblerC.nc, NONE, 1.1 QueryAssemblerM.nc, NONE,
1.1 QueryM.nc, NONE, 1.1 QueryProcessor.h, NONE,
1.1 QueryProcessorC.nc, NONE, 1.1 QueryProcessorM.nc, NONE,
1.1 RNTimer.nc, NONE, 1.1 ReadFromStorage.nc, NONE,
1.1 ReceivePacket.nc, NONE, 1.1 RequestUpdate.nc, NONE,
1.1 ScanLinks.h, NONE, 1.1 ScanMsg.h, NONE, 1.1 Sensing.nc,
NONE, 1.1 SensorMeterC.nc, NONE, 1.1 SensorMeterM.nc, NONE,
1.1 StorageIf.nc, NONE, 1.1 TestLinkUser.nc, NONE,
1.1 Transceiver.nc, NONE, 1.1 TransceiverM.nc, NONE,
1.1 ULLAStorageC.nc, NONE, 1.1 ULLAStorageM.nc, NONE,
1.1 UQLCmdMsg.h, NONE, 1.1 UcpIf.nc, NONE, 1.1 UllaAllocC.nc,
NONE, 1.1 UllaAllocM.nc, NONE, 1.1 UllaCoreC.nc, NONE,
1.1 UllaCoreM.nc, NONE, 1.1 UllaLinkProviderC.nc, NONE,
1.1 UllaLinkProviderM.nc, NONE, 1.1 UllaQuery.h, NONE,
1.1 UllaStorage.h, NONE, 1.1 UqpIf.nc, NONE,
1.1 WriteToStorage.nc, NONE, 1.1 msg_type.h, NONE, 1.1 ulla.h,
NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list