mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
Fix for autoreturning controller
This commit is contained in:
@@ -4384,7 +4384,9 @@ TController::UpdateSituation(double dt) {
|
||||
auto const reactiontime = std::min( ReactionTime, 2.0 );
|
||||
if( LastReactionTime < reactiontime ) { return; }
|
||||
|
||||
CheckTimeControllers();
|
||||
if (AIControllFlag) {
|
||||
CheckTimeControllers();
|
||||
}
|
||||
|
||||
LastReactionTime -= reactiontime;
|
||||
// Ra: nie wiem czemu ReactionTime potrafi dostać 12 sekund, to jest przegięcie, bo przeżyna STÓJ
|
||||
|
||||
@@ -96,6 +96,7 @@ static int const maxcc = 4; /*max. ilosc odbierakow pradu*/
|
||||
//static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
|
||||
static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/
|
||||
static int const LightsSwitchPosNo = 16;
|
||||
static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/
|
||||
|
||||
/*uszkodzenia toru*/
|
||||
static int const dtrack_railwear = 2;
|
||||
@@ -572,6 +573,20 @@ struct TMotorParameters
|
||||
}
|
||||
};
|
||||
|
||||
struct TUniversalCtrl
|
||||
{
|
||||
int mode = 0; /*tryb pracy zadajnika - pomocnicze*/
|
||||
double MinCtrlVal = 0.0; /*minimalna wartosc nastawy*/
|
||||
double MaxCtrlVal = 0.0; /*maksymalna wartosc nastawy*/
|
||||
double SetCtrlVal = 0.0; /*docelowa wartosc nastawy*/
|
||||
double SpeedUp = 0.0; /*szybkosc zwiekszania nastawy*/
|
||||
double SpeedDown = 0.0; /*szybkosc zmniejszania nastawy*/
|
||||
int ReturnPosition = 0; /*pozycja na ktora odskakuje zadajnik*/
|
||||
int NextPosFastInc = 0; /*nastepna duza pozycja przy przechodzeniu szybkim*/
|
||||
int PrevPosFastDec = 0; /*poprzednia duza pozycja przy przechodzeniu szybkim*/
|
||||
};
|
||||
typedef TUniversalCtrl TUniversalCtrlTable[UniversalCtrlArraySize + 1]; /*tablica sterowania uniwersalnego nastawnika*/
|
||||
|
||||
struct TSecuritySystem
|
||||
{
|
||||
int SystemType { 0 }; /*0: brak, 1: czuwak aktywny, 2: SHP/sygnalizacja kabinowa*/
|
||||
@@ -940,6 +955,8 @@ public:
|
||||
bool MBrake = false; /*Czy jest hamulec reczny*/
|
||||
double StopBrakeDecc = 0.0;
|
||||
TSecuritySystem SecuritySystem;
|
||||
TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/
|
||||
int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/
|
||||
|
||||
/*-sekcja parametrow dla lokomotywy elektrycznej*/
|
||||
TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/
|
||||
@@ -1563,6 +1580,7 @@ private:
|
||||
void LoadFIZ_MotorParamTable( std::string const &Input );
|
||||
void LoadFIZ_Circuit( std::string const &Input );
|
||||
void LoadFIZ_RList( std::string const &Input );
|
||||
void LoadFIZ_UCList(std::string const &Input);
|
||||
void LoadFIZ_DList( std::string const &Input );
|
||||
void LoadFIZ_FFList( std::string const &Input );
|
||||
void LoadFIZ_LightsList( std::string const &Input );
|
||||
@@ -1577,6 +1595,7 @@ private:
|
||||
bool readMPTDieselEngine( std::string const &line );
|
||||
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
|
||||
bool readRList( std::string const &Input );
|
||||
bool readUCList(std::string const &Input);
|
||||
bool readDList( std::string const &line );
|
||||
bool readFFList( std::string const &line );
|
||||
bool readWWList( std::string const &line );
|
||||
|
||||
@@ -5994,6 +5994,10 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
eimic -= clamp(-UniCtrlList[MainCtrlPos].SetCtrlVal + eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedDown); //odejmuj do X
|
||||
eimic += clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedUp); //dodawaj do X
|
||||
eimic = clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal);
|
||||
}
|
||||
eimic = clamp(eimic, -1.0, 1.0);
|
||||
}
|
||||
@@ -7242,7 +7246,7 @@ bool TMoverParameters::switch_physics(bool const State) // DO PRZETLUMACZENIA NA
|
||||
// *************************************************************************************************
|
||||
bool startBPT;
|
||||
bool startMPT, startMPT0;
|
||||
bool startRLIST;
|
||||
bool startRLIST, startUCLIST;
|
||||
bool startDLIST, startFFLIST, startWWLIST;
|
||||
bool startLIGHTSLIST;
|
||||
int LISTLINE;
|
||||
@@ -7437,6 +7441,31 @@ bool TMoverParameters::readRList( std::string const &Input ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readUCList(std::string const &line) {
|
||||
|
||||
cParser parser(line);
|
||||
parser.getTokens(10, false);
|
||||
auto idx = LISTLINE++;
|
||||
if (idx >= sizeof(UniCtrlList) / sizeof(TUniversalCtrl)) {
|
||||
WriteLog("Read UCList: number of entries exceeded capacity of the data table");
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
parser
|
||||
>> i
|
||||
>> UniCtrlList[idx].mode
|
||||
>> UniCtrlList[idx].MinCtrlVal
|
||||
>> UniCtrlList[idx].MaxCtrlVal
|
||||
>> UniCtrlList[idx].SetCtrlVal
|
||||
>> UniCtrlList[idx].SpeedUp
|
||||
>> UniCtrlList[idx].SpeedDown
|
||||
>> UniCtrlList[idx].ReturnPosition
|
||||
>> UniCtrlList[idx].NextPosFastInc
|
||||
>> UniCtrlList[idx].PrevPosFastDec;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readDList( std::string const &line ) {
|
||||
|
||||
cParser parser( line );
|
||||
@@ -7626,6 +7655,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
startMPT = false;
|
||||
startMPT0 = false;
|
||||
startRLIST = false;
|
||||
startUCLIST = false;
|
||||
startDLIST = false;
|
||||
startFFLIST = false;
|
||||
startWWLIST = false;
|
||||
@@ -7677,6 +7707,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
startRLIST = false;
|
||||
continue;
|
||||
}
|
||||
if (issection("END-RL", inputline)) {
|
||||
startBPT = false;
|
||||
startUCLIST = false;
|
||||
continue;
|
||||
}
|
||||
if( issection( "END-DL", inputline ) ) {
|
||||
startBPT = false;
|
||||
startDLIST = false;
|
||||
@@ -7880,6 +7915,15 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("UCList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("UCList", inputline);
|
||||
startUCLIST = true; LISTLINE = 0;
|
||||
LoadFIZ_RList(inputline);
|
||||
continue;
|
||||
}
|
||||
|
||||
if( issection( "DList:", inputline ) )
|
||||
{
|
||||
startBPT = false;
|
||||
@@ -7929,6 +7973,10 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
readRList( inputline );
|
||||
continue;
|
||||
}
|
||||
if (true == startUCLIST) {
|
||||
readRList(inputline);
|
||||
continue;
|
||||
}
|
||||
if( true == startDLIST ) {
|
||||
readDList( inputline );
|
||||
continue;
|
||||
@@ -8537,7 +8585,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
|
||||
extract_value( CoupledCtrl, "CoupledCtrl", line, "" );
|
||||
extract_value( EIMCtrlType, "EIMCtrlType", line, "" );
|
||||
clamp( EIMCtrlType, 0, 2 );
|
||||
clamp( EIMCtrlType, 0, 3 );
|
||||
|
||||
extract_value( ScndS, "ScndS", line, "" ); // brak pozycji rownoleglej przy niskiej nastawie PSR
|
||||
|
||||
@@ -8966,6 +9014,12 @@ void TMoverParameters::LoadFIZ_RList( std::string const &Input ) {
|
||||
extract_value( DynamicBrakeRes2, "DynBrakeRes2", Input, "");
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_UCList(std::string const &Input) {
|
||||
|
||||
extract_value(UniCtrlListSize, "Size", Input, "");
|
||||
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_DList( std::string const &Input ) {
|
||||
|
||||
extract_value( dizel_Mmax, "Mmax", Input, "" );
|
||||
|
||||
Reference in New Issue
Block a user