summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevron Rees <tripzero.kev@gmail.com>2013-03-16 14:06:10 -0700
committerKevron Rees <tripzero.kev@gmail.com>2013-03-16 14:06:10 -0700
commit85817b8a53ca3eeace22bce359554f1a2c41df52 (patch)
treef0d233bad24cc876e703203acb97017c9cf2c72e
parent0fd5e08da1342c5e423d1a083a33ff435d7b1447 (diff)
downloadautomotive-message-broker-85817b8a53ca3eeace22bce359554f1a2c41df52.tar.gz
fixed up example
-rw-r--r--plugins/database/databasesink.cpp5
-rw-r--r--plugins/examplesink.cpp47
2 files changed, 44 insertions, 8 deletions
diff --git a/plugins/database/databasesink.cpp b/plugins/database/databasesink.cpp
index 63af05c1..bafa660a 100644
--- a/plugins/database/databasesink.cpp
+++ b/plugins/database/databasesink.cpp
@@ -118,7 +118,10 @@ DatabaseSink::DatabaseSink(AbstractRoutingEngine *engine, map<std::string, std::
databaseName = config["databaseFile"];
}
- parseConfig();
+ if(config.find("properties") != config.end())
+ {
+ parseConfig();
+ }
for(auto itr=propertiesToSubscribeTo.begin();itr!=propertiesToSubscribeTo.end();itr++)
{
diff --git a/plugins/examplesink.cpp b/plugins/examplesink.cpp
index 9f5ed063..333fa674 100644
--- a/plugins/examplesink.cpp
+++ b/plugins/examplesink.cpp
@@ -56,7 +56,10 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
velocityRequest.property = VehicleProperty::VehicleSpeed;
velocityRequest.completed = [](AsyncPropertyReply* reply)
{
- DebugOut()<<"Velocity Async request completed: "<<reply->value->toString()<<endl;
+ if(!reply->success)
+ DebugOut(0)<<"Velocity Async request failed";
+ else
+ DebugOut(0)<<"Velocity Async request completed: "<<reply->value->toString()<<endl;
delete reply;
};
@@ -64,19 +67,40 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
AsyncPropertyRequest vinRequest;
vinRequest.property = VehicleProperty::VIN;
- vinRequest.completed = [](AsyncPropertyReply* reply) { DebugOut(1)<<"VIN Async request completed: "<<reply->value->toString()<<endl; delete reply; };
+ vinRequest.completed = [](AsyncPropertyReply* reply)
+ {
+ if(!reply->success)
+ DebugOut(0)<<"VIN Async request failed";
+ else
+ DebugOut(0)<<"VIN Async request completed: "<<reply->value->toString()<<endl;
+ delete reply;
+ };
routingEngine->getPropertyAsync(vinRequest);
AsyncPropertyRequest wmiRequest;
wmiRequest.property = VehicleProperty::WMI;
- wmiRequest.completed = [](AsyncPropertyReply* reply) { DebugOut(1)<<"WMI Async request completed: "<<reply->value->toString()<<endl; delete reply; };
+ wmiRequest.completed = [](AsyncPropertyReply* reply)
+ {
+ if(!reply->success)
+ DebugOut(0)<<"WMI Async request failed";
+ else
+ DebugOut(1)<<"WMI Async request completed: "<<reply->value->toString()<<endl;
+ delete reply;
+ };
routingEngine->getPropertyAsync(wmiRequest);
AsyncPropertyRequest batteryVoltageRequest;
batteryVoltageRequest.property = VehicleProperty::BatteryVoltage;
- batteryVoltageRequest.completed = [](AsyncPropertyReply* reply) { DebugOut(1)<<"BatteryVoltage Async request completed: "<<reply->value->toString()<<endl; delete reply; };
+ batteryVoltageRequest.completed = [](AsyncPropertyReply* reply)
+ {
+ if(!reply->success)
+ DebugOut(0)<<"BatteryVoltage Async request failed";
+ else
+ DebugOut(1)<<"BatteryVoltage Async request completed: "<<reply->value->toString()<<endl;
+ delete reply;
+ };
routingEngine->getPropertyAsync(batteryVoltageRequest);
@@ -84,7 +108,10 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
doorsPerRowRequest.property = VehicleProperty::DoorsPerRow;
doorsPerRowRequest.completed = [](AsyncPropertyReply* reply)
{
- DebugOut(1)<<"Doors per row: "<<reply->value->toString()<<endl;
+ if(!reply->success)
+ DebugOut(0)<<"Doors per row Async request failed";
+ else
+ DebugOut(1)<<"Doors per row: "<<reply->value->toString()<<endl;
delete reply;
};
@@ -94,7 +121,10 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
airbagStatus.property = VehicleProperty::AirbagStatus;
airbagStatus.completed = [](AsyncPropertyReply* reply)
{
- DebugOut(1)<<"Airbag Status: "<<reply->value->toString()<<endl;
+ if(!reply->success)
+ DebugOut(0)<<"Airbag Async request failed";
+ else
+ DebugOut(1)<<"Airbag Status: "<<reply->value->toString()<<endl;
delete reply;
};
@@ -104,7 +134,10 @@ void ExampleSink::supportedChanged(PropertyList supportedProperties)
exteriorBrightness.property = VehicleProperty::ExteriorBrightness;
exteriorBrightness.completed = [](AsyncPropertyReply* reply)
{
- DebugOut(1)<<"Exterior Brightness: "<<reply->value->toString()<<endl;
+ if(!reply->success)
+ DebugOut(0)<<"Exterior Brightness Async request failed";
+ else
+ DebugOut(1)<<"Exterior Brightness: "<<reply->value->toString()<<endl;
delete reply;
};