C
Qt Quick Ultralite Motorcycle Cluster Demo
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
#ifndef DRIVESTATES_H
#define DRIVESTATES_H
#include "simulation/smfwd.h"
#include "simulation/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