mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
main circuit logic enhancement, ai route scanning fix, event0 activation fix
This commit is contained in:
21
Driver.cpp
21
Driver.cpp
@@ -1392,6 +1392,12 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
|||||||
fVelDes = v;
|
fVelDes = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( ( true == TestFlag( sSpeedTable[ i ].iFlags, spEnd ) )
|
||||||
|
&& ( mvOccupied->CategoryFlag & 1 ) ) {
|
||||||
|
// if the railway track ends here set the velnext accordingly as well
|
||||||
|
// TODO: test this with turntables and such
|
||||||
|
fNext = 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sSpeedTable[i].iFlags & spTrack) // jeśli tor
|
else if (sSpeedTable[i].iFlags & spTrack) // jeśli tor
|
||||||
{ // tor ogranicza prędkość, dopóki cały skład nie przejedzie,
|
{ // tor ogranicza prędkość, dopóki cały skład nie przejedzie,
|
||||||
@@ -1403,12 +1409,6 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
|||||||
// ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie
|
// ograniczenie aktualnej prędkości aż do wyjechania za ograniczenie
|
||||||
fVelDes = v;
|
fVelDes = v;
|
||||||
}
|
}
|
||||||
if( ( sSpeedTable[ i ].iFlags & spEnd )
|
|
||||||
&& ( mvOccupied->CategoryFlag & 1 ) ) {
|
|
||||||
// if the railway track ends here set the velnext accordingly as well
|
|
||||||
// TODO: test this with turntables and such
|
|
||||||
fNext = 0.0;
|
|
||||||
}
|
|
||||||
// if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop
|
// if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop
|
||||||
continue; // i tyle wystarczy
|
continue; // i tyle wystarczy
|
||||||
}
|
}
|
||||||
@@ -2271,6 +2271,12 @@ bool TController::CheckVehicles(TOrders user)
|
|||||||
// zmiana czoła przez manewry
|
// zmiana czoła przez manewry
|
||||||
iDrivigFlags &= ~movePushPull;
|
iDrivigFlags &= ~movePushPull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( ( user == Connect )
|
||||||
|
|| ( user == Disconnect ) ) {
|
||||||
|
// HACK: force route table update on consist change, new consist length means distances to points of interest are now wrong
|
||||||
|
iTableDirection = 0;
|
||||||
|
}
|
||||||
} // blok wykonywany, gdy aktywnie prowadzi
|
} // blok wykonywany, gdy aktywnie prowadzi
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4813,7 +4819,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
iCoupler = 0; // dalsza jazda manewrowa już bez łączenia
|
iCoupler = 0; // dalsza jazda manewrowa już bez łączenia
|
||||||
iDrivigFlags &= ~moveConnect; // zdjęcie flagi doczepiania
|
iDrivigFlags &= ~moveConnect; // zdjęcie flagi doczepiania
|
||||||
SetVelocity( 0, 0, stopJoin ); // wyłączyć przyspieszanie
|
SetVelocity( 0, 0, stopJoin ); // wyłączyć przyspieszanie
|
||||||
CheckVehicles(); // sprawdzić światła nowego składu
|
CheckVehicles( Connect ); // sprawdzić światła nowego składu
|
||||||
JumpToNextOrder(); // wykonanie następnej komendy
|
JumpToNextOrder(); // wykonanie następnej komendy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5180,6 +5186,7 @@ TController::UpdateSituation(double dt) {
|
|||||||
// tylko jeśli odepnie
|
// tylko jeśli odepnie
|
||||||
WriteLog( mvOccupied->Name + " odczepiony." );
|
WriteLog( mvOccupied->Name + " odczepiony." );
|
||||||
iVehicleCount = -2;
|
iVehicleCount = -2;
|
||||||
|
CheckVehicles( Disconnect ); // update trainset state
|
||||||
} // a jak nie, to dociskać dalej
|
} // a jak nie, to dociskać dalej
|
||||||
}
|
}
|
||||||
if ((mvOccupied->Vel < 0.01) && !(iDrivigFlags & movePress))
|
if ((mvOccupied->Vel < 0.01) && !(iDrivigFlags & movePress))
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ global_settings::ConfigParse(cParser &Parser) {
|
|||||||
Parser.getTokens( 1, false );
|
Parser.getTokens( 1, false );
|
||||||
Parser >> FieldOfView;
|
Parser >> FieldOfView;
|
||||||
// guard against incorrect values
|
// guard against incorrect values
|
||||||
FieldOfView = clamp( FieldOfView, 15.0f, 75.0f );
|
FieldOfView = clamp( FieldOfView, 10.0f, 75.0f );
|
||||||
}
|
}
|
||||||
else if (token == "width")
|
else if (token == "width")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1247,6 +1247,8 @@ public:
|
|||||||
|
|
||||||
/*-zmienne dla lokomotyw*/
|
/*-zmienne dla lokomotyw*/
|
||||||
bool Mains = false; /*polozenie glownego wylacznika*/
|
bool Mains = false; /*polozenie glownego wylacznika*/
|
||||||
|
double MainsInitTime{ 0.0 }; // config, initialization time (in seconds) of the main circuit after it receives power, before it can be closed
|
||||||
|
double MainsInitTimeCountdown{ 0.0 }; // current state of main circuit initialization, remaining time (in seconds) until it's ready
|
||||||
int MainCtrlPos = 0; /*polozenie glownego nastawnika*/
|
int MainCtrlPos = 0; /*polozenie glownego nastawnika*/
|
||||||
int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/
|
int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/
|
||||||
int LightsPos = 0;
|
int LightsPos = 0;
|
||||||
@@ -1527,6 +1529,7 @@ public:
|
|||||||
bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/
|
bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/
|
||||||
|
|
||||||
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
/*-funkcje typowe dla lokomotywy elektrycznej*/
|
||||||
|
void MainsCheck( double const Deltatime );
|
||||||
void PowerCouplersCheck( double const Deltatime );
|
void PowerCouplersCheck( double const Deltatime );
|
||||||
void ConverterCheck( double const Timestep ); // przetwornica
|
void ConverterCheck( double const Timestep ); // przetwornica
|
||||||
void HeatingCheck( double const Timestep );
|
void HeatingCheck( double const Timestep );
|
||||||
|
|||||||
@@ -1309,10 +1309,11 @@ void TMoverParameters::compute_movement_( double const Deltatime ) {
|
|||||||
RunInternalCommand();
|
RunInternalCommand();
|
||||||
|
|
||||||
// automatyczny rozruch
|
// automatyczny rozruch
|
||||||
if (EngineType == TEngineType::ElectricSeriesMotor)
|
if( EngineType == TEngineType::ElectricSeriesMotor ) {
|
||||||
|
if( AutoRelayCheck() ) {
|
||||||
if (AutoRelayCheck())
|
|
||||||
SetFlag( SoundFlag, sound::relay );
|
SetFlag( SoundFlag, sound::relay );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( ( EngineType == TEngineType::DieselEngine )
|
if( ( EngineType == TEngineType::DieselEngine )
|
||||||
|| ( EngineType == TEngineType::DieselElectric ) ) {
|
|| ( EngineType == TEngineType::DieselElectric ) ) {
|
||||||
@@ -1324,6 +1325,8 @@ void TMoverParameters::compute_movement_( double const Deltatime ) {
|
|||||||
// TODO: gather and move current calculations to dedicated method
|
// TODO: gather and move current calculations to dedicated method
|
||||||
TotalCurrent = 0;
|
TotalCurrent = 0;
|
||||||
|
|
||||||
|
// main circuit
|
||||||
|
MainsCheck( Deltatime );
|
||||||
// traction motors
|
// traction motors
|
||||||
MotorBlowersCheck( Deltatime );
|
MotorBlowersCheck( Deltatime );
|
||||||
// uklady hamulcowe:
|
// uklady hamulcowe:
|
||||||
@@ -1365,6 +1368,37 @@ void TMoverParameters::compute_movement_( double const Deltatime ) {
|
|||||||
PowerCouplersCheck( Deltatime );
|
PowerCouplersCheck( Deltatime );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TMoverParameters::MainsCheck( double const Deltatime ) {
|
||||||
|
|
||||||
|
// TODO: move other main circuit checks here
|
||||||
|
|
||||||
|
if( MainsInitTime == 0.0 ) { return; }
|
||||||
|
|
||||||
|
if( MainsInitTimeCountdown > 0.0 ) {
|
||||||
|
MainsInitTimeCountdown -= Deltatime;
|
||||||
|
}
|
||||||
|
// TBD, TODO: move voltage calculation to separate method and use also in power coupler state calculation?
|
||||||
|
auto localvoltage { 0.0 };
|
||||||
|
switch( EnginePowerSource.SourceType ) {
|
||||||
|
case TPowerSource::CurrentCollector: {
|
||||||
|
localvoltage =
|
||||||
|
std::max(
|
||||||
|
localvoltage,
|
||||||
|
std::max(
|
||||||
|
PantFrontVolt,
|
||||||
|
PantRearVolt ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( ( localvoltage == 0.0 )
|
||||||
|
&& ( GetTrainsetVoltage() == 0 ) ) {
|
||||||
|
MainsInitTimeCountdown = MainsInitTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TMoverParameters::PowerCouplersCheck( double const Deltatime ) {
|
void TMoverParameters::PowerCouplersCheck( double const Deltatime ) {
|
||||||
// TODO: add support for other power sources
|
// TODO: add support for other power sources
|
||||||
auto localvoltage { 0.0 };
|
auto localvoltage { 0.0 };
|
||||||
@@ -2846,6 +2880,7 @@ void TMoverParameters::MainSwitch_( bool const State ) {
|
|||||||
if( ( false == State )
|
if( ( false == State )
|
||||||
|| ( ( ( ScndCtrlPos == 0 ) || ( EngineType == TEngineType::ElectricInductionMotor ) )
|
|| ( ( ( ScndCtrlPos == 0 ) || ( EngineType == TEngineType::ElectricInductionMotor ) )
|
||||||
&& ( ( ConvOvldFlag == false ) || ( TrainType == dt_EZT ) )
|
&& ( ( ConvOvldFlag == false ) || ( TrainType == dt_EZT ) )
|
||||||
|
&& ( MainsInitTimeCountdown <= 0.0 )
|
||||||
&& ( true == NoVoltRelay )
|
&& ( true == NoVoltRelay )
|
||||||
&& ( true == OvervoltageRelay )
|
&& ( true == OvervoltageRelay )
|
||||||
&& ( LastSwitchingTime > CtrlDelay )
|
&& ( LastSwitchingTime > CtrlDelay )
|
||||||
@@ -8959,6 +8994,8 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
|||||||
false;
|
false;
|
||||||
extract_value(SpeedCtrlAutoTurnOffFlag, "SpeedCtrlATOF", line, "");
|
extract_value(SpeedCtrlAutoTurnOffFlag, "SpeedCtrlATOF", line, "");
|
||||||
|
|
||||||
|
// main circuit
|
||||||
|
extract_value( MainsInitTime, "MainInitTime", line, "" );
|
||||||
// converter
|
// converter
|
||||||
{
|
{
|
||||||
std::map<std::string, start_t> starts {
|
std::map<std::string, start_t> starts {
|
||||||
|
|||||||
14
Train.cpp
14
Train.cpp
@@ -448,6 +448,8 @@ dictionary_source *TTrain::GetTrainState() {
|
|||||||
// basic systems state data
|
// basic systems state data
|
||||||
dict->insert( "battery", mvControlled->Battery );
|
dict->insert( "battery", mvControlled->Battery );
|
||||||
dict->insert( "linebreaker", mvControlled->Mains );
|
dict->insert( "linebreaker", mvControlled->Mains );
|
||||||
|
dict->insert( "main_init", ( mvControlled->MainsInitTimeCountdown < mvControlled->MainsInitTime ) && ( mvControlled->MainsInitTimeCountdown > 0.0 ) );
|
||||||
|
dict->insert( "main_ready", ( false == mvControlled->Mains ) && ( fHVoltage > 0.0 ) && ( mvControlled->MainsInitTimeCountdown <= 0.0 ) );
|
||||||
dict->insert( "converter", mvControlled->ConverterFlag );
|
dict->insert( "converter", mvControlled->ConverterFlag );
|
||||||
dict->insert( "converter_overload", mvControlled->ConvOvldFlag );
|
dict->insert( "converter_overload", mvControlled->ConvOvldFlag );
|
||||||
dict->insert( "compress", mvControlled->CompressorFlag );
|
dict->insert( "compress", mvControlled->CompressorFlag );
|
||||||
@@ -5107,10 +5109,11 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
if( ( ggMainButton.GetDesiredValue() > 0.95 )
|
if( ( ggMainButton.GetDesiredValue() > 0.95 )
|
||||||
|| ( ggMainOnButton.GetDesiredValue() > 0.95 ) ) {
|
|| ( ggMainOnButton.GetDesiredValue() > 0.95 ) ) {
|
||||||
// keep track of period the line breaker button is held down, to determine when/if circuit closes
|
// keep track of period the line breaker button is held down, to determine when/if circuit closes
|
||||||
if( ( fHVoltage > 0.5 * mvControlled->EnginePowerSource.MaxVoltage )
|
if( ( mvControlled->MainsInitTimeCountdown <= 0.0 )
|
||||||
|
&& ( ( fHVoltage > 0.5 * mvControlled->EnginePowerSource.MaxVoltage )
|
||||||
|| ( ( mvControlled->EngineType != TEngineType::ElectricSeriesMotor )
|
|| ( ( mvControlled->EngineType != TEngineType::ElectricSeriesMotor )
|
||||||
&& ( mvControlled->EngineType != TEngineType::ElectricInductionMotor )
|
&& ( mvControlled->EngineType != TEngineType::ElectricInductionMotor )
|
||||||
&& ( true == mvControlled->Battery ) ) ) {
|
&& ( true == mvControlled->Battery ) ) ) ) {
|
||||||
// prevent the switch from working if there's no power
|
// prevent the switch from working if there's no power
|
||||||
// TODO: consider whether it makes sense for diesel engines and such
|
// TODO: consider whether it makes sense for diesel engines and such
|
||||||
fMainRelayTimer += Deltatime;
|
fMainRelayTimer += Deltatime;
|
||||||
@@ -5648,9 +5651,10 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
|| (true == mvControlled->Mains) ) ?
|
|| (true == mvControlled->Mains) ) ?
|
||||||
true :
|
true :
|
||||||
false ) );
|
false ) );
|
||||||
// NOTE: 'off' variant uses the same test, but opposite resulting states
|
|
||||||
btLampkaWylSzybkiOff.Turn(
|
btLampkaWylSzybkiOff.Turn(
|
||||||
( ( ( m_linebreakerstate == 2 )
|
( ( ( mvControlled->MainsInitTimeCountdown > 0.0 )
|
||||||
|
|| ( fHVoltage == 0.0 )
|
||||||
|
|| ( m_linebreakerstate == 2 )
|
||||||
|| ( true == mvControlled->Mains ) ) ?
|
|| ( true == mvControlled->Mains ) ) ?
|
||||||
false :
|
false :
|
||||||
true ) );
|
true ) );
|
||||||
@@ -5882,7 +5886,7 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
auto const *mover { tmp->MoverParameters };
|
auto const *mover { tmp->MoverParameters };
|
||||||
|
|
||||||
btLampkaWylSzybkiB.Turn( mover->Mains );
|
btLampkaWylSzybkiB.Turn( mover->Mains );
|
||||||
btLampkaWylSzybkiBOff.Turn( false == mover->Mains );
|
btLampkaWylSzybkiBOff.Turn( ( false == mover->Mains ) && ( mover->MainsInitTimeCountdown <= 0.0 ) && ( fHVoltage != 0.0 ) );
|
||||||
|
|
||||||
btLampkaOporyB.Turn(mover->ResistorsFlagCheck());
|
btLampkaOporyB.Turn(mover->ResistorsFlagCheck());
|
||||||
btLampkaBezoporowaB.Turn(
|
btLampkaBezoporowaB.Turn(
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
|
|||||||
{ // przesuwanie wózka po torach o odległość (fDistance), z wyzwoleniem eventów
|
{ // przesuwanie wózka po torach o odległość (fDistance), z wyzwoleniem eventów
|
||||||
// bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd
|
// bPrimary=true - jest pierwszą osią w pojeździe, czyli generuje eventy i przepisuje pojazd
|
||||||
// Ra: zwraca false, jeśli pojazd ma być usunięty
|
// Ra: zwraca false, jeśli pojazd ma być usunięty
|
||||||
auto const ismoving { ( std::abs( fDistance ) > 0.01 ) && ( Owner->GetVelocity() > 0.01 ) };
|
auto const ismoving { /* ( std::abs( fDistance ) > 0.01 ) && */ ( Owner->GetVelocity() > 0.01 ) };
|
||||||
fDistance *= fDirection; // dystans mnożnony przez kierunek
|
fDistance *= fDirection; // dystans mnożnony przez kierunek
|
||||||
double s; // roboczy dystans
|
double s; // roboczy dystans
|
||||||
double dir; // zapamiętany kierunek do sprawdzenia, czy się zmienił
|
double dir; // zapamiętany kierunek do sprawdzenia, czy się zmienił
|
||||||
|
|||||||
Reference in New Issue
Block a user