{
"name" : "Database",
"path" : "/usr/lib/automotive-message-broker/databasesinkplugin.so",
- "properties" : "{ 'properties' : ['VehicleSpeed'] }",
- "startOnLoad" : "true"
+ "properties" : "{ 'properties' : ['VehicleSpeed','EngineSpeed'] }",
+ "startOnLoad" : "true",
+ "bufferLength" : "1"
},
{
"name" : "Example Sink",
#include "abstractroutingengine.h"
#include "listplusplus.h"
+int bufferLength = 100;
+
extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
{
return new DatabaseSinkManager(routingengine, config);
insertList.push_back(dict);
- if(insertList.size() > 100)
+ if(insertList.size() > bufferLength)
{
shared->db->exec("BEGIN IMMEDIATE TRANSACTION");
for(int i=0; i< insertList.size(); i++)
setDatabaseFileName(config["databaseFile"]);
}
+ if(config.find("bufferLength") != config.end())
+ {
+ bufferLength = atoi(config["bufferLength"].c_str());
+ }
+
if(config.find("properties") != config.end())
{
parseConfig();
if(!shared)
return;
+ if(!ListPlusPlus<VehicleProperty::Property>(&mSupported).contains(property))
+ {
+ mSupported.push_back(property);
+ routingEngine->setSupported(mSupported, this);
+ }
+
DBObject* obj = new DBObject;
obj->key = property;
obj->value = value->toString();
ostringstream query;
query.precision(15);
- query<<"SELECT * from "<<tablename<<" WHERE ";
+ query<<"SELECT * from "<<tablename<<" WHERE key='"<<reply->property<<"' AND";
if(reply->timeBegin && reply->timeEnd)
{
for(auto itr = values.begin(); itr != values.end(); itr++)
{
auto val = *itr;
- DebugOut(1)<<"Velocity value from past: "<<val->toString()<<" time: "<<val->timestamp<<endl;
+ DebugOut(1)<<"Value from past: ("<<val->name<<"): "<<val->toString()<<" time: "<<val->timestamp<<endl;
}
delete reply;