16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 19:49:19 +02:00

door and doorstep animations sync, temperature values included in the physics log

This commit is contained in:
tmj-fstate
2018-05-18 19:58:46 +02:00
parent 45e751312a
commit 6fd7dfc2fe
6 changed files with 129 additions and 44 deletions

View File

@@ -1535,12 +1535,15 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ), LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ),
std::ios::in | std::ios::out | std::ios::trunc ); std::ios::in | std::ios::out | std::ios::trunc );
#if LOGPRESS == 0 #if LOGPRESS == 0
LogFile << std::string( " Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] " LogFile
"Coupler.Force[N] TractionForce [kN] FrictionForce [kN] " << "Time[s] Velocity[m/s] Acceleration[m/ss] "
"BrakeForce [kN] BrakePress [MPa] PipePress [MPa] " << "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
"MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2" ) << "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
.c_str() << "MCP SCP BCP LBP Direction Command CVal1 CVal2 "
<< "Security Wheelslip "
<< "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
<< "\r\n"; << "\r\n";
LogFile << std::fixed << std::setprecision( 4 );
#endif #endif
#if LOGPRESS == 1 #if LOGPRESS == 1
LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n"; LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n";
@@ -3539,20 +3542,40 @@ void TController::PhysicsLog()
if (LogFile.is_open()) if (LogFile.is_open())
{ {
#if LOGPRESS == 0 #if LOGPRESS == 0
LogFile << ElapsedTime << " " << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) /*
<< " "; << "Time[s] Velocity[m/s] Acceleration[m/ss] "
LogFile << mvControlling->AccS << " " << mvOccupied->Couplers[1].Dist << " " << "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
<< mvOccupied->Couplers[1].CForce << " "; << "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
LogFile << mvOccupied->Ft << " " << mvOccupied->Ff << " " << mvOccupied->Fb << " " << "MCP SCP BCP LBP DmgFlag Command CVal1 CVal2 "
<< mvOccupied->BrakePress << " "; << "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
LogFile << mvOccupied->PipePress << " " << mvControlling->Im << " " */
<< int(mvControlling->MainCtrlPos) << " "; LogFile
LogFile << int(mvControlling->ScndCtrlPos) << " " << int(mvOccupied->BrakeCtrlPos) << ElapsedTime << " "
<< " " << int(mvOccupied->LocalBrakePos) << " "; << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) << " "
LogFile << int(mvControlling->ActiveDir) << " " << mvOccupied->CommandIn.Command.c_str() << mvControlling->AccS << " "
<< " " << mvOccupied->CommandIn.Value1 << " "; << mvOccupied->Couplers[1].Dist << " "
LogFile << mvOccupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.Status) << mvOccupied->Couplers[1].CForce << " "
<< " " << int(mvControlling->SlippingWheels) << "\r\n"; << mvOccupied->Ft << " "
<< mvOccupied->Ff << " "
<< mvOccupied->Fb << " "
<< mvOccupied->BrakePress << " "
<< mvOccupied->PipePress << " "
<< mvControlling->Im << " "
<< int(mvControlling->MainCtrlPos) << " "
<< int(mvControlling->ScndCtrlPos) << " "
<< int(mvOccupied->BrakeCtrlPos) << " "
<< int(mvOccupied->LocalBrakePos) << " "
<< int(mvControlling->ActiveDir) << " "
<< ( mvOccupied->CommandIn.Command.empty() ? "none" : mvOccupied->CommandIn.Command.c_str() ) << " "
<< mvOccupied->CommandIn.Value1 << " "
<< mvOccupied->CommandIn.Value2 << " "
<< int(mvControlling->SecuritySystem.Status) << " "
<< int(mvControlling->SlippingWheels) << " "
<< mvControlling->dizel_heat.Ts << " "
<< mvControlling->dizel_heat.To << " "
<< mvControlling->dizel_heat.temperatura1 << " "
<< mvControlling->dizel_heat.temperatura2
<< "\r\n";
#endif #endif
#if LOGPRESS == 1 #if LOGPRESS == 1
LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot)

View File

