bluemonkey enhancements
[profile/ivi/automotive-message-broker.git] / lib / vehicleproperty.h
index 86b5ff8..b2cfa81 100644 (file)
@@ -1,19 +1,19 @@
 /*
-    Copyright (C) 2012  Intel Corporation
+       Copyright (C) 2012  Intel Corporation
 
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
+       This library is free software; you can redistribute it and/or
+       modify it under the terms of the GNU Lesser General Public
+       License as published by the Free Software Foundation; either
+       version 2.1 of the License, or (at your option) any later version.
 
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
+       This library is distributed in the hope that it will be useful,
+       but WITHOUT ANY WARRANTY; without even the implied warranty of
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+       Lesser General Public License for more details.
 
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+       You should have received a copy of the GNU Lesser General Public
+       License along with this library; if not, write to the Free Software
+       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
 
 
@@ -80,6 +80,7 @@ enum TransmissionPositions
        Park = 255
 
 };
+/** TODO: deprecate in 0.13.  Replaced with Drive::Mode: **/
 enum Mode {
        Normal=0,
        Sports = 1,
@@ -94,6 +95,16 @@ enum Type {
        Manual = 1,
        CV = 2
 };
+
+namespace W3C
+{
+extern const char* Park;
+extern const char* Reverse;
+extern const char* Neutral;
+extern const char* Low;
+extern const char* Drive;
+extern const char* Overdrive;
+}
 }
 
 namespace Power {
@@ -144,6 +155,11 @@ enum Type
        SUV,
        Truck
 };
+enum SoundMode {
+       Normal = 0,
+       Quiet = 1,
+       Sportive = 2
+};
 }
 
 namespace Security {
@@ -174,6 +190,12 @@ enum Status
        Open,
        Ajar
 };
+namespace W3C
+{
+extern const char * Closed;
+extern const char * Open;
+extern const char * Ajar;
+}
 }
 
 namespace Seat
@@ -222,6 +244,14 @@ enum AirflowDirection
        Defroster = 1 << 2
 
 };
+
+namespace W3C
+{
+extern const char * FloorPanel;
+extern const char * FloorDuct;
+extern const char * Bilevel;
+extern const char * DefrostFloor;
+}
 }
 
 namespace Driving
@@ -233,12 +263,34 @@ enum Mode
 };
 }
 
+namespace Drive
+{
+enum Mode {
+       Normal=0,
+       Sports = 1,
+       Economy = 2,
+       OEMCustom1 = 3,
+       OEMCustom2 = 4
+};
+}
+
+namespace Measurement
+{
+enum Type
+{
+       Metric = 0,
+       ImperialUS = 1,
+       ImperialUK = 2
+};
+}
+
 #include <boost/preprocessor/comma.hpp>
 
 #define PROPERTYTYPE(property, propertyType, baseClass, valueType) \
        class propertyType : public baseClass { \
        public: propertyType(): baseClass(property) {} \
        propertyType(valueType val) : baseClass(property, val) {} \
+       using baseClass::operator=; \
        };
 
 #define PROPERTYTYPE1(property, propertyType, baseClass, valueType) \
@@ -251,6 +303,7 @@ enum Mode
        class property ## Type : public BasicPropertyType<valueType> { \
        public: property ## Type(): BasicPropertyType(property) {} \
        property ## Type(valueType val) : BasicPropertyType(property, val) {} \
+       using BasicPropertyType<valueType>::operator=; \
        };
 
 #define PROPERTYTYPEBASIC1(property, valueType) \
@@ -264,21 +317,28 @@ enum Mode
        public: propertyType(): baseClass(property) {} \
        };
 
