added trip meter property 09/2309/1
authorKevron Rees <kevron_m_rees@linux.intel.com>
Fri, 12 Oct 2012 20:45:18 +0000 (13:45 -0700)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Fri, 12 Oct 2012 20:45:18 +0000 (13:45 -0700)
docs/runningstatus.txt
examples/dbusconfig [new file with mode: 0644]
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/dbus/CMakeLists.txt
plugins/dbus/basicproperty.h
plugins/dbus/dbusinterfacemanager.cpp
plugins/dbus/dbusplugin.h
plugins/dbus/properties.h
plugins/exampleplugin.cpp

index 86a08ce..ee31306 100644 (file)
@@ -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 (file)
index 0000000..f7b10fc
--- /dev/null
@@ -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"
+               } 
+       ]
+}
+
index 0abbc37..851cea0 100644 (file)
@@ -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()
index 3b70d40..9ba25d3 100644 (file)
@@ -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();
 
index 0656767..eae6d21 100644 (file)
@@ -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 "")
index 818cd08..bedf1c2 100644 (file)
 #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
index 163cefb..216fd09 100644 (file)
@@ -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);
+
 
 }
 
index 7faa80b..2803eb1 100644 (file)
@@ -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;
index dd1c5d9..5d1f30d 100644 (file)
@@ -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
index 255e558..ab6a718 100644 (file)
@@ -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);
        }