/* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // the drive of a vehicle, by the kind of its engine (EngineType, the Engine section of the .fiz): what each kind of // drive does in the step of the vehicle, in place of a switch on the engine type in each of those places. the drives // hold no state of their own yet (it is in physics::Vehicle): there is one of each kind, shared by the vehicles #pragma once #include "physics/vehicletypes.h" namespace physics { class Vehicle; } // what the step of the traction gives the drive struct DriveStep { double dt{0.0}; // the length of the step [s] double posRatio{0.0}; // the share of the controller positions, of the drive of no engine model (Dumb) double revolutions{0.0}; // the revolutions of the engine double moment{0.0}; // the moment of the diesel engine double transmission{0.0}; // the ratio of the transmission of the diesel engine }; class TractionDrive { public: virtual ~TractionDrive() = default; // the power of the engine for the controller positions; returns the share of the positions (Dumb), 0 for the others virtual double UpdateEnginePower(physics::Vehicle &vehicle) const; // before the traction force, whether the reverser is set or not virtual void BeforeTractionForce(physics::Vehicle &vehicle, double dt) const; // the traction force of the step (Ft), the reverser set virtual void UpdateTractionForce(physics::Vehicle &vehicle, DriveStep const &step) const; // after the traction force, whether the reverser is set or not virtual void AfterTractionForce(physics::Vehicle &vehicle) const; // the blowers of the starting resistors and the fans of the radiators virtual void UpdateVentilators(physics::Vehicle &vehicle, double dt) const; // the current the given ammeter of the cab shows virtual double ShowCurrent(physics::Vehicle const &vehicle, int ammeter) const; // the revolutions of the engine against the most it gives at the present controller position, 0..1; 1 with no // engine of revolutions virtual double EngineRpmRatio(physics::Vehicle const &vehicle) const; // the revolutions of the engine idling and at most [rpm]; the largest double with no engine of revolutions virtual double EngineIdleRpm(physics::Vehicle const &vehicle) const; virtual double EngineMaxRpm(physics::Vehicle const &vehicle) const; // the revolutions of the engine in the step (enrot); returns the revolutions a diesel-electric engine aims for, 0 for // the others. a diesel engine with a mechanical transmission gives its ratio and its moment through the references virtual double UpdateEngineRevolutions(physics::Vehicle &vehicle, double dt, double &transmission, double &moment) const; // a notch up and down of the master controller, as the kind of the engine takes it; return whether it moved virtual bool IncreaseMainController(physics::Vehicle &vehicle, int speed) const; virtual bool DecreaseMainController(physics::Vehicle &vehicle, int speed) const; // whether the line breaker has the power it needs to close, before the genset of a dual-mode vehicle has its say virtual bool MainsPowerAvailable(physics::Vehicle const &vehicle) const; // the relays that open the line breaker at a voltage out of range, or the line contactors virtual void CheckVoltageRelays(physics::Vehicle &vehicle) const; // the engine in the step of the vehicle: the automatic start of the series motors, the diesel engine; returns // whether a relay clicked virtual bool UpdateEngine(physics::Vehicle &vehicle, double dt) const; // the voltage of the traction motors in the step (EngineVoltage) virtual void UpdateEngineVoltage(physics::Vehicle &vehicle, double dt) const; }; // the drive of the given kind of engine TractionDrive const &DriveOf(TEngineType type);