1 /****************************************************************************
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Copyright (C) 2018, 2019 Konsulko Group
5 ** Contact: https://www.qt.io/licensing/
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
19 ** Alternatively, you may use this file under the terms of the BSD license
22 ** "Redistribution and use in source and binary forms, with or without
23 ** modification, are permitted provided that the following conditions are
25 ** * Redistributions of source code must retain the above copyright
26 ** notice, this list of conditions and the following disclaimer.
27 ** * Redistributions in binary form must reproduce the above copyright
28 ** notice, this list of conditions and the following disclaimer in
29 ** the documentation and/or other materials provided with the
31 ** * Neither the name of The Qt Company Ltd nor the names of its
32 ** contributors may be used to endorse or promote products derived
33 ** from this software without specific prior written permission.
36 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
50 ****************************************************************************/
56 property bool mphDisplay: true
57 property real speedScaling: mphDisplay == true ? 0.621504 : 1.0
59 property real fuel: 0.85
60 property string gear: {
78 property string prindle: {
86 property bool start: true
87 property int turnSignal: -1
88 property bool startUp: false
89 property real temperature: 0.6
90 property bool cruiseEnabled: false
91 property bool cruiseSet: false
92 property bool laneDepartureWarnEnabled: false
93 property bool displayNumericSpeeds: true
95 function randomDirection() {
96 return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow;
100 target: SignalComposer
103 if (uid === "event.vehicle.speed") {
104 var speed_tmp = parseFloat(value)
109 valueSource.kph = speed_tmp
112 else if (uid === "event.engine.speed") {
114 valueSource.rpm = parseFloat(value) / 1000
117 else if (uid === "event.cruise.enable" && value === "true") {
118 if(valueSource.cruiseEnabled) {
119 valueSource.cruiseEnabled = false
120 valueSource.cruiseSet = false
122 valueSource.cruiseEnabled = true
125 else if ((uid === "event.cruise.set" || uid === "event.cruise.resume") &&
127 if(valueSource.cruiseEnabled) {
128 valueSource.cruiseSet = true
131 else if (uid === "event.cruise.cancel" && value === "true") {
132 valueSource.cruiseSet = false
134 else if (uid === "event.lane_departure_warning.enable" && value === "true") {
135 valueSource.laneDepartureWarnEnabled = !valueSource.laneDepartureWarnEnabled
137 else if (uid === "event.info" && value === "true") {
138 valueSource.displayNumericSpeeds = !valueSource.displayNumericSpeeds
143 SequentialAnimation {
144 running: runAnimation
147 // We want a small pause at the beginning, but we only want it to happen once.
158 SequentialAnimation {
159 loops: Animation.Infinite
161 // Simulate startup with indicators blink
180 easing.type: Easing.InOutSine
188 easing.type: Easing.InOutSine
195 // We changed gears so we lost a bit of speed.
199 easing.type: Easing.InOutSine
207 easing.type: Easing.InOutSine
217 easing.type: Easing.InOutSine
224 easing.type: Easing.InOutSine
230 // We changed gears so we lost a bit of speed.
234 easing.type: Easing.InOutSine
241 easing.type: Easing.InOutSine
250 easing.type: Easing.InOutSine
257 easing.type: Easing.InOutSine
263 // We changed gears so we lost a bit of speed.
267 easing.type: Easing.InOutSine
274 easing.type: Easing.InOutSine
284 easing.type: Easing.InOutSine
291 easing.type: Easing.InOutSine
302 easing.type: Easing.InOutSine
309 easing.type: Easing.InOutSine
318 property: "turnSignal"
319 value: randomDirection()
322 // Cruise for a while
327 easing.type: Easing.InOutSine
334 easing.type: Easing.InOutSine
343 property: "turnSignal"
351 easing.type: Easing.InOutSine
358 easing.type: Easing.InOutSine
364 // Start downshifting.
366 // Fifth to fourth gear.
371 easing.type: Easing.Linear
379 easing.type: Easing.InOutSine
385 // Fourth to third gear.
389 easing.type: Easing.InOutSine
398 easing.type: Easing.InOutSine
405 easing.type: Easing.InOutSine
411 // Third to second gear.
415 easing.type: Easing.InOutSine
424 easing.type: Easing.InOutSine
431 easing.type: Easing.InOutSine
440 easing.type: Easing.InOutSine
445 // Second to first gear.
450 easing.type: Easing.InOutSine
457 easing.type: Easing.InOutSine