diff options
author | Kevron Rees <kevron_m_rees@linux.intel.com> | 2012-10-12 13:45:18 -0700 |
---|---|---|
committer | Kevron Rees <kevron_m_rees@linux.intel.com> | 2012-10-12 13:45:18 -0700 |
commit | c7159b9c031b059726639fefbf187bdf529f6bdd (patch) | |
tree | bfacb01485636436672ed042fea0d84b3c276beb | |
parent | c873014593bef81384445cd93cde21fbcec5ba87 (diff) | |
download | automotive-message-broker-c7159b9c031b059726639fefbf187bdf529f6bdd.tar.gz |
added trip meter property
-rw-r--r-- | docs/runningstatus.txt | 8 | ||||
-rw-r--r-- | examples/dbusconfig | 15 | ||||
-rw-r--r-- | lib/vehicleproperty.cpp | 7 | ||||
-rw-r--r-- | lib/vehicleproperty.h | 5 | ||||
-rw-r--r-- | plugins/dbus/CMakeLists.txt | 4 | ||||
-rw-r--r-- | plugins/dbus/basicproperty.h | 21 | ||||
-rw-r--r-- | plugins/dbus/dbusinterfacemanager.cpp | 12 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.h | 7 | ||||
-rw-r--r-- | plugins/dbus/properties.h | 34 | ||||
-rw-r--r-- | plugins/exampleplugin.cpp | 2 |
10 files changed, 95 insertions, 20 deletions
diff --git a/docs/runningstatus.txt b/docs/runningstatus.txt index 86a08ce8..ee313061 100644 --- a/docs/runningstatus.txt +++ b/docs/runningstatus.txt @@ -35,12 +35,12 @@ Interface: org.automotive.tripMeter Object path: /org/automotive/runningStatus/tripMeter Properties: - uint32 A [readonly] + uint32 A [readwrite] - Distance from trip meter(s) in km. + Distance from trip meter(s) in km. This can be only set to "0". - uint32 B [readonly] - uint32 C [readonly] + uint32 B [readwrite] + uint32 C [readwrite] Interface: org.automotive.transmission Object path: /org/automotive/runningStatus/transmission diff --git a/examples/dbusconfig b/examples/dbusconfig new file mode 100644 index 00000000..f7b10fc4 --- /dev/null +++ b/examples/dbusconfig @@ -0,0 +1,15 @@ +{ + "sources" : [ + { + "name" : "ExampleSouce", + "path" : "/usr/lib/automotive-message-broker/examplesourceplugin.so" + } + ], + "sinks": [ + { + "name" : "DBusSink", + "path" : "/usr/lib/automotive-message-broker/dbussinkplugin.so" + } + ] +} + diff --git a/lib/vehicleproperty.cpp b/lib/vehicleproperty.cpp index 0abbc372..851cea06 100644 --- a/lib/vehicleproperty.cpp +++ b/lib/vehicleproperty.cpp @@ -59,13 +59,15 @@ const VehicleProperty::Property VehicleProperty::TirePressureRightFront = "TireP const VehicleProperty::Property VehicleProperty::TirePressureLeftRear = "TirePressureLeftRear"; const VehicleProperty::Property VehicleProperty::TirePressureRightRear = "TirePressureRightRear"; const VehicleProperty::Property VehicleProperty::VehiclePowerMode = "VehiclePowerMode"; +const VehicleProperty::Property VehicleProperty::TripMeterA = "TripMeterA"; +const VehicleProperty::Property VehicleProperty::TripMeterB = "TripMeterB"; +const VehicleProperty::Property VehicleProperty::TripMeterC = "TripMeterC"; std::list<VehicleProperty::Property> VehicleProperty::mCapabilities; VehicleProperty::VehicleProperty() { registerProperty( VehicleSpeed, [](){ return new VehicleSpeedType(0); }); - registerProperty(EngineSpeed, [](){ return new EngineSpeedType(0); }); registerProperty(TransmissionShiftPosition, [](){ return new TransmissionShiftPositionType(Transmission::Neutral); }); registerProperty(TransmissionGearPosition, [](){ return new TransmissionGearPositionType(Transmission::Neutral); }); @@ -92,6 +94,9 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTYWITHTYPE(TirePressureLeftRear, TirePressureType, 0); REGISTERPROPERTYWITHTYPE(TirePressureRightRear, TirePressureType, 0); registerProperty( VehiclePowerMode,[](){ return new VehiclePowerModeType(Power::Off); } ); + REGISTERPROPERTYWITHTYPE(TripMeterA,TripMeterType,0); + REGISTERPROPERTYWITHTYPE(TripMeterB,TripMeterType,0); + REGISTERPROPERTYWITHTYPE(TripMeterC,TripMeterType,0); } std::list<VehicleProperty::Property> VehicleProperty::capabilities() diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 3b70d40f..9ba25d3b 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -220,7 +220,10 @@ public: static const Property VehiclePowerMode; typedef BasicPropertyType<Power::PowerModes> VehiclePowerModeType; - + static const Property TripMeterA; + static const Property TripMeterB; + static const Property TripMeterC; + typedef BasicPropertyType<uint16_t> TripMeterType; static std::list<VehicleProperty::Property> capabilities(); diff --git a/plugins/dbus/CMakeLists.txt b/plugins/dbus/CMakeLists.txt index 0656767c..eae6d21a 100644 --- a/plugins/dbus/CMakeLists.txt +++ b/plugins/dbus/CMakeLists.txt @@ -3,8 +3,8 @@ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs}) pkg_check_modules(gio REQUIRED gio-2.0) -set(dbussinkplugin_headers dbusplugin.h abstractproperty.h abstractdbusinterface.h dbusinterfacemanager.h accelerationproperty.h basicproperty.h properties.h) -set(dbussinkplugin_sources dbusplugin.cpp abstractproperty.cpp abstractdbusinterface.cpp dbusinterfacemanager.cpp accelerationproperty.cpp basicproperty.cpp properties.cpp) +set(dbussinkplugin_headers dbusplugin.h abstractproperty.h abstractdbusinterface.h dbusinterfacemanager.h basicproperty.h properties.h) +set(dbussinkplugin_sources dbusplugin.cpp abstractproperty.cpp abstractdbusinterface.cpp dbusinterfacemanager.cpp basicproperty.cpp properties.cpp) add_library(dbussinkplugin MODULE ${dbussinkplugin_sources}) set_target_properties(dbussinkplugin PROPERTIES PREFIX "") diff --git a/plugins/dbus/basicproperty.h b/plugins/dbus/basicproperty.h index 818cd084..bedf1c2c 100644 --- a/plugins/dbus/basicproperty.h +++ b/plugins/dbus/basicproperty.h @@ -20,15 +20,17 @@ #define _BASICPROPERTY_H_ #include "abstractproperty.h" +#include "vehicleproperty.h" +#include "abstractroutingengine.h" template <typename T> class BasicProperty: public AbstractProperty { public: - BasicProperty(string propertyName, string signature, Access access, AbstractDBusInterface *interface) - :AbstractProperty(propertyName,signature,access,interface) + BasicProperty(AbstractRoutingEngine* re, string ambPropertyName, string propertyName, string signature, Access access, AbstractDBusInterface *interface) + :AbstractProperty(propertyName, signature, access, interface) { - + mAmbPropertyName = ambPropertyName; } void setValue(T val) @@ -48,8 +50,21 @@ public: virtual void fromGVariant(GVariant *value) { + T val; + g_variant_get(value,signature().c_str(), &val); + + AbstractPropertyType* apt = VehicleProperty::getPropertyTypeForPropertyNameValue(mAmbPropertyName,""); + apt->setValue(val); + routingEngine->setProperty(mAmbPropertyName, apt); + + ///delete this because we should be done + delete apt; } + +private: + VehicleProperty::Property mAmbPropertyName; + AbstractRoutingEngine* routingEngine; }; #endif diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp index 163cefb9..216fd096 100644 --- a/plugins/dbus/dbusinterfacemanager.cpp +++ b/plugins/dbus/dbusinterfacemanager.cpp @@ -26,14 +26,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include "accelerationproperty.h" #include "properties.h" +#define ConstructProperty(property) \ + new property(iface->re, connection); + using namespace std; static void on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { DBusInterfaceManager* iface = static_cast<DBusInterfaceManager*>(user_data); - AbstractDBusInterface* acceleration = new AccelerationPropertyInterface(iface->re, connection); - VehicleSpeedProperty* vehicleSpeed = new VehicleSpeedProperty(iface->re, connection); + + AbstractDBusInterface* acceleration = new AccelerationProperty(iface->re, connection); + AbstractDBusInterface* vehicleSpeed = new VehicleSpeedProperty(iface->re, connection); + AbstractDBusInterface* tirePressure = new TirePressureProperty(iface->re, connection); + ConstructProperty(VehiclePowerModeProperty); + ConstructProperty(TripMeterProperty); + } diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h index 7faa80b5..2803eb12 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -40,7 +40,12 @@ protected: template <typename T> void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access) { - propertyDBusMap[property] = new BasicProperty<T>(propertyName, signature, access, this); + propertyDBusMap[property] = new BasicProperty<T>(routingEngine, property, propertyName, signature, access, this); + } + + virtual void setProperty(VehicleProperty::Property name, AbstractPropertyType* value) + { + routingEngine->setProperty(name, value); } PropertyDBusMap propertyDBusMap; diff --git a/plugins/dbus/properties.h b/plugins/dbus/properties.h index dd1c5d99..5d1f30d8 100644 --- a/plugins/dbus/properties.h +++ b/plugins/dbus/properties.h @@ -42,10 +42,10 @@ public: TirePressureProperty(AbstractRoutingEngine* re, GDBusConnection* connection) :DBusSink("org.automotive.tirePressure","/org/automotive/maintainance/tirePressure", re, connection, map<string, string>()) { - wantProperty<uint16_t>(VehicleProperty::TirePressureLeftFront,"LeftFront", "i", AbstractProperty::Read); - wantProperty<uint16_t>(VehicleProperty::TirePressureRightFront,"RightFront", "i", AbstractProperty::Read); - wantProperty<uint16_t>(VehicleProperty::TirePressureLeftRear,"LeftRear", "i", AbstractProperty::Read); - wantProperty<uint16_t>(VehicleProperty::TirePressureRightRear,"RightRear", "i", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::TirePressureLeftFront,"LeftFront", "q", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::TirePressureRightFront,"RightFront", "q", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::TirePressureLeftRear,"LeftRear", "q", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::TirePressureRightRear,"RightRear", "q", AbstractProperty::Read); supportedChanged(re->supported()); } }; @@ -54,13 +54,37 @@ class VehiclePowerModeProperty: public DBusSink { public: VehiclePowerModeProperty(AbstractRoutingEngine* re, GDBusConnection* connection) - :DBusSink("org.automotive.tirePressure","/org/automotive/maintainance/tirePressure", re, connection, map<string, string>()) + :DBusSink("org.automotive.vehiclePowerMode","/org/automotive/runningstatus/vehiclePowerMode", re, connection, map<string, string>()) { wantProperty<uint16_t>(VehicleProperty::VehiclePowerMode, "VehiclePowerMode","b",AbstractProperty::Read); supportedChanged(re->supported()); } }; +class TripMeterProperty: public DBusSink +{ +public: + TripMeterProperty(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("org.automotive.tripMeter","/org/automotive/runningstatus/tripMeter", re, connection, map<string, string>()) + { + wantProperty<uint16_t>(VehicleProperty::TripMeterA, "A", "q", AbstractProperty::ReadWrite); + wantProperty<uint16_t>(VehicleProperty::TripMeterB, "B", "q", AbstractProperty::ReadWrite); + wantProperty<uint16_t>(VehicleProperty::TripMeterC, "C", "q", AbstractProperty::ReadWrite); + supportedChanged(re->supported()); + } +}; +class AccelerationProperty: public DBusSink +{ +public: + AccelerationProperty(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("org.automotive.acceleration","/org/automotive/runningstatus/acceleration", re, connection, map<string, string>()) + { + wantProperty<uint16_t>(VehicleProperty::AccelerationX, "X", "q", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::AccelerationY, "Y", "q", AbstractProperty::Read); + wantProperty<uint16_t>(VehicleProperty::AccelerationZ, "Z", "q", AbstractProperty::Read); + supportedChanged(re->supported()); + } +}; #endif diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index 255e5586..ab6a7188 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -100,7 +100,7 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) } else if(reply->property == VehicleProperty::VIN) { - VehicleProperty::VINType temp("abc00000000000000"); + VehicleProperty::VINType temp("ABC00000000000000"); reply->value = &temp; reply->completed(reply); } |