summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/qtcluster/qtiviclusterdata.cpp
blob: 8c78326db97c5daa7fc9d7c578f3348b1424db8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/****************************************************************************
**
** Copyright (C) 2015 Pelagicore AG
** Contact: http://www.qt.io/ or http://www.pelagicore.com/
**
** This file is part of the QtIVI module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3-PELAGICORE$
** Commercial License Usage
** Licensees holding valid commercial Qt IVI licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Pelagicore. For licensing terms
** and conditions, contact us at http://www.pelagicore.com.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** $QT_END_LICENSE$
**
** SPDX-License-Identifier: LGPL-3.0
**
****************************************************************************/

#include "qtiviclusterdata.h"

QtIVIClusterData::QtIVIClusterData(QObject* parent)
    : QObject(parent),
      m_vehicleSpeed(0),
      m_latitude(0),
      m_longitude(0),
      m_direction(0),
      m_flatTire(false),
      m_doorOpen(false),
      m_lightFailure(false),
      m_reverse(false),
      m_leftTurnLight(false),
      m_rightTurnLight(false),
      m_headLight(false),
      m_parkLight(false),
      m_carId(1),
      m_brake(false),
      m_engineTemp(60),
      m_oilTemp(0.0),
      m_oilPressure(0),
      m_batteryPotential(80.0),
      m_gasLevel(67.0),
      m_rpm(4000),
      m_gear(1)
{
    connectToServiceObject();
}

void QtIVIClusterData::connectToServiceObject()
{
    initializeZones();
}

ZonedProperties *QtIVIClusterData::zoneAt(const QString &zone) const
{
    foreach (ZonedProperties *f, m_zoneFeatures)
        if (f->zone() == zone)
            return f;
    return 0;
}

void QtIVIClusterData::initializeZones()
{

}

QVariantMap QtIVIClusterData::zoneFeatureMap() const
{
    return m_zoneFeatureMap;

}

double QtIVIClusterData::vehicleSpeed() const
{
    return m_vehicleSpeed;
}

double QtIVIClusterData::latitude() const
{
    return m_latitude;
}

double QtIVIClusterData::longitude() const
{
    return m_longitude;
}

double QtIVIClusterData::direction() const
{
    return m_direction;
}

bool QtIVIClusterData::flatTire() const
{
    return m_flatTire;
}

bool QtIVIClusterData::doorOpen() const
{
    return m_doorOpen;
}

bool QtIVIClusterData::lightFailure() const
{
    return m_lightFailure;
}

bool QtIVIClusterData::reverse() const
{
    return m_reverse;
}

bool QtIVIClusterData::leftTurnLight() const
{
    return m_leftTurnLight;
}

bool QtIVIClusterData::rightTurnLight() const
{
    return m_rightTurnLight;
}

bool QtIVIClusterData::headLight() const
{
    return m_headLight;
}

bool QtIVIClusterData::parkLight() const
{
    return m_parkLight;
}

int QtIVIClusterData::carId() const
{
    return m_carId;
}

bool QtIVIClusterData::brake() const
{
    return  m_brake;
}

int QtIVIClusterData::engineTemp() const
{
    return m_engineTemp;
}

double QtIVIClusterData::oilTemp() const
{
    return m_oilTemp;
}

int QtIVIClusterData::oilPressure() const
{
    return m_oilPressure;
}

double QtIVIClusterData::batteryPotential() const
{
    return  m_batteryPotential;
}

double QtIVIClusterData::gasLevel() const
{
    return m_gasLevel;
}

int QtIVIClusterData::rpm() const
{
    return m_rpm;
}

int QtIVIClusterData::gear() const
{
    return  m_gear;
}

void QtIVIClusterData::classBegin()
{

}

void QtIVIClusterData::componentComplete()
{

}

void QtIVIClusterData::onVehicleSpeedChanged(double vehicleSpeed, const QString &zone)
{
    Q_UNUSED(zone);
    m_vehicleSpeed = vehicleSpeed;
    emit vehicleSpeedChanged(vehicleSpeed);
}

void QtIVIClusterData::onLatitudeChanged(double latitude, const QString &zone)
{
    Q_UNUSED(zone);
    m_latitude = latitude;
    emit latitudeChanged(latitude);
}

