diff options
author | Kevron Rees <kevron_m_rees@linux.intel.com> | 2013-06-24 11:18:10 -0700 |
---|---|---|
committer | Kevron Rees <kevron_m_rees@linux.intel.com> | 2013-06-24 16:16:16 -0700 |
commit | 159303bc9d81e4d1f9a74ef897815055acfd9e68 (patch) | |
tree | 4473814f153b55a15561dd0ab89842c7197f9f62 | |
parent | 9c36f33c8b914273786f62c08d8e6a01f9881e67 (diff) | |
download | automotive-message-broker-159303bc9d81e4d1f9a74ef897815055acfd9e68.tar.gz |
implemented new abstractrouting things in core
-rw-r--r-- | TODO | 14 | ||||
-rw-r--r-- | ambd/core.cpp | 76 | ||||
-rw-r--r-- | ambd/core.h | 6 | ||||
-rw-r--r-- | ambd/pluginloader.cpp | 14 | ||||
-rw-r--r-- | ambd/pluginloader.h | 1 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/abstractpropertytype.h | 2 | ||||
-rw-r--r-- | lib/abstractsource.h | 5 | ||||
-rw-r--r-- | lib/mappropertytype.hpp | 2 | ||||
-rw-r--r-- | lib/vehicleproperty.h | 1 | ||||
-rw-r--r-- | plugins/database/databasesink.cpp | 6 | ||||
-rw-r--r-- | plugins/database/databasesink.h | 2 | ||||
-rw-r--r-- | plugins/exampleplugin.h | 2 | ||||
-rw-r--r-- | plugins/websocketsourceplugin/websocketsource.h | 15 |
14 files changed, 100 insertions, 48 deletions
@@ -1,9 +1,15 @@ -For 0.10.0 + + +For 0.11 + - Implement all the DBus properties in the docs/ directory. -- DBus support for time and sequece being included in dbus properties. -- DBus support for objects with multiple sources and multiple 'zones' (ie /org/automotive/${sourceID}/${zone}/batteryVoltage/${index}) +- DBus support for time and sequece being an additional api call (ie, getExtendedVehicleSpeedInfo()). +- DBus support for objects with multiple sources and multiple 'zones' (ie /org/automotive/${sourceID}/[${zone}/]batteryVoltage) - Document changes to the DBus API in the IDL - autoreconnect on a timeout when Obd2 disconnects if 'autoreconnect' is 'true' in the config +- update json protocol to include getPropertyInfo calls +- update database to support zone column +- no reason for pluginloader to track sources. core already does it. Other: - grep all the TODOs in the code and do them @@ -11,5 +17,5 @@ Other: - improve obd2source speed via Physical Addressing (see https://www.scantool.net/forum/index.php?topic=6661.msg25024#msg25024) - investigate and enable use of provisioning in ssl websockets - add API to get number of sources per a given property (ie uint AbstractRoutingEngine::sources(VehicleProperty::Property)) -- enable ambd/config.d/ +- enable ambd/plugins.d/ - finish implementing openxc plugin diff --git a/ambd/core.cpp b/ambd/core.cpp index d1c0ddb2..019196ab 100644 --- a/ambd/core.cpp +++ b/ambd/core.cpp @@ -161,7 +161,12 @@ void Core::updateProperty(VehicleProperty::Property property, AbstractPropertyTy for(SinkList::iterator itr = list.begin(); itr != list.end(); itr++) { - (*itr)->propertyChanged(property, value, uuid); + AbstractSink* sink = *itr; + + auto isFiltered = filteredSourceSinkMap.find(sink); + + if( (isFiltered != filteredSourceSinkMap.end() && filteredSourceSinkMap[sink] == uuid) || isFiltered == filteredSourceSinkMap.end()) + sink->propertyChanged(property, value, uuid); } } @@ -265,29 +270,18 @@ void Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* { DebugOut(1)<<"Subscribing to: "<<property<<endl; - /** TODO: Change behavior of subscribe to subscribe even if no sources provide a - * given property. When subscribers come online with support, core should tell - * the sources what properties have already been subscribed to. - */ - - /*if(!ListPlusPlus<VehicleProperty::Property>(&mMasterPropertyList).contains((property))) - { - DebugOut(1)<<__FUNCTION__<<"(): property not supported: "<<property<<endl; - return; - }*/ - if(propertySinkMap.find(property) == propertySinkMap.end()) { propertySinkMap[property] = SinkList(); } - + SinkList list = propertySinkMap[property]; - + if(!ListPlusPlus<AbstractSink*>(&list).contains(self)) { propertySinkMap[property].push_back(self); } - + for(SourceList::iterator itr = mSources.begin(); itr != mSources.end(); itr++) { AbstractSource* src = (*itr); @@ -297,18 +291,34 @@ void Core::subscribeToProperty(VehicleProperty::Property property, AbstractSink* src->subscribeToPropertyChanges(property); } } + +} + +void Core::subscribeToProperty(VehicleProperty::Property property, string sourceUuidFilter, AbstractSink *sink) +{ + if(filteredSourceSinkMap.find(sink) == filteredSourceSinkMap.end()) + { + filteredSourceSinkMap[sink] = sourceUuidFilter; + } + + subscribeToProperty(property,sink); } void Core::unsubscribeToProperty(VehicleProperty::Property property, AbstractSink* self) { if(propertySinkMap.find(property) == propertySinkMap.end()) { - DebugOut(1)<<__FUNCTION__<<"property not supported: "<<property<<endl; + DebugOut(1)<<__FUNCTION__<<" property not subscribed to: "<<property<<endl; return; } ListPlusPlus<AbstractSink*>(&propertySinkMap[property]).removeOne(self); + if( filteredSourceSinkMap.find(self) != filteredSourceSinkMap.end()) + { + filteredSourceSinkMap.erase(self); + } + /// Now we check to see if this is the last subscriber if(propertySinkMap.find(property) == propertySinkMap.end()) { @@ -325,3 +335,37 @@ void Core::unsubscribeToProperty(VehicleProperty::Property property, AbstractSin } } +PropertyInfo Core::getPropertyInfo(VehicleProperty::Property property, string sourceUuid) +{ + for(auto itr = mSources.begin(); itr != mSources.end(); itr++) + { + AbstractSource* src = *itr; + + if(src->uuid() == sourceUuid) + { + return src->getPropertyInfo(property); + } + } + + return PropertyInfo(); +} + +std::list<string> Core::getSourcesForProperty(VehicleProperty::Property property) +{ + std::list<std::string> list; + + for(auto itr = mSources.begin(); itr != mSources.end(); itr++) + { + AbstractSource* src = *itr; + + PropertyList supportedProperties = src->supported(); + + if(ListPlusPlus<VehicleProperty::Property>(&supportedProperties).contains(property)) + { + list.push_back(src->uuid()); + } + } + + return list; +} + diff --git a/ambd/core.h b/ambd/core.h index af488a6f..2ea5aba8 100644 --- a/ambd/core.h +++ b/ambd/core.h @@ -48,8 +48,12 @@ public: AsyncRangePropertyReply* getRangePropertyAsync(AsyncRangePropertyRequest request); AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request); void subscribeToProperty(VehicleProperty::Property, AbstractSink* self); + void subscribeToProperty(VehicleProperty::Property, std::string sourceUuidFilter, AbstractSink *self); void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self); PropertyList supported() { return mMasterPropertyList; } + + PropertyInfo getPropertyInfo(VehicleProperty::Property, std::string sourceUuid); + std::list<std::string> getSourcesForProperty(VehicleProperty::Property property); ~Core(); @@ -63,6 +67,8 @@ private: std::map<VehicleProperty::Property, SinkList> propertySinkMap; + std::map<AbstractSink*, std::string> filteredSourceSinkMap; + std::map<VehicleProperty::Property, std::string> previousValueMap; }; diff --git a/ambd/pluginloader.cpp b/ambd/pluginloader.cpp index 83c56e00..e452bdd6 100644 --- a/ambd/pluginloader.cpp +++ b/ambd/pluginloader.cpp @@ -200,26 +200,12 @@ PluginLoader::PluginLoader(string configFile, AbstractRoutingEngine* re, int arg DebugOut() << "Trying to free obj" << endl; //json_object_put(sinksobject); DebugOut() << "Done" << endl; - - - ///TODO: this will probably explode: - - //if(error) g_error_free(error); - - //g_object_unref(reader); - //g_object_unref(parser); - //*/ } PluginLoader::~PluginLoader() { } -SinkList PluginLoader::sinks() -{ - return mSinks; -} - IMainLoop *PluginLoader::mainloop() { return mMainLoop; diff --git a/ambd/pluginloader.h b/ambd/pluginloader.h index 09384e6b..5205070a 100644 --- a/ambd/pluginloader.h +++ b/ambd/pluginloader.h @@ -44,7 +44,6 @@ public: ~PluginLoader(); SourceList sources(); - SinkList sinks(); IMainLoop* mainloop(); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 13ee8be1..eba328e8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -14,7 +14,7 @@ endif(uuid_LIBRARY) include_directories( ${include_dirs} ${uuid_INCLUDE_DIR}) -target_link_libraries(amb ${libtool_LIBRARY} ${glib_LIBRARIES} ${gio_LIBRARIES} ${uuid_LIBRARY} ${json_LIBRARY}) +target_link_libraries(amb ${libtool_LIBRARY} ${glib_LIBRARIES} ${gio_LIBRARIES} ${uuid_LIBRARY} ${json_LIBRARIES}) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/automotive-message-broker.pc.in ${CMAKE_CURRENT_BINARY_DIR}/automotive-message-broker.pc @ONLY) diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index 0fae6d04..2ba1150d 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -53,7 +53,7 @@ public: AbstractPropertyType(std::string property): name(property), timestamp(-1), sequence(-1), zone(Zone::None), index(0) {} - ~AbstractPropertyType() { } + virtual ~AbstractPropertyType() { } virtual std::string toString() const = 0; diff --git a/lib/abstractsource.h b/lib/abstractsource.h index 55824f6b..cdee6154 100644 --- a/lib/abstractsource.h +++ b/lib/abstractsource.h @@ -40,7 +40,6 @@ typedef std::list<AbstractSource*> SourceList; class AbstractSource: public AbstractSink { -using namespace std; public: enum Operations { @@ -63,14 +62,14 @@ public: virtual int supportedOperations() = 0; - PropertyInfo getPropertyInfo(VehicleProperty::Property) = 0; + virtual PropertyInfo getPropertyInfo(VehicleProperty::Property property) = 0; protected: AbstractRoutingEngine* routingEngine; private: - AbstractSource():AbstractSink(nullptr, map<string,string>()) { } + AbstractSource():AbstractSink(nullptr, std::map<std::string,std::string>()) { } }; #endif // ABSTRACTSOURCE_H diff --git a/lib/mappropertytype.hpp b/lib/mappropertytype.hpp index 8f98fa89..f95e4968 100644 --- a/lib/mappropertytype.hpp +++ b/lib/mappropertytype.hpp @@ -3,7 +3,7 @@ #include "abstractpropertytype.h" -//#include "vehicleproperty.h" + #include <map> #include <debugout.h> #include <json/json.h> diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 0ae9fae0..9358d58c 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -30,6 +30,7 @@ #include "abstractpropertytype.h" #include "mappropertytype.hpp" + namespace ButtonEvents { enum ButtonEventType { NoButton = 0, diff --git a/plugins/database/databasesink.cpp b/plugins/database/databasesink.cpp index 33ce930c..423e0435 100644 --- a/plugins/database/databasesink.cpp +++ b/plugins/database/databasesink.cpp @@ -201,6 +201,12 @@ PropertyList DatabaseSink::supported() return mSupported; } +PropertyInfo DatabaseSink::getPropertyInfo(VehicleProperty::Property property) +{ + /// TODO: Compute update frequency for properties in the database + return PropertyInfo(); +} + void DatabaseSink::parseConfig() { json_object *rootobject; diff --git a/plugins/database/databasesink.h b/plugins/database/databasesink.h index 117d1350..f32862e5 100644 --- a/plugins/database/databasesink.h +++ b/plugins/database/databasesink.h @@ -158,6 +158,8 @@ public: virtual PropertyList supported(); int supportedOperations() { return GetRanged | Get | Set;} + PropertyInfo getPropertyInfo(VehicleProperty::Property property); + private: //methods: void parseConfig(); diff --git a/plugins/exampleplugin.h b/plugins/exampleplugin.h index 715f054c..8412de11 100644 --- a/plugins/exampleplugin.h +++ b/plugins/exampleplugin.h @@ -44,6 +44,8 @@ public: void supportedChanged(PropertyList) {} void randomizeProperties(); + + PropertyInfo getPropertyInfo(VehicleProperty::Property ) { return PropertyInfo(); } private: PropertyList mRequests; diff --git a/plugins/websocketsourceplugin/websocketsource.h b/plugins/websocketsourceplugin/websocketsource.h index d231d585..6b9103f1 100644 --- a/plugins/websocketsourceplugin/websocketsource.h +++ b/plugins/websocketsourceplugin/websocketsource.h @@ -32,8 +32,8 @@ class WebSocketSource : public AbstractSource { public: - WebSocketSource(AbstractRoutingEngine* re, map<string, string> config); - string uuid(); + WebSocketSource(AbstractRoutingEngine* re, std::map<std::string, std::string> config); + std::string uuid(); void getPropertyAsync(AsyncPropertyReply *reply); void getRangePropertyAsync(AsyncRangePropertyReply *reply); AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request); @@ -51,15 +51,16 @@ public: PropertyList activeRequests; PropertyList removeRequests; void setSupported(PropertyList list); - void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, string uuid) {} + void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid) {} void supportedChanged(PropertyList) {} - void setConfiguration(map<string, string> config); + void setConfiguration(std::map<std::string, std::string> config); //map<VehicleProperty::Property,AsyncPropertyReply*> propertyReplyMap; //map<VehicleProperty::Property,AsyncRangePropertyReply*> rangedPropertyReplyMap; - map<std::string,AsyncPropertyReply*> uuidReplyMap; - map<std::string,double> uuidTimeoutMap; - map<std::string,AsyncRangePropertyReply*> uuidRangedReplyMap; + std::map<std::string,AsyncPropertyReply*> uuidReplyMap; + std::map<std::string,double> uuidTimeoutMap; + std::map<std::string,AsyncRangePropertyReply*> uuidRangedReplyMap; + PropertyInfo getPropertyInfo(VehicleProperty::Property property); private: PropertyList m_supportedProperties; |