+class VehicleProperty;
+
+
+typedef std::vector<std::string> PropertyList;
+typedef std::set<std::string> PropertySet;
+
 class VehicleProperty
 {
 
 public:
-       
+
 
        /*!
         * \brief factory constructs a static instance of VehicleProperty.  This should be called once before VehicleProperty is used in the app
         */
        static void factory();
+
        /*!
         *
-     * \brief destroys static instance of VehicleProperty. This should be called at application shutdown
-     */
-    static void shutdown();
+        * \brief destroys static instance of VehicleProperty. This should be called at application shutdown
+        */
+       static void shutdown();
 
        typedef std::string Property;
 
@@ -329,11 +389,18 @@ public:
                                 BasicPropertyType<Transmission::TransmissionPositions>, Transmission::TransmissionPositions)
        //typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionGearPositionType;
 
+       /// TODO: deprecate in 0.13.  Replaced by Drive::Mode
        static const Property TransmissionMode;
        PROPERTYTYPE(TransmissionMode, TransmissionModeType,
                                 BasicPropertyType<Transmission::Mode>, Transmission::Mode)
        //typedef BasicPropertyType<Transmission::Mode> TransmissionModeType;
 
+       /**< TransmissionModeW3C
+        * see Transmission::W3C::Park, Transmission::W3C::Drive, etc
+        */
+       static const Property TransmissionModeW3C;
+       PROPERTYTYPE(TransmissionModeW3C, TransmissionModeW3CType, StringPropertyType, std::string)
+
        /**< Throttle position 0-100% */
        static const Property ThrottlePosition;
        PROPERTYTYPE(ThrottlePosition, ThrottlePositionType, BasicPropertyType<uint16_t> , uint16_t)
@@ -348,14 +415,20 @@ public:
        PROPERTYTYPE(WheelBrakePressure, WheelBrakePressureType, BasicPropertyType<uint16_t>, uint16_t)
        //typedef BasicPropertyType<uint16_t> WheelBrakePressureType;
 
-       /**< Steering wheel angle (0-359) */
+       /**< Steering wheel angle (0-359)
+        * TODO: Deprecate in 0.13.  Replace with SteeringWheelAngleW3C
+       */
        static const Property SteeringWheelAngle;
        PROPERTYTYPE(SteeringWheelAngle, SteeringWheelAngleType, BasicPropertyType<uint16_t>, uint16_t)
        //typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
 
+       /// TODO: Rename to "SteeringWheel" in 0.13
+       static const Property SteeringWheelAngleW3C;
+       PROPERTYTYPEBASIC(SteeringWheelAngleW3C, int16_t)
+
        /**< 0=off, 1=right, 2=left, 3=hazard */
        static const Property TurnSignal;
-       PROPERTYTYPE(TurnSignal, TurnSignalType, BasicPropertyType<TurnSignals::TurnSignalType> ,TurnSignals::TurnSignalType)
+       PROPERTYTYPEBASIC(TurnSignal, TurnSignals::TurnSignalType)
        //typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType;
 
        /**< Clutch pedal status 0=off, 1=on */
@@ -373,9 +446,12 @@ public:
        PROPERTYTYPE(EngineCoolantTemperature, EngineCoolantTemperatureType, BasicPropertyType<int>, int)
        //typedef BasicPropertyType<int> EngineCoolantTemperatureType;
 
+       static const Property EngineCoolantLevel;
+       PROPERTYTYPE(EngineCoolantLevel, EngineCoolantLevelType, BasicPropertyType<uint>, uint)
+
        /**< 0=off, 1=on */
        static const Property MachineGunTurretStatus;
-       PROPERTYTYPE(MachineGunTurretStatus, MachineGunTurretStatusType, BasicPropertyType<bool>, bool)
+       PROPERTYTYPEBASIC(MachineGunTurretStatus, bool)
        //typedef BasicPropertyType<bool> MachineGunTurretStatusType;
 
        /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
@@ -415,6 +491,9 @@ public:
        PROPERTYTYPE(BatteryCurrent, BatteryCurrentType, BasicPropertyType<double>, double)
        //typedef BasicPropertyType<double> BatteryCurrentType;
 
