added new properties
authorKevron Rees <kevron_m_rees@linux.intel.com>
Wed, 6 Feb 2013 18:44:42 +0000 (10:44 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Wed, 6 Feb 2013 22:13:43 +0000 (14:13 -0800)
docs/vehicleinfo.txt
lib/abstractpropertytype.cpp
lib/abstractpropertytype.h
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/dbus/dbusinterfacemanager.cpp
plugins/dbus/dbusplugin.h
plugins/dbus/vehicleinfo.h

index 99510c7..9a6c89f 100644 (file)
@@ -6,8 +6,8 @@ Object path     /org/automotive/vehicleInfo/*
 
 
 
-Interface:     org.automotive.VehicleId
-Object path:   /org/automotive/vehicleInfo/VehicleId
+Interface:     org.automotive.vehicleId
+Object path:   /org/automotive/vehicleInfo/vehicleId
 Properties:
 
                string WMI [readonly]
@@ -32,7 +32,7 @@ Properties:
                        length in mm
 
 Interface:     org.automotive.fuelInfo
-Object path:   /org/automotive/vehicleInfo/FuelInfo
+Object path:   /org/automotive/vehicleInfo/fuelInfo
 Properties:
 
                byte Type [readonly]
@@ -52,8 +52,8 @@ Properties:
                        Front = 2,
                        Rear = 3
 
-Interface:     org.automotive.VehicleType
-Object path:   /org/automotive/vehicleInfo/VehicleType
+Interface:     org.automotive.vehicleType
+Object path:   /org/automotive/vehicleInfo/vehicleType
 Properties:
 
                byte VehicleType [readonly]
@@ -65,45 +65,44 @@ Properties:
                        SUV = 4,
                        Truck = 5
 
-Interface:     org.automotive.DoorType
-Object path:   /org/automotive/vehicleInfo/DoorType
+Interface:     org.automotive.doors
+Object path:   /org/automotive/vehicleInfo/doors
 Properties:
 
-               array{ byte } DoorType [readonly]
+               array{ byte } DoorsPerRow [readonly]
                        
                        Number of doors in each row.  The index represents the row.  Position '0'
                        represents the first row, '1' the second row etc.
 
-                       Example a common mini-van may have DoorType[0] = 2 doors,
-                       DoorType[1] = 1 (side door), DoorType[2] = 1 (trunk).
+                       Example a common mini-van may have Doors[0] = 2 doors,
+                       Doors[1] = 1 (side door), Doors[2] = 1 (trunk).
 
-Interface:     org.automotive.EngineType
-Object path:   /org/automotive/vehicleInfo/EngineType
-Properties:
-
-               byte EngineType [readonly]
-               
-                       Gasoline = 0,
-                       Diesel = 1,
-                       Hybrid = 2,
-                       Electric = 3
-       
-Interface:     org.automotive.TransmissionGearType
-Object path:   /org/automotive/vehicleInfo/TransmissionGearType
+Interface:     org.automotive.transmissionGearType
+Object path:   /org/automotive/vehicleInfo/transmissionGearType
 Properties:
 
                byte TransmissionGearType [readonly]
                
                        Auto = 0,
                        Manual = 1,
-                       CVT
+                       CV = 2 (Constant Variable Transmission)
+
+
                        
-Interface:     org.automotive.WheelInformation
-Object path:   /org/automotive/vehicleInfo/WheelInformation
+Interface:     org.automotive.wheelInformation
+Object path:   /org/automotive/vehicleInfo/wheelInformation
 Properties:
 
-               struct{ double, double } WheelInformation [readonly]
-               
-                       Radius of Wheel, Wheel Track.
+               uint16 FrontRadius [readonly]
+
+                       Radius of Front Wheel(s) in mm.
+
+               uint16 RearRadius [readonly]
+       
+                       Radius of Rear Wheel(s) in mm.
+
+               uint32 Track [readonly]
+
+                       Wheel Track in mm.
                                
                        
index e69de29..d964d67 100644 (file)
@@ -0,0 +1,92 @@
+#include "abstractpropertytype.h"
+
+
+void ListPropertyType::append(AbstractPropertyType *property)
+{
+       mList.push_back(property->copy());
+}
+
+
+ListPropertyType::ListPropertyType()
+{
+
+}
+
+ListPropertyType::ListPropertyType(int)
+{
+
+}
+
+ListPropertyType::ListPropertyType(ListPropertyType &other)
+{
+       std::list<AbstractPropertyType*> l = other.list();
+       for(auto itr = l.begin(); itr != l.end(); itr++)
+       {
+               append(*itr);
+       }
+}
+
+
+ListPropertyType::~ListPropertyType()
+{
+
+}
+
+
+uint ListPropertyType::count()
+{
+       return mList.size();
+}
+
+
+AbstractPropertyType *ListPropertyType::copy()
+{
+       return new ListPropertyType(*this);
+}
+
+
+std::string ListPropertyType::toString() const
+{
+       std::string str = "[";
+
+       for(auto itr = mList.begin(); itr != mList.end(); itr++)
+       {
+               if(str != "[")
+                       str += ",";
+
+               AbstractPropertyType* t = *itr;
+
+               str += t->toString();
+       }
+
+       str += "]";
+
+       return str;
+}
+
+
+void ListPropertyType::fromString(std::string)
+{
+       /// TODO: try to use VehicleProperty::getPropertyType... here
+}
+
+
+GVariant *ListPropertyType::toVariant()
+{
+       GVariantBuilder params;
+       g_variant_builder_init(&params,G_VARIANT_TYPE_ARRAY);
+
+       for(auto itr = mList.begin(); itr != mList.end(); itr++)
+       {
+               AbstractPropertyType* t;
+               g_variant_builder_add_value(&params, t->toVariant());
+       }
+
+       return g_variant_builder_end(&params);
+}
+
+
+void ListPropertyType::fromVariant(GVariant *v)
+{
+
+}
index cb189fd..67c63a9 100644 (file)
@@ -27,6 +27,7 @@
 #include <boost/utility.hpp>
 #include <type_traits>
 #include <glib.h>
+#include <list>
 #include "timestamp.h"
 
 class AbstractPropertyType
@@ -361,4 +362,32 @@ private:
        GVariant* mVariant;
 };
 
+class ListPropertyType: public AbstractPropertyType
+{
+public:
+
+       ListPropertyType();
+       ListPropertyType(int unused);
+       ListPropertyType(ListPropertyType & other);
+       ~ListPropertyType();
+
+       void append(AbstractPropertyType* property);
+
+       uint count();
+
+       AbstractPropertyType* copy();
+
+       std::string toString() const;
+       void fromString(std::string );
+
+
+       GVariant* toVariant();
+       void fromVariant(GVariant* v);
+
+       std::list<AbstractPropertyType*> list() { return mList; }
+
+private:
+       std::list<AbstractPropertyType*> mList;
+};
+
 #endif
index baa013a..279b505 100644 (file)
@@ -103,6 +103,11 @@ const VehicleProperty::Property VehicleProperty::VehicleWidth = "VehicleWidth";
 const VehicleProperty::Property VehicleProperty::VehicleHeight = "VehicleHeight";
 const VehicleProperty::Property VehicleProperty::VehicleLength = "VehicleLength";
 const VehicleProperty::Property VehicleProperty::VehicleType = "VehicleType";
+const VehicleProperty::Property VehicleProperty::DoorsPerRow = "DoorsPerRow";
+const VehicleProperty::Property VehicleProperty::TransmissionGearType = "TransmissionGearType";
+const VehicleProperty::Property VehicleProperty::FrontWheelRadius = "FrontWheelRadius";
+const VehicleProperty::Property VehicleProperty::RearWheelRadius = "RearWheelRadius";
+const VehicleProperty::Property VehicleProperty::WheelTrack = "WheelTrack";
 
 std::list<VehicleProperty::Property> VehicleProperty::mCapabilities;
 std::list<VehicleProperty::Property> VehicleProperty::mCustomProperties;
@@ -177,6 +182,12 @@ VehicleProperty::VehicleProperty()
        REGISTERPROPERTY(Altitude,0);
        REGISTERPROPERTY(Direction,0);
        REGISTERPROPERTY(VehicleType,Vehicle::Unknown);
+       REGISTERPROPERTY(DoorsPerRow,0);
+       REGISTERPROPERTY(TransmissionGearType,Transmission::Unknown);
+       REGISTERPROPERTYWITHTYPE(FrontWheelRadius, WheelRadiusType, 0);
+       REGISTERPROPERTYWITHTYPE(RearWheelRadius, WheelRadiusType, 0);
+       REGISTERPROPERTY(WheelTrack,0);
+
 
 
 }
index 7773b6f..672d07a 100644 (file)
@@ -86,6 +86,13 @@ enum Mode {
        OEMCustom1 = 3,
        OEMCustom2 = 4
 };
+
+enum Type {
+       Unknown = -1,
+       Auto = 0,
+       Manual = 1,
+       CV = 2
+};
 }
 
 namespace Power {
@@ -138,6 +145,8 @@ enum Type
 };
 }
 
+
+
 class VehicleProperty
 {
 
@@ -359,7 +368,18 @@ public:
        static const Property VehicleType;
        typedef BasicPropertyType<Vehicle::Type> VehicleTypeType;
 
+       static const Property DoorsPerRow;
+       typedef ListPropertyType DoorsPerRowType;
+
+       static const Property TransmissionGearType;
+       typedef BasicPropertyType<Transmission::Type> TransmissionGearTypeType;
+
+       static const Property FrontWheelRadius;
+       static const Property RearWheelRadius;
+       typedef BasicPropertyType<uint16_t> WheelRadiusType;
 
+       static const Property WheelTrack;
+       typedef BasicPropertyType<uint> WheelTrackType;
 
        /** END PROPERTIES **/
 
index 8df3a47..40a2a08 100644 (file)
@@ -55,6 +55,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d
        ConstructProperty(EngineOilProperty);
        ConstructProperty(ExteriorBrightnessProperty);
        ConstructProperty(VehicleId);
+       ConstructProperty(DoorsProperty);
 
        PropertyList list = VehicleProperty::customProperties();
 
@@ -71,11 +72,13 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d
 static void
 on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
+
 }
 
 static void
 on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
