From 89b76e284157a09ba1dcb433a6edcacba48c5a28 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 7 Oct 2014 08:49:27 -0700 Subject: updated docs. added deleted callback --- ambd/core.cpp | 18 +++++++ examples/bluemonkey/bluemonkeyconfig | 6 +-- lib/abstractpropertytype.h | 100 +++++++++++++++++++++++++++++------ lib/asyncqueue.hpp | 7 +++ 4 files changed, 111 insertions(+), 20 deletions(-) diff --git a/ambd/core.cpp b/ambd/core.cpp index 9911cc10..277ba5a6 100644 --- a/ambd/core.cpp +++ b/ambd/core.cpp @@ -157,11 +157,29 @@ void Core::updateProperty(AbstractPropertyType *value, const string & uuid) if(value->priority == AbstractPropertyType::Instant) updateProperty(value); else if(value->priority == AbstractPropertyType::High) + { + value->destroyed.push_back([this](AbstractPropertyType* v) + { + updatePropertyQueueHigh.remove(v); + }); updatePropertyQueueHigh.append(value); + } else if(value->priority == AbstractPropertyType::Normal) + { + value->destroyed.push_back([this](AbstractPropertyType* v) + { + updatePropertyQueue.remove(v); + }); updatePropertyQueue.append(value); + } else if(value->priority == AbstractPropertyType::Low) + { + value->destroyed.push_back([this](AbstractPropertyType* v) + { + updatePropertyQueueLow.remove(v); + }); updatePropertyQueueLow.append(value); + } } void Core::updateProperty(AbstractPropertyType * value) diff --git a/examples/bluemonkey/bluemonkeyconfig b/examples/bluemonkey/bluemonkeyconfig index fb0080c8..97d3ddb5 100644 --- a/examples/bluemonkey/bluemonkeyconfig +++ b/examples/bluemonkey/bluemonkeyconfig @@ -1,9 +1,9 @@ { - "mainloop" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/qtmainloopplugin.so", + "mainloop" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/qtmainloopplugin.so", "sources" : [ { - "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/bluemonkeyplugin.so", + "path" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/bluemonkeyplugin.so", "config" : "/etc/ambd/bluemonkey/config.js" } ], @@ -11,7 +11,7 @@ "sinks" : [ { - "path" : "/usr/lib/i386-linux-gnu/automotive-message-broker/automotive-message-broker/examplesinkplugin.so" + "path" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/examplesinkplugin.so" } ] } diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index decc456a..b9e2a339 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -74,27 +75,55 @@ public: */ enum Priority { - Normal = 0, - Low, - High, - Instant + Normal = 0, /*!< normal priority. This is default */ + Low, /*!< Low priority. */ + High, /*!< High priority*/ + Instant /*!< Instant. Using this priority is not thread safe. This is typically used for + * Properties that need to be deterministic. + */ }; - AbstractPropertyType(std::string property): name(property), timestamp(amb::currentTime()), sequence(-1), zone(Zone::None), priority(Normal) + AbstractPropertyType(std::string property) + : name(property), timestamp(amb::currentTime()), sequence(-1), zone(Zone::None), priority(Normal) { void*(name); } - virtual ~AbstractPropertyType() { } + virtual ~AbstractPropertyType() + { + for(auto i : destroyed) + { + if(i) i(this); + } + } + /** + * @brief toString + * @return strigified value + */ virtual std::string toString() const = 0; + /** + * @brief fromString converts from string value + */ virtual void fromString(std::string)= 0; + /** + * @brief toVariant + * @return GVariant representation of value. Caller must unref the returned GVariant + */ virtual GVariant* toVariant() = 0; + /** + * @brief fromVariant converts GVariant value into compatible native value. Caller owns + * GVariant argument. + */ virtual void fromVariant(GVariant*) = 0; + /** + * @brief copy + * @return a copy of the AbstractPropertyType + */ virtual AbstractPropertyType* copy() = 0; /** @@ -126,14 +155,33 @@ public: return one != two; } + /** + * @brief name Property name. @see VehicleProperty for built-in supported property names + */ std::string name; + /** + * @brief timestamp. Timestamp when the value was last updated by the system. This is updated automatically + * any time setValue() is called + * @see amb::currentTime() + * @see setValue() + */ double timestamp; + /** + * @brief sequence internal counter. Useful as a unique indentifier. values is -1 if not used (default). + */ int32_t sequence; + /** + * @brief sourceUuid uuid of the source that produced this property. This is set by the routingengine + * if left unmodified. + */ std::string sourceUuid; + /** + * @brief zone that the property is situated in. + */ Zone::Type zone; /*! @@ -144,23 +192,40 @@ public: */ Priority priority; + /** + * @brief setValue + * @param val boost::any value. NOTE: boost::any does not accept type coercion. Types must match exactly + * with native type. (ie, don't use "int" if the native type is "uint") + */ virtual void setValue(boost::any val) { mValue = val; timestamp = amb::currentTime(); } + /** + * \brief value() native value. Does not use type coercion. Will throw if types do not match. + */ template T value() const { return boost::any_cast(mValue); } + /** + * @brief anyValue + * @return boost::any value + */ boost::any anyValue() { return mValue; } + /** + * @brief destroyed is called if this property is destroyed. + */ + std::vector> destroyed; + protected: boost::any mValue; @@ -319,7 +384,13 @@ public: } }; - +/** + * \brief BasicPropertyType is a typed property type. Most internal types are derived from this class + * \example + * std::unique_ptr> boostPSI = new BasicPropertyType("BoostPSI",5); + * boostPSI->priority = AbstractPropertyType::Instant; //set instant because we clean up right after. + * routingEngine->updateProperty(boostPSI.get(), sourceUuid()); + */ template class BasicPropertyType: public AbstractPropertyType { @@ -406,16 +477,6 @@ public: mValue = T(); } - /*BasicPropertyType(std::string val) - :AbstractPropertyType("") - { - if(!val.empty() && val != "") - { - serialize(val); - } - else setValue(T()); - }*/ - AbstractPropertyType* copy() { return new BasicPropertyType(*this); @@ -448,6 +509,11 @@ public: setValue(deserializeVariant(v)); } + /** + * @brief basicValue + * @return Typed version of value. Slightly more useful than @see AbstractPropertyType::value() + */ + T basicValue() { return value(); diff --git a/lib/asyncqueue.hpp b/lib/asyncqueue.hpp index ce2c1f72..f7881e4f 100644 --- a/lib/asyncqueue.hpp +++ b/lib/asyncqueue.hpp @@ -19,6 +19,7 @@ #include #include +#include "listplusplus.h" #include #include @@ -66,6 +67,12 @@ public: mQueue.insert(item); } + void remove(T item) + { + std::lock_guard lock(mutex); + removeOne(&mQueue, item); + } + protected: std::mutex mutex; std::unordered_set, Pred> mQueue; -- cgit v1.2.1 From 96c972e6a4fa0a46ea972c56462658522e443ff9 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Mon, 13 Oct 2014 13:18:02 -0700 Subject: fixed obd2 disconnect bug --- examples/bluemonkey/bluemonkeyconfig | 18 ------------------ plugins/obd2plugin/obd2source.cpp | 9 ++++----- plugins/obd2plugin/obd2source.h | 3 ++- 3 files changed, 6 insertions(+), 24 deletions(-) delete mode 100644 examples/bluemonkey/bluemonkeyconfig diff --git a/examples/bluemonkey/bluemonkeyconfig b/examples/bluemonkey/bluemonkeyconfig deleted file mode 100644 index 97d3ddb5..00000000 --- a/examples/bluemonkey/bluemonkeyconfig +++ /dev/null @@ -1,18 +0,0 @@ -{ - "mainloop" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/qtmainloopplugin.so", - - "sources" : [ - { - "path" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/bluemonkeyplugin.so", - "config" : "/etc/ambd/bluemonkey/config.js" - } - ], - - "sinks" : [ - - { - "path" : "/usr/local/lib/x86_64-linux-gnu/automotive-message-broker/automotive-message-broker/examplesinkplugin.so" - } - ] -} - diff --git a/plugins/obd2plugin/obd2source.cpp b/plugins/obd2plugin/obd2source.cpp index 1032ab3b..c95bda20 100644 --- a/plugins/obd2plugin/obd2source.cpp +++ b/plugins/obd2plugin/obd2source.cpp @@ -463,14 +463,13 @@ static int updateProperties( gpointer data) StatusMessage *reply = (StatusMessage*)retval; if (reply->statusStr == "disconnected") { - OBD2Source::Obd2ConnectType val(Obd2Connected,false); - src->updateProperty(&val); + src->obd2Connected.setValue(false); + src->updateProperty(&src->obd2Connected); } else if (reply->statusStr == "connected") { - OBD2Source::Obd2ConnectType val(Obd2Connected, true); - val.priority = OBD2Source::Obd2ConnectType::Instant; - src->updateProperty(&val); + src->obd2Connected.setValue(false); + src->updateProperty(&src->obd2Connected); } else if (reply->statusStr == "error:nodata" || reply->statusStr == "error:timeout") { diff --git a/plugins/obd2plugin/obd2source.h b/plugins/obd2plugin/obd2source.h index 39774807..ba8cc2bf 100644 --- a/plugins/obd2plugin/obd2source.h +++ b/plugins/obd2plugin/obd2source.h @@ -187,12 +187,13 @@ public: GThread *m_gThread; typedef BasicPropertyType Obd2ConnectType; + Obd2ConnectType obd2Connected; private: PropertyList m_supportedProperties; std::map oldValueMap; GMutex *threadQueueMutex; - Obd2ConnectType obd2Connected; + }; -- cgit v1.2.1 From 42e69b8c39e28dddfe743f1b1d294293dddb6a8f Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 14 Oct 2014 10:04:33 -0700 Subject: fixed bluemonkey config path --- examples/bluemonkey/bluemonkeyconfig.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/bluemonkey/bluemonkeyconfig.in b/examples/bluemonkey/bluemonkeyconfig.in index 434651bd..64f299c3 100644 --- a/examples/bluemonkey/bluemonkeyconfig.in +++ b/examples/bluemonkey/bluemonkeyconfig.in @@ -1,9 +1,9 @@ { - "mainloop" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/qtmainloopplugin.so", + "mainloop" : "@PLUGIN_INSTALL_PATH@/qtmainloopplugin.so", "sources" : [ { - "path" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/bluemonkeyplugin.so", + "path" : "@PLUGIN_INSTALL_PATH@/bluemonkeyplugin.so", "config" : "/etc/ambd/bluemonkey/config.js" } ], @@ -11,7 +11,7 @@ "sinks" : [ { - "path" : "@PLUGIN_INSTALL_PATH@/automotive-message-broker/examplesinkplugin.so" + "path" : "@PLUGIN_INSTALL_PATH@/examplesinkplugin.so" } ] } -- cgit v1.2.1 From 2c0c4fb9ba5e93d9625921f8fa86934f1553163e Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 14 Oct 2014 10:39:14 -0700 Subject: fixed FanSpeedLevel name --- plugins/dbus/environmentproperties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dbus/environmentproperties.h b/plugins/dbus/environmentproperties.h index 40655a15..10db753c 100644 --- a/plugins/dbus/environmentproperties.h +++ b/plugins/dbus/environmentproperties.h @@ -196,7 +196,7 @@ public: { wantPropertyVariant(VehicleProperty::AirflowDirectionW3C, "AirflowDirection", AbstractProperty::ReadWrite); - wantPropertyVariant(VehicleProperty::FanSpeed, "FanSpeed", AbstractProperty::ReadWrite); + wantPropertyVariant(VehicleProperty::FanSpeed, "FanSpeedLevel", AbstractProperty::ReadWrite); wantPropertyVariant(VehicleProperty::TargetTemperature, "TargetTemperature", AbstractProperty::ReadWrite); -- cgit v1.2.1 From 22342d46a0bc1790283d5d096d6c922d85b5acf8 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 14 Oct 2014 14:36:42 -0700 Subject: update cache of dbus properties even if not currently registered --- plugins/dbus/dbusplugin.cpp | 3 --- plugins/dbus/varianttype.cpp | 4 ++-- plugins/wheel/wheelplugin.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/dbus/dbusplugin.cpp b/plugins/dbus/dbusplugin.cpp index b936e4a4..3e9fc86a 100644 --- a/plugins/dbus/dbusplugin.cpp +++ b/plugins/dbus/dbusplugin.cpp @@ -71,9 +71,6 @@ void DBusSink::supportedChanged(const PropertyList &supportedProperties) void DBusSink::propertyChanged(AbstractPropertyType *value) { - if(!isRegistered()) - return; - VehicleProperty::Property property = value->name; if( value->zone != zoneFilter) diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp index 730ed59c..933eccad 100644 --- a/plugins/dbus/varianttype.cpp +++ b/plugins/dbus/varianttype.cpp @@ -36,7 +36,7 @@ void VariantType::initialize() /// do not request if not supported: PropertyList proplist = routingEngine->supported(); - if(contains(proplist,mAmbPropertyName)) + if(contains(proplist, mAmbPropertyName)) routingEngine->getPropertyAsync(request); } @@ -55,7 +55,7 @@ GVariant *VariantType::toGVariant() void VariantType::fromGVariant(GVariant *val) { AbstractPropertyType *v = VehicleProperty::getPropertyTypeForPropertyNameValue(mAmbPropertyName); - v->fromVariant( val ); + v->fromVariant(val); AsyncSetPropertyRequest request; request.property = mAmbPropertyName; diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp index f6ebdbb6..0ddfd799 100644 --- a/plugins/wheel/wheelplugin.cpp +++ b/plugins/wheel/wheelplugin.cpp @@ -99,6 +99,7 @@ private: VehicleProperty::EngineOilPressureType *oilPSI; VehicleProperty::EngineCoolantTemperatureType *coolantTemp; VehicleProperty::SteeringWheelAngleType *steeringAngle; + VehicleProperty::SteeringWheelAngleW3CType *steeringAngleW3C; VehicleProperty::ThrottlePositionType *throttle; VehicleProperty::ClutchStatusType *clutch; VehicleProperty::WheelBrakeType *brake; @@ -162,6 +163,7 @@ PropertyList WheelSourcePlugin::supported() props.push_back(VehicleProperty::ThrottlePosition); props.push_back(VehicleProperty::WheelBrake); props.push_back(VehicleProperty::SteeringWheelAngle); + props.push_back(VehicleProperty::SteeringWheelAngleW3C); props.push_back(VehicleProperty::TurnSignal); props.push_back(VehicleProperty::ClutchStatus); props.push_back(VehicleProperty::EngineOilPressure); @@ -208,6 +210,7 @@ WheelPrivate::WheelPrivate(WheelSourcePlugin *parent, AbstractRoutingEngine *rou engineSpeed(new VehicleProperty::EngineSpeedType(0)), vehicleSpeed(new VehicleProperty::VehicleSpeedType(0)), steeringAngle(new VehicleProperty::SteeringWheelAngleType(0)), + steeringAngleW3C(new VehicleProperty::SteeringWheelAngleW3CType(0)), clutch(new VehicleProperty::ClutchStatusType(false)), brake(new VehicleProperty::WheelBrakeType(false)), tempButton(new VehicleProperty::ButtonEventType(ButtonEvents::NoButton)), @@ -308,6 +311,8 @@ AbstractPropertyType *WheelPrivate::getProperty(VehicleProperty::Property propTy return this->brake; else if (propType == VehicleProperty::SteeringWheelAngle) return this->steeringAngle; + else if (propType == VehicleProperty::SteeringWheelAngleW3C) + return this->steeringAngleW3C; else if (propType == VehicleProperty::TurnSignal) return this->turnSignal; else if (propType == VehicleProperty::ClutchStatus) @@ -536,7 +541,9 @@ void WheelPrivate::changeCoolantTemp(bool increase) void WheelPrivate::changeSteeringAngle(int val) { *steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; + *steeringAngleW3C = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; this->re->updateProperty(steeringAngle, mParent->uuid()); + this->re->updateProperty(steeringAngleW3C, mParent->uuid()); } void WheelPrivate::changeClutch(int val) -- cgit v1.2.1 From 11c2adaa772e664dcf11b76f345adff19abf4541 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Wed, 15 Oct 2014 13:09:15 -0700 Subject: fixed battery ChargeLevel type error --- plugins/dbus/maintenance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dbus/maintenance.h b/plugins/dbus/maintenance.h index 97bc187f..6f1cd941 100644 --- a/plugins/dbus/maintenance.h +++ b/plugins/dbus/maintenance.h @@ -101,7 +101,7 @@ public: **/ wantPropertyVariant(VehicleProperty::BatteryCurrent, "Current", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::BatteryCurrent, "ChargeLevel", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::BatteryChargeLevel, "ChargeLevel", AbstractProperty::Read); } }; -- cgit v1.2.1 From 386768a44f2213bc49d2c3f2f57e40efe0776976 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Wed, 15 Oct 2014 14:55:58 -0700 Subject: fixed Temperature interface name --- plugins/dbus/environmentproperties.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dbus/environmentproperties.h b/plugins/dbus/environmentproperties.h index 10db753c..3815152d 100644 --- a/plugins/dbus/environmentproperties.h +++ b/plugins/dbus/environmentproperties.h @@ -28,7 +28,7 @@ class Temperature: public DBusSink { public: Temperature(AbstractRoutingEngine* re, GDBusConnection* connection) - :DBusSink("InteriorTemperature", re, connection, map()) + :DBusSink("Temperature", re, connection, map()) { /** * @attributeName Interior -- cgit v1.2.1