+       static const Property BatteryChargeLevel;
+       PROPERTYTYPEBASIC(BatteryChargeLevel, uint16_t)
+
        /**< Interior Air Temperature in degrees celcius */
        static const Property InteriorTemperature;
        PROPERTYTYPE(InteriorTemperature, InteriorTemperatureType, BasicPropertyType<int>, int)
@@ -444,27 +523,17 @@ public:
        //class WMIType: public StringPropertyType { public: WMIType(std::string val):StringPropertyType(WMI,val){} };
 
        /**< Tire pressure in kPa */
-       static const Property TirePressureLeftFront;
-       PROPERTYTYPE(TirePressureLeftFront, TirePressureLeftFrontType, BasicPropertyType<double>, double)
-       static const Property TirePressureRightFront;
-       PROPERTYTYPE(TirePressureRightFront, TirePressureRightFrontType, BasicPropertyType<double>, double)
-       static const Property TirePressureLeftRear;
-       PROPERTYTYPE(TirePressureLeftRear, TirePressureLeftRearType, BasicPropertyType<double>, double)
-       static const Property TirePressureRightRear;
-       PROPERTYTYPE(TirePressureRightRear, TirePressureRightRearType, BasicPropertyType<double>, double)
-       //typedef BasicPropertyType<double> TirePressureType;
+       static const Property TirePressure;
+       PROPERTYTYPEBASIC(TirePressure, uint16_t)
+
+       /**< Tire pressure low */
+       static const Property TirePressureLow;
+       PROPERTYTYPEBASIC(TirePressureLow, bool)
 
        /**< Tire temperature in degrees C */
-       static const Property TireTemperatureLeftFront;
-       PROPERTYTYPE(TireTemperatureLeftFront, TireTemperatureLeftFrontType, BasicPropertyType<double>, double)
-       static const Property TireTemperatureRightFront;
-       PROPERTYTYPE(TireTemperatureRightFront, TireTemperatureRightFrontType, BasicPropertyType<double>, double)
-       static const Property TireTemperatureLeftRear;
-       PROPERTYTYPE(TireTemperatureLeftRear, TireTemperatureLeftRearType, BasicPropertyType<double>, double)
-       static const Property TireTemperatureRightRear;
-       PROPERTYTYPE(TireTemperatureRightRear, TireTemperatureRightRearType, BasicPropertyType<double>, double)
-       //typedef BasicPropertyType<double> TireTemperatureType;
-       
+       static const Property TireTemperature;
+       PROPERTYTYPEBASIC(TireTemperature, int16_t)
+
        /**< Vehicle Power Mode.
         *@see Power::PowerModes
         */
@@ -500,7 +569,11 @@ public:
        PROPERTYTYPE(LightParking, LightParkingType, BasicPropertyType<bool>, bool)
        static const Property LightHighBeam;
        PROPERTYTYPE(LightHighBeam, LightHighBeamType, BasicPropertyType<bool>, bool)
-       //typedef BasicPropertyType<bool> LightStatusType;
+       static const Property LightAutomatic;
+       PROPERTYTYPEBASIC(LightAutomatic, bool)
+       static const Property LightDynamicHighBeam;
+       PROPERTYTYPEBASIC(LightDynamicHighBeam, bool)
+
 
        static const Property InteriorLightDriver;
        PROPERTYTYPE(InteriorLightDriver, InteriorLightDriverType, BasicPropertyType<bool>, bool)
