16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 15:09: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" ),
std::ios::in | std::ios::out | std::ios::trunc );
#if LOGPRESS == 0
LogFile << std::string( " Time [s] Velocity [m/s] Acceleration [m/ss] Coupler.Dist[m] "
"Coupler.Force[N] TractionForce [kN] FrictionForce [kN] "
"BrakeForce [kN] BrakePress [MPa] PipePress [MPa] "
"MotorCurrent [A] MCP SCP BCP LBP DmgFlag Command CVal1 CVal2" )
.c_str()
LogFile
<< "Time[s] Velocity[m/s] Acceleration[m/ss] "
<< "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
<< "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
<< "MCP SCP BCP LBP Direction Command CVal1 CVal2 "
<< "Security Wheelslip "
<< "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
<< "\r\n";
LogFile << std::fixed << std::setprecision( 4 );
#endif
#if LOGPRESS == 1
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 LOGPRESS == 0
LogFile << ElapsedTime << " " << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot)
<< " ";
LogFile << mvControlling->AccS << " " << mvOccupied->Couplers[1].Dist << " "
<< mvOccupied->Couplers[1].CForce << " ";
LogFile << mvOccupied->Ft << " " << mvOccupied->Ff << " " << mvOccupied->Fb << " "
<< mvOccupied->BrakePress << " ";
LogFile << mvOccupied->PipePress << " " << mvControlling->Im << " "
<< int(mvControlling->MainCtrlPos) << " ";
LogFile << int(mvControlling->ScndCtrlPos) << " " << int(mvOccupied->BrakeCtrlPos)
<< " " << int(mvOccupied->LocalBrakePos) << " ";
LogFile << int(mvControlling->ActiveDir) << " " << mvOccupied->CommandIn.Command.c_str()
<< " " << mvOccupied->CommandIn.Value1 << " ";
LogFile << mvOccupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.Status)
<< " " << int(mvControlling->SlippingWheels) << "\r\n";
/*
<< "Time[s] Velocity[m/s] Acceleration[m/ss] "
<< "Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
<< "BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
<< "MCP SCP BCP LBP DmgFlag Command CVal1 CVal2 "
<< "EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg]"
*/
LogFile
<< ElapsedTime << " "
<< fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) << " "
<< mvControlling->AccS << " "
<< mvOccupied->Couplers[1].Dist << " "
<< mvOccupied->Couplers[1].CForce << " "
<< 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
#if LOGPRESS == 1
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
// TODO: fully generalized door assembly
if( ( dDoorMoveL < MoverParameters->DoorMaxShiftL )
&& ( true == MoverParameters->DoorLeftOpened ) ) {
dDoorMoveL += dt1 * MoverParameters->DoorOpenSpeed;
dDoorMoveL = std::min( dDoorMoveL, MoverParameters->DoorMaxShiftL );
// open left door
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;
}
if( ( dDoorMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened ) ) {
// close left door
DoorDelayL += dt1;
if( DoorDelayL > MoverParameters->DoorCloseDelay ) {
dDoorMoveL -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3648,12 +3665,28 @@ bool TDynamicObject::Update(double dt, double dt1)
}
if( ( dDoorMoveR < MoverParameters->DoorMaxShiftR )
&& ( true == MoverParameters->DoorRightOpened ) ) {
dDoorMoveR += dt1 * MoverParameters->DoorOpenSpeed;
dDoorMoveR = std::min( dDoorMoveR, MoverParameters->DoorMaxShiftR );
// open right door
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;
}
if( ( dDoorMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened ) ) {
// close right door
DoorDelayR += dt1;
if( DoorDelayR > MoverParameters->DoorCloseDelay ) {
dDoorMoveR -= dt1 * MoverParameters->DoorCloseSpeed;
@@ -3663,6 +3696,7 @@ bool TDynamicObject::Update(double dt, double dt1)
// doorsteps
if( ( dDoorstepMoveL < 1.0 )
&& ( true == MoverParameters->DoorLeftOpened ) ) {
// unfold left doorstep
dDoorstepMoveL = std::min(
1.0,
dDoorstepMoveL + MoverParameters->PlatformSpeed * dt1 );
@@ -3670,12 +3704,25 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveL > 0.0 )
&& ( false == MoverParameters->DoorLeftOpened )
&& ( DoorDelayL > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveL = std::max(
0.0,
dDoorstepMoveL - MoverParameters->PlatformSpeed * dt1 );
// fold left doorstep
if( ( MoverParameters->TrainType == dt_EZT )
|| ( 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 )
&& ( true == MoverParameters->DoorRightOpened ) ) {
// unfold right doorstep
dDoorstepMoveR = std::min(
1.0,
dDoorstepMoveR + MoverParameters->PlatformSpeed * dt1 );
@@ -3683,9 +3730,21 @@ bool TDynamicObject::Update(double dt, double dt1)
if( ( dDoorstepMoveR > 0.0 )
&& ( false == MoverParameters->DoorRightOpened )
&& ( DoorDelayR > MoverParameters->DoorCloseDelay ) ) {
dDoorstepMoveR = std::max(
0.0,
dDoorstepMoveR - MoverParameters->PlatformSpeed * dt1 );
// fold right doorstep
if( ( MoverParameters->TrainType == dt_EZT )
|| ( 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
if( MoverParameters->Vel > 5.0 ) {
@@ -4044,10 +4103,13 @@ void TDynamicObject::RenderSounds() {
}
}
// NBMX Obsluga drzwi, MC: zuniwersalnione
// TODO: fully generalized door assembly
if( true == MoverParameters->DoorLeftOpened ) {
// open left door
// 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 ) {
if( door.rsDoorClose.offset().x > 0.f ) {
// determine left side doors from their offset
@@ -4094,7 +4156,9 @@ void TDynamicObject::RenderSounds() {
if( true == MoverParameters->DoorRightOpened ) {
// open right door
// 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 ) {
if( door.rsDoorClose.offset().x < 0.f ) {
// 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*/
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 PlatformMaxShift { 45.0 }; /*wysuniecie stopnia*/
double PlatformMaxShift { 0.0 }; /*wysuniecie stopnia*/
int PlatformOpenMethod { 2 }; /*sposob animacji stopnia*/
double MirrorMaxShift { 90.0 };
bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/

View File

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

10
Train.h
View File

@@ -310,11 +310,11 @@ class TTrain
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
// members
TDynamicObject *DynamicObject; // przestawia zmiana pojazdu [F5]
TMoverParameters *mvControlled; // człon, w którym sterujemy silnikiem
TMoverParameters *mvOccupied; // człon, w którym sterujemy hamulcem
TMoverParameters *mvSecond; // drugi człon (ET40, ET41, ET42, ukrotnienia)
TMoverParameters *mvThird; // trzeci człon (SN61)
TDynamicObject *DynamicObject { nullptr }; // przestawia zmiana pojazdu [F5]
TMoverParameters *mvControlled { nullptr }; // człon, w którym sterujemy silnikiem
TMoverParameters *mvOccupied { nullptr }; // człon, w którym sterujemy hamulcem
TMoverParameters *mvSecond { nullptr }; // drugi człon (ET40, ET41, ET42, ukrotnienia)
TMoverParameters *mvThird { nullptr }; // trzeci człon (SN61)
// 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)
static const commandhandler_map m_commandhandlers;

View File

@@ -950,7 +950,7 @@ ui_layer::render() {
glMatrixMode(GL_MODELVIEW);
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_DEPTH_TEST );
glDisable( GL_ALPHA_TEST );
@@ -973,7 +973,7 @@ ui_layer::render() {
render_panels();
render_tooltip();
glPopAttrib();
glPopAttrib();
}
void