18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 02:56:01 +01:00

feat(ai): suggested pantograph setup for shunting in the .fiz (eu07/maszyna#461)

A new optional key in the AI section of the .fiz, ShuntPantstate= (bits as in
Pantstate: 1 front, 2 rear, 3 both), sets the pantographs the AI driver keeps
up while its order is Shunt or Loose_shunt, moving and standing alike: it
raises those of the setup and lowers the others once one of the setup
collects the voltage, and doesn't raise more when idling. Lowering on the
track's demand still comes first. Without the key (default 0) nothing
changes, so an ET41 no longer has to shunt on all four pantographs once its
.fiz says so.

SVN data, optional: add "AI: ShuntPantstate=<1|2|3>" to the .fiz of vehicles
that should shunt on fewer pantographs, e.g. dynamic/pkp/et41_v2/203e-a.fiz,
203e-b.fiz and their _dsa150 variants (no AI line there yet). Without it the
vehicles behave as before.

(eu07/maszyna#461)
This commit is contained in:
jerrrrycho
2026-11-07 21:32:41 +01:00
parent 939e42b611
commit 8f51ea9a19
5 changed files with 79 additions and 1 deletions

View File

@@ -6115,6 +6115,13 @@ TController::control_pantographs() {
fActionTime = -2.0 - Random(10);
}
// the pantograph setup the .fiz suggests for shunting (AI: ShuntPantstate=, eu07/maszyna#461), 0 when there's none
// or the vehicle isn't shunting
auto const shuntpantographsetup {
( OrderCurrentGet() & ( Shunt | Loose_shunt ) ) != 0 ?
mvOccupied->AIHintShuntPantstate :
0 };
// raise/lower pantographs as needed
auto const useregularpantographlayout {
pVehicle->Next(coupling::control) == nullptr // standalone
@@ -6141,7 +6148,11 @@ TController::control_pantographs() {
// jeśli nie trzeba opuszczać pantografów
// TODO: check if faction alone reduces frequency enough
if( fActionTime > 0.0 ) {
if( mvOccupied->AIHintPantstate == 0 ) {
if( shuntpantographsetup != 0 ) {
// shunting with the pantograph setup the .fiz suggests for it
control_pantographs_setup( shuntpantographsetup );
}
else if( mvOccupied->AIHintPantstate == 0 ) {
// jazda na tylnym
if( iDirection >= 0 && useregularpantographlayout ) {
// jak jedzie w kierunku sprzęgu 0
@@ -6194,6 +6205,12 @@ TController::control_pantographs() {
}
}
}
else if( shuntpantographsetup != 0 ) {
// shunting with the suggested setup, also while standing, and without raising more pantographs when idling
if( fOverhead2 <= 0.0 && iOverheadDown == 0 ) {
control_pantographs_setup( shuntpantographsetup );
}
}
else {
if( !mvOccupied->AIHintPantUpIfIdle || IdleTime <= 45.0 || std::abs(fStopTime) <= 15.0 || mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo <= 1 )
{
@@ -6220,6 +6237,31 @@ TController::control_pantographs() {
}
}
// raises the pantographs of the suggested setup (bit 0: front, bit 1: rear) and lowers the others, these only once
// a pantograph of the setup collects the voltage, so the vehicle doesn't lose its power on the way
void
TController::control_pantographs_setup( int const Setup ) {
auto const front { ( Setup & 1 << 0 ) != 0 };
auto const rear { ( Setup & 1 << 1 ) != 0 };
if( front ) {
cue_action( driver_hint::frontpantographvalveon );
}
if( rear ) {
cue_action( driver_hint::rearpantographvalveon );
}
if( auto const setuplive { ( front && mvPantographUnit->PantFrontVolt != 0.0 ) || ( rear && mvPantographUnit->PantRearVolt != 0.0 ) };
false == setuplive ) {
return;
}
if( false == front ) {
cue_action( driver_hint::frontpantographvalveoff );
}
if( false == rear ) {
cue_action( driver_hint::rearpantographvalveoff );
}
}
void
TController::control_horns( double const Timedelta ) {
// horn control