mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 16:39:13 +01:00
* fix(ai): a standing train starts only with its brakes charged, held on the locomotive brake while it charges Prepared from cold, the AI filled the brake pipe at once with the locomotive brake off: the distributors released while the auxiliary reservoirs were still empty, so the train had no air to brake with, and on a gradient it rolled as it released. The train counted as ready as soon as it was released. A train placed cold with its pipe below the lock of the FV4a driver's brake valve (2.75 bar) wasn't unlocked until the order to go, and went on what its reservoirs got meanwhile (TMS77185 in linia_107_objazdy: 40 minutes at 1.2-1.9 bar, the last wagon at 4.3 bar at the start). - Standing, PrepareEngine() applies the locomotive brake first, then fills the pipe. Where the locomotive brake alone doesn't hold the train (1.1 x the grade force), the train brake goes to the first service position instead, so the reservoirs charge with the train held. Multiple units with the electro-pneumatic brake are released as before. - Standing to charge, the AI unlocks the pipe as it does to go (the releaser, or the unlock button). A handle which has to be moved to unlock is left where the light application holds the train. - A train is ready only once the pipe and the auxiliary reservoir of every vehicle with a working brake are within 0.5 bar of the working pressure (4.5 of 5.0: the last wagon of a long train stays at about 4.6-4.7 from what leaks along the pipe), with the pipe fed at the head of the train. Brakes cut out don't count. - The locomotive brake comes off only once the train is charged, also against DecBrakeEIM(), which for a vehicle without the integrated handle releases it too; an uphill start begins only then. - A human driver gets the same wait as a hint: "Wait for the train brakes to charge" (driver_hint::waitbrakecharge), and the hint to release the brakes waits with it once the train brake is off (brake_charge::release_waits()). The train brake may still come off: released, it fills the pipe. - A charge that rises by less than 0.02 bar in 60 s lets the train go all the same, with a line in the log. The time counts only while there is air to charge with (the engine prepared, the main reservoir above what the pipe charges to, the pipe fed at the head): a train with its compressor not running yet or a locked pipe is waited out. Once let go, a train stays so until it is to stand again: otherwise the pipe refilling behind the release held it at a crawl (et22-1075 with 36 wagons, baltyk_interregio). - The check applies to the pneumatic brake only, to the first start of a train that hasn't run (above 1 km/h) since it was placed, and to a start with the pipe below 2.5 bar (near empty, after an emergency application). A start after an ordinary stop, a service stop (3.0-3.5 bar), a change of direction or a shunting move isn't held: waiting there only delayed the train, and the scenery set the routes of the others later. - The release of the train brake in PrepareEngine() had a stray semicolon after its condition; the condition applies again in motion. - Unit tests for the charge check (brake_charge::charged(), locomotive_brake_holds(), release_waits()). Run on all 174 shipped sceneries (20 minutes each, against master): no train stuck that moved on master, 466 timetable departures compared, 459 within 15 s, mean -1.2 s. Waits for the charge: median 4 s, 90% 39 s, longest 106 s (a heavy freight train charged from 2.2 bar). * test(ai): the brake charge test counts its looks in whole numbers, not in a floating-point time SonarCloud took the loop of the test of a train with nothing to charge with yet for a bug (cpp:S2193, a counter of type double). The same 120 looks, 5 s apart. * fix(ai): the light application that holds a charging train stays on, and an empty pipe is no charge Runs of a cold train on a gradient (P33000 at Lupkow in linia_107_objazdy, 13-16 per mille, with an SM42 and 32 wagons, 1556 t) showed three faults of the charged-brakes start: - The locomotive brake was taken to hold the train with the force of its brake blocks alone, 1031 kN for an ST43: several times what its wheels pass on to the rails. It is limited to a quarter of the locomotive's weight (brake_charge::adhesion), so a light locomotive with a heavy train gets the light application of the train brake. - That application was taken off again as soon as the order to go came, by the rule that puts the handle back to running with the main reservoir below 5 bar, and by DecBrake(). The train then stood on the locomotive brake that doesn't hold it, and moved as its wagons let go (to 0.3 km/h). It stays on until the train is charged (brake_charge::holds_application()). - With the train brake applied the train counted as charged to what the head of the pipe has, which is nothing with the pipe empty: charged at 0.02 bar the moment the brake was applied. The pipe at the head counts no lower than a full service application leaves (brake_charge::reference()). The SM42 with the 32 wagons now stands still while it charges and starts without rolling back, 2 min 30 s after it was prepared (4 min 40 s before, with a start that rolled back at 0.3 km/h). An ST43 with 33 wagons and a 754 with 8 coaches there are as before, their locomotive brake holds them. In eight of the sceneries run before (l053_poranek, calkowo_v2_cementa, calkowo_v2_ctl-wegiela, calkowo_v2_osoba_jar_poranek, calkowo_retro_zima, linia61_towarowy2, l053-sluzba-brutto-posp, baltyk_interregio) the 60 timetable departures compared are the same, within 15 s, mean 0.0 s. Unit tests for the two new decisions. * fix(ai): the locomotive brake counted of the occupied vehicle alone locomotive_brake_force() added the brake of every powered vehicle of the train. The locomotive brake handle acts on the occupied vehicle only (LocalBrakePosA is set on mvOccupied and passed to no other vehicle), so a second locomotive, in multiple control or hauled dead, made the brake count as holding a train it doesn't hold, and the train brake was released on a gradient with the leading locomotive alone holding. The estimate of one vehicle is brake_charge::locomotive_brake_force(), with a test. brakecharge.h named TController::control_brake_charge(), which doesn't exist: the logic is in determine_consist_state().
1357 lines
54 KiB
C++
1357 lines
54 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/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "vehicle/Driver.h"
|
|
#include "utilities/Globals.h"
|
|
#include "utilities/utilities.h"
|
|
|
|
void
|
|
TController::hint( driver_hint const Value, hintpredicate const Predicate, float const Predicateparameter ) {
|
|
|
|
if( Predicate( Predicateparameter ) ) { return; }
|
|
// check already recorded hints, if there's a match update it instead of adding a new one
|
|
for( auto &hint : m_hints ) {
|
|
if( std::get<driver_hint>( hint ) == Value ) {
|
|
std::get<float>( hint ) = Predicateparameter;
|
|
return; // done, can bail out early
|
|
}
|
|
}
|
|
m_hints.emplace_back( Value, Predicate, Predicateparameter );
|
|
}
|
|
|
|
void
|
|
TController::update_hints() {
|
|
|
|
m_hints.remove_if(
|
|
[]( auto const &Hint ) {
|
|
return std::get<hintpredicate>(Hint)(std::get<float>(Hint)); } );
|
|
}
|
|
|
|
void
|
|
TController::remove_hint( driver_hint const Value ) {
|
|
|
|
m_hints.remove_if(
|
|
[Value]( auto const &Hint ) {
|
|
return std::get<driver_hint>(Hint) == Value; } );
|
|
}
|
|
|
|
void
|
|
TController::remove_train_brake_hints() {
|
|
|
|
remove_hint( driver_hint::trainbrakesetpipeunlock );
|
|
remove_hint( driver_hint::trainbrakerelease );
|
|
remove_hint( driver_hint::trainbrakeapply );
|
|
remove_hint( driver_hint::brakingforcedecrease );
|
|
remove_hint( driver_hint::brakingforceincrease );
|
|
remove_hint( driver_hint::brakingforcesetzero );
|
|
remove_hint( driver_hint::brakingforcelap );
|
|
}
|
|
|
|
void
|
|
TController::remove_master_controller_hints() {
|
|
|
|
remove_hint( driver_hint::mastercontrollersetidle );
|
|
remove_hint( driver_hint::mastercontrollersetseriesmode );
|
|
remove_hint( driver_hint::mastercontrollersetzerospeed );
|
|
remove_hint( driver_hint::mastercontrollersetreverserunlock );
|
|
remove_hint( driver_hint::tractiveforcedecrease );
|
|
remove_hint( driver_hint::tractiveforceincrease );
|
|
remove_hint( driver_hint::bufferscompress );
|
|
}
|
|
|
|
void
|
|
TController::remove_reverser_hints() {
|
|
|
|
remove_hint( driver_hint::directionforward );
|
|
remove_hint( driver_hint::directionbackward );
|
|
remove_hint( driver_hint::directionother );
|
|
remove_hint( driver_hint::directionnone );
|
|
}
|
|
|
|
void
|
|
TController::cue_action( driver_hint const Action, float const Actionparameter ) {
|
|
|
|
switch( Action ) {
|
|
// battery
|
|
case driver_hint::batteryon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->BatterySwitch( true );
|
|
}
|
|
remove_hint( driver_hint::batteryoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::batteryoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->BatterySwitch( false );
|
|
}
|
|
remove_hint( driver_hint::batteryon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == false; } );
|
|
break;
|
|
}
|
|
// battery
|
|
case driver_hint::cabactivation: {
|
|
if (AIControllFlag && mvOccupied->Power24vIsAvailable) {
|
|
mvOccupied->CabActivisation();
|
|
CheckVehicles();
|
|
}
|
|
remove_hint( driver_hint::cabdeactivation );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->AutomaticCabActivation || mvOccupied->IsCabMaster(); } );
|
|
break;
|
|
}
|
|
case driver_hint::cabdeactivation: {
|
|
if (AIControllFlag) {
|
|
mvOccupied->CabDeactivisation();
|
|
}
|
|
remove_hint( driver_hint::cabactivation );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->AutomaticCabActivation || (mvOccupied->CabMaster == false && mvOccupied->CabActive == 0); } );
|
|
break;
|
|
}
|
|
// radio
|
|
case driver_hint::radioon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->Radio = true;
|
|
}
|
|
remove_hint( driver_hint::radiooff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->Radio == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::radiofuseon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->RadioFuse = true;
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->RadioFuse == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::radiochannel: {
|
|
if( AIControllFlag ) {
|
|
iRadioChannel = static_cast<int>( Actionparameter );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
return iRadioChannel == static_cast<int>(Parameter); },
|
|
Actionparameter );
|
|
break;
|
|
}
|
|
case driver_hint::radiooff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->Radio = false;
|
|
}
|
|
remove_hint( driver_hint::radioon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->Radio == false; } );
|
|
break;
|
|
}
|
|
// oil pump
|
|
case driver_hint::oilpumpon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OilPumpSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::oilpumpoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->OilPump };
|
|
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || mvOccupied->Mains; } );
|
|
break;
|
|
}
|
|
case driver_hint::oilpumpoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OilPumpSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::oilpumpon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->OilPump };
|
|
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
|
break;
|
|
}
|
|
// fuel pump
|
|
case driver_hint::fuelpumpon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->FuelPumpSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::fuelpumpoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->FuelPump };
|
|
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::fuelpumpoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->FuelPumpSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::fuelpumpon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->FuelPump };
|
|
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
|
break;
|
|
}
|
|
// pantographs
|
|
case driver_hint::pantographairsourcesetmain: {
|
|
if( AIControllFlag ) {
|
|
mvPantographUnit->bPantKurek3 = true;
|
|
}
|
|
remove_hint( driver_hint::pantographairsourcesetauxiliary );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->bPantKurek3 == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::pantographairsourcesetauxiliary: {
|
|
if( AIControllFlag ) {
|
|
mvPantographUnit->bPantKurek3 = false;
|
|
}
|
|
remove_hint( driver_hint::pantographcompressoron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->bPantKurek3 == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::pantographcompressoron: {
|
|
if( AIControllFlag ) {
|
|
mvPantographUnit->PantCompFlag = true;
|
|
}
|
|
remove_hint( driver_hint::pantographcompressoroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->PantCompFlag == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::pantographcompressoroff: {
|
|
if( AIControllFlag ) {
|
|
mvPantographUnit->PantCompFlag = false;
|
|
}
|
|
remove_hint( driver_hint::pantographcompressoron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->PantCompFlag == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::pantographsvalveon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OperatePantographsValve( operation_t::enable );
|
|
}
|
|
remove_hint( driver_hint::pantographsvalveoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->PantsValve.is_active == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::frontpantographvalveon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OperatePantographValve( end::front, operation_t::enable );
|
|
}
|
|
remove_hint( driver_hint::frontpantographvalveoff );
|
|
hint(
|
|
Action,
|
|
[ this ]( float const Parameter ) {
|
|
return mvPantographUnit->Pantographs[end::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
|
|
Actionparameter );
|
|
break;
|
|
}
|
|
case driver_hint::frontpantographvalveoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OperatePantographValve( end::front, operation_t::disable );
|
|
}
|
|
remove_hint( driver_hint::frontpantographvalveon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->Pantographs[end::front].valve.is_active == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::rearpantographvalveon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OperatePantographValve( end::rear, operation_t::enable );
|
|
}
|
|
remove_hint( driver_hint::rearpantographvalveoff );
|
|
hint(
|
|
Action,
|
|
[ this ]( float const Parameter ) {
|
|
return mvPantographUnit->Pantographs[end::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
|
|
Actionparameter );
|
|
break;
|
|
}
|
|
case driver_hint::rearpantographvalveoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->OperatePantographValve( end::rear, operation_t::disable );
|
|
}
|
|
remove_hint( driver_hint::rearpantographvalveon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->Pantographs[end::rear].valve.is_active == false; } );
|
|
break;
|
|
}
|
|
// converter
|
|
case driver_hint::converteron: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->ConverterSwitch( true );
|
|
// the local switch of the converter too, where the line contactors wait for the vehicle's own converter
|
|
// (LineContactorsInterlock): left off by the human driver, that vehicle would never take power
|
|
pVehicle->for_each(
|
|
coupling::control,
|
|
[]( TDynamicObject * Vehicle ) {
|
|
auto *vehicle { Vehicle->MoverParameters };
|
|
if( vehicle->LineContactorsHeldByLocalConverterSwitch() ) {
|
|
vehicle->ConverterAllowLocal = true; } } );
|
|
}
|
|
remove_hint( driver_hint::converteroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyConverterEnabled == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::converteroff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->ConverterSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::converteron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyConverterExplicitlyEnabled == false; } );
|
|
break;
|
|
}
|
|
// relays
|
|
case driver_hint::primaryconverteroverloadreset: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->RelayReset( relay_t::primaryconverteroverload );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->ConverterOverloadRelayStart != start_t::manual || mvOccupied->ConvOvldFlag == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::maincircuitgroundreset: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->RelayReset( relay_t::maincircuitground );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->GroundRelayStart != start_t::manual || mvOccupied->GroundRelay == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::tractionnmotoroverloadreset: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->RelayReset( relay_t::tractionnmotoroverload );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->FuseFlag == false; } );
|
|
break;
|
|
}
|
|
// line breaker
|
|
case driver_hint::linebreakerclose: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->MainSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::linebreakeropen );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyLineBreakerOpen == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::linebreakeropen: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->MainSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::linebreakerclose );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
// TBD, TODO: replace with consist-wide flag set true if any line breaker is closed?
|
|
return mvControlling->Mains == false; } );
|
|
break;
|
|
}
|
|
// compressor
|
|
case driver_hint::compressoron: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->CompressorSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::compressoroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyCompressorEnabled == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::compressoroff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->CompressorSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::compressoron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyCompressorExplicitlyEnabled == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::frontmotorblowerson: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->MotorBlowersSwitchOff( false, end::front );
|
|
mvOccupied->MotorBlowersSwitch( true, end::front );
|
|
}
|
|
remove_hint( driver_hint::frontmotorblowersoff );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
auto const &device { mvOccupied->MotorBlowers[ end::front ] };
|
|
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
|
|
break;
|
|
}
|
|
case driver_hint::rearmotorblowerson: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->MotorBlowersSwitchOff( false, end::rear );
|
|
mvOccupied->MotorBlowersSwitch( true, end::rear );
|
|
}
|
|
remove_hint( driver_hint::rearmotorblowersoff );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
auto const &device { mvOccupied->MotorBlowers[ end::rear ] };
|
|
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
|
|
break;
|
|
}
|
|
// spring brake
|
|
case driver_hint::springbrakeon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->SpringBrakeActivate( true );
|
|
}
|
|
remove_hint( driver_hint::springbrakeoff );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvOccupied->SpringBrake.Activate == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::springbrakeoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->SpringBrakeActivate( false );
|
|
}
|
|
remove_hint( driver_hint::springbrakeon );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvOccupied->SpringBrake.Activate == false; } );
|
|
break;
|
|
}
|
|
// manual brake
|
|
case driver_hint::manualbrakon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->IncManualBrakeLevel( ManualBrakePosNo );
|
|
}
|
|
remove_hint( driver_hint::manualbrakoff );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == ManualBrakePosNo; } );
|
|
break;
|
|
}
|
|
case driver_hint::manualbrakoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->DecManualBrakeLevel( ManualBrakePosNo );
|
|
}
|
|
remove_hint( driver_hint::manualbrakon );
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == 0; } );
|
|
break;
|
|
}
|
|
// master controller
|
|
case driver_hint::mastercontrollersetidle: {
|
|
if( AIControllFlag ) {
|
|
while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0
|
|
&& mvControlling->IncMainCtrl(1) ) {
|
|
// all work is done in the loop header
|
|
}
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0; } );
|
|
break;
|
|
}
|
|
case driver_hint::mastercontrollersetseriesmode: {
|
|
if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1) {
|
|
// limit yourself to series mode
|
|
if( mvControlling->ScndCtrlPos ) {
|
|
mvControlling->DecScndCtrl( 2 );
|
|
}
|
|
while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
|
|
&& mvControlling->DecMainCtrl(1) ) {
|
|
// all work is performed in the header
|
|
}
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this]( float const /*Parameter*/ ) {
|
|
return mvControlling->RList[mvControlling->MainCtrlPos].Bn < 2; } );
|
|
break;
|
|
}
|
|
case driver_hint::mastercontrollersetzerospeed: {
|
|
if( AIControllFlag ) {
|
|
ZeroSpeed();
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->IsMainCtrlNoPowerPos() && mvControlling->IsScndCtrlNoPowerPos(); } );
|
|
break;
|
|
}
|
|
case driver_hint::mastercontrollersetreverserunlock: {
|
|
if( AIControllFlag ) {
|
|
while( false == mvControlling->EIMDirectionChangeAllow()
|
|
&& mvControlling->DecMainCtrl(1) ) {
|
|
// all work is done in the loop header
|
|
}
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->EIMDirectionChangeAllow(); },
|
|
static_cast<float>(mvControlling->MainCtrlMaxDirChangePos) );
|
|
break;
|
|
}
|
|
case driver_hint::tractiveforcedecrease: {
|
|
if( AIControllFlag ) {
|
|
DecSpeed();
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
return std::abs(mvControlling->Ft) <= Parameter; },
|
|
static_cast<float>(std::min(
|
|
0.0,
|
|
std::max(
|
|
std::abs( mvControlling->Ft ) * 0.95,
|
|
std::abs( mvControlling->Ft ) - 5.0 ) )) );
|
|
break;
|
|
}
|
|
case driver_hint::tractiveforceincrease: {
|
|
if( AIControllFlag ) {
|
|
IncSpeed();
|
|
}
|
|
remove_master_controller_hints();
|
|
// clear potentially remaining braking hints
|
|
// TODO: add other brake application hints, refactor into a method
|
|
{
|
|
remove_hint( driver_hint::brakingforceincrease );
|
|
remove_hint( driver_hint::independentbrakeapply );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == mvOccupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 ||
|
|
(mvOccupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
|
|
break;
|
|
}
|
|
case driver_hint::bufferscompress: {
|
|
if (AIControllFlag && std::abs( mvControlling->Ft ) < 50000.0) {
|
|
IncSpeed();
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return std::abs(mvControlling->Ft) > 30.0 || (OrderCurrentGet() & Disconnect) == 0; } );
|
|
break;
|
|
}
|
|
|
|
case driver_hint::secondcontrollersetzero: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->DecScndCtrl( 2 );
|
|
}
|
|
remove_master_controller_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->IsScndCtrlNoPowerPos(); } );
|
|
break;
|
|
}
|
|
|
|
case driver_hint::waterpumpon: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterPumpSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::waterpumpoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterPump };
|
|
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterpumpoff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterPumpSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::waterpumpon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterPump };
|
|
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
|
break;
|
|
}
|
|
case driver_hint::waterpumpbreakeron: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterPumpBreakerSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::waterpumpbreakeroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterPump };
|
|
return device.breaker == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterpumpbreakeroff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterPumpBreakerSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::waterpumpbreakeron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterPump };
|
|
return device.breaker == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterheateron: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterHeaterSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::waterheateroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterHeater };
|
|
return device.is_enabled == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterheateroff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterHeaterSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::waterheateron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterHeater };
|
|
return device.is_enabled == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterheaterbreakeron: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterHeaterBreakerSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::waterheaterbreakeroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterHeater };
|
|
return device.breaker == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::waterheaterbreakeroff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterHeaterBreakerSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::waterheaterbreakeron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvControlling->WaterHeater };
|
|
return device.breaker == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::watercircuitslinkon: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterCircuitsLinkSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::watercircuitslinkoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::watercircuitslinkoff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->WaterCircuitsLinkSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::watercircuitslinkon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::waittemperaturetoolow: {
|
|
// NOTE: this action doesn't have AI component
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return false == IsHeatingTemperatureTooLow; } );
|
|
break;
|
|
}
|
|
case driver_hint::waitpressuretoolow: {
|
|
// NOTE: this action doesn't have AI component
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->ScndPipePress > 4.5 || mvControlling->VeselVolume == 0.0; } );
|
|
break;
|
|
}
|
|
case driver_hint::waitpantographpressuretoolow: {
|
|
// NOTE: this action doesn't have AI component
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvPantographUnit->PantPress >= (is_emu() ? (mvPantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } );
|
|
break;
|
|
}
|
|
case driver_hint::waitbrakecharge: {
|
|
// NOTE: this action doesn't have AI component: the ai waits through Ready and DecBrake()
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsConsistCharged; } );
|
|
break;
|
|
}
|
|
case driver_hint::waitloadexchange: {
|
|
// NOTE: this action doesn't have AI component
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return ExchangeTime <= 0; } );
|
|
break;
|
|
}
|
|
case driver_hint::waitdeparturetime: {
|
|
// NOTE: this action doesn't have AI component
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAtPassengerStop == false; } );
|
|
break;
|
|
}
|
|
|
|
// train brake and braking force. mutually exclusive:
|
|
// driver_hint_trainbrakesetpipeunlock
|
|
// driver_hint_trainbrakerelease
|
|
// driver_hint_brakingforcedecrease
|
|
// driver_hint_brakingforceincrease
|
|
// driver_hint_brakingforcesetzero
|
|
// driver_hint_brakingforcelap
|
|
case driver_hint::trainbrakesetpipeunlock: {
|
|
if (AIControllFlag && mvOccupied->HandleUnlock != -3) {
|
|
while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
|
|
&& BrakeLevelAdd(-1) ) {
|
|
// all work is done in the header
|
|
}
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->HandleUnlock == -3 || BrakeCtrlPosition == mvOccupied->HandleUnlock; } );
|
|
break;
|
|
}
|
|
case driver_hint::trainbrakerelease: {
|
|
if( AIControllFlag ) {
|
|
// mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
|
|
BrakeLevelSet( gbh_RP );
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) || (mvOccupied->Handle->Time && mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05); } );
|
|
// return ( BrakeCtrlPosition == gbh_RP ); } );
|
|
break;
|
|
}
|
|
case driver_hint::trainbrakeapply: {
|
|
if( AIControllFlag ) {
|
|
// za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach powino zostać wyłączone)
|
|
if( BrakeSystem == TBrakeSystem::ElectroPneumatic && false == ForcePNBrake ) {
|
|
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) );
|
|
}
|
|
else {
|
|
BrakeCtrlPosition = 3;
|
|
}
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsConsistBraked /*|| ( ( OrderCurrentGet() & Disconnect ) == 0 ) */; } );
|
|
break;
|
|
}
|
|
case driver_hint::brakingforcedecrease: {
|
|
if( AIControllFlag ) {
|
|
auto const brakingcontrolschange { DecBrake() };
|
|
// set optional delay between brake adjustments
|
|
if( brakingcontrolschange && Actionparameter > 0 ) {
|
|
fBrakeTime = Actionparameter;
|
|
}
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
return std::abs(mvControlling->Fb) <= Parameter; },
|
|
static_cast<float>(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) )) ); // keep hint until 5% decrease
|
|
break;
|
|
}
|
|
case driver_hint::brakingforceincrease: {
|
|
if( AIControllFlag ) {
|
|
auto const brakingcontrolschange { IncBrake() };
|
|
// set optional delay between brake adjustments
|
|
if( brakingcontrolschange && Actionparameter > 0 ) {
|
|
fBrakeTime = Actionparameter;
|
|
}
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); },
|
|
static_cast<float>(std::max(
|
|
0.0,
|
|
std::max(
|
|
std::abs( mvControlling->Fb ) * 1.05,
|
|
std::abs( mvControlling->Fb ) + 5.0 ) )) );
|
|
break;
|
|
}
|
|
case driver_hint::brakingforcesetzero: { // releases both train and independent brake
|
|
if( AIControllFlag ) {
|
|
while( true == DecBrake() ) {
|
|
// all work is done in the loop condition
|
|
}
|
|
}
|
|
remove_train_brake_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return Ready && fReady < 0.4 && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2); } );
|
|
break;
|
|
}
|
|
case driver_hint::brakingforcelap: {
|
|
if( AIControllFlag ) {
|
|
LapBrake();
|
|
}
|
|
remove_train_brake_hints();
|
|
// NOTE: this action doesn't have human component
|
|
// TBD, TODO: provide one?
|
|
break;
|
|
}
|
|
// independent brake
|
|
case driver_hint::independentbrakeapply: {
|
|
if (AIControllFlag && mvOccupied->LocalBrakePosA < 1.0) {
|
|
mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
|
|
if (mvOccupied->EIMCtrlEmergency) {
|
|
mvOccupied->DecLocalBrakeLevel(1);
|
|
}
|
|
}
|
|
remove_hint( driver_hint::independentbrakerelease );
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
return mvOccupied->LocalBrakePosA >= Parameter; },
|
|
( LocalBrakePosNo - ( mvOccupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo );
|
|
break;
|
|
}
|
|
case driver_hint::independentbrakerelease: {
|
|
if( AIControllFlag ) {
|
|
ZeroLocalBrake();
|
|
}
|
|
remove_hint( driver_hint::independentbrakeapply );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->LocalBrakePosA < 0.05; } );
|
|
break;
|
|
}
|
|
// reverser
|
|
case driver_hint::directionforward: {
|
|
if( AIControllFlag ) {
|
|
OrderDirectionChange( 1, mvOccupied );
|
|
}
|
|
remove_reverser_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->DirActive * mvOccupied->CabActive > 0; } );
|
|
break;
|
|
}
|
|
case driver_hint::directionbackward: {
|
|
if( AIControllFlag ) {
|
|
OrderDirectionChange( -1, mvOccupied );
|
|
}
|
|
remove_reverser_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->DirActive * mvOccupied->CabActive < 0; } );
|
|
break;
|
|
}
|
|
case driver_hint::directionother: {
|
|
if( AIControllFlag ) {
|
|
// DirectionForward( mvOccupied->DirAbsolute < 0 );
|
|
OrderDirectionChange( iDirectionOrder, mvOccupied );
|
|
DirectionChange();
|
|
}
|
|
remove_reverser_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return iDirection == iDirectionOrder; } );
|
|
break;
|
|
}
|
|
case driver_hint::directionnone: {
|
|
if( AIControllFlag ) {
|
|
ZeroDirection();
|
|
}
|
|
remove_reverser_hints();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->DirActive == 0; } );
|
|
break;
|
|
}
|
|
// anti-slip systems
|
|
case driver_hint::sandingon: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->Sandbox( true );
|
|
}
|
|
remove_hint( driver_hint::sandingoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::sandingoff: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->Sandbox( false );
|
|
}
|
|
remove_hint( driver_hint::sandingon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->Sand == 0 || mvControlling->SandDose == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::antislip: {
|
|
if( AIControllFlag ) {
|
|
mvControlling->AntiSlippingButton();
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvControlling->ASBType != 1 || (mvControlling->Hamulec->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } );
|
|
break;
|
|
}
|
|
// horns
|
|
case driver_hint::hornon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->WarningSignal = static_cast<int>( Actionparameter );
|
|
}
|
|
remove_hint( driver_hint::hornoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
// NOTE: we provide slightly larger horn activation window for human driver
|
|
return fWarningDuration + 5.0 < 0.05 || mvOccupied->WarningSignal != 0; } );
|
|
break;
|
|
}
|
|
case driver_hint::hornoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->WarningSignal = 0;
|
|
}
|
|
/*
|
|
// NOTE: for human driver the hint to switch horn on will disappear automatically
|
|
remove_hint( driver_hint::hornon );
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) -> bool {
|
|
return ( mvOccupied->WarningSignal == 0 ); } );
|
|
*/
|
|
break;
|
|
}
|
|
// door locks
|
|
case driver_hint::consistdoorlockson: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->LockDoors( true );
|
|
}
|
|
// TODO: remove other door lock hints
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->Doors.has_lock == false || mvOccupied->Doors.lock_enabled == true; } );
|
|
break;
|
|
}
|
|
// departure signal
|
|
case driver_hint::departuresignalon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->signal_departure( true );
|
|
}
|
|
remove_hint( driver_hint::departuresignaloff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == true || mvOccupied->Vel > 5.0; } );
|
|
break;
|
|
}
|
|
case driver_hint::departuresignaloff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->signal_departure( false );
|
|
}
|
|
remove_hint( driver_hint::departuresignalon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == false; } );
|
|
break;
|
|
}
|
|
// consist doors
|
|
case driver_hint::doorrightopen: {
|
|
if( AIControllFlag
|
|
|| pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
|
|
pVehicle->MoverParameters->OperateDoors( side::right, true );
|
|
}
|
|
remove_hint( driver_hint::doorrightclose );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorOpen[side::right] == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorrightclose: {
|
|
if( AIControllFlag
|
|
|| pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
|
|
pVehicle->MoverParameters->OperateDoors( side::right, false );
|
|
}
|
|
remove_hint( driver_hint::doorrightopen );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorOpen[side::right] == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorleftopen: {
|
|
if( AIControllFlag
|
|
|| pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
|
|
pVehicle->MoverParameters->OperateDoors( side::left, true );
|
|
}
|
|
remove_hint( driver_hint::doorleftclose );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorOpen[side::left] == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorleftclose: {
|
|
if( AIControllFlag
|
|
|| pVehicle->MoverParameters->Doors.open_control == control_t::conductor ) {
|
|
pVehicle->MoverParameters->OperateDoors( side::left, false );
|
|
}
|
|
remove_hint( driver_hint::doorleftopen );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorOpen[side::left] == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorrightpermiton: {
|
|
if( AIControllFlag ) {
|
|
pVehicle->MoverParameters->PermitDoors( side::right, true );
|
|
}
|
|
remove_hint( driver_hint::doorrightpermitoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorPermitActive[side::right] == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorrightpermitoff: {
|
|
if( AIControllFlag ) {
|
|
pVehicle->MoverParameters->PermitDoors( side::right, false );
|
|
}
|
|
remove_hint( driver_hint::doorrightpermiton );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorPermitActive[side::right] == false; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorleftpermiton: {
|
|
if( AIControllFlag ) {
|
|
pVehicle->MoverParameters->PermitDoors( side::left, true );
|
|
}
|
|
remove_hint( driver_hint::doorleftpermitoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorPermitActive[side::left] == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::doorleftpermitoff: {
|
|
if( AIControllFlag ) {
|
|
pVehicle->MoverParameters->PermitDoors( side::left, false );
|
|
}
|
|
remove_hint( driver_hint::doorleftpermiton );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return IsAnyDoorPermitActive[side::left] == false; } );
|
|
break;
|
|
}
|
|
// consist lights
|
|
case driver_hint::consistlightson: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->CompartmentLightsSwitch( true );
|
|
mvOccupied->CompartmentLightsSwitchOff( false );
|
|
}
|
|
remove_hint( driver_hint::consistlightsoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->CompartmentLights };
|
|
return Global.fLuminance * ConsistShade > 0.40 || device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::consistlightsoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->CompartmentLightsSwitch( false );
|
|
mvOccupied->CompartmentLightsSwitchOff( true );
|
|
}
|
|
remove_hint( driver_hint::consistlightson );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const &device { mvOccupied->CompartmentLights };
|
|
return Global.fLuminance * ConsistShade < 0.35 || device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
|
break;
|
|
}
|
|
// consist heating
|
|
case driver_hint::consistheatingon: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->HeatingSwitch( true );
|
|
}
|
|
remove_hint( driver_hint::consistheatingoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->HeatingAllow == true; } );
|
|
break;
|
|
}
|
|
case driver_hint::consistheatingoff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->HeatingSwitch( false );
|
|
}
|
|
remove_hint( driver_hint::consistheatingon );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return mvOccupied->HeatingAllow == false; } );
|
|
break;
|
|
}
|
|
|
|
case driver_hint::securitysystemreset: {
|
|
if (AIControllFlag && mvOccupied->SecuritySystem.is_blinking())
|
|
mvOccupied->SecuritySystemReset();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return !mvOccupied->SecuritySystem.is_vigilance_blinking(); } );
|
|
break;
|
|
}
|
|
case driver_hint::shpsystemreset: {
|
|
if (AIControllFlag && mvOccupied->SecuritySystem.is_cabsignal_blinking())
|
|
mvOccupied->SecuritySystem.cabsignal_reset();
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return !mvOccupied->SecuritySystem.is_cabsignal_blinking(); } );
|
|
break;
|
|
}
|
|
case driver_hint::couplingadapterattach: {
|
|
// TODO: run also for potential settings-based virtual assistant
|
|
if( AIControllFlag ) {
|
|
pVehicles[ end::front ]->attach_coupler_adapter( static_cast<int>(Actionparameter) );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast<int>( Parameter ) ] };
|
|
return device.type() == TCouplerType::Automatic; } );
|
|
break;
|
|
}
|
|
case driver_hint::couplingadapterremove: {
|
|
if( AIControllFlag || Global.AITrainman ) {
|
|
pVehicles[ end::front ]->remove_coupler_adapter( static_cast<int>(Actionparameter) );
|
|
}
|
|
hint(
|
|
Action,
|
|
[this](float const Parameter) {
|
|
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast<int>( Parameter ) ] };
|
|
return false == device.has_adapter(); } );
|
|
break;
|
|
}
|
|
// lights
|
|
case driver_hint::headcodepc1: {
|
|
if( AIControllFlag ) {
|
|
pVehicles[ end::front ]->RaLightsSet( light::headlight_left | light::headlight_right | light::headlight_upper, -1 );
|
|
}
|
|
remove_hint( driver_hint::headcodepc2 );
|
|
remove_hint( driver_hint::headcodetb1 );
|
|
remove_hint( driver_hint::lightsoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return pVehicles[end::front]->has_signal_pc1_on(); } );
|
|
break;
|
|
}
|
|
case driver_hint::headcodepc2: {
|
|
if( AIControllFlag ) {
|
|
pVehicles[ end::front ]->RaLightsSet( light::redmarker_left | light::headlight_right | light::headlight_upper, -1 );
|
|
}
|
|
remove_hint( driver_hint::headcodepc1 );
|
|
remove_hint( driver_hint::headcodetb1 );
|
|
remove_hint( driver_hint::lightsoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return pVehicles[end::front]->has_signal_pc2_on(); } );
|
|
break;
|
|
}
|
|
case driver_hint::headcodetb1: {
|
|
// HACK: the 'front' and 'rear' of the consist is determined by current consist direction
|
|
// since direction shouldn't affect Tb1 light configuration, we 'counter' this behaviour by virtually swapping end vehicles
|
|
if( AIControllFlag ) {
|
|
if( mvOccupied->DirActive >= 0 ) { Lights( light::headlight_right, light::headlight_left ); }
|
|
else { Lights( light::headlight_left, light::headlight_right ); }
|
|
}
|
|
remove_hint( driver_hint::headcodepc1 );
|
|
remove_hint( driver_hint::headcodepc2 );
|
|
remove_hint( driver_hint::headcodepc5 );
|
|
remove_hint( driver_hint::lightsoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
|
|
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
|
|
return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, light::headlight_left); } );
|
|
break;
|
|
}
|
|
case driver_hint::headcodepc5: {
|
|
if( AIControllFlag
|
|
|| ( Global.AITrainman && false == pVehicles[end::rear]->is_connected(pVehicle, coupling::control) ) ) {
|
|
pVehicles[ end::rear ]->RaLightsSet( -1, light::redmarker_left | light::redmarker_right | light::rearendsignals );
|
|
}
|
|
remove_hint( driver_hint::headcodetb1 );
|
|
remove_hint( driver_hint::lightsoff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return pVehicles[end::rear]->has_signal_pc5_on(); } );
|
|
break;
|
|
}
|
|
case driver_hint::lightsoff: {
|
|
if( AIControllFlag ) {
|
|
Lights( 0, 0 );
|
|
}
|
|
remove_hint( driver_hint::headcodepc1 );
|
|
remove_hint( driver_hint::headcodepc2 );
|
|
remove_hint( driver_hint::headcodepc5 );
|
|
remove_hint( driver_hint::headcodetb1 );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
|
|
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
|
|
return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, 0); } );
|
|
break;
|
|
}
|
|
// releaser
|
|
case driver_hint::releaseron: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->BrakeReleaser( 1 );
|
|
}
|
|
remove_hint( driver_hint::releaseroff );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return true == mvOccupied->Hamulec->Releaser(); } );
|
|
break;
|
|
}
|
|
case driver_hint::releaseroff: {
|
|
if( AIControllFlag ) {
|
|
mvOccupied->BrakeReleaser( 0 );
|
|
}
|
|
remove_hint( driver_hint::releaseron );
|
|
hint(
|
|
Action,
|
|
[this](float const /*Parameter*/) {
|
|
return false == mvOccupied->Hamulec->Releaser(); } );
|
|
break;
|
|
}
|
|
|
|
default: {
|
|
break;
|
|
}
|
|
}
|
|
}
|