@@ -3632,14 +3632,31 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
// NBMX Obsluga drzwi, MC: zuniwersalnione // NBMX Obsluga drzwi, MC: zuniwersalnione
// TODO: fully generalized door assembly
if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL )
&& ( true == MoverParameters->DoorLeftOpened ) ) { && ( true == MoverParameters->DoorLeftOpened ) ) {
dDoorMoveL += dt1 * MoverParameters->DoorOpenSpeed; // open left door
dDoorMoveL = std::min( dDoorMoveL, MoverParameters->DoorMaxShiftL ); if( ( MoverParameters->TrainType == dt_EZT )
|| ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically open door only after unfolding the doorstep
if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep
|| ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep
|| ( dDoorstepMoveL == 1.0 ) ) {
dDoorMoveL = std::min(
MoverParameters->DoorMaxShiftL,
dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 );
}
}
else {
dDoorMoveL = std::min(
MoverParameters->DoorMaxShiftL,
dDoorMoveL + MoverParameters->DoorOpenSpeed * dt1 );
}
DoorDelayL = 0.f; DoorDelayL = 0.f;
} }
if( ( dDoorMoveL > 0.0 ) if( ( dDoorMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened ) ) { && ( false == MoverParameters->DoorLeftOpened ) ) {
// close left door
DoorDelayL += dt1; DoorDelayL += dt1;
if( DoorDelayL > MoverParameters->DoorCloseDelay ) { if( DoorDelayL > MoverParameters->DoorCloseDelay ) {
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3648,12 +3665,28 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR )
&& ( true == MoverParameters->DoorRightOpened ) ) { && ( true == MoverParameters->DoorRightOpened ) ) {
dDoorMoveR += dt1 * MoverParameters->DoorOpenSpeed; // open right door
dDoorMoveR = std::min( dDoorMoveR, MoverParameters->DoorMaxShiftR ); if( ( MoverParameters->TrainType == dt_EZT )
|| ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically open door only after unfolding the doorstep
if( ( MoverParameters->PlatformMaxShift == 0.0 ) // no wait if no doorstep
|| ( MoverParameters->PlatformOpenMethod == 2 ) // no wait for rotating doorstep
|| ( dDoorstepMoveR == 1.0 ) ) {
dDoorMoveR = std::min(
MoverParameters->DoorMaxShiftR,
dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 );
}
}
else {
dDoorMoveR = std::min(
MoverParameters->DoorMaxShiftR,
dDoorMoveR + MoverParameters->DoorOpenSpeed * dt1 );
}
DoorDelayR = 0.f; DoorDelayR = 0.f;
} }
if( ( dDoorMoveR > 0.0 ) if( ( dDoorMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened ) ) { && ( false == MoverParameters->DoorRightOpened ) ) {
// close right door
DoorDelayR += dt1; DoorDelayR += dt1;
if( DoorDelayR > MoverParameters->DoorCloseDelay ) { if( DoorDelayR > MoverParameters->DoorCloseDelay ) {
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed; dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3663,6 +3696,7 @@ bool TDynamicObject::Update(double dt, double dt1)
// doorsteps // doorsteps
if( ( dDoorstepMoveL < 1.0 ) if( ( dDoorstepMoveL < 1.0 )
&& ( true == MoverParameters->DoorLeftOpened ) ) { && ( true == MoverParameters->DoorLeftOpened ) ) {
// unfold left doorstep
dDoorstepMoveL = std::min( dDoorstepMoveL = std::min(
1.0, 1.0,
dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 ); dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 );
@@ -3670,12 +3704,25 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveL > 0.0 ) if( ( dDoorstepMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened ) && ( false == MoverParameters->DoorLeftOpened )
&& ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) { && ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveL = std::max( // fold left doorstep
0.0, if( ( MoverParameters->TrainType == dt_EZT )
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 ); || ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically fold the doorstep only after closing the door
if( dDoorMoveL == 0.0 ) {
dDoorstepMoveL = std::max(
0.0,
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 );
}
}
else {
dDoorstepMoveL = std::max(
0.0,
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 );
}
} }
if( ( dDoorstepMoveR < 1.0 ) if( ( dDoorstepMoveR < 1.0 )
&& ( true == MoverParameters->DoorRightOpened ) ) { && ( true == MoverParameters->DoorRightOpened ) ) {
// unfold right doorstep
dDoorstepMoveR = std::min( dDoorstepMoveR = std::min(
1.0, 1.0,
dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 ); dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 );
@@ -3683,9 +3730,21 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveR > 0.0 ) if( ( dDoorstepMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened ) && ( false == MoverParameters->DoorRightOpened )
&& ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) { && ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveR = std::max( // fold right doorstep
0.0, if( ( MoverParameters->TrainType == dt_EZT )
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 ); || ( MoverParameters->TrainType == dt_DMU ) ) {
// multi-unit vehicles typically fold the doorstep only after closing the door
if( dDoorMoveR == 0.0 ) {
dDoorstepMoveR = std::max(
0.0,
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 );
}
}
else {
dDoorstepMoveR = std::max(
0.0,
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 );
}
} }
// mirrors // mirrors
if( MoverParameters->Vel > 5.0 ) { if( MoverParameters->Vel > 5.0 ) {
@@ -4044,10 +4103,13 @@ void TDynamicObject::RenderSounds() {
} }
} }
// NBMX Obsluga drzwi, MC: zuniwersalnione // NBMX Obsluga drzwi, MC: zuniwersalnione
// TODO: fully generalized door assembly
if( true == MoverParameters->DoorLeftOpened ) { if( true == MoverParameters->DoorLeftOpened ) {
// open left door // open left door
// door sounds // door sounds
if( dDoorMoveL < MoverParameters->DoorMaxShiftL ) { // due to potential wait for the doorstep we play the sound only during actual animation
if( ( dDoorMoveL > 0.0 )
&& ( dDoorMoveL < MoverParameters->DoorMaxShiftL ) ) {
for( auto &door : m_doorsounds ) { for( auto &door : m_doorsounds ) {
if( door.rsDoorClose.offset().x > 0.f ) { if( door.rsDoorClose.offset().x > 0.f ) {
// determine left side doors from their offset // determine left side doors from their offset
@@ -4094,7 +4156,9 @@ void TDynamicObject::RenderSounds() {
if( true == MoverParameters->DoorRightOpened ) { if( true == MoverParameters->DoorRightOpened ) {
// open right door // open right door
// door sounds // door sounds
if( dDoorMoveR < MoverParameters->DoorMaxShiftR ) { // due to potential wait for the doorstep we play the sound only during actual animation
if( ( dDoorMoveR > 0.0 )
&& ( dDoorMoveR < MoverParameters->DoorMaxShiftR ) ) {
for( auto &door : m_doorsounds ) { for( auto &door : m_doorsounds ) {
if( door.rsDoorClose.offset().x < 0.f ) { if( door.rsDoorClose.offset().x < 0.f ) {
// determine right side doors from their offset // determine right side doors from their offset

View File

@@ -947,7 +947,7 @@ public:
int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/ int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/
float DoorCloseDelay { 0.f }; // delay (in seconds) before the door begin closing, once conditions to close are met float DoorCloseDelay { 0.f }; // delay (in seconds) before the door begin closing, once conditions to close are met
double PlatformSpeed = 0.5; /*szybkosc stopnia*/ double PlatformSpeed = 0.5; /*szybkosc stopnia*/
double PlatformMaxShift { 45.0 }; /*wysuniecie stopnia*/ double PlatformMaxShift { 0.0 }; /*wysuniecie stopnia*/
int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/ int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/
double MirrorMaxShift { 90.0 }; double MirrorMaxShift { 90.0 };
bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/ bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/

View File

@@ -335,9 +335,7 @@ std::vector<std::string> const TTrain::fPress_labels = {
}; };
TTrain::TTrain() { TTrain::TTrain() {
/*
Universal4Active = false;
*/
ShowNextCurrent = false; ShowNextCurrent = false;
// McZapkie-240302 - przyda sie do tachometru // McZapkie-240302 - przyda sie do tachometru
fTachoVelocity = 0; fTachoVelocity = 0;
@@ -428,10 +426,10 @@ bool TTrain::Init(TDynamicObject *NewDynamicObject, bool e3d)
PyObject *TTrain::GetTrainState() { PyObject *TTrain::GetTrainState() {
auto const &mover = DynamicObject->MoverParameters; auto const *mover = DynamicObject->MoverParameters;
auto *dict = PyDict_New(); auto *dict = PyDict_New();
if( ( dict == nullptr ) if( ( dict == nullptr )
|| ( mover == nullptr ) ) { || ( mover == nullptr ) ) {
return nullptr; return nullptr;
} }

10
Train.h
View File

@@ -310,11 +310,11 @@ class TTrain
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command ); static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
// members // members
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5] TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5]
TMoverParameters *mvControlled; // człon, w którym sterujemy silnikiem TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem
TMoverParameters *mvOccupied; // człon, w którym sterujemy hamulcem TMoverParameters *mvOccupied { nullptr }; // człon, w którym sterujemy hamulcem
TMoverParameters *mvSecond; // drugi człon (ET40, ET41, ET42, ukrotnienia) TMoverParameters *mvSecond { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia)
TMoverParameters *mvThird; // trzeci człon (SN61) TMoverParameters *mvThird { nullptr }; // trzeci człon (SN61)
// helper variable, to prevent immediate switch between closing and opening line breaker circuit // helper variable, to prevent immediate switch between closing and opening line breaker circuit
int m_linebreakerstate { 0 }; // 0: open, 1: closed, 2: freshly closed (and yes this is awful way to go about it) int m_linebreakerstate { 0 }; // 0: open, 1: closed, 2: freshly closed (and yes this is awful way to go about it)
static const commandhandler_map m_commandhandlers; static const commandhandler_map m_commandhandlers;

View File

@@ -950,7 +950,7 @@ ui_layer::render() {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT ); glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT ); // blendfunc included since 3rd party gui doesn't play nice
glDisable( GL_LIGHTING ); glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST ); glDisable( GL_DEPTH_TEST );
glDisable( GL_ALPHA_TEST ); glDisable( GL_ALPHA_TEST );
@@ -973,7 +973,7 @@ ui_layer::render() {
render_panels(); render_panels();
render_tooltip(); render_tooltip();
glPopAttrib(); glPopAttrib();
} }
void void