demosink uses strings for turn signal
authorKevron Rees <kevron_m_rees@linux.intel.com>
Tue, 11 Sep 2012 19:46:44 +0000 (12:46 -0700)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Tue, 11 Sep 2012 19:46:44 +0000 (12:46 -0700)
plugins/demosink/demosinkplugin.cpp
plugins/demosink/demosinkplugin.h
plugins/examplesink.cpp
plugins/examplesink.h

index 99b6be1..0d5eb47 100644 (file)
@@ -49,13 +49,15 @@ string findReplace(string str, string tofind, string replacewith, string exclusi
                i+=replacewith.size();
        }
 
+       return str;
 }
 
 
 DemoSink::DemoSink(AbstractRoutingEngine* re)
 :AbstractSink(re)
 {
-
+       routingEngine->subscribeToProperty(VehicleProperty::ButtonEvent, this);
+       routingEngine->subscribeToProperty(VehicleProperty::TurnSignal, this);
 }
 
 DemoSink::~DemoSink()
@@ -76,16 +78,32 @@ string DemoSink::uuid()
 void DemoSink::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
 {
        std::string app = configuration["script"];
+       std::string strValue = value->toString();
+       if(property == VehicleProperty::TurnSignal)
+       {
+               if(value->value<TurnSignals::TurnSignalType>() == TurnSignals::Right)
+               {
+                       strValue = "Right";
+               }
+               else if(value->value<TurnSignals::TurnSignalType>() == TurnSignals::Left)
+               {
+                       strValue = "Left";
+               }
+               else if(value->value<TurnSignals::TurnSignalType>() == TurnSignals::Off)
+               {
+                       strValue = "Off";
+               }
+       }
 
-       string cmdline = findReplace(app,"%1",value->toString());
+       string cmdline = findReplace(app,"%1",strValue);
        GError* error = NULL;
 
-       g_spawn_command_line_async(cmdline.c_str(), &error);
+       if(!g_spawn_command_line_async(cmdline.c_str(), &error))
+               DebugOut()<<"Failed to launch command: "<<cmdline<<endl;
 
 }
 
 void DemoSink::supportedChanged(PropertyList list)
 {
-       routingEngine->subscribeToProperty(VehicleProperty::ButtonEvent, this);
-       routingEngine->subscribeToProperty(VehicleProperty::TurnSignal, this);
+
 }
index 9556764..1393841 100644 (file)
@@ -49,7 +49,13 @@ public:
        DemoSinkManager(AbstractRoutingEngine* engine)
        :AbstractSinkManager(engine)
        {
-               new DemoSink(engine);
+
+       }
+
+       void setConfiguration(map<string, string> config)
+       {
+               DemoSink* sink = new DemoSink(routingEngine);
+               sink->setConfiguration(config);
        }
 };
 
index f67c0a9..0fd2102 100644 (file)
@@ -31,11 +31,11 @@ ExampleSink::ExampleSink(AbstractRoutingEngine* engine): AbstractSink(engine)
        routingEngine->subscribeToProperty(VehicleProperty::EngineSpeed, this);
        routingEngine->subscribeToProperty(VehicleProperty::VehicleSpeed, this);
 
-       /*AsyncPropertyRequest velocityRequest;
+       AsyncPropertyRequest velocityRequest;
        velocityRequest.property = VehicleProperty::VehicleSpeed;
-       velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<reply->value->toString()<<endl; };
+       velocityRequest.completed = [](AsyncPropertyReply* reply) { DebugOut()<<"Velocity Async request completed: "<<reply->value->toString()<<endl; delete reply; };
 
-       AsyncPropertyReply* reply = routingEngine->getPropertyAsync(velocityRequest);*/
+       AsyncPropertyReply* reply = routingEngine->getPropertyAsync(velocityRequest);
 
 }
 
index 717ffec..a522993 100644 (file)
@@ -40,7 +40,13 @@ public:
        ExampleSinkManager(AbstractRoutingEngine* engine)
        :AbstractSinkManager(engine)
        {
-               new ExampleSink(engine);
+
+       }
+
+       void setConfiguration(map<string, string> config)
+       {
+               ExampleSink* sink = new ExampleSink(routingEngine);
+               sink->setConfiguration(config);
        }
 };