mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 18:56:49 +01:00
74f0aa240d
TTrain and whois_event reached into the private members of TController as its
friends; they read what the AI knows of its consist and its route through
queries now (ConsistDoorsOpen(), ConsistConverterOverloaded(), ConsistLength(),
DesiredVelocity(), NextSignalVelocity(), BrakesReleaseLevel(), ...), and the cab
changes the radio channel through SetRadioChannel() rather than a reference to
the AI's field. The reversers of the consist, the stations of the timetable and
the obstacle ahead are public queries and operations.
The public fields of TController are private: whether the AI drives
(AIControllFlag()), the masks of the running without current the vehicles of
the consist set (MarkOverhead(), the same bits TDynamicObject::OverheadTrack()
set itself), the most deceleration of the blended brakes (MedAmax(),
SetMedAmax()), and the positions the driving aid panels show. Only the four
debug and timetable panels stay friends.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
864 lines
46 KiB
C++
864 lines
46 KiB
C++
/*
|
|
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/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
#include "utilities/Classes.h"
|
|
#include "utilities/utilities.h"
|
|
#include "physics/vehicletypes.h"
|
|
#include "vehicle/driverorders.h"
|
|
#include "audio/sound.h"
|
|
#include "vehicle/DynObj.h"
|
|
#include "world/mtable.h"
|
|
#include "utilities/translation.h"
|
|
#include "application/driverhints.h"
|
|
#include "vehicle/uphillstart.h"
|
|
#include "vehicle/brakecharge.h"
|
|
#include "vehicle/blackbox.h"
|
|
#include "vehicle/aipower.h"
|
|
|
|
auto const EU07_AI_ACCELERATION = 0.05;
|
|
auto const EU07_AI_NOACCELERATION = -0.05;
|
|
auto const EU07_AI_BRAKINGTESTACCELERATION = -0.06;
|
|
auto const EU07_AI_NOMOVEMENT = 0.05; // standstill velocity threshold
|
|
auto const EU07_AI_MOVEMENT = 1.0; // deliberate movement velocity threshold
|
|
auto const EU07_AI_UPHILLGRAVITY = -0.025; // [m/s2] about 2.5 per mille up: the gradient that rolls a standing train back
|
|
auto const EU07_AI_SPEEDLIMITEXTENDSBEYONDSCANRANGE = 10000.0;
|
|
auto const EU07_AI_SANDEDSTARTVELOCITY = 15.0; // [km/h] a start that slipped keeps the sand on up to this speed
|
|
|
|
|
|
// the signals the map asks the driver to show (SetSignal)
|
|
enum TSignals
|
|
{
|
|
Signal_START = 30,
|
|
Signal_Pc6 = 30,
|
|
Signal_A1 = 31,
|
|
Signal_MAX = 31
|
|
};
|
|
|
|
// what the driver keeps in mind about the movement of the train: each a condition of its own, set and cleared on its own
|
|
struct DrivingFlags
|
|
{
|
|
bool stopCloser{ false }; // podjechać blisko W4 (nie podjeżdżać na początku ani po zmianie czoła)
|
|
bool stopPoint{ true }; // stawać na W4 (wyłączone podczas zmiany czoła)
|
|
bool active{ false }; // pojazd jest załączony i skanuje
|
|
bool press{ false }; // dociskanie przy odłączeniu
|
|
bool connect{ false }; // jest blisko innego pojazdu i można próbować podłączyć
|
|
bool primary{ false }; // ma priorytet w składzie (master)
|
|
bool late{ false }; // spóźnienie, włączy bardziej
|
|
bool stopHere{ true }; // nie podjeżdżać do semafora, jeśli droga nie jest wolna
|
|
bool startHorn{ true }; // podawaj sygnał po podaniu wolnej drogi
|
|
bool startHornNow{ false }; // podaj sygnał po odhamowaniu
|
|
bool startHornDone{ false }; // podano sygnał po podaniu wolnej drogi
|
|
bool oerlikons{ false }; // skład wyłącznie z zaworami Oerlikona
|
|
bool incSpeed{ false }; // załączenie jazdy (np. dla EZT)
|
|
bool trackEnd{ false }; // dalsza jazda do przodu trwale ograniczona (W5, koniec toru)
|
|
bool switchFound{ false }; // na drodze skanowania do przodu jest rozjazd
|
|
bool guardSignal{ false }; // sygnał od kierownika (minął czas postoju)
|
|
bool visibility{ false }; // jazda na widoczność po przejechaniu S1 na SBL
|
|
bool doorOpened{ false }; // drzwi zostały otwarte - doliczyć czas na zamknięcie
|
|
bool pushPull{ false }; // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku
|
|
bool signalFound{ false }; // na drodze skanowania został znaleziony semafor
|
|
bool stopPointFound{ false }; // stop point detected ahead
|
|
bool guardOpenDoor{ false }; // time for opening a door before departure
|
|
bool departureWarned{ false }; // driver has already warned about the doors being closed (only for manual warning - i.e. EN57-ish)
|
|
bool signalPc6{ false }; // the map asked to show the Pc6 signal (SetSignal); nothing reads it yet
|
|
bool signalA1{ false }; // the map asked to show the A1 signal (SetSignal); nothing reads it yet
|
|
|
|
// the names of the flags set, for the debug panel
|
|
std::vector<std::string_view> ActiveNames() const;
|
|
};
|
|
|
|
enum TStopReason
|
|
{ // powód zatrzymania, dodawany do SetVelocity 0 - w zasadzie do usunięcia
|
|
stopNone, // nie ma powodu - powinien jechać
|
|
stopSleep, // nie został odpalony, to nie pojedzie
|
|
stopSem, // semafor zamknięty
|
|
stopTime, // czekanie na godzinę odjazdu
|
|
stopEnd, // brak dalszej części toru
|
|
stopDir, // trzeba stanąć, by zmienić kierunek jazdy
|
|
stopJoin, // stoi w celu połączenia wagonów
|
|
stopBlock, // przeszkoda na drodze ruchu
|
|
stopComm, // otrzymano taką komendę (niewiadomego pochodzenia)
|
|
stopOut, // komenda wyjazdu poza stację (raczej nie powinna zatrzymywać!)
|
|
stopRadio, // komunikat przekazany radiem (Radiostop)
|
|
stopExt, // komenda z zewnątrz
|
|
stopError // z powodu błędu w obliczeniu drogi hamowania
|
|
};
|
|
|
|
enum class TAction : int
|
|
{ // przechowanie aktualnego stanu AI od poprzedniego przebłysku świadomości
|
|
actUnknown, // stan nieznany (domyślny na początku)
|
|
actPantUp, // podnieś pantograf (info dla użytkownika)
|
|
actConv, // załącz przetwornicę (info dla użytkownika)
|
|
actCompr, // załącz sprężarkę (info dla użytkownika)
|
|
actSleep, //śpi (wygaszony)
|
|
actDrive, // jazda
|
|
actGo, // ruszanie z miejsca
|
|
actSlow, // przyhamowanie przed ograniczeniem
|
|
sctStop, // hamowanie w celu precyzyjnego zatrzymania
|
|
actIdle, // luzowanie składu przed odjazdem
|
|
actRelease, // luzowanie składu po zmniejszeniu prędkości
|
|
actConnect, // dojazd w celu podczepienia
|
|
actWait, // czekanie na przystanku
|
|
actReady, // zgłoszona gotowość do odjazdu od kierownika
|
|
actEmergency, // hamowanie awaryjne
|
|
actGoUphill, // ruszanie pod górę
|
|
actTest, // hamowanie kontrolne (podczas jazdy)
|
|
actTrial // próba hamulca (na postoju)
|
|
};
|
|
|
|
// what a position of the speed table of the AI is and what became of it
|
|
enum class SpeedPointFlag : unsigned
|
|
{
|
|
none = 0x0,
|
|
enabled = 0x1, // pozycja brana pod uwagę
|
|
track = 0x2, // to jest tor
|
|
reverse = 0x4, // odwrotnie
|
|
switchTrack = 0x8, // to zwrotnica
|
|
switchState = 0x10, // stan zwrotnicy
|
|
elapsed = 0x20, // pozycja minięta przez pojazd
|
|
trackEnd = 0x40, // koniec
|
|
curve = 0x80, // łuk
|
|
event = 0x100, // event
|
|
shuntSignal = 0x200, // tarcza manewrowa
|
|
passengerStop = 0x400, // przystanek osobowy (wskaźnik W4)
|
|
stopOnAutomaticBlock = 0x800, // zatrzymanie na SBL
|
|
commandSent = 0x1000, // komenda wysłana
|
|
outsideStation = 0x2000, // wskaźnik końca manewrów
|
|
signal = 0x4000, // semafor pociągowy
|
|
roadSpeed = 0x8000, // zadanie prędkości drogowej
|
|
sectionSpeed = 0x20000, // odcinek z ograniczeniem
|
|
proximitySpeed = 0x40000, // odcinek z ograniczeniem i podaną jego długością
|
|
pointSpeed = 0x80000, // ograniczenie dla czoła w punkcie fPointDist za wpisem (PointVelocity)
|
|
roadSpeedHeld = 0x100000, // a road speed sign passed by the head, handled, kept until the rear is past it
|
|
signalAreaEnd = 0x200000, // end of the interlocking area of the signal passed last
|
|
};
|
|
template <> struct IsEnumSetKind<SpeedPointFlag> : std::true_type
|
|
{
|
|
};
|
|
using SpeedPointFlags = EnumSet<SpeedPointFlag>;
|
|
|
|
class TSpeedPos
|
|
{ // pozycja tabeli prędkości dla AI
|
|
public:
|
|
double fDist{ 0.0 }; // aktualna odległość (ujemna gdy minięte)
|
|
double fVelNext{ -1.0 }; // prędkość obowiązująca od tego miejsca
|
|
double fSectionVelocityDist{ 0.0 }; // długość ograniczenia prędkości
|
|
double fPointDist{ 0.0 }; // PointVelocity: o ile dalej od wpisu leży punkt, w którym czoło ma mieć fVelNext
|
|
SpeedPointFlags flags; // flagi typu wpisu do tabelki
|
|
int crossRoute{ 0 }; // the segment of a crossing the route takes, -8..7, the sign the direction (in the top 4 bits of the flags before)
|
|
bool bMoved{ false }; // czy przesunięty (dotyczy punktu zatrzymania w peronie)
|
|
double fMoved{ 0.0 }; // ile przesunięty (dotyczy punktu zatrzymania w peronie)
|
|
bool bSeenAhead{ false }; // the head of the train had it ahead once: only such a point can be passed by the train
|
|
glm::dvec3 vPos; // współrzędne XYZ do liczenia odległości
|
|
struct
|
|
{
|
|
TTrack *trTrack{ nullptr }; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica)
|
|
basic_event *evEvent{ nullptr }; // połączenie z eventem albo komórką pamięci
|
|
};
|
|
void CommandCheck();
|
|
// the flags and the route as the one number they were before: the scan of the route reads its sign, the table its hex
|
|
int LegacyFlagsValue() const {
|
|
return static_cast<int>( ( static_cast<unsigned>( crossRoute ) << 28 ) | static_cast<unsigned>( flags.Bits() ) ); }
|
|
// no flags and no route: the position doesn't count any more
|
|
void ResetFlags() {
|
|
flags = {};
|
|
crossRoute = 0; }
|
|
|
|
public:
|
|
TSpeedPos(TTrack *track, double dist, SpeedPointFlags flag);
|
|
TSpeedPos(basic_event *event, double dist, double length, DriverOrders order);
|
|
TSpeedPos() = default;
|
|
void Clear();
|
|
bool Update();
|
|
// aktualizuje odległość we wpisie
|
|
inline
|
|
void
|
|
UpdateDistance( double dist ) {
|
|
fDist -= dist; }
|
|
// Standing: the train stands, so an event found behind its head wasn't passed by it
|
|
bool Set(basic_event *e, double d, double length, DriverOrders order = DriverOrder::waitForOrders, bool Standing = false);
|
|
void Set(TTrack *t, double d, SpeedPointFlags f);
|
|
std::string TableText() const;
|
|
std::string GetName() const;
|
|
bool IsProperSemaphor(DriverOrders order = DriverOrder::waitForOrders);
|
|
};
|
|
|
|
//----------------------------------------------------------------------------
|
|
static const bool Aggressive = true;
|
|
static const bool Easyman = false;
|
|
static const bool AIdriver = true;
|
|
static const bool Humandriver = false;
|
|
static const int maxorders = 64; // ilość rozkazów w tabelce
|
|
static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie
|
|
extern bool WriteLogFlag; // logowanie parametrów fizycznych
|
|
// the physics logs of the trains only (physicslog.trains yes): of each driver of rail vehicles who drives them, not
|
|
// of the passengers nor of the vehicles of the roads
|
|
extern bool WriteTrainLogFlag;
|
|
static const int BrakeAccTableSize = 20;
|
|
|
|
static const int gbh_NP = -2; //odciecie w hamulcu ogolnym
|
|
static const int gbh_RP = 0; //jazda w hamulcu ogolnym
|
|
static const int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym
|
|
static const int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym
|
|
static const int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym
|
|
//----------------------------------------------------------------------------
|
|
|
|
// the running brake test of a train run (hamowanie kontrolne), as the timetable asks for it
|
|
struct RunningBrakeTest
|
|
{
|
|
enum class Stage
|
|
{
|
|
waiting, // for the speed to run it at
|
|
applying, // the brake applied, the electropneumatic brake still in
|
|
switchingToAir, // the electropneumatic brake out, the train braked by the air brake alone
|
|
measuring, // braking down by 8 km/h, timed
|
|
releasing, // the brakes released
|
|
done
|
|
};
|
|
Stage stage{ Stage::waiting };
|
|
double velocityBrake{ 0.0 }; // where the braking began, then where its timed part began [km/h]
|
|
double velocityRelease{ 0.0 }; // the speed the brakes are released at [km/h]
|
|
double velocityFinish{ 0.0 }; // the speed the test ended at [km/h]
|
|
double brakingTime{ 0.0 }; // when the braking began, then how long its timed part took [s]
|
|
double releasingTime{ 0.0 }; // when the release began, then how long it took [s]
|
|
double midPointAcc{ 0.0 }; // the deceleration at the end of the timed part [m/s2]
|
|
|
|
// the brakes applied by the test, until the release
|
|
bool IsBraking() const { return stage >= Stage::applying && stage <= Stage::measuring; }
|
|
};
|
|
|
|
// how far the train falls short of the braking it is asked for, as the driver watches it
|
|
struct BrakingShortfall
|
|
{
|
|
double value{ 0.0 }; // at the last check [m/s2]
|
|
double time{ 0.0 }; // when that was checked
|
|
int growth{ 0 }; // how many checks in a row it has grown
|
|
};
|
|
|
|
// a start in which the wheels slipped: sand while under power until the train is under way
|
|
struct SandedStart
|
|
{
|
|
bool active{ false };
|
|
double decreaseTime{ -1.0 }; // when the power was last taken down a step for a slip
|
|
};
|
|
|
|
class TController {
|
|
// TBD: few authorized inspectors, or bunch of public getters?
|
|
friend class drivingaid_panel;
|
|
friend class timetable_panel;
|
|
friend class scenario_panel;
|
|
friend class debug_panel;
|
|
|
|
public:
|
|
TController( bool AI, TDynamicObject *NewControll, bool InitPsyche, bool primary = true );
|
|
~TController();
|
|
|
|
// ai operations logic
|
|
// types
|
|
using hintpredicate = std::function<bool(float)>; // returns true if action hint can be removed
|
|
|
|
// methods
|
|
public:
|
|
void Update( double dt ); // uruchamiac przynajmniej raz na sekundę
|
|
void MoveTo( TDynamicObject *to );
|
|
void TakeControl( bool const Aidriver, bool const Forcevehiclecheck = false );
|
|
inline
|
|
bool primary( bool const Primary ) {
|
|
drivingFlags.primary = Primary;
|
|
return primary(); }
|
|
inline
|
|
bool primary() const {
|
|
return drivingFlags.primary; };
|
|
inline
|
|
physics::Vehicle const *Controlling() const {
|
|
return mvControlling; }
|
|
inline
|
|
physics::Vehicle const *Occupied() const {
|
|
return occupied; }
|
|
void DirectionInitial();
|
|
void DirectionChange();
|
|
inline
|
|
int Direction() const {
|
|
return iDirection; }
|
|
inline
|
|
TAction & action() {
|
|
return eAction; }
|
|
inline
|
|
TAction const & action() const {
|
|
return eAction; }
|
|
inline
|
|
bool is_active() const {
|
|
return drivingFlags.active; }
|
|
bool is_train() const;
|
|
bool is_car() const;
|
|
bool is_emu() const;
|
|
bool is_dmu() const;
|
|
bool has_diesel_engine() const;
|
|
TBrakeSystem consist_brake_system() const;
|
|
// the next change of the speed limit ahead, as the driving aid tells it: the speed and the distance to it.
|
|
// the speed is the present limit (VelDesired) when nothing worth telling changes within the scan range
|
|
std::pair<int, double> next_speed_limit() const;
|
|
// what the AI would do at this place and speed, worked out also while a human drives, for the black box
|
|
blackbox::ai_reference ai_reference() const;
|
|
// the light pattern the timetable or the scenery asks for at an end of the train, -1 the usual one
|
|
int light_hint( VehicleEnd const End ) const { return m_lighthints[ End ]; }
|
|
// the order the driver goes by now: a train run, shunting and the like
|
|
DriverOrders order_current() const { return OrderCurrentGet(); }
|
|
// the reversers of the consist set as the driver's one, where they went apart
|
|
void sync_consist_reversers();
|
|
// the stations of the timetable: where the train is among them, how many there are, whether it stops at the next
|
|
int StationIndex() const;
|
|
int StationCount() const;
|
|
bool IsStop() const;
|
|
// what the cab shows of the consist the driver leads
|
|
BySide<bool> const &ConsistDoorsOpen() const { return IsAnyDoorOpen; }
|
|
BySide<bool> const &ConsistDoorsOnlyOpen() const { return IsAnyDoorOnlyOpen; } // the steps not counted
|
|
BySide<bool> const &ConsistDoorPermits() const { return IsAnyDoorPermitActive; }
|
|
door_closure_t ConsistDoorClosure() const { return DoorClosure; }
|
|
bool ConsistConverterOverloaded() const { return IsAnyConverterOverloadRelayOpen; }
|
|
bool ConsistCompressorEnabled() const { return IsAnyCompressorEnabled; }
|
|
double ConsistLength() const { return fLength; }
|
|
int RadioChannel() const { return iRadioChannel; }
|
|
void SetRadioChannel( int const Channel ) { iRadioChannel = Channel; }
|
|
int Helper() const { return HelperState; }
|
|
// what the driver goes by on the route, for the screens of the cab and the events
|
|
double DesiredVelocity() const { return VelDesired; }
|
|
double RoadVelocity() const { return VelRoad; }
|
|
double LastLimitVelocity() const { return VelLimitLast; }
|
|
double LastSignalVelocity() const { return VelSignalLast; }
|
|
double NextSignalVelocity() const { return VelSignalNext; }
|
|
double NextVelocity() const { return VelNext; }
|
|
double ProximityDistance() const { return ActualProximityDist; }
|
|
bool AtPassengerStop() const { return IsAtPassengerStop; }
|
|
// how far the brakes of the consist are released (fReady), the most braked vehicle counting
|
|
double BrakesReleaseLevel() const { return fReady; }
|
|
// the distance to the obstacle ahead on the track
|
|
double TrackObstacle() const;
|
|
private:
|
|
// tells the black box of the train at the station of its timetable it makes for, at the stop point given
|
|
void record_station( TSpeedPos const &Point, std::uint8_t Kind ) const;
|
|
void Activation(); // umieszczenie obsady w odpowiednim członie
|
|
void ControllingSet(); // znajduje człon do sterowania
|
|
void SetDriverPsyche();
|
|
bool IncBrake();
|
|
bool DecBrake();
|
|
void LapBrake();
|
|
void ZeroLocalBrake();
|
|
bool IncSpeed();
|
|
bool DecSpeed( bool force = false );
|
|
void ZeroSpeed( bool const Enforce = false );
|
|
bool IncBrakeEIM();
|
|
bool DecBrakeEIM();
|
|
bool IncSpeedEIM();
|
|
bool DecSpeedEIM( int const Amount = 1 );
|
|
void BrakeLevelSet( double b );
|
|
bool BrakeLevelAdd( double b );
|
|
void SpeedSet();
|
|
void SpeedCntrl( double DesiredSpeed );
|
|
void SetTimeControllers(); /*setting state of time controllers depending of desired action*/
|
|
void CheckTimeControllers(); /*checking state of time controllers to reset them to stable position*/
|
|
double ESMVelocity( bool Main );
|
|
void PrepareDirection();
|
|
bool PrepareHeating();
|
|
// uaktualnia informacje o prędkości
|
|
void SetVelocity( double NewVel, double NewVelNext, TStopReason r = stopNone );
|
|
int CheckDirection();
|
|
void WaitingSet( double Seconds );
|
|
void DirectionForward( bool forward );
|
|
void ZeroDirection();
|
|
int OrderDirectionChange( int newdir, physics::Vehicle *Vehicle );
|
|
void Lights( int head, int rear );
|
|
std::string StopReasonText() const;
|
|
double BrakeAccFactor() const;
|
|
// modifies brake distance for low target speeds, to ease braking rate in such situations
|
|
float
|
|
braking_distance_multiplier( float const Targetvelocity ) const;
|
|
inline
|
|
DrivingFlags const &DrivingFlagsState() const {
|
|
return drivingFlags; }
|
|
double DirectionalVel() const;
|
|
|
|
double brake_increase_margin() const;
|
|
bool uphill_stop_hold() const;
|
|
bool uphill_brake_committed( double const Velocity ) const;
|
|
void control_uphill_start();
|
|
void end_uphill_start();
|
|
bool uphill_brake_top_up();
|
|
void secure_standing_train();
|
|
double locomotive_brake_force() const;
|
|
std::pair<double, double> train_proximity_margins( bool const Passengerstop ) const;
|
|
|
|
void update_timers( double const dt );
|
|
void update_logs( double const dt );
|
|
void determine_consist_state();
|
|
void determine_braking_distance();
|
|
void determine_proximity_ranges();
|
|
void scan_route( double const Range );
|
|
void scan_obstacles( double const Range );
|
|
void control_wheelslip();
|
|
void control_pantographs();
|
|
void control_pantographs_setup( int const Setup );
|
|
void control_horns( double const Timedelta );
|
|
void control_security_system( double const Timedelta );
|
|
void control_handles();
|
|
void control_lights();
|
|
void sync_lights_selector();
|
|
void sync_lights_dimmer();
|
|
void control_compartment_lights();
|
|
void control_doors();
|
|
void UpdateCommand();
|
|
void handle_engine();
|
|
void handle_orders();
|
|
void UpdateNextStop();
|
|
void check_load_exchange(); // returns: estimated remaining time of load exchange, in seconds
|
|
void check_departure();
|
|
void UpdateConnect();
|
|
void UpdateDisconnect();
|
|
int unit_count( int const Threshold ) const;
|
|
void UpdateChangeDirection();
|
|
void UpdateLooseShunt();
|
|
void UpdateObeyTrain();
|
|
void GuardOpenDoor();
|
|
void pick_optimal_speed( double const Range );
|
|
void adjust_desired_speed_for_obstacles();
|
|
void adjust_desired_speed_for_limits();
|
|
void set_velocity_for_uncoupling();
|
|
bool increase_train_brake();
|
|
void hold_train_coming_to_stand_uphill();
|
|
void adjust_desired_speed_for_final_approach( double const Vel );
|
|
void adjust_desired_speed_for_braking_curve( double const Vel );
|
|
void adjust_desired_speed_for_target_speed( double const Range );
|
|
void adjust_desired_speed_for_current_speed();
|
|
void adjust_desired_speed_for_braking_test();
|
|
void control_tractive_and_braking_force();
|
|
void control_releaser();
|
|
void control_main_pipe();
|
|
void update_brake_charging();
|
|
bool is_brake_charging_done() const;
|
|
double consist_max_crp() const;
|
|
bool is_departure_blocked( double const Delay ) const;
|
|
void control_field_shunting();
|
|
void control_relays();
|
|
void control_motor_connectors();
|
|
void control_tractive_force();
|
|
void increase_tractive_force();
|
|
bool is_too_fast_uphill() const;
|
|
void control_braking_force();
|
|
// how far short of a stop the AI aims: in train running the middle of the 8-15 m window before a signal,
|
|
// otherwise (a W4 stop point, shunting, coupling) half the minimum proximity distance, as before
|
|
double stopping_margin() const {
|
|
return ( OrderCurrentGet().HasAny(DriverOrder::obeyTrain) ) && !IsAtPassengerStop ?
|
|
fMinProximityDist + 3.5 :
|
|
0.5 * fMinProximityDist; }
|
|
void apply_independent_brake_only();
|
|
void check_route_ahead( double const Range );
|
|
void check_route_behind( double const Range );
|
|
void UpdateBrakingHelper();
|
|
void hint( driver_hint const Value, hintpredicate const Predicate, float const Predicateparameter = 0.f );
|
|
void update_hints();
|
|
void remove_hint( driver_hint const Value );
|
|
void remove_train_brake_hints();
|
|
void remove_master_controller_hints();
|
|
void remove_reverser_hints();
|
|
void cue_action( driver_hint const Action, float const Actionparameter = 0.f );
|
|
// members
|
|
public:
|
|
// the AI drives, or a human does
|
|
bool AIControllFlag() const { return aiControlled; }
|
|
// what the overhead line of the track under a vehicle of the consist asks for (TDynamicObject::OverheadTrack()), by the
|
|
// bit of that vehicle: below zero the usual running, above it running without current with the pantographs down, zero
|
|
// running without current with them up
|
|
void MarkOverhead( int const Mask, float const Mode ) {
|
|
if( Mode < 0.0 ) { // normalna jazda po tym torze
|
|
iOverheadZero &= ~Mask; // zerowanie bitu - może pobierać prąd
|
|
iOverheadDown &= ~Mask; // zerowanie bitu - może podnieść pantograf
|
|
}
|
|
else if( Mode > 0.0 ) { // opuszczenie pantografów
|
|
iOverheadZero |= Mask; // ustawienie bitu - ma jechać bez pobierania prądu
|
|
iOverheadDown |= Mask; // ustawienie bitu - ma opuścić pantograf
|
|
}
|
|
else { // jazda bezprądowa z podniesionym pantografem
|
|
iOverheadZero |= Mask; // ustawienie bitu - ma jechać bez pobierania prądu
|
|
iOverheadDown &= ~Mask; // zerowanie bitu - może podnieść pantograf
|
|
}
|
|
}
|
|
// the most deceleration of the service braking of the consist with the blended brakes, which the driver goes by
|
|
double MedAmax() const { return fMedAmax; }
|
|
void SetMedAmax( double const Deceleration ) { fMedAmax = Deceleration; }
|
|
private:
|
|
bool aiControlled = false; // rzeczywisty/wirtualny maszynista
|
|
int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami
|
|
int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami
|
|
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
|
|
int UniversalBrakeButtons = 0.0; // flag of which universal buttons need to be pressed
|
|
int DizelPercentage = 0; // oczekiwane procenty jazdy/hamowania szynobusem
|
|
int DizelPercentage_Speed = 0; // oczekiwane procenty jazdy/hamowania szynobusem w związku z osiąganiem VelDesired
|
|
double fMedAmax = 0.8; //maximum decceleration when using ep/med brake
|
|
private:
|
|
bool Psyche = false;
|
|
int HelperState = 0; //stan pomocnika maszynisty
|
|
TDynamicObject *pVehicle = nullptr; // pojazd w którym siedzi sterujący
|
|
physics::Vehicle *mvControlling = nullptr; // jakim pojazdem steruje (może silnikowym w EZT)
|
|
physics::Vehicle *occupied = nullptr; // jakim pojazdem hamuje
|
|
physics::Vehicle *pantographUnit = nullptr; //pantograph equipped vehicle in the occupied/controlled set
|
|
std::string VehicleName;
|
|
ByEnd<int> m_lighthints = { -1, -1 }; // suggested light patterns
|
|
double AccPreferred = 0.0; // preferowane przyspieszenie (wg psychiki kierującego, zmniejszana przy wykryciu kolizji)
|
|
double AccDesired = 0.0; // przyspieszenie, jakie ma utrzymywać (<0:nie przyspieszaj,<-0.1:hamuj)
|
|
double VelDesired = 0.0; // predkość, z jaką ma jechać, wynikająca z analizy tableki; <=VelSignal
|
|
double fAccDesiredAv = 0.0; // uśrednione przyspieszenie z kolejnych przebłysków świadomości, żeby ograniczyć migotanie
|
|
double fBrakeHeldTime = 0.0; // czas od ostatniego przestawienia kranu hamulca zasadniczego
|
|
bool bStopTargetIsPassengerStop = false; // the point the train is to stop at, found by the last scan of the route, is a passenger stop
|
|
BrakingShortfall brakingShortfall;
|
|
uphill_start::Progress uphillStart; // a start uphill, the train brake holding the train until the power does
|
|
SandedStart sandedStart;
|
|
bool IsConsistReleased = true; // the brakes of the consist are off, the hold of an uphill start not counted
|
|
bool IsConsistCharged = true; // standing, the brake pipe and the auxiliary reservoirs are charged to start (or stopped charging)
|
|
brake_charge::state BrakeCharge; // standing, how the charge of the brakes rose
|
|
// the next start waits for the brakes to charge: the first after the train was prepared standing, or one with the
|
|
// pipe near empty. cleared once the train runs
|
|
bool bBrakeChargeStart = false;
|
|
bool bHasRun = false; // the train has moved (above 1 km/h) since it was placed
|
|
bool bBrakeChargeHold = false; // charging, the train stands on a light application of the train brake as well
|
|
double fConsistVelocity = 0.0; // the mass-weighted speed of the consist, positive in the direction of travel [km/h]
|
|
double fAccDesiredGravity = 0.0; // część AccDesired odjęta na spadku jako kompensacja pochylenia; AbsAccS zawiera ją już sam
|
|
double VelforDriver = -1.0; // prędkość, używana przy zmianie kierunku (ograniczenie przy nieznajmości szlaku?)
|
|
double VelSignal = 0.0; // ograniczenie prędkości z kompilacji znaków i sygnałów // normalnie na początku ma stać, no chyba że jedzie
|
|
double VelLimit = -1.0; // predkość zadawana przez event jednokierunkowego ograniczenia prędkości // -1: brak ograniczenia prędkości
|
|
double VelSignalLast = -1.0; // prędkość zadana na ostatnim semaforze // ostatni semafor też bez ograniczenia
|
|
double VelSignalNext = 0.0; // prędkość zadana na następnym semaforze
|
|
double VelLimitLast = -1.0; // prędkość zadana przez ograniczenie // ostatnie ograniczenie bez ograniczenia
|
|
double VelRoad = -1.0; // aktualna prędkość drogowa (ze znaku W27) (PutValues albo komendą) // prędkość drogowa bez ograniczenia
|
|
double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist
|
|
double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop
|
|
double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora
|
|
double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia
|
|
std::pair<double, double> VelLimitLastDist { 0.0, 0.0 }; // distance to velocity change point
|
|
double SwitchClearDist { 0.0 }; // distance to point after farthest detected switch
|
|
double SignalAreaEndDist { -1.0 }; // distance the train has to go to be past the nearest end of an interlocking area, -1 when none is in the scan
|
|
int iDirection = 0; // kierunek jazdy względem sprzęgów pojazdu, w którym siedzi AI (1=przód,-1=tył)
|
|
int iDirectionOrder = 0; //żadany kierunek jazdy (służy do zmiany kierunku)
|
|
std::optional<int> iDirectionBackup; // consist direction to be restored after coupling/uncoupling and similar direction-changing operations
|
|
std::optional<std::pair<TDynamicObject*,int>> iCouplingVehicle; // <vehicle, coupler> to be coupled with another consist in current coupling operation
|
|
int iVehicleCount = -2; // wartość neutralna // ilość pojazdów do odłączenia albo zabrania ze składu (-1=wszystkie)
|
|
CouplingSet iCoupler; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia
|
|
int iDriverFailCount = 0; // licznik błędów AI
|
|
bool Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała
|
|
// bool Need_BrakeRelease = true;
|
|
bool IsHeatingTemperatureOK{ true };
|
|
bool IsHeatingTemperatureTooLow{ false };
|
|
bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post
|
|
bool IsScheduledPassengerStopVisible{ false };
|
|
double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować
|
|
double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!)
|
|
double fOverhead2 = -1.0; // informacja o sposobie jazdy (-1=normalnie, 0=bez prądu, >0=z opuszczonym i ograniczeniem prędkości)
|
|
double fVoltage = 0.0; // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić rozruch o losowy czas
|
|
double fMaxProximityDist = 50.0; // stawanie między 30 a 60 m przed przeszkodą // akceptowalna odległość stanięcia przed przeszkodą
|
|
TStopReason eStopReason = stopSleep; // powód zatrzymania przy ustawieniu zerowej prędkości // na początku śpi
|
|
double fVelPlus = 0.0; // dopuszczalne przekroczenie prędkości na ograniczeniu bez hamowania
|
|
double fVelMinus = 0.0; // margines obniżenia prędkości, powodujący załączenie napędu
|
|
double fWarningDuration = 0.0; // ile czasu jeszcze trąbić
|
|
double WaitingTime = 0.0; // zliczany czas oczekiwania do samoistnego ruszenia
|
|
double WaitingExpireTime = 31.0; // tyle ma czekać, zanim się ruszy // maksymlany czas oczekiwania do samoistnego ruszenia
|
|
double IdleTime{}; // keeps track of time spent at a stop
|
|
double fStopTime = 0.0; // czas postoju przed dalszą jazdą (np. na przystanku)
|
|
float ExchangeTime{ 0.0 }; // time needed to finish current load exchange
|
|
double fShuntVelocity = 40.0; // prędkość manewrowania, zależy m.in. od składu
|
|
DrivingFlags drivingFlags; // what the driver keeps in mind about the movement of the train
|
|
double fDriverBraking = 0.0; // po pomnożeniu przez v^2 [km/h] daje ~drogę hamowania [m]
|
|
double fDriverDist = 0.0; // dopuszczalna odległość podjechania do przeszkody
|
|
double fVelMax = -1.0; // maksymalna prędkość składu (sprawdzany każdy pojazd)
|
|
double fBrakeDist = 0.0; // przybliżona droga hamowania
|
|
double fBrakeReaction = 1.0; //opóźnienie zadziałania hamulca - czas w s / (km/h)
|
|
double fNominalAccThreshold = 0.0; // nominalny próg opóźnienia dla zadziałania hamulca
|
|
double fAccThreshold = 0.0; // aktualny próg opóźnienia dla zadziałania hamulca
|
|
double AbsAccS = 0.0; // próg opóźnienia dla zadziałania hamulca
|
|
// dla fBrake_aX:
|
|
// indeks [0] - wartości odpowiednie dla aktualnej prędkości
|
|
// a potem jest 20 wartości dla różnych prędkości zmieniających się co 5 % Vmax pojazdu obsadzonego
|
|
double fBrake_a0[ BrakeAccTableSize + 1 ] = { 0.0 }; // opóźnienia hamowania przy ustawieniu zaworu maszynisty w pozycji 1.0
|
|
double fBrake_a1[ BrakeAccTableSize + 1 ] = { 0.0 }; // przyrost opóźnienia hamowania po przestawieniu zaworu maszynisty o 0,25 pozycji
|
|
double BrakingInitialLevel{ 1.0 };
|
|
double BrakingLevelIncrease{ 0.25 };
|
|
double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI
|
|
double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca
|
|
double BrakeChargingCooldown{}; // prevents the ai from trying to charge the train brake too frequently
|
|
double BrakeChargingStart = -1.0;
|
|
std::unordered_map<TDynamicObject const *, double> BrakeChargingPipeOverchargeStart;
|
|
double DepartBlockedStart = -1.0;
|
|
TBrakeSystem BrakeSystem = TBrakeSystem::Individual; //type of main brake
|
|
bool ForcePNBrake = false; //is it necessary to use PN brake instead of EP brake
|
|
RunningBrakeTest brakeTest;
|
|
double LastReactionTime = 0.0;
|
|
double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi
|
|
double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations
|
|
TAction eAction{ TAction::actUnknown }; // aktualny stan
|
|
std::list< std::tuple<driver_hint, hintpredicate, float> > m_hints; // queued ai operations
|
|
|
|
// orders
|
|
// methods
|
|
public:
|
|
void PutCommand( std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation, TStopReason reason = stopComm );
|
|
bool PutCommand( std::string NewCommand, double NewValue1, double NewValue2, glm::dvec3 const *NewLocation, TStopReason reason = stopComm );
|
|
// defines assignment data
|
|
inline auto assignment() -> std::string & { return m_assignment; }
|
|
inline auto assignment() const -> std::string const & { return m_assignment; }
|
|
std::string OrderCurrent() const;
|
|
private:
|
|
void RecognizeCommand(); // odczytuje komende przekazana lokomotywie
|
|
void JumpToNextOrder( bool const Skipmergedchangedirection = false );
|
|
void JumpToFirstOrder();
|
|
void OrderPush( DriverOrders NewOrder );
|
|
void OrderNext( DriverOrders NewOrder );
|
|
inline DriverOrders OrderCurrentGet() const;
|
|
inline void OrderCurrentSet( DriverOrders const Order );
|
|
inline DriverOrders OrderNextGet() const;
|
|
void OrderCheck();
|
|
void OrdersInit( double fVel );
|
|
void OrdersClear();
|
|
void OrdersDump( std::string const Neworder, bool const Verbose = true );
|
|
std::string Order2Str( DriverOrders Order ) const;
|
|
// members
|
|
std::string m_assignment;
|
|
glm::dvec3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego odnosi sie komenda // NOTE: not used
|
|
DriverOrders OrderList[ maxorders ]; // lista rozkazów
|
|
int OrderPos = 0,
|
|
OrderTop = 0; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych
|
|
|
|
// scantable
|
|
// methods
|
|
public:
|
|
int CrossRoute( TTrack *tr );
|
|
inline void MoveDistanceAdd( double distance ) {
|
|
dMoveLen += distance * iDirection;
|
|
} //jak jedzie do tyłu to trzeba uwzględniać, że distance jest ujemna
|
|
private:
|
|
// Ra: metody obsługujące skanowanie toru
|
|
std::vector<basic_event *> CheckTrackEvent( TTrack *Track, double const fDirection ) const;
|
|
bool TableAddNew();
|
|
bool TableNotFound( basic_event const *Event, double const Distance ) const;
|
|
void TableTraceRoute( double fDistance, TDynamicObject *pVehicle );
|
|
void TableCheck( double fDistance );
|
|
// called after TSpeedPos::Update() of a position of the speed table, with its spElapsed flag from before it:
|
|
// reports the head of the train going past it, if it's a signal: to the black box, and to the test mode if it showed stop
|
|
void CheckSignalPassed( TSpeedPos const &Point, bool Passedbefore ) const;
|
|
TCommandType TableUpdate( double &fVelDes, double &fDist, double &fNext, double &fAcc );
|
|
bool TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance );
|
|
bool TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPos &Point, double &Signaldistance, int const Pointindex );
|
|
bool TableUpdateRoadVelocity( TSpeedPos &Point );
|
|
double held_road_velocity_beyond( TSpeedPos const &Point ) const;
|
|
bool is_road_velocity_held( TSpeedPos const &Point ) const;
|
|
void TableDropPassedEvent( TSpeedPos &Point ) const;
|
|
void TableUpdateSignalAreaEnd( TSpeedPos &Point );
|
|
// keeps the PointVelocity limit of a speed table entry whose cell the head has just passed
|
|
void latch_point_limit( TSpeedPos const &Point );
|
|
// moves the latched point limits by the movement of the consist, drops those passed and those read anew
|
|
void update_point_limits();
|
|
// the latched point limits ahead in the direction of travel, taken as the points of the speed table are
|
|
void apply_point_limits( double &Velocity, double &Distance, double &Next, double &Acceleration );
|
|
// the way the consist runs, along the track under the vehicle whose movement is measured; zero when it isn't known
|
|
glm::dvec3 travel_direction() const;
|
|
// how far the end of the consist lying the farthest along the heading is ahead of the measured vehicle
|
|
double point_limit_end( glm::dvec3 const &Heading ) const;
|
|
// whether the state of the cell is latched already
|
|
bool point_limit_latched( basic_event const *Cell ) const;
|
|
// how far before a point limit the speed is held down to it
|
|
double point_limit_approach() const;
|
|
void TablePurger();
|
|
void TableSort();
|
|
inline double MoveDistanceGet() const {
|
|
return dMoveLen;
|
|
}
|
|
inline void MoveDistanceReset() {
|
|
dMoveLen = 0.0;
|
|
}
|
|
std::size_t TableSize() const { return sSpeedTable.size(); }
|
|
void TableClear();
|
|
int TableDirection() { return iTableDirection; }
|
|
// Ra: stare funkcje skanujące, używane do szukania sygnalizatora z tyłu
|
|
bool IsOccupiedByAnotherConsist( TTrack *Track, double const Distance = 0 );
|
|
basic_event *CheckTrackEventBackward( double fDirection, TTrack *Track, TDynamicObject *Vehicle, int const Eventdirection = 1, VehicleEnd const End = VehicleEnd::rear );
|
|
TTrack *BackwardTraceRoute( double &fDistance, double &fDirection, TDynamicObject *Vehicle, basic_event *&Event, int const Eventdirection = 1, VehicleEnd const End = VehicleEnd::rear, bool const Untiloccupied = true );
|
|
void SetProximityVelocity( double dist, double vel, glm::dvec3 const *pos );
|
|
TCommandType BackwardScan( double const Range );
|
|
std::string TableText( std::size_t const Index ) const;
|
|
/*
|
|
void RouteSwitch(int d);
|
|
*/
|
|
// members
|
|
int iLast{ 0 }; // ostatnia wypełniona pozycja w tabeli <iFirst (modulo iSpeedTableSize)
|
|
int iTableDirection{ 0 }; // kierunek zapełnienia tabelki względem pojazdu z AI
|
|
std::vector<TSpeedPos> sSpeedTable;
|
|
double fLastVel = 0.0; // prędkość na poprzednio sprawdzonym torze
|
|
TTrack *tLast = nullptr; // ostatni analizowany tor
|
|
basic_event *eSignSkip = nullptr; // można pominąć ten SBL po zatrzymaniu
|
|
static constexpr std::size_t npos{ std::numeric_limits<std::size_t>::max() };
|
|
std::size_t SemNextIndex{ npos };
|
|
std::size_t SemNextStopIndex{ npos };
|
|
double dMoveLen = 0.0; // odległość przejechana od ostatniego sprawdzenia tabelki
|
|
// a PointVelocity limit latched when the head passed its cell. kept apart from the speed table, which is built
|
|
// anew on a change of direction, a change of the consist or a takeover, and measured by the movement in the world,
|
|
// so stopping, backing up and going on between the cell and the point keeps it
|
|
struct point_limit {
|
|
basic_event const *source { nullptr }; // the cell, as the head passed it
|
|
double velocity { -1.0 }; // what the cell said then
|
|
double distance { 0.0 }; // left for the head to the point, along the line
|
|
double celldistance { 0.0 }; // from the cell to the point; the head farther than that from the point is behind the cell
|
|
glm::dvec3 heading { 0.0 }; // the way towards the point, in the world
|
|
double end { 0.0 }; // point_limit_end() at the last update, to follow vehicles coupled or uncoupled at that end
|
|
bool endknown { false };
|
|
};
|
|
std::vector<point_limit> m_pointlimits;
|
|
TDynamicObject const *m_pointlimitsvehicle { nullptr }; // the vehicle whose movement moves the points
|
|
glm::dvec3 m_pointlimitsposition { 0.0 }; // where it was at the last update
|
|
TDynamicObject const *m_pointlimitsends[ 2 ] { nullptr, nullptr }; // the end vehicles of the consist at the last update
|
|
double m_pointlimitslength { 0.0 }; // and its length
|
|
basic_event *eSignNext = nullptr; // sygnał zmieniający prędkość, do pokazania na [F2]
|
|
neighbour_data Obstacle; // nearest vehicle detected ahead on current route
|
|
|
|
// timetable
|
|
// methods
|
|
public:
|
|
const std::string &TrainName() const;
|
|
Mtable::TTrainParameters const & TrainTimetable() const;
|
|
private:
|
|
std::string Relation() const;
|
|
std::string NextStop() const;
|
|
// tests whether the train is delayed and sets accordingly a driving flag
|
|
void UpdateDelayFlag();
|
|
// members
|
|
Mtable::TTrainParameters TrainParams; // rozkład jazdy zawsze jest, nawet jeśli pusty
|
|
std::string asNextStop; // nazwa następnego punktu zatrzymania wg rozkładu
|
|
// int iStationStart = 0; // numer pierwszej stacji pokazywanej na podglądzie rozkładu
|
|
std::string m_lastexchangestop; // HACK: safeguard to prevent multiple load exchanges per station
|
|
int m_lastexchangeplatforms { 0 }; // cached station platforms for last exchange
|
|
int m_lastexchangedirection { 0 }; //
|
|
timetable::service_flags m_stopflags; // service flags of the timetable at the stop the train is at or left last
|
|
double fLastStopExpDist = -1.0; // odległość wygasania ostateniego przystanku
|
|
int iRadioChannel = 1; // numer aktualnego kanału radiowego
|
|
int iGuardRadio = 0; // numer kanału radiowego kierownika (0, gdy nie używa radia)
|
|
sound_source tsGuardSignal{ sound_placement::internal };
|
|
announcement_t m_lastannouncement{ announcement_t::idle };
|
|
bool m_makenextstopannouncement{ false };
|
|
|
|
// consist
|
|
// methods
|
|
public:
|
|
bool CheckVehicles( DriverOrders user = DriverOrder::waitForOrders );
|
|
private:
|
|
bool PrepareEngine();
|
|
// tells in the log, once, of standing with the pantographs up and no voltage (eu07/maszyna#421)
|
|
void report_power_stall( bool const Poweravailable, double const Pantographpressure );
|
|
ai_power::reporter m_powerstall; // the reports of report_power_stall()
|
|
void close_line_breaker();
|
|
bool ReleaseEngine();
|
|
void Doors( bool const Open, int const Side = 0 );
|
|
// returns true if any vehicle in the consist has an open door
|
|
bool doors_open() const;
|
|
bool doors_permit_active() const;
|
|
void AutoRewident(); // ustawia hamulce w składzie
|
|
void reinspect_brakes(); // AutoRewident() again once the train stands, when it left a brake to cut out on the run
|
|
bool BrakeReinspectionPending{ false }; // AutoRewident() left a brake to cut out (Cw-1 §19.9) for the next standstill
|
|
void announce( announcement_t const Announcement );
|
|
// members
|
|
double fLength = 0.0; // długość składu (do wyciągania z ograniczeń)
|
|
double fMass = 0.0; // całkowita masa do liczenia stycznej składowej grawitacji
|
|
double fAccGravity = 0.0; // przyspieszenie składowej stycznej grawitacji
|
|
int iVehicles = 0; // ilość pojazdów w składzie
|
|
int ControlledEnginesCount{ 0 }; // number of powered vehicles under driver's control
|
|
bool iEngineActive{ false }; // ABu: Czy silnik byl juz zalaczony
|
|
bool IsPassengerTrain{ false };
|
|
bool IsCargoTrain{ false };
|
|
bool IsHeavyCargoTrain{ false };
|
|
double fReady = 0.0; // poziom odhamowania wagonów
|
|
bool Ready = false; // ABu: stan gotowosci do odjazdu - sprawdzenie odhamowania wagonow
|
|
bool IsConsistBraked { false };
|
|
double ConsistShade{ 1.0 }; // averaged amount of sunlight received by the consist
|
|
ByEnd<TDynamicObject *> pVehicles; // skrajne pojazdy w składzie (niekoniecznie bezpośrednio sterowane)
|
|
bool DoesAnyDoorNeedOpening{ false };
|
|
BySide<bool> IsAnyDoorOpen; // state of door in the consist
|
|
BySide<bool> IsAnyDoorOnlyOpen; // state of door in the consist regardless of step
|
|
BySide<bool> IsAnyDoorPermitActive; // state of door permit in the consist
|
|
door_closure_t DoorClosure{ door_closure_t::none }; // state of the door closure signalling (SOD) of the consist
|
|
bool IsAnyLineBreakerOpen{ false }; // state of line breaker in all powered vehicles under control
|
|
bool IsAnyConverterOverloadRelayOpen{ false }; // state of converter overload relays in all vehicles under control
|
|
bool IsAnyMotorOverloadRelayOpen{ false }; // state of motor overload relays in all vehicles under control
|
|
bool IsAnyGroundRelayOpen{ false };
|
|
bool IsAnyCompressorPresent { false };
|
|
bool IsAnyCompressorEnabled{ false };
|
|
bool IsAnyCompressorExplicitlyEnabled{ false }; // only takes into account manually controlled devices
|
|
bool IsAnyConverterPresent{ false };
|
|
bool IsAnyConverterEnabled{ false };
|
|
bool IsAnyConverterExplicitlyEnabled{ false }; // only takes into account manually controlled devices
|
|
bool IsAnyCouplerStretched{ false }; // whether there's a coupler in the consist stretched above limit
|
|
|
|
// logs
|
|
// methods
|
|
// the line of the log, to PhysicsLogs (utilities/physicslog.h)
|
|
void PhysicsLog();
|
|
// its log begun anew, its file emptied and given the header
|
|
void begin_physicslog();
|
|
// members
|
|
bool PhysicsLogBegun = false; // its log was begun, by this driver
|
|
double LastUpdatedTime = 0.0; // czas od ostatniego logu
|
|
double ElapsedTime = 0.0; // czas od poczatku logu
|
|
|
|
// getters
|
|
public:
|
|
TDynamicObject const *Vehicle() const {
|
|
return pVehicle; }
|
|
// the physics log (physicslog/<vehicle>.dat): the name of its file without the extension, its first line and
|
|
// a line of it as the vehicle is now, each with its line end. the black box keeps the lines of the vehicle the
|
|
// user is in, to write its log at the end when the logs of all the vehicles are off
|
|
std::string const &physicslog_name() const {
|
|
return VehicleName; }
|
|
// whether it writes its physics log itself: all with "physicslog yes", with "physicslog.trains yes" one who drives
|
|
// rail vehicles. a driver made primary later begins its log then
|
|
bool writes_physicslog() const {
|
|
return WriteLogFlag || ( WriteTrainLogFlag && is_train() && primary() ); }
|
|
static std::string_view physicslog_header();
|
|
std::string physicslog_line() const;
|
|
TDynamicObject *Vehicle( VehicleEnd const Side ) const {
|
|
return pVehicles[ Side ]; }
|
|
private:
|
|
std::string OwnerName() const;
|
|
|
|
// leftovers
|
|
/*
|
|
int iRouteWanted = 3; // oczekiwany kierunek jazdy (0-stop,1-lewo,2-prawo,3-prosto) np. odpala migacz lub czeka na stan zwrotnicy
|
|
*/
|
|
|
|
};
|
|
|
|
inline DriverOrders TController::OrderCurrentGet() const {
|
|
if( OrderPos < 0 || OrderPos >= maxorders ) {
|
|
return DriverOrder::waitForOrders;
|
|
}
|
|
return OrderList[ OrderPos ];
|
|
}
|
|
|
|
inline void TController::OrderCurrentSet( DriverOrders const Order ) {
|
|
if( OrderPos < 0 || OrderPos >= maxorders ) {
|
|
return;
|
|
}
|
|
OrderList[ OrderPos ] = Order;
|
|
}
|
|
|
|
inline DriverOrders TController::OrderNextGet() const {
|
|
if( OrderPos < 0 || OrderPos >= maxorders ) {
|
|
return DriverOrder::waitForOrders;
|
|
}
|
|
// the order list wraps around, same as in JumpToNextOrder()
|
|
return OrderList[ ( OrderPos + 1 ) % maxorders ];
|
|
}
|