AsyncPropertyReply *ExampleSourcePlugin::setProperty(AsyncSetPropertyRequest request ) { AsyncPropertyReply *reply = new AsyncPropertyReply(request); reply->success = false; if(reply->property == VehicleProperty::AirConditioning) { if(acStatus.find(reply->zoneFilter) == acStatus.end()) { reply->success = false; reply->error = AsyncPropertyReply::ZoneNotSupported; reply->completed(reply); } else { acStatus[reply->zoneFilter] = reply->value->value<bool>(); ///we need to update subscribers of this change: routingEngine->updateProperty(reply->value,uuid()); ///Now reply to the set request: reply->success = true; reply->completed(reply); } return reply; } reply->error = AsyncPropertyReply::InvalidOperation; reply->completed(reply); return reply; }
void OpenCvLuxPlugin::updateProperty(uint lux) { VehicleProperty::ExteriorBrightnessType l(lux); for(auto itr = replyQueue.begin(); itr != replyQueue.end(); itr++) { AsyncPropertyReply* reply = *itr; reply->value = &l; reply->success = true; try{ reply->completed(reply); } catch(...) { DebugOut(DebugOut::Warning)<<"reply failed"<<endl; } } replyQueue.clear(); if(lux != lastLux && shared->mRequests.size()) { lastLux = lux; routingEngine->updateProperty(VehicleProperty::ExteriorBrightness,&l, uuid()); } }
AsyncPropertyReply *OBD2Source::setProperty(AsyncSetPropertyRequest request ) { AsyncPropertyReply* reply = new AsyncPropertyReply (request); if(request.property == Obd2Connected) { propertyReplyMap[reply->property] = reply; reply->success = true; if(request.value->value<bool>() == true) { CommandRequest *req = new CommandRequest(); req->req = "connectifnot"; g_async_queue_push(commandQueue,req); } else { CommandRequest *req = new CommandRequest(); req->req = "disconnect"; g_async_queue_push(commandQueue,req); } } else { reply->success = false; try { reply->completed(reply); } catch (...) { } } return reply; }