本文整理汇总了C++中ControllerMessage::getParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ ControllerMessage::getParameter方法的具体用法?C++ ControllerMessage::getParameter怎么用?C++ ControllerMessage::getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControllerMessage
的用法示例。
在下文中一共展示了ControllerMessage::getParameter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decodeData
std::string ProtocolMandolyn::decodeData(const ControllerMessage &dataMsg) {
std::string data = dataMsg.getParameter("data");
uint32_t value = (uint32_t)TelldusCore::hexTo64l(data);
// parity not used
// bool parity = value & 0x1;
value >>= 1;
double temp = static_cast<double>(value & 0x7FFF) - static_cast<double>(6400);
temp = temp/128.0;
value >>= 15;
uint8_t humidity = (value & 0x7F);
value >>= 7;
// battOk not used
// bool battOk = value & 0x1;
value >>= 3;
uint8_t channel = (value & 0x3)+1;
value >>= 2;
uint8_t house = value & 0xF;
std::stringstream retString;
retString << "class:sensor;protocol:mandolyn;id:"
<< house*10+channel
<< ";model:temperaturehumidity;"
<< "temp:" << std::fixed << std::setprecision(1) << temp
<< ";humidity:" << static_cast<int>(humidity) << ";";
return retString.str();
}
示例2: decodeData
std::string ProtocolWaveman::decodeData(ControllerMessage& dataMsg)
{
unsigned long allData = 0;
unsigned int house = 0;
unsigned int unit = 0;
unsigned int method = 0;
sscanf(dataMsg.getParameter("data").c_str(), "%lx", &allData);
method = allData & 0xF00;
method >>= 8;
unit = allData & 0xF0;
unit >>= 4;
unit++;
house = allData & 0xF;
if(house < 0 || house > 16 || unit < 1 || unit > 16){
//not waveman
return "";
}
house = house + 'A'; //house from A to P
if(method != 6 && lastArctecCodeSwitchWasTurnOff == 1){
lastArctecCodeSwitchWasTurnOff = 0;
return ""; //probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
//one turnon/bell, but it's better than the alternative...
}
if(method == 6){
lastArctecCodeSwitchWasTurnOff = 1;
}
std::stringstream retString;
retString << "class:command;protocol:waveman;model:codeswitch;house:" << char(house);
if(method == 0){
retString << ";unit:" << unit << ";method:turnoff;";
}
else if(method == 14){
retString << ";unit:" << unit << ";method:turnon;";
}
else {
//not waveman
return "";
}
return retString.str();
}
示例3: setSensorValueAndSignal
void DeviceManager::setSensorValueAndSignal( const std::string &dataType, int dataTypeId, Sensor *sensor, const ControllerMessage &msg, time_t timestamp) const {
if (!msg.hasParameter(dataType)) {
return;
}
sensor->setValue(dataTypeId, msg.getParameter(dataType), timestamp);
EventUpdateData *eventData = new EventUpdateData();
eventData->messageType = L"TDSensorEvent";
eventData->protocol = sensor->protocol();
eventData->model = sensor->model();
eventData->sensorId = sensor->id();
eventData->dataType = dataTypeId;
eventData->value = TelldusCore::charToWstring(sensor->value(dataTypeId).c_str());
eventData->timestamp = static_cast<int>(timestamp);
d->deviceUpdateEvent->signal(eventData);
}
示例4: decodeData
std::string ProtocolFineoffset::decodeData(const ControllerMessage &dataMsg) {
std::string data = dataMsg.getParameter("data");
if (data.length() < 8) {
return "";
}
// Checksum currently not used
// uint8_t checksum = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2));
data = data.substr(0, data.length()-2);
uint8_t humidity = (uint8_t)TelldusCore::hexTo64l(data.substr(data.length()-2));
data = data.substr(0, data.length()-2);
uint16_t value = (uint16_t)TelldusCore::hexTo64l(data.substr(data.length()-3));
double temperature = (value & 0x7FF)/10.0;
value >>= 11;
if (value & 1) {
temperature = -temperature;
}
data = data.substr(0, data.length()-3);
uint16_t id = (uint16_t)TelldusCore::hexTo64l(data) & 0xFF;
std::stringstream retString;
retString << "class:sensor;protocol:fineoffset;id:" << id << ";model:";
if (humidity <= 100) {
retString << "temperaturehumidity;humidity:" << static_cast<int>(humidity) << ";";
} else if (humidity == 0xFF) {
retString << "temperature;";
} else {
return "";
}
retString << "temp:" << std::fixed << std::setprecision(1) << temperature << ";";
return retString.str();
}