mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 20:39:18 +02:00
Added complex speedctrl for EIM
This commit is contained in:
@@ -690,21 +690,21 @@ struct speed_control {
|
|||||||
bool BrakeInterventionUnbraking = false;
|
bool BrakeInterventionUnbraking = false;
|
||||||
bool Standby = true;
|
bool Standby = true;
|
||||||
bool Parking = false;
|
bool Parking = false;
|
||||||
double InitialPower = 0.3;
|
double InitialPower = 1.0;
|
||||||
double FullPowerVelocity = 3;
|
double FullPowerVelocity = -1;
|
||||||
double StartVelocity = 3;
|
double StartVelocity = -1;
|
||||||
double VelocityStep = 5;
|
double VelocityStep = 5;
|
||||||
double PowerStep = 0.1;
|
double PowerStep = 0.1;
|
||||||
double MinPower = 0.3;
|
double MinPower = 0.0;
|
||||||
double MaxPower = 1.0;
|
double MaxPower = 1.0;
|
||||||
double MinVelocity = 20;
|
double MinVelocity = 0;
|
||||||
double MaxVelocity = 120;
|
double MaxVelocity = 120;
|
||||||
double DesiredVelocity = 0;
|
double DesiredVelocity = 0;
|
||||||
double DesiredPower = 1.0;
|
double DesiredPower = 1.0;
|
||||||
double Offset = -0.5;
|
double Offset = -0.5;
|
||||||
double FactorPpos = 0.1;
|
double FactorPpos = 0.5;
|
||||||
double FactorPneg = 0.4;
|
double FactorPneg = 0.5;
|
||||||
double FactorIpos = 0.04;
|
double FactorIpos = 0.0;
|
||||||
double FactorIneg = 0.0;
|
double FactorIneg = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6639,28 +6639,31 @@ void TMoverParameters::CheckEIMIC(double dt)
|
|||||||
|
|
||||||
void TMoverParameters::CheckSpeedCtrl(double dt)
|
void TMoverParameters::CheckSpeedCtrl(double dt)
|
||||||
{
|
{
|
||||||
if (MainCtrlPos < MainCtrlPosNo - 2) {
|
double accfactor = SpeedCtrlUnit.DesiredPower;
|
||||||
SpeedCtrlUnit.Standby = true;
|
if (EIMCtrlType >= 2) {
|
||||||
}
|
if (MainCtrlPos < MainCtrlPosNo - 2) {
|
||||||
if (MainCtrlPos > MainCtrlPosNo - 1) {
|
SpeedCtrlUnit.Standby = true;
|
||||||
SpeedCtrlUnit.Standby = false;
|
}
|
||||||
|
if (MainCtrlPos > MainCtrlPosNo - 1) {
|
||||||
|
SpeedCtrlUnit.Standby = false;
|
||||||
|
}
|
||||||
|
if (UniCtrlList[MainCtrlPos].SpeedUp > 0) {
|
||||||
|
accfactor = 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (SpeedCtrlUnit.IsActive) {//speed control
|
if (SpeedCtrlUnit.IsActive) {//speed control
|
||||||
if (EngineType == TEngineType::DieselEngine) {
|
if (true) {
|
||||||
if ((!SpeedCtrlUnit.Standby)) {
|
if ((!SpeedCtrlUnit.Standby)) {
|
||||||
if (SpeedCtrlUnit.ManualStateOverride) {
|
if (SpeedCtrlUnit.ManualStateOverride) {
|
||||||
/* if (MainCtrlPos < MainCtrlPosNo - 1) {
|
if (eimic > 0.009) eimic = 1.0;
|
||||||
eimic = std::min(eimic, 0.0);
|
|
||||||
eimicSpeedCtrlIntegral = 0.0;
|
|
||||||
}
|
|
||||||
else*/ if (eimic > 0.009) eimic = 1.0;
|
|
||||||
}
|
}
|
||||||
double error = (std::max(SpeedCtrlValue + SpeedCtrlUnit.Offset, 0.0) - Vel);
|
double error = (std::max(SpeedCtrlValue + SpeedCtrlUnit.Offset, 0.0) - Vel);
|
||||||
double factorP = error > 0 ? SpeedCtrlUnit.FactorPpos : SpeedCtrlUnit.FactorPneg;
|
double factorP = error > 0 ? SpeedCtrlUnit.FactorPpos : SpeedCtrlUnit.FactorPneg;
|
||||||
double eSCP = clamp(factorP * error, -1.2, 1.0); //P module
|
double eSCP = clamp(factorP * error, -1.2, 1.0); //P module
|
||||||
|
bool hydrounlock = (EngineType != TEngineType::DieselEngine) || (Vel < hydro_TC_UnlockSpeed);
|
||||||
if (eSCP < -1.0)
|
if (eSCP < -1.0)
|
||||||
{
|
{
|
||||||
SpeedCtrlUnit.BrakeInterventionBraking = (eSCP < -1.1) && (Vel < hydro_TC_UnlockSpeed);
|
SpeedCtrlUnit.BrakeInterventionBraking = (eSCP < -1.1) && hydrounlock;
|
||||||
eSCP = -1.0;
|
eSCP = -1.0;
|
||||||
}
|
}
|
||||||
SpeedCtrlUnit.BrakeInterventionUnbraking = (eSCP > 0.0) || (Vel == 0.0);
|
SpeedCtrlUnit.BrakeInterventionUnbraking = (eSCP > 0.0) || (Vel == 0.0);
|
||||||
@@ -6673,7 +6676,7 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
|
|||||||
else {
|
else {
|
||||||
eimicSpeedCtrlIntegral = 0;
|
eimicSpeedCtrlIntegral = 0;
|
||||||
}
|
}
|
||||||
eimicSpeedCtrl = clamp(eimicSpeedCtrlIntegral + eSCP, -SpeedCtrlUnit.DesiredPower, SpeedCtrlUnit.DesiredPower*double(UniCtrlList[MainCtrlPos].SpeedUp > 0));
|
eimicSpeedCtrl = clamp(eimicSpeedCtrlIntegral + eSCP, -SpeedCtrlUnit.DesiredPower, accfactor);
|
||||||
if (Vel < SpeedCtrlUnit.FullPowerVelocity) {
|
if (Vel < SpeedCtrlUnit.FullPowerVelocity) {
|
||||||
eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower);
|
eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -501,7 +501,9 @@ dictionary_source *TTrain::GetTrainState() {
|
|||||||
dict->insert( "scnd_ctrl_actual_pos", mvControlled->ScndCtrlActualPos );
|
dict->insert( "scnd_ctrl_actual_pos", mvControlled->ScndCtrlActualPos );
|
||||||
dict->insert( "new_speed", mvOccupied->NewSpeed);
|
dict->insert( "new_speed", mvOccupied->NewSpeed);
|
||||||
dict->insert( "speedctrl", mvOccupied->SpeedCtrlValue);
|
dict->insert( "speedctrl", mvOccupied->SpeedCtrlValue);
|
||||||
dict->insert( "speedctrlpower", mvOccupied->SpeedCtrlUnit.DesiredPower);
|
dict->insert( "speedctrlpower", mvOccupied->SpeedCtrlUnit.DesiredPower );
|
||||||
|
dict->insert( "speedctrlactive", mvOccupied->SpeedCtrlUnit.IsActive );
|
||||||
|
dict->insert( "speedctrlstandby", mvOccupied->SpeedCtrlUnit.Standby );
|
||||||
// brakes
|
// brakes
|
||||||
dict->insert( "manual_brake", ( mvOccupied->ManualBrakePos > 0 ) );
|
dict->insert( "manual_brake", ( mvOccupied->ManualBrakePos > 0 ) );
|
||||||
bool const bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[ 0 ][ 2 ] > 0.01 );
|
bool const bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[ 0 ][ 2 ] > 0.01 );
|
||||||
|
|||||||
Reference in New Issue
Block a user