@@ -511,59 +584,54 @@ public:
 
        static const Property EngineLoad;
        PROPERTYTYPE(EngineLoad, EngineLoadType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> EngineLoadType;
 
        static const Property Horn;
        PROPERTYTYPE(Horn, HornType, BasicPropertyType<bool>, bool)
-       //typedef BasicPropertyType<bool> HornType;
 
        static const Property FuelLevel;
        PROPERTYTYPE(FuelLevel, FuelLevelType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> FuelLevelType;
 
        static const Property FuelRange;
        PROPERTYTYPE(FuelRange, FuelRangeType, BasicPropertyType<uint16_t> , uint16_t)
-       //typedef BasicPropertyType<uint16_t> FuelRangeType;
 
        static const Property FuelConsumption;
-       PROPERTYTYPE(FuelConsumption, FuelConsumptionType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> FuelConsumptionType;
+       PROPERTYTYPE(FuelConsumption, FuelConsumptionType, BasicPropertyType<uint>, uint)
 
        static const Property FuelEconomy;
        PROPERTYTYPE(FuelEconomy, FuelEconomyType, BasicPropertyType<uint16_t>, uint16_t)
-//     /typedef BasicPropertyType<uint16_t> FuelEconomyType;
 
        static const Property FuelAverageEconomy;
        PROPERTYTYPE(FuelAverageEconomy, FuelAverageEconomyType, BasicPropertyType<uint16_t> , uint16_t)
-       //typedef BasicPropertyType<uint16_t> FuelAverageEconomyType;
+
+       static const Property FuelAverageConsumption;
+       PROPERTYTYPEBASIC(FuelAverageConsumption, uint)
+
+       static const Property FuelTimeSinceRestart;
+       PROPERTYTYPEBASIC(FuelTimeSinceRestart, uint)
+
+       static const Property FuelConsumptionSinceRestart;
+       PROPERTYTYPEBASIC(FuelConsumptionSinceRestart, uint)
 
        static const Property FuelType;
        PROPERTYTYPE(FuelType, FuelTypeType, BasicPropertyType<Fuel::Type>, Fuel::Type)
-       //typedef BasicPropertyType<Fuel::Type> FuelTypeType;
 
        static const Property FuelPositionSide;
        PROPERTYTYPE(FuelPositionSide, FuelPositionSideType, BasicPropertyType<Fuel::RefuelPosition>, Fuel::RefuelPosition)
-//     /typedef BasicPropertyType<Fuel::RefuelPosition> FuelPositionSideType;
 
        static const Property ExteriorBrightness;
        PROPERTYTYPE(ExteriorBrightness, ExteriorBrightnessType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> ExteriorBrightnessType;
-       
+
        static const Property Latitude;
        PROPERTYTYPE(Latitude, LatitudeType, BasicPropertyType<double>, double)
-       //typedef BasicPropertyType<double> LatitudeType;
 
        static const Property Longitude;
        PROPERTYTYPE(Longitude, LongitudeType, BasicPropertyType<double>, double)
-       //typedef BasicPropertyType<double> LongitudeType;
 
        static const Property Altitude;
        PROPERTYTYPE(Altitude, AltitudeType, BasicPropertyType<double> , double)
-       //typedef BasicPropertyType<double> AltitudeType;
 
        static const Property Direction;
        PROPERTYTYPE(Direction, DirectionType, BasicPropertyType<uint16_t>, uint16_t)
-       //typedef BasicPropertyType<uint16_t> DirectionType;
 
        static const Property VehicleWidth;
        PROPERTYTYPE(VehicleWidth, VehicleWidthType, BasicPropertyType<uint>, uint)
@@ -599,9 +667,15 @@ public:
        PROPERTYTYPEBASIC(BrakePressure, uint16_t)
        //typedef BasicPropertyType<uint16_t> BrakePressureType;
 
+       /// TODO: deprecated.  remove in 0.13.  Use DistanceTotal
        static const Property Odometer;
        PROPERTYTYPEBASIC(Odometer, uint)
-       //typedef BasicPropertyType<uint> OdometerType;
+
+       static const Property DistanceTotal;
+       PROPERTYTYPEBASIC(DistanceTotal, uint)
+
+       static const Property DistanceSinceStart;
+       PROPERTYTYPEBASIC(DistanceSinceStart, uint)
 
        /**< Transmission Fluid Level 0-100%.
         **/
@@ -665,9 +739,15 @@ public:
        static const Property AirbagStatus;
        PROPERTYTYPEBASIC(AirbagStatus, Airbag::Status)
 
+       /// TODO: deprecate in 0.13.  Use DoorStatusW3C
        static const Property DoorStatus;
        PROPERTYTYPEBASIC(DoorStatus, Door::Status)
 
+       /** use with Door::W3C::*
+        */
+       static const Property DoorStatusW3C;
+       PROPERTYTYPE(DoorStatusW3C, DoorStatusW3CType, StringPropertyType, std::string)
+
        static const Property DoorLockStatus;
        PROPERTYTYPEBASIC(DoorLockStatus, bool)
 
@@ -678,7 +758,7 @@ public:
        PROPERTYTYPEBASIC(SeatBeltStatus, bool)
 
        static const Property WindowLockStatus;
-       PROPERTYTYPEBASIC(WindowLockStatus, bool )
+       PROPERTYTYPEBASIC(WindowLockStatus, bool)
 
        static const Property OccupantStatus;
        PROPERTYTYPEBASIC(OccupantStatus, Seat::Occupant)
@@ -694,33 +774,38 @@ public:
        PROPERTYTYPEBASIC(WindshieldWiper,Window::WiperSpeed)
        //typedef BasicPropertyType<Window::WiperSpeed> WindshieldWiperType;
 
+       /// TODO: Deprecated.  Remove in 0.13
        static const Property AirflowDirection;
        PROPERTYTYPEBASIC(AirflowDirection,HVAC::AirflowDirection)
-       //typedef BasicPropertyType<HVAC::AirflowDirection> AirflowDirectionType;
+
+       static const Property AirflowDirectionW3C;
+       PROPERTYTYPE(AirflowDirectionW3C, AirflowDirectionW3CType, StringPropertyType, std::string)
 
        static const Property FanSpeed;
        PROPERTYTYPEBASIC(FanSpeed, uint16_t)
-       //typedef BasicPropertyType<uint16_t> FanSpeedType;
 
        static const Property TargetTemperature;
        PROPERTYTYPEBASIC(TargetTemperature, int)
-       //typedef BasicPropertyType<int> TargetTemperatureType;
 
        static const Property AirConditioning;
        PROPERTYTYPEBASIC(AirConditioning,bool)
-       //typedef BasicPropertyType<bool> AirConditioningType;
 
        static const Property AirRecirculation;
        PROPERTYTYPEBASIC(AirRecirculation,bool)
-       //typedef BasicPropertyType<bool> AirRecirculationType;
 
        static const Property Heater;
        PROPERTYTYPEBASIC(Heater, bool)
-       //typedef BasicPropertyType<bool> HeaterType;
 
+       /// TODO: deprecated. remove in 0.13
        static const Property Defrost;
        PROPERTYTYPEBASIC(Defrost, bool )
 
+       static const Property DefrostWindow;
+       PROPERTYTYPEBASIC(DefrostWindow, bool )
+
+       static const Property DefrostMirror;
+       PROPERTYTYPEBASIC(DefrostMirror, bool )
+
        static const Property SteeringWheelHeater;
        PROPERTYTYPEBASIC(SteeringWheelHeater,bool)
        //typedef BasicPropertyType<bool> SteeringWheelHeaterType;
@@ -754,6 +839,54 @@ public:
        static const Property DrivingMode;
        PROPERTYTYPEBASIC(DrivingMode, Driving::Mode)
 
+       static const Property DrivingModeW3C;
+       PROPERTYTYPEBASIC(DrivingModeW3C, bool)
+
+       static const Property KeyId;
+       PROPERTYTYPE(KeyId, KeyIdType, StringPropertyType, std::string)
+
+       static const Property Language;
+       PROPERTYTYPE(Language, LanguageType, StringPropertyType, std::string)
+
+       static const Property MeasurementSystem;
+       PROPERTYTYPEBASIC(MeasurementSystem, Measurement::Type)
+
+       static const Property MirrorSettingPan;
+       static const Property MirrorSettingTilt;
+
+       PROPERTYTYPEBASIC(MirrorSettingPan, uint16_t)
+       PROPERTYTYPEBASIC(MirrorSettingTilt, uint16_t)
+
+       static const Property SteeringWheelPositionSlide;
+       static const Property SteeringWheelPositionTilt;
+
+       PROPERTYTYPEBASIC(SteeringWheelPositionSlide, uint16_t)
+       PROPERTYTYPEBASIC(SteeringWheelPositionTilt, uint16_t)
+
+       static const Property SeatPositionRecline;
+       static const Property SeatPositionSlide;
+       static const Property SeatPositionCushionHeight;
+       static const Property SeatPositionHeadrest;
+       static const Property SeatPositionBackCushion;
+       static const Property SeatPositionSideCushion;
+
+       PROPERTYTYPEBASIC(SeatPositionRecline, uint16_t)
+       PROPERTYTYPEBASIC(SeatPositionSlide, uint16_t)
+       PROPERTYTYPEBASIC(SeatPositionCushionHeight, uint16_t)
+       PROPERTYTYPEBASIC(SeatPositionHeadrest, uint16_t)
+       PROPERTYTYPEBASIC(SeatPositionBackCushion, uint16_t)
+       PROPERTYTYPEBASIC(SeatPositionSideCushion, uint16_t)
+
+       static const Property DashboardIllumination;
+       PROPERTYTYPEBASIC(DashboardIllumination, uint16_t)
+
+       static const Property GeneratedVehicleSoundMode;
+       PROPERTYTYPEBASIC(GeneratedVehicleSoundMode, Vehicle::SoundMode)
+
+       static const Property DriverId;
+       PROPERTYTYPE(DriverId, DriverIdType, StringPropertyType, std::string)
+
+
        /** END PROPERTIES **/
 
 
@@ -762,13 +895,13 @@ public:
         * \return returns list of all registered properties
         * \see VehicleProperty::registerProperty
         */
-       static std::list<VehicleProperty::Property> capabilities();
+       static PropertyList capabilities();
 
        /*!
         * \brief customProperties
         * \return returns list of custom properties defined by plugins using VehicleProperty::registerProperty
         */
-       static std::list<VehicleProperty::Property> customProperties();
+       static PropertyList customProperties();
 
        /*! \brief getPropertyTypeForPropertyNameValue returns an AbstractPropertyType* for the property name
          * with the value specified by 'value'.  Ownership of the returned AbstractPropertyType* is
@@ -790,7 +923,7 @@ public:
         *  //Somewhere in a source plugin:
         *  ...
         *  Property VehicleJetEngineStatus = "VehicleJetEngineStatus";
-        *  VehicleProperty::registerProperty(VehicleJetEngineStatus, [](){return new BasicPropertyType<bool>(false);});
+        *  VehicleProperty::registerProperty(VehicleJetEngineStatus, [](){return new BasicPropertyType<bool>(VehicleJetEngineStatus, false);});
         *  ...
         *  //other initialization
         */
@@ -807,11 +940,9 @@ private:
        static bool registerPropertyPriv(Property name, PropertyTypeFactoryCallback factory);
 
        static std::map<Property, PropertyTypeFactoryCallback> registeredPropertyFactoryMap;
-       static std::list<VehicleProperty::Property> mCapabilities;
-       static std::list<VehicleProperty::Property> mCustomProperties;
+       static PropertyList mCapabilities;
+       static PropertyList mCustomProperties;
 };
 
-typedef std::list<VehicleProperty::Property> PropertyList;
-typedef std::set<VehicleProperty::Property> PropertySet;
-
 #endif // VEHICLEPROPERTY_H
+