当前位置: 首页>>代码示例>>C++>>正文


C++ Sensor::getSensorID方法代码示例

本文整理汇总了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);
			}

		}

	}
}
开发者ID:fluxxone,项目名称:RootControl,代码行数:77,代码来源:brainRoot.cpp


注:本文中的Sensor::getSensorID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。