Make repair button vehicle in debug mode instead call resetconsist command, add pantograph damage flag, repair pantographs in resetconsist command

This commit is contained in:
milek7
2021-01-30 13:25:18 +01:00
parent 810b7ad074
commit 372f99afee
4 changed files with 22 additions and 13 deletions

View File

@@ -121,6 +121,7 @@ static int const dtrain_engine = 32; /*dla lokomotyw*/
static int const dtrain_loaddestroyed = 32;/*dla wagonow*/ static int const dtrain_loaddestroyed = 32;/*dla wagonow*/
static int const dtrain_axle = 64; static int const dtrain_axle = 64;
static int const dtrain_out = 128; /*wykolejenie*/ static int const dtrain_out = 128; /*wykolejenie*/
static int const dtrain_pantograph = 256; /*polamanie pantografu*/
/*wagi prawdopodobienstwa dla funkcji FuzzyLogic*/ /*wagi prawdopodobienstwa dla funkcji FuzzyLogic*/
#define p_elengproblem (1e-02) #define p_elengproblem (1e-02)

View File

@@ -546,18 +546,10 @@ debug_panel::render() {
// sections // sections
ImGui::Separator(); ImGui::Separator();
if( true == render_section( "Vehicle", m_vehiclelines ) ) { if( true == render_section( "Vehicle", m_vehiclelines ) ) {
if( ( m_input.mover ) if( DebugModeFlag && ( m_input.mover ) && ( m_input.mover->DamageFlag != 0 ) ) {
&& ( m_input.mover->DamageFlag != 0 ) ) { if( true == ImGui::Button( "Stop and repair consist" ) ) {
if( true == ImGui::Button( "Fix Status" ) ) { command_relay relay;
// TODO: refactor status reset into mover method relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
m_input.mover->DamageFlag = 0;
m_input.mover->EngDmgFlag = 0;
m_input.mover->V = 0.0001; // HACK: force vehicle position re-calculation
m_input.mover->DistCounter = 0.0;
m_input.mover->WheelFlat = 0.0;
m_input.mover->AlarmChainFlag = false;
m_input.mover->OffsetTrackH = 0.0;
m_input.mover->OffsetTrackV = 0.0;
} }
} }
} }

View File

@@ -82,6 +82,7 @@ basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex
// i do tego jeszcze wejdzie pod ślizg // i do tego jeszcze wejdzie pod ślizg
if( fHorizontal <= 0.0 ) { if( fHorizontal <= 0.0 ) {
// 0.635 dla AKP-1 AKP-4E // 0.635 dla AKP-1 AKP-4E
SetFlag( Vehicle->MoverParameters->DamageFlag, dtrain_pantograph );
pantograph->PantWys = -1.0; // ujemna liczba oznacza połamanie pantograph->PantWys = -1.0; // ujemna liczba oznacza połamanie
pantograph->hvPowerWire = nullptr; // bo inaczej się zasila w nieskończoność z połamanego pantograph->hvPowerWire = nullptr; // bo inaczej się zasila w nieskończoność z połamanego
if( Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { if( Vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) {

View File

@@ -369,12 +369,27 @@ void state_manager::process_commands() {
while (vehicle) { while (vehicle) {
vehicle->MoverParameters->DamageFlag = 0; vehicle->MoverParameters->DamageFlag = 0;
vehicle->MoverParameters->EngDmgFlag = 0; vehicle->MoverParameters->EngDmgFlag = 0;
vehicle->MoverParameters->V = 0.0; vehicle->MoverParameters->V = 0.000001; // HACK: force vehicle position re-calculation
vehicle->MoverParameters->DistCounter = 0.0; vehicle->MoverParameters->DistCounter = 0.0;
vehicle->MoverParameters->WheelFlat = 0.0; vehicle->MoverParameters->WheelFlat = 0.0;
vehicle->MoverParameters->AlarmChainFlag = false; vehicle->MoverParameters->AlarmChainFlag = false;
vehicle->MoverParameters->OffsetTrackH = 0.0; vehicle->MoverParameters->OffsetTrackH = 0.0;
vehicle->MoverParameters->OffsetTrackV = 0.0; vehicle->MoverParameters->OffsetTrackV = 0.0;
// pantographs
for( auto idx = 0; idx < vehicle->iAnimType[ ANIM_PANTS ]; ++idx ) {
auto &pantograph { *( vehicle->pants[ idx ].fParamPants ) };
if( pantograph.PantWys >= 0.0 ) // negative value means pantograph is broken
continue;
pantograph.fAngleL = pantograph.fAngleL0;
pantograph.fAngleU = pantograph.fAngleU0;
pantograph.PantWys =
pantograph.fLenL1 * std::sin( pantograph.fAngleL )
+ pantograph.fLenU1 * std::sin( pantograph.fAngleU )
+ pantograph.fHeight;
vehicle->MoverParameters->EnginePowerSource.CollectorParameters.CollectorsNo;
}
vehicle = vehicle->Prev(); vehicle = vehicle->Prev();
} }
} }