From: Kevron Rees Date: Fri, 12 Oct 2012 20:45:18 +0000 (-0700) Subject: added trip meter property X-Git-Tag: 0.6.0~30^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7159b9c031b059726639fefbf187bdf529f6bdd;p=profile%2Fivi%2Fautomotive-message-broker.git added trip meter property --- diff --git a/docs/runningstatus.txt b/docs/runningstatus.txt index 86a08ce..ee31306 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 0000000..f7b10fc --- /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 0abbc37..851cea0 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::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::capabilities() diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 3b70d40..9ba25d3 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -220,7 +220,10 @@ public: static const Property VehiclePowerMode; typedef BasicPropertyType VehiclePowerModeType; - + static const Property TripMeterA; + static const Property TripMeterB; + static const Property TripMeterC; + typedef BasicPropertyType TripMeterType; static std::list capabilities(); diff --git a/plugins/dbus/CMakeLists.txt b/plugins/dbus/CMakeLists.txt index 0656767..eae6d21 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 818cd08..bedf1c2 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 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 163cefb..216fd09 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(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 7faa80b..2803eb1 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -40,7 +40,12 @@ protected: template void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access) { - propertyDBusMap[property] = new BasicProperty(propertyName, signature, access, this); + propertyDBusMap[property] = new BasicProperty(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 dd1c5d9..5d1f30d 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()) { - wantProperty(VehicleProperty::TirePressureLeftFront,"LeftFront", "i", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureRightFront,"RightFront", "i", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureLeftRear,"LeftRear", "i", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureRightRear,"RightRear", "i", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureLeftFront,"LeftFront", "q", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureRightFront,"RightFront", "q", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureLeftRear,"LeftRear", "q", AbstractProperty::Read); + wantProperty(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()) + :DBusSink("org.automotive.vehiclePowerMode","/org/automotive/runningstatus/vehiclePowerMode", re, connection, map()) { wantProperty(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()) + { + wantProperty(VehicleProperty::TripMeterA, "A", "q", AbstractProperty::ReadWrite); + wantProperty(VehicleProperty::TripMeterB, "B", "q", AbstractProperty::ReadWrite); + wantProperty(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()) + { + wantProperty(VehicleProperty::AccelerationX, "X", "q", AbstractProperty::Read); + wantProperty(VehicleProperty::AccelerationY, "Y", "q", AbstractProperty::Read); + wantProperty(VehicleProperty::AccelerationZ, "Z", "q", AbstractProperty::Read); + supportedChanged(re->supported()); + } +}; #endif diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index 255e558..ab6a718 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); }