Version bump 0.2
[profile/ivi/automotive-message-broker.git] / plugins / exampleplugin.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 #include "exampleplugin.h"
20
21 #include <iostream>
22 #include <boost/assert.hpp>
23
24 using namespace std;
25
26 #include "enginespeedproperty.h"
27 #include "vehiclepowermodeproperty.h"
28 #include "fueleconomyproperty.h"
29 #include "tripmeterproperty.h"
30 #include "transmissiongearstatus.h"
31 #include "cruisecontrolstatus.h"
32 #include "wheelbrakeproperty.h"
33 #include "lightstatusproperty.h"
34 #include "interiorlightstatusproperty.h"
35 #include "hornproperty.h"
36 #include "chime.h"
37 #include "fuellevelproperty.h"
38 #include "fuelrangeproperty.h"
39 #include "engineoilproperty.h"
40 #include "enginecoolantproperty.h"
41 #include "accelerationproperty.h"
42 #include "steeringwheelangleproperty.h"
43
44 #include "debugout.h"
45
46 ExamplePlugin::ExamplePlugin()
47 {
48         uint16_t velocity = 5;
49         
50         VehicleSpeedProperty* speed = new VehicleSpeedProperty();
51         *speed = velocity;
52         
53         EngineSpeedProperty* engineSpeed = new EngineSpeedProperty();
54         engineSpeed->setValue(2000);
55         
56         VehiclePowerModeProperty* vehiclePowerMode = new VehiclePowerModeProperty();
57         *vehiclePowerMode = VehiclePowerModeProperty::Run;
58         
59         FuelEconomyProperty* fueleconomyproperty = new FuelEconomyProperty();
60         *fueleconomyproperty = 42;
61         
62         TripMeters trips;
63         trips.push_back(1500);
64         trips.push_back(1000);
65         
66         TripMeterProperty* tripmeterproperty = new TripMeterProperty();
67         *tripmeterproperty = trips;
68         
69         TransmissionGearStatusProperty* transmissiongearstatus = new TransmissionGearStatusProperty();
70         transmissiongearstatus->setValue(TransmissionGearStatusProperty::First);
71         
72         CruiseControlStatus cruisecontrolstatus = CruiseControlStatus(true, velocity);
73
74         CruiseControlStatusProperty * cruisecontrolstatusproperty = new CruiseControlStatusProperty();
75         *cruisecontrolstatusproperty = cruisecontrolstatus;
76         
77         WheelBrakeProperty *wheelbrakeproperty = new WheelBrakeProperty();
78         *wheelbrakeproperty = false;
79         
80         LightStatusProperty::LightStatus lights;
81         lights[LightStatusProperty::Brake] = wheelbrakeproperty->value();
82         lights[LightStatusProperty::Fog] = true;
83         lights[LightStatusProperty::Head] = true;
84         lights[LightStatusProperty::HighBeam] = false;
85         lights[LightStatusProperty::Hazard] = false;
86         lights[LightStatusProperty::LeftTurn] = false;
87         lights[LightStatusProperty::RightTurn] = false;
88         lights[LightStatusProperty::Parking] = false;
89         
90         LightStatusProperty *lightstatusproperty = new LightStatusProperty();
91         *lightstatusproperty = lights;
92         
93         InteriorLightStatusProperty::InteriorLightStatus interiorLights;
94         interiorLights[InteriorLightStatusProperty::Driver] = false;
95         interiorLights[InteriorLightStatusProperty::Passenger] = true;
96         interiorLights[InteriorLightStatusProperty::Center] = false;
97         
98         InteriorLightStatusProperty* interiorlightstatusproperty = new InteriorLightStatusProperty();
99         *interiorlightstatusproperty = interiorLights;
100
101         HornProperty *hornProperty = new HornProperty();
102         *hornProperty = false;
103
104         Chime * chime = new Chime();
105         *chime = false;
106
107         bool val = *chime;
108
109         BOOST_ASSERT(val == false);
110
111         FuelLevelProperty *fuelLevel = new FuelLevelProperty();
112         *fuelLevel = (uint8_t)95;
113
114         uint8_t fl = *fuelLevel;
115
116         BOOST_ASSERT(fl == 95);
117
118         FuelRangeProperty* fuelRange = new FuelRangeProperty();
119
120         *fuelRange = 321;
121
122         uint16_t fr = *fuelRange;
123
124         BOOST_ASSERT(fr == 321);
125
126         EngineOilProperty *oilproperty = new EngineOilProperty();
127
128         EngineOil oil;
129         oil.temperature = 32;
130         oil.pressure = 400;
131         oil.remaining = 88;
132
133         *oilproperty = oil;
134
135         EngineOil ol = *oilproperty;
136
137         BOOST_ASSERT(ol == oil);
138
139         EngineCoolant coolant;
140         coolant.level= 99;
141         coolant.temperature = 44;
142
143         EngineCoolantProperty *coolantProp = new EngineCoolantProperty();
144         *coolantProp = coolant;
145
146         EngineCoolant ec = *coolantProp;
147
148         BOOST_ASSERT(ec == coolant);
149
150         AccelerationProperty* accelerationProp = new AccelerationProperty();
151         Acceleration accel;
152         accel.x = 1;
153         accel.y = 0.25;
154         accel.z = 0;
155
156         *accelerationProp = accel;
157
158         SteeringWheelAngleProperty * steeringWheelAngle = new SteeringWheelAngleProperty();
159
160         *steeringWheelAngle = 100;
161 }
162
163 extern "C" void create()
164 {
165         new ExamplePlugin;
166 }