void QtIVIClusterData::onLongitudeChanged(double longitude, const QString &zone)
{
    Q_UNUSED(zone);
    m_longitude = longitude;
    emit longitudeChanged(longitude);
}

void QtIVIClusterData::onDirectionChanged(double direction, const QString &zone)
{
    Q_UNUSED(zone);
    m_direction = direction;
    emit directionChanged(direction);
}

void QtIVIClusterData::onFlatTireChanged(bool flatTire, const QString &zone)
{
    Q_UNUSED(zone);
    m_flatTire = flatTire;
    emit flatTireChanged(flatTire);
}

void QtIVIClusterData::onDoorOpenChanged(bool doorOpen, const QString &zone)
{
    ZonedProperties *z = zoneAt(zone);
    if (z) {
        z->setDoorOpen(doorOpen);
    }
}

void QtIVIClusterData::onLightFailureChanged(bool lightFailure, const QString &zone)
{
    Q_UNUSED(zone);
    m_lightFailure = lightFailure;
    emit lightFailureChanged(lightFailure);
}

void QtIVIClusterData::onReverseChanged(bool reverse, const QString &zone)
{
    Q_UNUSED(zone);
    m_reverse = reverse;
    emit reverseChanged(reverse);
}

void QtIVIClusterData::onLeftTurnLightChanged(bool leftTurnLight, const QString &zone)
{
    Q_UNUSED(zone);
    m_leftTurnLight = leftTurnLight;
    emit leftTurnLightChanged(leftTurnLight);
}

void QtIVIClusterData::onRightTurnLightChanged(bool rightTurnLight, const QString &zone)
{
    Q_UNUSED(zone);
    m_rightTurnLight = rightTurnLight;
    emit rightTurnLightChanged(rightTurnLight);
}

void QtIVIClusterData::onHeadLightChanged(bool headLight, const QString &zone)
{
    Q_UNUSED(zone);
    m_headLight = headLight;
    emit headLightChanged(headLight);
}

void QtIVIClusterData::onParkLightChanged(bool parkLight, const QString &zone)
{
    Q_UNUSED(zone);
    m_parkLight = parkLight;
    emit parkLightChanged(parkLight);
}

void QtIVIClusterData::onCarIdChanged(int carId, const QString &zone)
{
    Q_UNUSED(zone);
    m_carId = carId;
    emit carIdChanged(carId);
}

void QtIVIClusterData::onBrakeChanged(bool brakeOn, const QString &zone)
{
    Q_UNUSED(zone);
    m_brake = brakeOn;
    emit brakeChanged(brakeOn);
}

void QtIVIClusterData::onEngineTempChanged(int engineTemp, const QString &zone)
{
    Q_UNUSED(zone);
    m_engineTemp = engineTemp;
    emit engineTempChanged(engineTemp);
}

void QtIVIClusterData::onOilTempChanged(double oilTemp, const QString &zone)
{
    Q_UNUSED(zone);
    m_oilTemp = oilTemp;
    emit oilTempChanged(oilTemp);
}

void QtIVIClusterData::onOilPressureChanged(int oilPressure, const QString &zone)
{
    Q_UNUSED(zone);
    m_oilPressure = oilPressure;
    emit oilPressureChanged(oilPressure);
}

void QtIVIClusterData::onBatteryPotentialChanged(double batteryPotential, const QString &zone)
{
    Q_UNUSED(zone);
    m_batteryPotential = batteryPotential;
    emit batteryPotentialChanged(batteryPotential);
}

void QtIVIClusterData::onGasLevelChanged(double gasLevel, const QString &zone)
{
    Q_UNUSED(zone);
    m_gasLevel = gasLevel;
    emit gasLevelChanged(gasLevel);
}

void QtIVIClusterData::onRpmChanged(int rpm, const QString &zone)
{
    Q_UNUSED(zone);
    m_rpm = rpm;
    emit rpmChanged(rpm);
}

void QtIVIClusterData::onGearChanged(int gear, const QString &zone)
{
    Q_UNUSED(zone);
    m_gear = gear;
    emit gearChanged(gear);
}