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$ ** ******************************************************************************/
#ifndef STATES_H #define STATES_H #include "simulation/smfwd.h" #include "simulation/drivetrain.h" #include "simulation/speedlimits.h" #include "Automotive/MainModel.h" namespace Simulation { struct SimulationState : Machine::AbstractState { void onEnter(const StateId &, const Layer &, Machine &) {} void onUpdate(uint32_t, const Layer &, Machine &) {} void onLeave(const StateId &, const Layer &, Machine &) {} }; struct MenuState : SimulationState { MenuState(const StateId &nextState); StateId _nextState; }; struct ClusterModeState : public SimulationState { ClusterModeState(Automotive::MainModel::ClusterMode); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); private: Automotive::MainModel::ClusterMode mode; }; struct IntroState : public ClusterModeState { typedef void (*IntroFinishedCallback)(Machine &sm); IntroState(IntroFinishedCallback finishedCallback); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); void onLeave(const StateId &nextState, const Layer &layer, Machine &sm); private: enum Step { Step_Blank, Step_ShowQtLogo, Step_ShowCluster, Step_ShowTellTales, Step_ShowGauges, Step_MaxGauges, Step_ResetGauges, Step_TellTalesResetLights, Step_TellTalesResetPark, Step_TellTalesResetAirbag, Step_Done } _step; IntroFinishedCallback _finishedCallback; }; struct EndState : public SimulationState { EndState(const StateId &nextState); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); private: StateId _nextState; }; struct PhoneState : public MenuState { PhoneState(const StateId &nextState); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); private: enum Step { Step_Blank, Step_ShowMenu, Step_ChangeTab, Step_ChooseNextContact, Step_ScrollToNextContact, Step_StartCall, Step_EndCall, Step_Done } _step; int8_t _contactsToScroll; }; struct MediaPlayerState : public MenuState { MediaPlayerState(const StateId &nextState); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); private: enum Step { Step_Play, Step_ChangeTracks, Step_Done } _step; void nextStep(Step step); uint64_t _cumulatedTime; uint64_t _changeTracksDuration; }; struct NaviState : public MenuState { NaviState(const StateId &nextState); void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); private: enum Step { Step_Navi, Step_Done } _step; uint64_t _cumulatedTime; }; struct DriveModeMenuState : public SimulationState { void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); private: enum Step { Step_Blank, Step_DisplayDriveModeMenu, Step_SwitchDriveModeOption, Step_ChangeDriveMode, Step_Done } _step; }; struct CarStatusMenuState : public SimulationState { void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); }; struct LastTripMenuState : public SimulationState { void onEnter(const StateId &prevState, const Layer &layer, Machine &sm); }; struct InteractiveModeState : public SimulationState { void onUpdate(uint32_t tick, const Layer &layer, Machine &sm); }; } // namespace Simulation #endif // STATES_H