mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 08:09:19 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
@@ -1614,7 +1614,7 @@ void TMoverParameters::OilPumpCheck( double const Timestep ) {
|
||||
|
||||
OilPump.pressure_target = (
|
||||
enrot > 0.1 ? interpolate( minpressure, OilPump.pressure_maximum, static_cast<float>( clamp( enrot / maxrevolutions, 0.0, 1.0 ) ) ) * OilPump.resource_amount :
|
||||
true == OilPump.is_active ? minpressure :
|
||||
true == OilPump.is_active ? std::min( minpressure + 0.1f, OilPump.pressure_maximum ) : // slight pressure margin to give time to switch off the pump and start the engine
|
||||
0.f );
|
||||
|
||||
if( OilPump.pressure_present < OilPump.pressure_target ) {
|
||||
@@ -3300,7 +3300,7 @@ void TMoverParameters::CompressorCheck(double dt)
|
||||
CompressedVolume +=
|
||||
CompressorSpeed
|
||||
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor
|
||||
* ( DElist[ MainCtrlPos ].RPM / DElist[ MainCtrlPosNo ].RPM )
|
||||
* ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM )
|
||||
* dt;
|
||||
}
|
||||
else {
|
||||
@@ -3465,7 +3465,7 @@ void TMoverParameters::CompressorCheck(double dt)
|
||||
// the compressor is coupled with the diesel engine, engine revolutions affect the output
|
||||
if( false == CompressorGovernorLock ) {
|
||||
auto const enginefactor { (
|
||||
EngineType == DieselElectric ? ( DElist[ MainCtrlPos ].RPM / DElist[ MainCtrlPosNo ].RPM ) :
|
||||
EngineType == DieselElectric ? ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM ) :
|
||||
EngineType == DieselEngine ? ( std::abs( enrot ) / nmax ) :
|
||||
1.0 ) }; // shouldn't ever get here but, eh
|
||||
CompressedVolume +=
|
||||
@@ -4424,8 +4424,7 @@ double TMoverParameters::CouplerForce(int CouplerN, double dt)
|
||||
// Q: 20160714
|
||||
// oblicza sile trakcyjna lokomotywy (dla elektrowozu tez calkowity prad)
|
||||
// *************************************************************************************************
|
||||
double TMoverParameters::TractionForce(double dt)
|
||||
{
|
||||
double TMoverParameters::TractionForce( double dt ) {
|
||||
double PosRatio, dmoment, dtrans, tmp;
|
||||
|
||||
Ft = 0;
|
||||
@@ -4441,13 +4440,15 @@ double TMoverParameters::TractionForce(double dt)
|
||||
|
||||
if( ( true == Heating )
|
||||
&& ( HeatingPower > 0 )
|
||||
&& ( MainCtrlPosNo > MainCtrlPos ) ) {
|
||||
|
||||
int i = MainCtrlPosNo;
|
||||
while( DElist[ i - 2 ].RPM / 60.0 > tmp ) {
|
||||
--i;
|
||||
}
|
||||
tmp = DElist[ i ].RPM / 60.0;
|
||||
&& ( EngineHeatingRPM > 0 ) ) {
|
||||
// bump engine revolutions up if needed, when heating is on
|
||||
tmp =
|
||||
std::max(
|
||||
tmp,
|
||||
std::min(
|
||||
DElist[ MainCtrlPosNo ].RPM,
|
||||
EngineHeatingRPM )
|
||||
/ 60.0 );
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -4458,8 +4459,8 @@ double TMoverParameters::TractionForce(double dt)
|
||||
enrot = clamp(
|
||||
enrot + ( dt / 1.25 ) * ( // TODO: equivalent of dizel_aim instead of fixed inertia
|
||||
enrot < tmp ?
|
||||
1.0 :
|
||||
-2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not
|
||||
1.0 :
|
||||
-2.0 ), // NOTE: revolutions drop faster than they rise, maybe? TBD: maybe not
|
||||
0.0, std::max( tmp, enrot ) );
|
||||
if( std::abs( tmp - enrot ) < 0.001 ) {
|
||||
enrot = tmp;
|
||||
@@ -4501,7 +4502,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
|
||||
case 1: { // manual
|
||||
if( ( ActiveDir != 0 )
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) {
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) {
|
||||
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
@@ -4513,7 +4514,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
case 2: { // automatic
|
||||
auto const motorcurrent{ std::min<double>( ImaxHi, std::abs( Im ) ) };
|
||||
if( ( std::abs( Itot ) > RVentMinI )
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) {
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) {
|
||||
|
||||
RventRot +=
|
||||
( RVentnmax
|
||||
@@ -4523,7 +4524,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
* RVentSpeed * dt;
|
||||
}
|
||||
else if( ( DynamicBrakeType == dbrake_automatic )
|
||||
&& ( true == DynamicBrakeFlag ) ) {
|
||||
&& ( true == DynamicBrakeFlag ) ) {
|
||||
RventRot += ( RVentnmax * motorcurrent / ImaxLo - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
@@ -4577,13 +4578,35 @@ double TMoverParameters::TractionForce(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
switch( EngineType ) {
|
||||
case Dumb: {
|
||||
PosRatio = ( MainCtrlPos + ScndCtrlPos ) / ( MainCtrlPosNo + ScndCtrlPosNo + 0.01 );
|
||||
EnginePower = 1000.0 * Power * PosRatio;
|
||||
break;
|
||||
}
|
||||
case DieselEngine: {
|
||||
EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 );
|
||||
if( MainCtrlPos > 1 ) {
|
||||
// dodatkowe opory z powodu sprezarki}
|
||||
dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DieselElectric: {
|
||||
EnginePower = 0; // the actual calculation is done in two steps later in the method
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ActiveDir != 0)
|
||||
switch (EngineType)
|
||||
{
|
||||
case Dumb:
|
||||
{
|
||||
PosRatio = (MainCtrlPos + ScndCtrlPos) / (MainCtrlPosNo + ScndCtrlPosNo + 0.01);
|
||||
if (Mains && (ActiveDir != 0) && (CabNo != 0))
|
||||
if (Mains && (CabNo != 0))
|
||||
{
|
||||
if (Vel > 0.1)
|
||||
{
|
||||
@@ -4595,7 +4618,6 @@ double TMoverParameters::TractionForce(double dt)
|
||||
}
|
||||
else
|
||||
Ft = 0;
|
||||
EnginePower = 1000.0 * Power * PosRatio;
|
||||
break;
|
||||
} // Dumb
|
||||
|
||||
@@ -4680,11 +4702,6 @@ double TMoverParameters::TractionForce(double dt)
|
||||
|
||||
case DieselEngine:
|
||||
{
|
||||
EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 );
|
||||
if( MainCtrlPos > 1 ) {
|
||||
// dodatkowe opory z powodu sprezarki}
|
||||
dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax );
|
||||
}
|
||||
Mm = dmoment; //bylo * dizel_engage
|
||||
Mw = Mm * dtrans; // dmoment i dtrans policzone przy okazji enginerotation
|
||||
Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles;
|
||||
@@ -4702,6 +4719,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) {
|
||||
Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) );
|
||||
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output
|
||||
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
|
||||
auto const rpmratio { 60.0 * enrot / DElist[ MainCtrlPos ].RPM };
|
||||
tmp = rpmratio * ( SST[ MainCtrlPos ].Pmax * AnPos ) + ( SST[ MainCtrlPos ].Pmin * ( 1.0 - AnPos ) );
|
||||
Ft = tmp * 1000.0 / ( abs( tmpV ) + 1.6 );
|
||||
@@ -4718,6 +4736,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
if( true == Heating ) { power -= HeatingPower; }
|
||||
if( power < 0.0 ) { power = 0.0; }
|
||||
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output
|
||||
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
|
||||
auto const currentgenpower { (
|
||||
DElist[ MainCtrlPos ].RPM > 0 ?
|
||||
DElist[ MainCtrlPos ].GenPower * ( 60.0 * enrot / DElist[ MainCtrlPos ].RPM ) :
|
||||
@@ -4833,6 +4852,8 @@ double TMoverParameters::TractionForce(double dt)
|
||||
else {
|
||||
if( AutoRelayFlag ) {
|
||||
|
||||
auto const shuntfieldstate { ScndCtrlPos };
|
||||
|
||||
switch( RelayType ) {
|
||||
|
||||
case 0: {
|
||||
@@ -4978,6 +4999,10 @@ double TMoverParameters::TractionForce(double dt)
|
||||
break;
|
||||
}
|
||||
} // switch RelayType
|
||||
|
||||
if( ScndCtrlPos != shuntfieldstate ) {
|
||||
SetFlag( SoundFlag, ( sound::relay | sound::shuntfield ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -4993,9 +5018,7 @@ double TMoverParameters::TractionForce(double dt)
|
||||
}
|
||||
}
|
||||
if( true == Mains ) {
|
||||
|
||||
//tempomat
|
||||
|
||||
if (ScndCtrlPosNo > 1)
|
||||
{
|
||||
if (ScndCtrlPos != NewSpeed)
|
||||
@@ -5019,7 +5042,6 @@ double TMoverParameters::TractionForce(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dtrans = Hamulec->GetEDBCP();
|
||||
if (((DoorLeftOpened) || (DoorRightOpened)))
|
||||
DynamicBrakeFlag = true;
|
||||
@@ -5239,6 +5261,20 @@ double TMoverParameters::TractionForce(double dt)
|
||||
break;
|
||||
}
|
||||
} // case EngineType
|
||||
|
||||
switch( EngineType ) {
|
||||
case DieselElectric: {
|
||||
// rough approximation of extra effort to overcome friction etc
|
||||
auto const rpmratio{ 60.0 * enrot / DElist[ MainCtrlPosNo ].RPM };
|
||||
EnginePower += rpmratio * 0.2 * DElist[ MainCtrlPosNo ].GenPower;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Ft;
|
||||
}
|
||||
|
||||
@@ -5986,6 +6022,18 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
|
||||
case 2:
|
||||
dizel_EngageSwitch(1.0);
|
||||
break;
|
||||
case 3:
|
||||
if (Vel>dizel_minVelfullengage)
|
||||
dizel_EngageSwitch(1.0);
|
||||
else
|
||||
dizel_EngageSwitch(0.5);
|
||||
break;
|
||||
case 4:
|
||||
if (Vel>dizel_minVelfullengage)
|
||||
dizel_EngageSwitch(1.0);
|
||||
else
|
||||
dizel_EngageSwitch(0.66);
|
||||
break;
|
||||
default:
|
||||
if (hydro_TC && hydro_TC_Fill>0.01)
|
||||
dizel_EngageSwitch(1.0);
|
||||
@@ -6125,6 +6173,18 @@ double TMoverParameters::dizel_fillcheck(int mcp)
|
||||
else
|
||||
nreg = dizel_nmin;
|
||||
break;
|
||||
case 3:
|
||||
if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage))
|
||||
nreg = dizel_nmax;
|
||||
else
|
||||
nreg = dizel_nmin;
|
||||
break;
|
||||
case 4:
|
||||
if ((dizel_automaticgearstatus == 0) && (Vel > dizel_minVelfullengage))
|
||||
nreg = dizel_nmax;
|
||||
else
|
||||
nreg = dizel_nmin * 0.75 + dizel_nmax * 0.25;
|
||||
break;
|
||||
default:
|
||||
realfill = 0; // sluczaj
|
||||
break;
|
||||
@@ -6401,7 +6461,7 @@ void TMoverParameters::dizel_Heat( double const dt ) {
|
||||
&& ( dizel_heat.water_aux.config.temp_cooling > 0 )
|
||||
&& ( dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - ( dizel_heat.water_aux.is_warm ? 8 : 0 ) ) ) );
|
||||
auto const PTC2 { ( dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0 ) };
|
||||
dizel_heat.rpmwz2 = PTC2 * 80 * rpm / ( ( 0.5 * rpm ) + 500 );
|
||||
dizel_heat.rpmwz2 = PTC2 * ( dizel_heat.fan_speed >= 0 ? ( rpm * dizel_heat.fan_speed ) : ( dizel_heat.fan_speed * -1 ) );
|
||||
dizel_heat.zaluzje2 = ( dizel_heat.water_aux.config.shutters ? ( PTC2 == 1 ) : true ); // no shutters is an equivalent to having them open
|
||||
auto const zaluzje2 { ( dizel_heat.zaluzje2 ? 1 : 0 ) };
|
||||
// auxiliary water circuit heat transfer values
|
||||
@@ -6429,7 +6489,7 @@ void TMoverParameters::dizel_Heat( double const dt ) {
|
||||
&& ( dizel_heat.water.config.temp_cooling > 0 )
|
||||
&& ( dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - ( dizel_heat.water.is_warm ? 8 : 0 ) ) ) );
|
||||
auto const PTC1 { ( dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0 ) };
|
||||
dizel_heat.rpmwz = PTC1 * 80 * rpm / ( ( 0.5 * rpm ) + 500 );
|
||||
dizel_heat.rpmwz = PTC1 * ( dizel_heat.fan_speed >= 0 ? ( rpm * dizel_heat.fan_speed ) : ( dizel_heat.fan_speed * -1 ) );
|
||||
dizel_heat.zaluzje1 = ( dizel_heat.water.config.shutters ? ( PTC1 == 1 ) : true ); // no shutters is an equivalent to having them open
|
||||
auto const zaluzje1 { ( dizel_heat.zaluzje1 ? 1 : 0 ) };
|
||||
// primary water circuit heat transfer values
|
||||
@@ -8030,6 +8090,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
{ "test", testH },
|
||||
{ "D2", D2 },
|
||||
{ "MHZ_EN57", MHZ_EN57 },
|
||||
{ "MHZ_K5P", MHZ_K5P },
|
||||
{ "M394", M394 },
|
||||
{ "Knorr", Knorr },
|
||||
{ "Westinghouse", West },
|
||||
@@ -8385,6 +8446,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
|
||||
ImaxHi = 2;
|
||||
ImaxLo = 1;
|
||||
}
|
||||
extract_value( EngineHeatingRPM, "HeatingRPM", Input, "" );
|
||||
break;
|
||||
}
|
||||
case ElectricInductionMotor: {
|
||||
@@ -8415,8 +8477,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
|
||||
extract_value( eimc[ eimc_p_eped ], "edep", Input, "" );
|
||||
extract_value( EIMCLogForce, "eimclf", Input, "" );
|
||||
|
||||
Flat = ( extract_value( "Flat", Input ) == "1" );
|
||||
|
||||
extract_value( Flat, "Flat", Input, "");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -8450,6 +8511,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
|
||||
extract_value( dizel_heat.water_aux.config.shutters, "WaterAuxShutters", Input, "" );
|
||||
extract_value( dizel_heat.oil.config.temp_min, "OilMinTemperature", Input, "" );
|
||||
extract_value( dizel_heat.oil.config.temp_max, "OilMaxTemperature", Input, "" );
|
||||
extract_value( dizel_heat.fan_speed, "WaterCoolingFanSpeed", Input, "" );
|
||||
// water heater
|
||||
extract_value( WaterHeater.config.temp_min, "HeaterMinTemperature", Input, "" );
|
||||
extract_value( WaterHeater.config.temp_max, "HeaterMaxTemperature", Input, "" );
|
||||
@@ -8836,6 +8898,9 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
|
||||
case St113:
|
||||
Handle = std::make_shared<TSt113>();
|
||||
break;
|
||||
case MHZ_K5P:
|
||||
Handle = std::make_shared<TMHZ_K5P>();
|
||||
break;
|
||||
default:
|
||||
Handle = std::make_shared<TDriverHandle>();
|
||||
}
|
||||
@@ -9515,6 +9580,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
else {
|
||||
OK = false;
|
||||
}
|
||||
SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
}
|
||||
else if (Command == "Sandbox")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user