From: Kevron Rees Date: Wed, 6 Feb 2013 18:44:42 +0000 (-0800) Subject: added new properties X-Git-Tag: accepted/2.0/20130307.223917~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4846b581fbfd334d0d2ec50ef5e097274d78d670;p=profile%2Fivi%2Fautomotive-message-broker.git added new properties --- diff --git a/docs/vehicleinfo.txt b/docs/vehicleinfo.txt index 99510c7..9a6c89f 100644 --- a/docs/vehicleinfo.txt +++ b/docs/vehicleinfo.txt @@ -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. diff --git a/lib/abstractpropertytype.cpp b/lib/abstractpropertytype.cpp index e69de29..d964d67 100644 --- a/lib/abstractpropertytype.cpp +++ b/lib/abstractpropertytype.cpp @@ -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 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(¶ms,G_VARIANT_TYPE_ARRAY); + + for(auto itr = mList.begin(); itr != mList.end(); itr++) + { + AbstractPropertyType* t; + g_variant_builder_add_value(¶ms, t->toVariant()); + } + + return g_variant_builder_end(¶ms); +} + + +void ListPropertyType::fromVariant(GVariant *v) +{ + +} diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index cb189fd..67c63a9 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -27,6 +27,7 @@ #include #include #include +#include #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 list() { return mList; } + +private: + std::list mList; +}; + #endif diff --git a/lib/vehicleproperty.cpp b/lib/vehicleproperty.cpp index baa013a..279b505 100644 --- a/lib/vehicleproperty.cpp +++ b/lib/vehicleproperty.cpp @@ -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::mCapabilities; std::list 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); + } diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 7773b6f..672d07a 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -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 VehicleTypeType; + static const Property DoorsPerRow; + typedef ListPropertyType DoorsPerRowType; + + static const Property TransmissionGearType; + typedef BasicPropertyType TransmissionGearTypeType; + + static const Property FrontWheelRadius; + static const Property RearWheelRadius; + typedef BasicPropertyType WheelRadiusType; + static const Property WheelTrack; + typedef BasicPropertyType WheelTrackType; /** END PROPERTIES **/ diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp index 8df3a47..40a2a08 100644 --- a/plugins/dbus/dbusinterfacemanager.cpp +++ b/plugins/dbus/dbusinterfacemanager.cpp @@ -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) { + } diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h index ab9acac..5cc44dd 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -23,6 +23,8 @@ #include "abstractproperty.h" #include "abstractdbusinterface.h" #include "basicproperty.h" +#include "varianttype.h" + #include #include @@ -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: diff --git a/plugins/dbus/vehicleinfo.h b/plugins/dbus/vehicleinfo.h index 789fe4d..87bb8a7 100644 --- a/plugins/dbus/vehicleinfo.h +++ b/plugins/dbus/vehicleinfo.h @@ -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()) + { + wantProperty(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()) + { + 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()) + { + wantProperty(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()) + { + wantProperty(VehicleProperty::FrontWheelRadius, "FrontWheelRadius", "i", AbstractProperty::Read); + wantProperty(VehicleProperty::RearWheelRadius, "RearWheelRadius", "i", AbstractProperty::Read); + wantProperty(VehicleProperty::WheelTrack, "WheelTrack", "i", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + #endif