51f344ca5173ec7db4b7a8d9575fc446df247c7e
[profile/ivi/automotive-message-broker.git] / lib / vehicleproperty.cpp
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 #include "vehicleproperty.h"
21 #include <map>
22
23 using namespace std;
24
25 const VehicleProperty::Property VehicleProperty::NoValue = "NoValue";
26 const VehicleProperty::Property VehicleProperty::VehicleSpeed = "VehicleSpeed";
27 const VehicleProperty::Property VehicleProperty::EngineSpeed = "EngineSpeed";
28 const VehicleProperty::Property VehicleProperty::TransmissionShiftPosition = "TransmissionShiftPosition";
29 const VehicleProperty::Property VehicleProperty::TransmissionGearPosition = "TransmissionGearPostion";
30 const VehicleProperty::Property VehicleProperty::ThrottlePosition = "ThrottlePosition";
31 const VehicleProperty::Property VehicleProperty::WheelBrake = "WheelBrake";
32 const VehicleProperty::Property VehicleProperty::SteeringWheelAngle = "SteeringWheelAngle";
33 const VehicleProperty::Property VehicleProperty::TurnSignal = "TurnSignal";
34 const VehicleProperty::Property VehicleProperty::ClutchStatus = "ClutchStatus";
35 const VehicleProperty::Property VehicleProperty::EngineOilPressure = "EngineOilPressure";
36 const VehicleProperty::Property VehicleProperty::EngineCoolantTemperature = "EngineCoolantTemperature";
37 const VehicleProperty::Property VehicleProperty::MachineGunTurretStatus = "MachineGunTurretStatus";
38 const VehicleProperty::Property VehicleProperty::AccelerationX = "AccelerationX";
39 const VehicleProperty::Property VehicleProperty::AccelerationY = "AccelerationY";
40 const VehicleProperty::Property VehicleProperty::AccelerationZ = "AccelerationZ";
41 const VehicleProperty::Property VehicleProperty::MassAirFlow = "MassAirFlow";
42 const VehicleProperty::Property VehicleProperty::ButtonEvent = "ButtonEvent";
43 const VehicleProperty::Property VehicleProperty::AirIntakeTemperature = "AirIntakeTemperature";
44 const VehicleProperty::Property VehicleProperty::BatteryVoltage = "BatteryVoltage";
45 const VehicleProperty::Property VehicleProperty::InteriorTemperature = "InteriorTemperature";
46 const VehicleProperty::Property VehicleProperty::EngineOilTemperature = "EngineOilTemperature";
47 const VehicleProperty::Property VehicleProperty::VIN = "VIN";
48 const VehicleProperty::Property VehicleProperty::WMI = "WMI";
49
50 VehicleProperty::VehicleProperty()
51 {
52
53 }
54
55 std::list<VehicleProperty::Property> VehicleProperty::capabilities()
56 {
57         PropertyList mProperties;
58
59         mProperties.push_back(VehicleSpeed);
60         mProperties.push_back(EngineSpeed);
61         mProperties.push_back(TransmissionShiftPosition);
62         mProperties.push_back(TransmissionGearPosition);
63         mProperties.push_back(ThrottlePosition);
64         mProperties.push_back(WheelBrake);
65         mProperties.push_back(SteeringWheelAngle);
66         mProperties.push_back(TurnSignal);
67         mProperties.push_back(ClutchStatus);
68         mProperties.push_back((EngineOilPressure));
69         mProperties.push_back(EngineCoolantTemperature);
70         mProperties.push_back(AccelerationX);
71         mProperties.push_back(AccelerationY);
72         mProperties.push_back(AccelerationZ);
73         mProperties.push_back(MassAirFlow);
74         mProperties.push_back(ButtonEvent);
75         mProperties.push_back(AirIntakeTemperature);
76         mProperties.push_back(BatteryVoltage);
77         mProperties.push_back(InteriorTemperature);
78         mProperties.push_back(EngineOilTemperature);
79         mProperties.push_back(VIN);
80         mProperties.push_back(WMI);
81
82         return mProperties;
83 }
84
85 AbstractPropertyType* VehicleProperty::getPropertyTypeForPropertyNameValue(VehicleProperty::Property name, std::string value)
86 {
87
88         if(name == VehicleSpeed ) return new VehicleSpeedType(value);
89         else if(name == EngineSpeed) return new EngineSpeedType(value);
90         else if(name == TransmissionShiftPosition) return new TransmissionShiftPositionType(value);
91         else if(name == TransmissionGearPosition) return new TransmissionGearPositionType(value);
92         else if(name == ThrottlePosition) return new ThrottlePositionType(value);
93         else if(name == WheelBrake) return new WheelBrakeType(value);
94         else if(name == SteeringWheelAngle) return new SteeringWheelAngleType(value);
95         else if(name == TurnSignal) return new TurnSignalType(value);
96         else if(name == ClutchStatus) return new ClutchStatusType(value);
97         else if(name == EngineOilPressure) return new EngineOilPressureType(value);
98         else if(name == EngineCoolantTemperature) return new EngineCoolantTemperatureType(value);
99         else if(name == AccelerationX) return new AccelerationType(value);
100         else if(name == AccelerationY) return new AccelerationType(value);
101         else if(name == AccelerationZ) return new AccelerationType(value);
102         else if(name == MassAirFlow) return new MassAirFlowType(value);
103         else if(name == AirIntakeTemperature) return new AirIntakeTemperatureType(value);
104         else if(name == BatteryVoltage) return new BatteryVoltageType(value);
105         else if(name == InteriorTemperature) return new InteriorTemperatureType(value);
106         else if(name == EngineOilTemperature) return new EngineOilTemperatureType(value);
107         else if(name == VIN) return new VINType(value);
108         else if(name == WMI) return new WMIType(value);
109
110
111         return nullptr;
112 }