C
Qt Quick Ultralite Motorcycle 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 DRIVESTATES_H #define DRIVESTATES_H #include "simulation/smfwd.h" #include "simulation/+small/states.h" #include "MotorCluster/NavigationModel.h" namespace Simulation { class NormalDriveState : public SimulationState { public: NormalDriveState(StateId nextState); void onEnter(const StateId &, const Layer &layer, Machine &sm); void onUpdate(uint32_t, const Layer &layer, Machine &sm); void onLeave(const StateId &, const Layer &layer, Machine &sm); void updateModel(); private: enum Step { Step_Start, Step_GoingOut, Step_FirstCorner, Step_FirstStright, Step_SecondCorner, Step_BeginnigOfLongStright, Step_OilProblems, Step_SlowingDownToPetrolStation, Step_TurningToPetrolStation, Step_PetrolStation, Step_FillingTheTank, Step_ShowStatistics, Step_TurnOffNavigation, Step_TypeDestination, Step_backToDriveMode, Step_LeavingPetrolStation, Step_SecondStright, Step_BatteryProblems, Step_EngineProblems, Step_EndOfSecondStright, Step_MoveToNextState } _step; void moveToNextStep(const Layer &layer, Machine &sm); void calculateDriveData(uint32_t tick); void setSpeedTarget(int targetSpeed, bool withRandomAccChanges = true); void setFuelTarget(float targetFuel, float fuelSpeed); void setDistanceToTarget(float distance); void setNavigation(MotorCluster::NavigationModel::NaviState state, MotorCluster::NavigationModel::ArrowsState arrowsConfiguration, float distance); int _timeToFinishStepWhenTargetSpeedWasMet; bool _wasSpeedToFinishStepMet; StateId _nextState; }; } // namespace Simulation #endif // DRIVESTATES_H