only export dbus properties that are supported
[profile/ivi/automotive-message-broker.git] / lib / vehicleproperty.h
1 /*
2     Copyright (C) 2012  Intel Corporation
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Lesser General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19
20 #ifndef VEHICLEPROPERTY_H
21 #define VEHICLEPROPERTY_H
22
23 #include "nullptr.h"
24 #include <string>
25 #include <list>
26 #include <set>
27 #include <sstream>
28 #include <map>
29
30 #include <abstractpropertytype.h>
31
32 namespace ButtonEvents {
33 enum ButtonEventType {
34         NoButton = 0,
35         PlayButton = 1,
36         SkipButton = 1 << 1,
37         PrevButton = 1 << 2,
38         PauseButton = 1 << 3,
39         Preset1Button = 1 << 4,
40         Preset2Button = 1 << 5,
41         Preset3Button = 1 << 6,
42         Preset4Button = 1 << 7,
43         StopButton = 1 << 8,
44         NavigateUpButton = 1 << 9,
45         NavigateDownButton = 1 << 10,
46         NavigateLeftButton = 1 << 11,
47         NavigateRightButton = 1 << 12
48 };
49 }
50
51 namespace TurnSignals {
52 enum TurnSignalType
53 {
54         Off=0,
55         Right=1,
56         Left=2,
57         Hazard=3
58 };
59 }
60
61 namespace Transmission {
62 enum TransmissionPositions
63 {
64         Neutral = 0,
65         First,
66         Second,
67         Third,
68         Forth,
69         Fifth,
70         Sixth,
71         Seventh,
72         Eighth,
73         Ninth,
74         Tenth,
75         CVT = 64,
76         Drive = 96,
77         Reverse = 128,
78         Park = 255
79
80 };
81 enum Mode {
82         Normal=0,
83         Sports = 1,
84         Economy = 2,
85         OEMCustom1 = 3,
86         OEMCustom2 = 4
87 };
88 }
89
90 namespace Power {
91 enum PowerModes
92 {
93         Off = 0,
94         Accessory1 = 1,
95         Accessory2 = 2,
96         Run = 3
97 };
98 }
99
100 class VehicleProperty
101 {
102
103 public:
104         
105
106         VehicleProperty();
107
108         typedef std::string Property;
109         typedef std::function<AbstractPropertyType* (void)> PropertyTypeFactoryCallback;
110
111         /// Various property types:
112
113         static const Property NoValue;
114
115         /**< Vehicle Velocity in km/h */
116         static const Property VehicleSpeed;
117         typedef BasicPropertyType<uint16_t> VehicleSpeedType;
118
119         /**< Engine Speed in rotations per minute */
120         static const Property EngineSpeed;
121         typedef BasicPropertyType<uint16_t> EngineSpeedType;
122
123          /**< Transmission Shift Position
124          * 0 = Neutral
125          * 1 = 1st
126          * 2 = 2nd
127          * ...
128          * 96 = Drive
129          * 128 = Reverse
130          * 255 = Park
131          */
132         static const Property TransmissionShiftPosition;
133         typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionShiftPositionType;
134
135         /**< Transmission Gear Position
136         * 0 = Neutral
137         * 1 = 1st
138         * 2 = 2nd
139         * ...
140         * 64 = CVT
141         * 128 = Reverse
142         */
143         static const Property TransmissionGearPosition;
144         typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionGearPositionType;
145
146         static const Property TransmissionMode;
147         typedef BasicPropertyType<Transmission::Mode> TransmissionModeType;
148
149         /**< Throttle position 0-100% */
150         static const Property ThrottlePosition;
151         typedef BasicPropertyType<uint16_t> ThrottlePositionType;
152
153         /**< Wheel brake position.  Engaged = true, Idle = false */
154         static const Property WheelBrake;
155         typedef BasicPropertyType<bool> WheelBrakeType;
156
157         /**< Steering wheel angle (0-359) */
158         static const Property SteeringWheelAngle;
159         typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
160
161         /**< 0=off, 1=right, 2=left, 3=hazard */
162         static const Property TurnSignal;
163         typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType;
164
165         /**< Clutch pedal status 0=off, 1=on */
166         static const Property ClutchStatus;
167         typedef BasicPropertyType<bool> ClutchStatusType;
168
169          /**< Oil pressure TODO: units */
170         static const Property EngineOilPressure;
171         typedef BasicPropertyType<uint16_t> EngineOilPressureType;
172
173         /**< Engine coolant temperature in degrees celcius **/
174         static const Property EngineCoolantTemperature;
175         typedef BasicPropertyType<int> EngineCoolantTemperatureType;
176
177         /**< 0=off, 1=on */
178         static const Property MachineGunTurretStatus;
179         typedef BasicPropertyType<bool> MachineGunTurretStatusType;
180
181         /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
182         static const Property AccelerationX;
183         typedef BasicPropertyType<uint16_t> AccelerationType;
184
185         /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
186         static const Property AccelerationY;
187
188         /**< Acceleration on the 'z' axis in 1/1000 gravitational acceleration "g-force" */
189         static const Property AccelerationZ;
190
191         /**< Mass Air Flow.  TODO: units */
192         static const Property MassAirFlow;
193         typedef BasicPropertyType<uint16_t> MassAirFlowType;
194
195         /**< Button Event @see ButtonEvents::ButtonEventType */
196         static const Property ButtonEvent;
197         typedef BasicPropertyType<ButtonEvents::ButtonEventType> ButtonEventType;
198
199         /**< Air intake temperature in degrees celcius */
200         static const Property AirIntakeTemperature;
201         typedef BasicPropertyType<int> AirIntakeTemperatureType;
202
203         /**< Battery voltage in volts */
204         static const Property BatteryVoltage;
205         typedef BasicPropertyType<double> BatteryVoltageType;
206
207         /**< Interior Air Temperature in degrees celcius */
208         static const Property InteriorTemperature;
209         typedef BasicPropertyType<int> InteriorTemperatureType;
210
211         /**< Engine Oil Temperature in degrees celcius */
212         static const Property EngineOilTemperature;
213         typedef BasicPropertyType<int> EngineOilTemperatureType;
214
215         /**< Vehicle Identification Number (ISO 3779) 17 chars**/
216         static const Property VIN;
217         typedef StringPropertyType VINType;
218
219         /**< World Manufacturer Identifier (SAE) 3 characters. */
220         static const Property WMI;
221         typedef StringPropertyType WMIType;
222
223         /**< Tire pressure in kPa */
224         static const Property TirePressureLeftFront;
225         static const Property TirePressureRightFront;
226         static const Property TirePressureLeftRear;
227         static const Property TirePressureRightRear;
228         typedef BasicPropertyType<uint16_t> TirePressureType;
229
230         static const Property VehiclePowerMode;
231         typedef BasicPropertyType<Power::PowerModes> VehiclePowerModeType;
232
233         static const Property TripMeterA;
234         static const Property TripMeterB;
235         static const Property TripMeterC;
236         typedef BasicPropertyType<uint16_t> TripMeterType;
237
238         static std::list<VehicleProperty::Property> capabilities();
239
240         /*! getPropertyTypeForPropertyNameValue returns an AbstractPropertyType* for the property name
241           * with the value specified by 'value'.  Ownership of the returned AbstractPropertyType* is
242           * transfered to the caller.
243           */
244         static AbstractPropertyType* getPropertyTypeForPropertyNameValue(Property name, std::string value);
245
246         static void registerProperty(Property name, PropertyTypeFactoryCallback factory);
247
248 private:
249
250         static std::map<Property, PropertyTypeFactoryCallback> registeredPropertyFactoryMap;
251         static std::list<VehicleProperty::Property> mCapabilities;
252 };
253
254 typedef std::list<VehicleProperty::Property> PropertyList;
255 typedef std::set<VehicleProperty::Property> PropertySet;
256
257 #endif // VEHICLEPROPERTY_H