diff --git a/DynObj.cpp b/DynObj.cpp index e82ac470..c20aa012 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -3129,6 +3129,7 @@ bool TDynamicObject::Update(double dt, double dt1) p->MoverParameters->MED_Vref) * 1000; // sila hamowania pn FmaxED += ((p->MoverParameters->Mains) && (p->MoverParameters->DirActive != 0) && + (p->MoverParameters->InvertersRatio == 1.0) && (p->MoverParameters->eimc[eimc_p_Fh] * p->MoverParameters->NPoweredAxles > 0) ? p->MoverParameters->eimc[eimc_p_Fh] * 1000 : diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 1c588d76..2c6da258 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -769,6 +769,16 @@ struct speed_control { double PowerDownSpeed = 1000; }; +struct inverter { + double Freal = 0.0; + double Request = 0.0; + bool IsActive = true; + bool Activate = true; + bool Error = false; + bool Failure_Drive = false; + bool Failure_Const = false; +}; + class TMoverParameters { // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :) private: @@ -1269,6 +1279,9 @@ public: bool EIMCLogForce = false; // static std::vector const eimc_labels; double InverterFrequency { 0.0 }; // current frequency of power inverters + int InvertersNo = 0; // number of inverters + double InvertersRatio = 0.0; + std::vector Inverters; //all inverters /* -dla pojazdów z blendingiem EP/ED (MED) */ double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 68c08476..7133d97a 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -5916,6 +5916,12 @@ double TMoverParameters::TractionForce( double dt ) { case TEngineType::ElectricInductionMotor: { if( true == Mains ) { + double ActiveInverters = 0.0; + for (auto &inv : Inverters) { + if (inv.IsActive) + ActiveInverters += 1.0; + } + InvertersRatio = ActiveInverters / (double)InvertersNo; //tempomat if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime) { @@ -6011,7 +6017,7 @@ double TMoverParameters::TractionForce( double dt ) { PosRatio *= 0.9; Hamulec->SetED(Max0R(0.0, std::min(PosRatio, 1.0))); //ustalenie stopnia zmniejszenia ciśnienia // ustalanie siły hamowania ED - if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001)) //jeśli PN wyłącza ED + if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001) || (ActiveInverters < InvertersNo)) //jeśli PN wyłącza ED { PosRatio = 0; eimv[eimv_Fzad] = 0; @@ -6057,6 +6063,11 @@ double TMoverParameters::TractionForce( double dt ) { // switch sandbox off SandboxAuto( false, range_t::unit ); } + if (ActiveInverters == 0.0) + { + PosRatio = 0; + eimv_pr = 0; + } eimv_pr += Max0R(Min0R(PosRatio - eimv_pr, 0.02), -0.02) * 12 * (tmp /*2{+4*byte(PosRatio 0 && Power > 0 && InvertersNo == 0) { + InvertersNo = 1; + } + Inverters.resize(InvertersNo); + /*for (int i = 0; i > InvertersNo; i++) + { + inverter x; + Inverters.emplace_back(x); + }*/ break; } default: { diff --git a/Train.cpp b/Train.cpp index d332a3e4..b75d8490 100644 --- a/Train.cpp +++ b/Train.cpp @@ -647,8 +647,24 @@ dictionary_source *TTrain::GetTrainState() { dict->insert( ( "eimp_u" + std::to_string( i + 1 ) + "_comp_a" ), bComp[ i ][ 0 ] ); dict->insert( ( "eimp_u" + std::to_string( i + 1 ) + "_comp_w" ), bComp[ i ][ 1 ] ); dict->insert( ( "eimp_c" + std::to_string( i + 1 ) + "_heat" ), bHeat[ i ] ); - } + + bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0); + TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4); + int in = 0; + while (p && in < 8) + { + if (p->MoverParameters->eimc[eimc_p_Pmax] > 1) + { + in++; + for (int j = 0; j < p->MoverParameters->InvertersNo; j++) { + dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_act"), p->MoverParameters->Inverters[j].IsActive); + dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_error"), p->MoverParameters->Inverters[j].Error); + dict->insert(("eimp_c" + std::to_string(in) + "_inv" + std::to_string(j + 1) + "_allow"), p->MoverParameters->Inverters[j].Activate); + } + } + p = (kier ? p->NextC(4) : p->PrevC(4)); + } for( int i = 0; i < 20; ++i ) { for( int j = 0; j < 3; ++j ) { dict->insert( ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ), fPress[ i ][ j ] );