2 Copyright (C) 2012 Intel Corporation
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #include "dbusplugin.h"
21 #include <boost/lexical_cast.hpp>
25 #include "abstractroutingengine.h"
27 #include "listplusplus.h"
29 std::map<std::string, std::string> DBusSink::dbusConfig;
31 DBusSink::DBusSink(std::string propertyName, AbstractRoutingEngine* engine, GDBusConnection* connection, std::map<std::string, std::string> config)
32 :AbstractDBusInterface("org.automotive."+propertyName, propertyName, connection),
33 AbstractSink(engine, dbusConfig)
35 AbstractDBusInterface::re = engine;
39 if(configuration.find("frequency") != configuration.end())
41 int t = boost::lexical_cast<int>(configuration["frequency"]);
49 void DBusSink::supportedChanged(const PropertyList &supportedProperties)
53 for(auto itr : propertyDBusMap)
55 if(contains(supportedProperties, itr->ambPropertyName()))
57 PropertyInfo info = re->getPropertyInfo(itr->ambPropertyName(), mSourceFilter);
59 if (!info.isValid() || !contains(info.zones(), zoneFilter))
64 VariantType* prop = itr;
65 prop->setSourceFilter(mSourceFilter);
66 prop->setZoneFilter(zoneFilter);
68 VehicleProperty::Property p = itr->ambPropertyName();
69 routingEngine->subscribeToProperty(p, mSourceFilter, this);
72 mTime = amb::currentTime();
77 void DBusSink::propertyChanged(AbstractPropertyType *value)
79 VehicleProperty::Property property = value->name;
81 if( value->zone != zoneFilter)
84 for(auto i : propertyDBusMap)
86 if(i->ambPropertyName() == property)
88 VariantType* prop = i;
89 mTime = value->timestamp;
90 prop->updateValue(value);
96 const string DBusSink::uuid()
98 return "c2e6cafa-eef5-4b8a-99a0-0f2c9be1057d";