C

Qt Quick Ultralite Automotive Cluster Demo

/****************************************************************************** ** ** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt 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 The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
#include "simulationcontroller.h" #include "Automotive/MainModel.h" #include "statemachine.h" #include "simulation/smfwd.h" #include "simulation/states.h" #include "simulation/drivestates.h" using namespace Simulation; void introFinished(Machine &sm); namespace { // State Machine instance Machine sm(State_Idle); // State Instances IntroState introState(introFinished); DriveModeMenuState driveModeMenuState; CarStatusMenuState carStatusMenuState; LastTripMenuState lastTripMenuState; NormalDriveState normalDriveState; MediaPlayerState mediaPlayerState(State_Navi); NaviState naviState(State_Phone); PhoneState phoneState(State_DriveModeMenu); SportDriveState sportDriveState; InteractiveModeState interactiveModeState; EndState endState(State_Intro); } // namespace SimulationController::SimulationController() { sm.registerState(State_Intro, &introState); sm.registerState(State_NormalDrive, &normalDriveState); sm.registerState(State_MediaPlayer, &mediaPlayerState); sm.registerState(State_Navi, &naviState); sm.registerState(State_Phone, &phoneState); sm.registerState(State_DriveModeMenu, &driveModeMenuState); sm.registerState(State_CarStatus, &carStatusMenuState); sm.registerState(State_LastTrip, &lastTripMenuState); sm.registerState(State_SportDrive, &sportDriveState); sm.registerState(State_InteractiveMode, &interactiveModeState); sm.registerState(State_End, &endState); } void SimulationController::start() { sm.changeState(State_Intro, Layer_Gauges); sm.changeState(State_MediaPlayer, Layer_Menu, 5000); } void SimulationController::startInteractiveMode() { if (sm.getCurrentStateId(Layer_Menu) != State_InteractiveMode) { sm.dismissUpdate(Layer_Menu); sm.dismissScheduledStateChanges(Layer_Menu); sm.changeState(State_InteractiveMode, Layer_Menu); } } void SimulationController::stopInteractiveMode() { sm.requestUpdate(0, false, Layer_Menu); } void SimulationController::switchToNormalMode() { sm.changeState(State_NormalDrive, Layer_Gauges); } void SimulationController::switchToSportMode() { sm.changeState(State_SportDrive, Layer_Gauges); } void introFinished(Machine &sm) { sm.changeState(State_NormalDrive, Layer_Gauges); sm.changeState(State_MediaPlayer, Layer_Menu); }