2 Copyright (C) 2012 Intel Corporation
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.
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.
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
20 #ifndef VEHICLEPROPERTY_H
21 #define VEHICLEPROPERTY_H
31 #include <abstractpropertytype.h>
33 namespace ButtonEvents {
34 enum ButtonEventType {
40 Preset1Button = 1 << 4,
41 Preset2Button = 1 << 5,
42 Preset3Button = 1 << 6,
43 Preset4Button = 1 << 7,
45 NavigateUpButton = 1 << 9,
46 NavigateDownButton = 1 << 10,
47 NavigateLeftButton = 1 << 11,
48 NavigateRightButton = 1 << 12
52 namespace TurnSignals {
62 namespace Transmission {
63 enum TransmissionPositions
99 /**< Vehicle Power Modes
100 * Off = Vehicle is off and key is in the "off" position.
101 * Accessory1 = Vehicle is off and key is in Accessory1 position.
102 * Accessory2 = Vehicle is off and key is in Accessory2 position.
103 * Run = Vehichle is running. Key is in the running position.
127 UnknownPosition = -1,
158 class VehicleProperty
166 typedef std::string Property;
167 typedef std::function<AbstractPropertyType* (void)> PropertyTypeFactoryCallback;
169 /// Various property types:
171 static const Property NoValue;
173 /**< Vehicle Velocity in km/h */
174 static const Property VehicleSpeed;
175 typedef BasicPropertyType<uint16_t> VehicleSpeedType;
177 /**< Engine Speed in rotations per minute */
178 static const Property EngineSpeed;
179 typedef BasicPropertyType<uint16_t> EngineSpeedType;
181 /**< Transmission Shift Position
190 static const Property TransmissionShiftPosition;
191 typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionShiftPositionType;
193 /**< Transmission Gear Position
201 static const Property TransmissionGearPosition;
202 typedef BasicPropertyType<Transmission::TransmissionPositions> TransmissionGearPositionType;
204 static const Property TransmissionMode;
205 typedef BasicPropertyType<Transmission::Mode> TransmissionModeType;
207 /**< Throttle position 0-100% */
208 static const Property ThrottlePosition;
209 typedef BasicPropertyType<uint16_t> ThrottlePositionType;
211 /**< Wheel brake position. Engaged = true, Idle = false */
212 static const Property WheelBrake;
213 typedef BasicPropertyType<bool> WheelBrakeType;
215 static const Property WheelBrakePressure;
216 typedef BasicPropertyType<uint16_t> WheelBrakePressureType;
218 /**< Steering wheel angle (0-359) */
219 static const Property SteeringWheelAngle;
220 typedef BasicPropertyType<uint16_t> SteeringWheelAngleType;
222 /**< 0=off, 1=right, 2=left, 3=hazard */
223 static const Property TurnSignal;
224 typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType;
226 /**< Clutch pedal status 0=off, 1=on */
227 static const Property ClutchStatus;
228 typedef BasicPropertyType<bool> ClutchStatusType;
230 /**< Oil pressure TODO: units */
231 static const Property EngineOilPressure;
232 typedef BasicPropertyType<uint16_t> EngineOilPressureType;
234 /**< Engine coolant temperature in degrees celcius **/
235 static const Property EngineCoolantTemperature;
236 typedef BasicPropertyType<int> EngineCoolantTemperatureType;
239 static const Property MachineGunTurretStatus;
240 typedef BasicPropertyType<bool> MachineGunTurretStatusType;
242 /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */
243 static const Property AccelerationX;
244 typedef BasicPropertyType<uint16_t> AccelerationType;
246 /**< Acceleration on the 'y' axis in 1/1000 gravitational acceleration "g-force" */
247 static const Property AccelerationY;
249 /**< Acceleration on the 'z' axis in 1/1000 gravitational acceleration "g-force" */
250 static const Property AccelerationZ;
252 /**< Mass Air Flow. TODO: units */
253 static const Property MassAirFlow;
254 typedef BasicPropertyType<uint16_t> MassAirFlowType;
256 /**< Button Event @see ButtonEvents::ButtonEventType */
257 static const Property ButtonEvent;
258 typedef BasicPropertyType<ButtonEvents::ButtonEventType> ButtonEventType;
260 /**< Air intake temperature in degrees celcius */
261 static const Property AirIntakeTemperature;
262 typedef BasicPropertyType<int> AirIntakeTemperatureType;
264 /**< Battery voltage in volts */
265 static const Property BatteryVoltage;
266 typedef BasicPropertyType<double> BatteryVoltageType;
268 static const Property BatteryCurrent;
269 typedef BasicPropertyType<double> BatteryCurrentType;
271 /**< Interior Air Temperature in degrees celcius */
272 static const Property InteriorTemperature;
273 typedef BasicPropertyType<int> InteriorTemperatureType;
275 /**< Engine Oil Temperature in degrees celcius */
276 static const Property EngineOilTemperature;
277 typedef BasicPropertyType<int> EngineOilTemperatureType;
279 static const Property EngineOilRemaining;
280 typedef BasicPropertyType<uint16_t> EngineOilRemainingType;
282 /**< Vehicle Identification Number (ISO 3779) 17 chars**/
283 static const Property VIN;
284 typedef StringPropertyType VINType;
286 /**< World Manufacturer Identifier (SAE) 3 characters. */
287 static const Property WMI;
288 typedef StringPropertyType WMIType;
290 /**< Tire pressure in kPa */
291 static const Property TirePressureLeftFront;
292 static const Property TirePressureRightFront;
293 static const Property TirePressureLeftRear;
294 static const Property TirePressureRightRear;
295 typedef BasicPropertyType<double> TirePressureType;
297 /**< Tire temperature in degrees C */
298 static const Property TireTemperatureLeftFront;
299 static const Property TireTemperatureRightFront;
300 static const Property TireTemperatureLeftRear;
301 static const Property TireTemperatureRightRear;
302 typedef BasicPropertyType<double> TireTemperatureType;
304 /**< Vehicle Power Mode.
305 *@see Power::PowerModes
307 static const Property VehiclePowerMode;
308 typedef BasicPropertyType<Power::PowerModes> VehiclePowerModeType;
310 static const Property TripMeterA;
311 static const Property TripMeterB;
312 static const Property TripMeterC;
313 typedef BasicPropertyType<uint16_t> TripMeterType;
315 static const Property CruiseControlActive;
316 typedef BasicPropertyType<bool> CruiseControlActiveType;
318 static const Property CruiseControlSpeed;
319 typedef BasicPropertyType<uint16_t> CruiseControlSpeedType;
321 static const Property LightHead;
322 static const Property LightRightTurn;
323 static const Property LightLeftTurn;
324 static const Property LightBrake;
325 static const Property LightFog;
326 static const Property LightHazard;
327 static const Property LightParking;
328 static const Property LightHighBeam;
329 typedef BasicPropertyType<bool> LightStatusType;
330 static const Property InteriorLightDriver;
331 static const Property InteriorLightCenter;
332 static const Property InteriorLightPassenger;
334 static const Property EngineLoad;
335 typedef BasicPropertyType<uint16_t> EngineLoadType;
337 static const Property Horn;
338 typedef BasicPropertyType<bool> HornType;
340 static const Property FuelLevel;
341 typedef BasicPropertyType<uint16_t> FuelLevelType;
343 static const Property FuelRange;
344 typedef BasicPropertyType<uint16_t> FuelRangeType;
346 static const Property FuelConsumption;
347 typedef BasicPropertyType<uint16_t> FuelConsumptionType;
349 static const Property FuelEconomy;
350 typedef BasicPropertyType<uint16_t> FuelEconomyType;
352 static const Property FuelAverageEconomy;
353 typedef BasicPropertyType<uint16_t> FuelAverageEconomyType;
355 static const Property FuelType;
356 typedef BasicPropertyType<Fuel::Type> FuelTypeType;
358 static const Property FuelPositionSide;
359 typedef BasicPropertyType<Fuel::RefuelPosition> FuelPositionSideType;
361 static const Property ExteriorBrightness;
362 typedef BasicPropertyType<uint16_t> ExteriorBrightnessType;
364 static const Property Latitude;
365 typedef BasicPropertyType<double> LatitudeType;
367 static const Property Longitude;
368 typedef BasicPropertyType<double> LongitudeType;
370 static const Property Altitude;
371 typedef BasicPropertyType<double> AltitudeType;
373 static const Property Direction;
374 typedef BasicPropertyType<uint> DirectionType;
376 static const Property VehicleWidth;
377 static const Property VehicleHeight;
378 static const Property VehicleLength;
379 typedef BasicPropertyType<uint> VehicleSizeType;
382 static const Property VehicleType;
383 typedef BasicPropertyType<Vehicle::Type> VehicleTypeType;
385 static const Property DoorsPerRow;
386 typedef ListPropertyType<BasicPropertyType<uint16_t> > DoorsPerRowType;
388 static const Property TransmissionGearType;
389 typedef BasicPropertyType<Transmission::Type> TransmissionGearTypeType;
391 static const Property FrontWheelRadius;
392 static const Property RearWheelRadius;
393 typedef BasicPropertyType<uint16_t> WheelRadiusType;
395 static const Property WheelTrack;
396 typedef BasicPropertyType<uint> WheelTrackType;
398 static const Property Odometer;
399 typedef BasicPropertyType<uint> OdometerType;
401 /**< Transmission Fluid Level 0-100%.
403 static const Property TransmissionFluidLevel;
404 typedef BasicPropertyType<uint16_t> TransmissionFluidLevelType;
406 /**< Brake Fluid Level 0-100%.
408 static const Property BrakeFluidLevel;
409 typedef BasicPropertyType<uint16_t> BrakeFluidLevelType;
411 /**< Washer Fluid Level 0-100%.
413 static const Property WasherFluidLevel;
414 typedef BasicPropertyType<uint16_t> WasherFluidLevelType;
416 /**< Securty Alert Status
417 * status of security alert
418 * @see Security::Status
420 static const Property SecurityAlertStatus;
421 typedef BasicPropertyType<Security::Status> SecurityAlertStatusType;
423 /**< Parking Brake Status
424 * status of parking break active (true) or inactive (false)
426 static const Property ParkingBrakeStatus;
427 typedef BasicPropertyType<bool> ParkingBrakeStatusType;
429 /**< Parking Light Status
430 * status of parking lights active (true) or inactive (false)
432 static const Property ParkingLightStatus;
433 typedef BasicPropertyType<bool> ParkingLightStatusType;
435 /**< Hazard Lights Status
436 * status of parking lights active (true) or inactive (false)
438 static const Property HazardLightStatus;
439 typedef BasicPropertyType<bool> HazardLightStatusType;
442 /** END PROPERTIES **/
445 static std::list<VehicleProperty::Property> capabilities();
446 static std::list<VehicleProperty::Property> customProperties();
448 /*! getPropertyTypeForPropertyNameValue returns an AbstractPropertyType* for the property name
449 * with the value specified by 'value'. Ownership of the returned AbstractPropertyType* is
450 * transfered to the caller.
452 static AbstractPropertyType* getPropertyTypeForPropertyNameValue(Property name, std::string value="");
454 /*! registerProperty registers properties with the Vehicle Property system. Returns true if property
455 * has been registered successfully.
456 * @param name - name of property. Name cannot match any existing property or it will be rejected and
457 * this method will return false.
458 * @param factor - callback function that returns an AbstractPropertyType representation of the value.
459 * custom properties will need to return a custom AbstractPropertyType based object.
462 * #include <vehicleproperty.h>
463 * #include <abstractpropertytype.h>
465 * //Somewhere in a source plugin:
467 * Property VehicleJetEngineStatus = "VehicleJetEngineStatus";
468 * VehicleProperty::registerProperty(VehicleJetEngineStatus, [](){return new BasicPropertyType<bool>(false);});
470 * //other initialization
472 static bool registerProperty(Property name, PropertyTypeFactoryCallback factory);
477 static bool registerPropertyPriv(Property name, PropertyTypeFactoryCallback factory);
479 static std::map<Property, PropertyTypeFactoryCallback> registeredPropertyFactoryMap;
480 static std::list<VehicleProperty::Property> mCapabilities;
481 static std::list<VehicleProperty::Property> mCustomProperties;
484 typedef std::list<VehicleProperty::Property> PropertyList;
485 typedef std::set<VehicleProperty::Property> PropertySet;
487 #endif // VEHICLEPROPERTY_H