mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
65
Train.cpp
65
Train.cpp
@@ -547,13 +547,18 @@ PyObject *TTrain::GetTrainState() {
|
||||
PyDict_SetItemString( dict, "velnext", PyGetFloat( driver->VelNext ) );
|
||||
PyDict_SetItemString( dict, "actualproximitydist", PyGetFloat( driver->ActualProximityDist ) );
|
||||
// train data
|
||||
auto const *timetable{ driver->TrainTimetable() };
|
||||
|
||||
PyDict_SetItemString( dict, "trainnumber", PyGetString( driver->TrainName().c_str() ) );
|
||||
PyDict_SetItemString( dict, "train_brakingmassratio", PyGetFloat( timetable->BrakeRatio ) );
|
||||
PyDict_SetItemString( dict, "train_enginetype", PyGetString( timetable->LocSeries.c_str() ) );
|
||||
PyDict_SetItemString( dict, "train_engineload", PyGetFloat( timetable->LocLoad ) );
|
||||
|
||||
PyDict_SetItemString( dict, "train_stationindex", PyGetInt( driver->StationIndex() ) );
|
||||
auto const stationcount { driver->StationCount() };
|
||||
PyDict_SetItemString( dict, "train_stationcount", PyGetInt( stationcount ) );
|
||||
if( stationcount > 0 ) {
|
||||
// timetable stations data, if there's any
|
||||
auto const *timetable { driver->TrainTimetable() };
|
||||
for( auto stationidx = 1; stationidx <= stationcount; ++stationidx ) {
|
||||
auto const stationlabel { "train_station" + std::to_string( stationidx ) + "_" };
|
||||
auto const &timetableline { timetable->TimeTable[ stationidx ] };
|
||||
@@ -567,7 +572,9 @@ PyObject *TTrain::GetTrainState() {
|
||||
PyDict_SetItemString( dict, ( stationlabel + "dm" ).c_str(), PyGetInt( timetableline.Dm ) );
|
||||
}
|
||||
}
|
||||
PyDict_SetItemString( dict, "train_atpassengerstop", PyGetBool( driver->IsAtPassengerStop ) );
|
||||
// world state data
|
||||
PyDict_SetItemString( dict, "scenario", PyGetString( Global.SceneryFile.c_str() ) );
|
||||
PyDict_SetItemString( dict, "hours", PyGetInt( simulation::Time.data().wHour ) );
|
||||
PyDict_SetItemString( dict, "minutes", PyGetInt( simulation::Time.data().wMinute ) );
|
||||
PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) );
|
||||
@@ -811,7 +818,7 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric )
|
||||
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||
Train->mvControlled->AnPos = clamp(
|
||||
Train->mvControlled->AnPos + 0.025,
|
||||
0.0, 1.0 );
|
||||
@@ -905,6 +912,9 @@ void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ) {
|
||||
if (Command.action == GLFW_RELEASE)
|
||||
return;
|
||||
|
||||
auto const targetposition { std::min<int>( Command.param1, Train->mvControlled->ScndCtrlPosNo ) };
|
||||
while( ( targetposition < Train->mvControlled->GetVirtualScndPos() )
|
||||
&& ( true == Train->mvControlled->DecScndCtrl( 1 ) ) ) {
|
||||
@@ -966,10 +976,13 @@ void TTrain::OnCommand_independentbrakedecreasefast( TTrain *Train, command_data
|
||||
|
||||
void TTrain::OnCommand_independentbrakeset( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
Train->mvControlled->LocalBrakePosA = (
|
||||
clamp(
|
||||
Command.param1,
|
||||
0.0, 1.0 ) );
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
|
||||
Train->mvControlled->LocalBrakePosA = (
|
||||
clamp(
|
||||
Command.param1,
|
||||
0.0, 1.0 ) );
|
||||
}
|
||||
/*
|
||||
Train->mvControlled->LocalBrakePos = (
|
||||
std::round(
|
||||
@@ -1351,13 +1364,11 @@ void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_da
|
||||
if( ( ( Train->mvOccupied->BrakeOpModeFlag << 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) {
|
||||
// next mode
|
||||
Train->mvOccupied->BrakeOpModeFlag <<= 1;
|
||||
// audio feedback
|
||||
Train->dsbPneumaticSwitch.play();
|
||||
// visual feedback
|
||||
Train->ggBrakeOperationModeCtrl.UpdateValue(
|
||||
Train->mvOccupied->BrakeOpModeFlag > 0 ?
|
||||
std::log2( Train->mvOccupied->BrakeOpModeFlag ) :
|
||||
0 );
|
||||
0 ); // audio fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1369,8 +1380,6 @@ void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_da
|
||||
if( ( ( Train->mvOccupied->BrakeOpModeFlag >> 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) {
|
||||
// previous mode
|
||||
Train->mvOccupied->BrakeOpModeFlag >>= 1;
|
||||
// audio feedback
|
||||
Train->dsbPneumaticSwitch.play();
|
||||
// visual feedback
|
||||
Train->ggBrakeOperationModeCtrl.UpdateValue(
|
||||
Train->mvOccupied->BrakeOpModeFlag > 0 ?
|
||||
@@ -5423,8 +5432,8 @@ bool TTrain::Update( double const Deltatime )
|
||||
btLampkaRadioStop.Turn( mvOccupied->Radio && mvOccupied->RadioStopFlag );
|
||||
btLampkaHamulecReczny.Turn(mvOccupied->ManualBrakePos > 0);
|
||||
// NBMX wrzesien 2003 - drzwi oraz sygnał odjazdu
|
||||
btLampkaDoorLeft.Turn(mvOccupied->DoorLeftOpened);
|
||||
btLampkaDoorRight.Turn(mvOccupied->DoorRightOpened);
|
||||
btLampkaDoorLeft.Turn( DynamicObject->dDoorMoveL > 0.0 );// mvOccupied->DoorLeftOpened);
|
||||
btLampkaDoorRight.Turn( DynamicObject->dDoorMoveR > 0.0 ); //mvOccupied ->DoorRightOpened);
|
||||
btLampkaBlokadaDrzwi.Turn(mvOccupied->DoorBlockedFlag());
|
||||
btLampkaDoorLockOff.Turn( false == mvOccupied->DoorLockEnabled );
|
||||
btLampkaDepartureSignal.Turn( mvControlled->DepartureSignal );
|
||||
@@ -5733,7 +5742,12 @@ bool TTrain::Update( double const Deltatime )
|
||||
InstrumentLightType == 0 ? mvControlled->Battery || mvControlled->ConverterFlag :
|
||||
InstrumentLightType == 1 ? mvControlled->Mains :
|
||||
InstrumentLightType == 2 ? mvControlled->ConverterFlag :
|
||||
InstrumentLightType == 3 ? mvControlled->Battery || mvControlled->ConverterFlag :
|
||||
false ) };
|
||||
if( InstrumentLightType == 3 ) {
|
||||
// TODO: link the light state with the state of the master key
|
||||
InstrumentLightActive = true;
|
||||
}
|
||||
btInstrumentLight.Turn( InstrumentLightActive && lightpower );
|
||||
btDashboardLight.Turn( DashboardLightActive && lightpower );
|
||||
btTimetableLight.Turn( TimetableLightActive && lightpower );
|
||||
@@ -5791,7 +5805,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggHornLowButton.Update();
|
||||
ggHornHighButton.Update();
|
||||
ggWhistleButton.Update();
|
||||
ggHelperButton.UpdateValue(DynamicObject->Mechanik->HelperState);
|
||||
if( DynamicObject->Mechanik != nullptr ) {
|
||||
ggHelperButton.UpdateValue( DynamicObject->Mechanik->HelperState );
|
||||
}
|
||||
ggHelperButton.Update();
|
||||
for( auto &universal : ggUniversals ) {
|
||||
universal.Update();
|
||||
@@ -5859,7 +5875,8 @@ bool TTrain::Update( double const Deltatime )
|
||||
|
||||
// NOTE: crude way to have the pantographs go back up if they're dropped due to insufficient pressure etc
|
||||
// TODO: rework it into something more elegant, when redoing the whole consist/unit/cab etc arrangement
|
||||
if( DynamicObject->Mechanik != nullptr && !DynamicObject->Mechanik->AIControllFlag ) {
|
||||
if( ( DynamicObject->Mechanik == nullptr )
|
||||
|| ( false == DynamicObject->Mechanik->AIControllFlag ) ) {
|
||||
// don't mess with the ai driving, at least not while switches don't follow ai-set vehicle state
|
||||
if( ( mvControlled->Battery )
|
||||
|| ( mvControlled->ConverterFlag ) ) {
|
||||
@@ -7284,8 +7301,8 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
0.f ) );
|
||||
// doors
|
||||
// NOTE: we're relying on the cab models to have switches reversed for the rear cab(?)
|
||||
ggDoorLeftButton.PutValue( mvOccupied->DoorLeftOpened ? 1.f : 0.f );
|
||||
ggDoorRightButton.PutValue( mvOccupied->DoorRightOpened ? 1.f : 0.f );
|
||||
ggDoorLeftButton.PutValue( /*mvOccupied->DoorLeftOpened*/ DynamicObject->dDoorMoveL > 0.0 ? 1.f : 0.f );
|
||||
ggDoorRightButton.PutValue( /*mvOccupied->DoorRightOpened*/ DynamicObject->dDoorMoveR > 0.0 ? 1.f : 0.f );
|
||||
// door lock
|
||||
ggDoorSignallingButton.PutValue(
|
||||
mvOccupied->DoorLockEnabled ?
|
||||
@@ -7491,14 +7508,18 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
||||
btInstrumentLight.Load( Parser, DynamicObject );
|
||||
InstrumentLightType = 0;
|
||||
}
|
||||
else if( Label == "i-instrumentlight_M:" ) {
|
||||
else if( Label == "i-instrumentlight_m:" ) {
|
||||
btInstrumentLight.Load( Parser, DynamicObject );
|
||||
InstrumentLightType = 1;
|
||||
}
|
||||
else if( Label == "i-instrumentlight_C:" ) {
|
||||
else if( Label == "i-instrumentlight_c:" ) {
|
||||
btInstrumentLight.Load( Parser, DynamicObject );
|
||||
InstrumentLightType = 2;
|
||||
}
|
||||
else if( Label == "i-instrumentlight_a:" ) {
|
||||
btInstrumentLight.Load( Parser, DynamicObject );
|
||||
InstrumentLightType = 3;
|
||||
}
|
||||
else if (Label == "i-doors:")
|
||||
{
|
||||
int i = Parser.getToken<int>() - 1;
|
||||
@@ -7734,6 +7755,12 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
gauge.Load(Parser, DynamicObject, 0.1);
|
||||
gauge.AssignDouble(&mvOccupied->PipePress);
|
||||
}
|
||||
else if( Label == "scndpress:" ) {
|
||||
// manometr przewodu hamulcowego
|
||||
auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka
|
||||
gauge.Load( Parser, DynamicObject, 0.1 );
|
||||
gauge.AssignDouble( &mvOccupied->ScndPipePress );
|
||||
}
|
||||
else if (Label == "limpipepress:")
|
||||
{
|
||||
// manometr zbiornika sterujacego zaworu maszynisty
|
||||
|
||||
Reference in New Issue
Block a user