+
 }
 
 
index ab9acac..5cc44dd 100644 (file)
@@ -23,6 +23,8 @@
 #include "abstractproperty.h"
 #include "abstractdbusinterface.h"
 #include "basicproperty.h"
+#include "varianttype.h"
+
 #include <map>
 #include <type_traits>
 
@@ -50,6 +52,11 @@ protected:
                propertyDBusMap[property] = new StringDBusProperty(routingEngine, property, propertyName, signature, access, this);
        }
 
+       void wantPropertyVariant(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
+       {
+               propertyDBusMap[property] = new VariantType(routingEngine, signature, property, access, this);
+       }
+
        PropertyDBusMap propertyDBusMap;
 private:
 
index 789fe4d..87bb8a7 100644 (file)
@@ -47,4 +47,55 @@ public:
                }
 };
 
+
+class VehicleTypeProperty: public DBusSink
+{
+public:
+       VehicleTypeProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
+               :DBusSink("org.automotive.vehicleType","/org/automotive/vehicleinfo/vehicleType", re, connection, map<string, string>())
+       {
+               wantProperty<Vehicle::Type>(VehicleProperty::VehicleType, "Type", "i", AbstractProperty::Read);
+
+               supportedChanged(re->supported());
+       }
+};
+
+class DoorsProperty: public DBusSink
+{
+public:
+       DoorsProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
+               :DBusSink("org.automotive.doors","/org/automotive/vehicleinfo/doors", re, connection, map<string, string>())
+       {
+               wantPropertyVariant(VehicleProperty::DoorsPerRow, "DoorsPerRow", "a(i)", AbstractProperty::Read);
+
+               supportedChanged(re->supported());
+       }
+};
+
+class TransmissionInfoProperty: public DBusSink
+{
+public:
+       TransmissionInfoProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
+               :DBusSink("org.automotive.transmissionGearType","/org/automotive/vehicleinfo/transmissionGearType", re, connection, map<string, string>())
+       {
+               wantProperty<Transmission::Type>(VehicleProperty::TransmissionGearType, "TransmissionGearType", "i", AbstractProperty::Read);
+
+               supportedChanged(re->supported());
+       }
+};
+
+class WheelInformationProperty: public DBusSink
+{
+public:
+       WheelInformationProperty(AbstractRoutingEngine* re, GDBusConnection* connection)
+               :DBusSink("org.automotive.WheelInformationProperty","/org/automotive/vehicleinfo/WheelInformationProperty", re, connection, map<string, string>())
+       {
+               wantProperty<uint16_t>(VehicleProperty::FrontWheelRadius, "FrontWheelRadius", "i", AbstractProperty::Read);
+               wantProperty<uint16_t>(VehicleProperty::RearWheelRadius, "RearWheelRadius", "i", AbstractProperty::Read);
+               wantProperty<uint>(VehicleProperty::WheelTrack, "WheelTrack", "i", AbstractProperty::Read);
+
+               supportedChanged(re->supported());
+       }
+};
+
 #endif