本文整理汇总了C++中Sensor::getSensorID方法的典型用法代码示例。如果您正苦于以下问题:C++ Sensor::getSensorID方法的具体用法?C++ Sensor::getSensorID怎么用?C++ Sensor::getSensorID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sensor
的用法示例。
在下文中一共展示了Sensor::getSensorID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void BrainRoot::run()
{
DEBUG.print("Brain thread started!\r\n");
writeLog("Brain log starting\r\n");
while(1)
{
Mbox::Message msg = MailBox->pendMail();
int d = msg.data;
if(msg.SenderPtr->getEmitterType() == EMITTER_TYPE_SENSOR)
{
struct tm t = sensClock::Time_ConvUnixToCalendar(SENSCLOCK.getTimeDateUnix());
Sensor* sens = dynamic_cast<Sensor*>(msg.SenderPtr);
switch(sens->getSensorID())
{
case SENSOR_ID_HUMIDITY:
if(d > (_targetHumi + _humiHyst/2))
humidityActuator.setValue(ACTHUMI_DEHUMIDIFY);
else if(d < (_targetHumi - _humiHyst/2))
humidityActuator.setValue(ACTHUMI_HUMIDIFY);
else if ( d >= (_targetHumi - _humiHyst/4) && d <= (_targetHumi + _humiHyst/4))
humidityActuator.setValue(ACTHUMI_TURN_OFF);
writeLog("%d.%d.%d. %02d:%02d:%02d: ", t.tm_mday, \
t.tm_mon+1, t.tm_year,\
t.tm_hour, t.tm_min, t.tm_sec);
writeLog("HUM=%d\r\n",d);
break;
case SENSOR_ID_TEMPERATURE:
if(d > (_targetTemp + _tempHyst/2))
temperatureActuator.setValue(ACTTEMP_COOL_ON);
else if(d < (_targetTemp - _tempHyst/2))
temperatureActuator.setValue(ACTTEMP_HEAT_ON);
else if (d >= (_targetTemp - _tempHyst/4) && d <= (_targetTemp + _tempHyst/4))
temperatureActuator.setValue(ACTTEMP_TURN_OFF);
writeLog("%d.%d.%d. %02d:%02d:%02d: ", t.tm_mday, \
t.tm_mon+1, t.tm_year,\
t.tm_hour, t.tm_min, t.tm_sec);
writeLog("TEMP=%d\r\n",d);
break;
case SENSOR_ID_CLOCK:
{
struct tm _time = sensClock::Time_ConvUnixToCalendar((time_t)msg.data);
if ((_time.tm_hour*60 + _time.tm_min) >= (_hrOn*60 + _minOn) &&
(_time.tm_hour*60 + _time.tm_min) < (_hrOff*60 + _minOff))
{
if (_LedFlag == false)
{
writeLog("%d.%d.%d. %02d:%02d:%02d: ", t.tm_mday, \
t.tm_mon+1, t.tm_year,\
t.tm_hour, t.tm_min, t.tm_sec);
writeLog("LED ON\r\n");
ledActuator.setValue(ACTLED_ON);
_LedFlag = true;
}
}
else
{
if (_LedFlag == true)
{
writeLog("%d.%d.%d. %02d:%02d:%02d: ", t.tm_mday, \
t.tm_mon+1, t.tm_year,\
t.tm_hour, t.tm_min, t.tm_sec);
writeLog("LED OFF\r\n");
ledActuator.setValue(ACTLED_OFF);
_LedFlag = false;
}
}
}
break;
default:
DEBUG.print("Got something unknown %d\r\n",d);
}
}
}
}