fixed up example
authorKevron Rees <tripzero.kev@gmail.com>
Sat, 16 Mar 2013 21:06:10 +0000 (14:06 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Sat, 16 Mar 2013 21:06:10 +0000 (14:06 -0700)
plugins/database/databasesink.cpp
plugins/examplesink.cpp

index 63af05c..bafa660 100644 (file)
@@ -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++)
        {
index 9f5ed06..333fa67 100644 (file)
@@ -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;
        };