i+=replacewith.size();
}
+ return str;
}
DemoSink::DemoSink(AbstractRoutingEngine* re)
:AbstractSink(re)
{
-
+ routingEngine->subscribeToProperty(VehicleProperty::ButtonEvent, this);
+ routingEngine->subscribeToProperty(VehicleProperty::TurnSignal, this);
}
DemoSink::~DemoSink()
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);
+
}
DemoSinkManager(AbstractRoutingEngine* engine)
:AbstractSinkManager(engine)
{
- new DemoSink(engine);
+
+ }
+
+ void setConfiguration(map<string, string> config)
+ {
+ DemoSink* sink = new DemoSink(routingEngine);
+ sink->setConfiguration(config);
}
};
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);
}
ExampleSinkManager(AbstractRoutingEngine* engine)
:AbstractSinkManager(engine)
{
- new ExampleSink(engine);
+
+ }
+
+ void setConfiguration(map<string, string> config)
+ {
+ ExampleSink* sink = new ExampleSink(routingEngine);
+ sink->setConfiguration(config);
}
};