mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
build 181117. load exchange time calculation improvement, pantograph tank pressure cab control, ui info panel vehicle selection tweak
This commit is contained in:
19
Driver.cpp
19
Driver.cpp
@@ -966,8 +966,8 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
|
||||
// perform loading/unloading
|
||||
auto const platformside = static_cast<int>( std::floor( std::abs( sSpeedTable[ i ].evEvent->input_value( 2 ) ) ) ) % 10;
|
||||
auto const exchangetime = std::max( 5.0, simulation::Station.update_load( pVehicles[ 0 ], *TrainParams, platformside ) );
|
||||
WaitingSet( std::max( -fStopTime, exchangetime ) ); // na końcu rozkładu się ustawia 60s i tu by było skrócenie
|
||||
auto const exchangetime = simulation::Station.update_load( pVehicles[ 0 ], *TrainParams, platformside );
|
||||
WaitingSet( exchangetime );
|
||||
|
||||
if( TrainParams->CheckTrainLatency() < 0.0 ) {
|
||||
// odnotowano spóźnienie
|
||||
@@ -1009,6 +1009,21 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// sitting at passenger stop
|
||||
if( fStopTime < 0 ) {
|
||||
// verify progress of load exchange
|
||||
auto exchangetime { 0.f };
|
||||
auto *vehicle { pVehicles[ 0 ] };
|
||||
while( vehicle != nullptr ) {
|
||||
exchangetime = std::max( exchangetime, vehicle->LoadExchangeTime() );
|
||||
vehicle = vehicle->Next();
|
||||
}
|
||||
if( exchangetime > 0 ) {
|
||||
WaitingSet( exchangetime );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OrderCurrentGet() & Shunt) {
|
||||
OrderNext(Obey_train); // uruchomić jazdę pociągową
|
||||
|
||||
38
DynObj.cpp
38
DynObj.cpp
@@ -2636,13 +2636,39 @@ void TDynamicObject::LoadExchange( int const Disembark, int const Embark, int co
|
||||
}
|
||||
m_exchange.unload_count += Disembark;
|
||||
m_exchange.load_count += Embark;
|
||||
m_exchange.speed_factor = (
|
||||
Platform == 3 ?
|
||||
2.0 :
|
||||
1.0 );
|
||||
m_exchange.platforms = Platform;
|
||||
m_exchange.time = 0.0;
|
||||
}
|
||||
|
||||
// calculates time needed to complete current load change
|
||||
float TDynamicObject::LoadExchangeTime() const {
|
||||
|
||||
if( ( m_exchange.unload_count < 0.01 ) && ( m_exchange.load_count < 0.01 ) ) { return 0.f; }
|
||||
|
||||
auto const baseexchangetime { m_exchange.unload_count / MoverParameters->UnLoadSpeed + m_exchange.load_count / MoverParameters->LoadSpeed };
|
||||
auto const nominalexchangespeedfactor { ( m_exchange.platforms == 3 ? 2.f : 1.f ) };
|
||||
auto const actualexchangespeedfactor { LoadExchangeSpeed() };
|
||||
|
||||
return baseexchangetime / ( actualexchangespeedfactor > 0.f ? actualexchangespeedfactor : nominalexchangespeedfactor );
|
||||
}
|
||||
|
||||
// calculates current load exchange rate
|
||||
float TDynamicObject::LoadExchangeSpeed() const {
|
||||
// platforms (1:left, 2:right, 3:both)
|
||||
// with exchange performed on both sides waiting times are halved
|
||||
auto exchangespeedfactor { 0.f };
|
||||
auto const lewe { ( DirectionGet() > 0 ) ? 1 : 2 };
|
||||
auto const prawe { 3 - lewe };
|
||||
if( m_exchange.platforms & lewe ) {
|
||||
exchangespeedfactor += ( MoverParameters->DoorLeftOpened ? 1.f : 0.f );
|
||||
}
|
||||
if( m_exchange.platforms & prawe ) {
|
||||
exchangespeedfactor += ( MoverParameters->DoorRightOpened ? 1.f : 0.f );
|
||||
}
|
||||
|
||||
return exchangespeedfactor;
|
||||
}
|
||||
|
||||
// update state of load exchange operation
|
||||
void TDynamicObject::update_exchange( double const Deltatime ) {
|
||||
|
||||
@@ -2660,7 +2686,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) {
|
||||
&& ( m_exchange.time >= 1.0 ) ) {
|
||||
|
||||
m_exchange.time -= 1.0;
|
||||
auto const exchangesize = std::min( m_exchange.unload_count, MoverParameters->UnLoadSpeed * m_exchange.speed_factor );
|
||||
auto const exchangesize = std::min( m_exchange.unload_count, MoverParameters->UnLoadSpeed * LoadExchangeSpeed() );
|
||||
m_exchange.unload_count -= exchangesize;
|
||||
MoverParameters->LoadStatus = 1;
|
||||
MoverParameters->LoadAmount = std::max( 0.f, MoverParameters->LoadAmount - exchangesize );
|
||||
@@ -2674,7 +2700,7 @@ void TDynamicObject::update_exchange( double const Deltatime ) {
|
||||
&& ( m_exchange.time >= 1.0 ) ) {
|
||||
|
||||
m_exchange.time -= 1.0;
|
||||
auto const exchangesize = std::min( m_exchange.load_count, MoverParameters->LoadSpeed * m_exchange.speed_factor );
|
||||
auto const exchangesize = std::min( m_exchange.load_count, MoverParameters->LoadSpeed * LoadExchangeSpeed() );
|
||||
m_exchange.load_count -= exchangesize;
|
||||
MoverParameters->LoadStatus = 2;
|
||||
MoverParameters->LoadAmount = std::min( MoverParameters->MaxLoad, MoverParameters->LoadAmount + exchangesize ); // std::max not strictly needed but, eh
|
||||
|
||||
6
DynObj.h
6
DynObj.h
@@ -289,7 +289,7 @@ private:
|
||||
struct exchange_data {
|
||||
float unload_count { 0.f }; // amount to unload
|
||||
float load_count { 0.f }; // amount to load
|
||||
float speed_factor { 1.f }; // operation speed modifier
|
||||
int platforms { 0 }; // platforms which may take part in the exchange
|
||||
float time { 0.f }; // time spent on the operation
|
||||
};
|
||||
|
||||
@@ -529,6 +529,10 @@ private:
|
||||
bool UpdateForce(double dt, double dt1, bool FullVer);
|
||||
// initiates load change by specified amounts, with a platform on specified side
|
||||
void LoadExchange( int const Disembark, int const Embark, int const Platform );
|
||||
// calculates time needed to complete current load change
|
||||
float LoadExchangeTime() const;
|
||||
// calculates current load exchange factor, where 1 = nominal rate, higher = faster
|
||||
float LoadExchangeSpeed() const; // TODO: make private when cleaning up
|
||||
void LoadUpdate();
|
||||
void update_load_sections();
|
||||
void update_load_visibility();
|
||||
|
||||
@@ -7775,6 +7775,12 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
gauge.Load( Parser, DynamicObject );
|
||||
gauge.AssignFloat( &mvControlled->dizel_heat.temperatura2 );
|
||||
}
|
||||
else if( Label == "pantpress:" ) {
|
||||
// pantograph tank pressure
|
||||
auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka
|
||||
gauge.Load( Parser, DynamicObject, 0.1 );
|
||||
gauge.AssignDouble( &mvOccupied->PantPress );
|
||||
}
|
||||
// yB - dla drugiej sekcji
|
||||
else if (Label == "hvbcurrent1:")
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ drivingaid_panel::update() {
|
||||
{ // alerter, hints
|
||||
std::string expandedtext;
|
||||
if( is_expanded ) {
|
||||
auto const stoptime { static_cast<int>( -1.0 * controlled->Mechanik->fStopTime ) };
|
||||
auto const stoptime { static_cast<int>( std::ceil( -1.0 * controlled->Mechanik->fStopTime ) ) };
|
||||
if( stoptime > 0 ) {
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
@@ -175,10 +175,10 @@ timetable_panel::update() {
|
||||
text_lines.emplace_back( m_buffer.data(), Global.UITextColor );
|
||||
}
|
||||
|
||||
auto *vehicle {
|
||||
( FreeFlyModeFlag ?
|
||||
std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) :
|
||||
controlled ) }; // w trybie latania lokalizujemy wg mapy
|
||||
auto *vehicle { (
|
||||
false == FreeFlyModeFlag ? controlled :
|
||||
camera.m_owner != nullptr ? camera.m_owner :
|
||||
std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ) }; // w trybie latania lokalizujemy wg mapy
|
||||
|
||||
if( vehicle == nullptr ) { return; }
|
||||
// if the nearest located vehicle doesn't have a direct driver, try to query its owner
|
||||
@@ -288,10 +288,10 @@ debug_panel::update() {
|
||||
m_input.train = simulation::Train;
|
||||
m_input.controlled = ( m_input.train ? m_input.train->Dynamic() : nullptr );
|
||||
m_input.camera = &( Global.pCamera );
|
||||
m_input.vehicle =
|
||||
( FreeFlyModeFlag ?
|
||||
std::get<TDynamicObject *>( simulation::Region->find_vehicle( m_input.camera->Pos, 20, false, false ) ) :
|
||||
m_input.controlled ); // w trybie latania lokalizujemy wg mapy
|
||||
m_input.vehicle = (
|
||||
false == FreeFlyModeFlag ? m_input.controlled :
|
||||
m_input.camera->m_owner != nullptr ? m_input.camera->m_owner :
|
||||
std::get<TDynamicObject *>( simulation::Region->find_vehicle( m_input.camera->Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy
|
||||
m_input.mover =
|
||||
( m_input.vehicle != nullptr ?
|
||||
m_input.vehicle->MoverParameters :
|
||||
|
||||
14
station.cpp
14
station.cpp
@@ -37,12 +37,6 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch
|
||||
// go through all vehicles and update their load
|
||||
// NOTE: for the time being we limit ourselves to passenger-carrying cars only
|
||||
auto exchangetime { 0.f };
|
||||
// platform (1:left, 2:right, 3:both)
|
||||
// with exchange performed on both sides waiting times are halved
|
||||
auto const exchangetimemodifier { (
|
||||
Platform == 3 ?
|
||||
0.5f :
|
||||
1.0f ) };
|
||||
|
||||
auto *vehicle { First };
|
||||
while( vehicle != nullptr ) {
|
||||
@@ -69,18 +63,14 @@ basic_station::update_load( TDynamicObject *First, Mtable::TTrainParameters &Sch
|
||||
0 :
|
||||
Random( parameters.MaxLoad * 0.15f * stationsizemodifier ) );
|
||||
if( true == firststop ) {
|
||||
// slightly larger group at the initial station
|
||||
// larger group at the initial station
|
||||
loadcount *= 2;
|
||||
}
|
||||
|
||||
if( ( unloadcount > 0 ) || ( loadcount > 0 ) ) {
|
||||
|
||||
vehicle->LoadExchange( unloadcount, loadcount, Platform );
|
||||
/*
|
||||
vehicle->LoadUpdate();
|
||||
vehicle->update_load_visibility();
|
||||
*/
|
||||
exchangetime = std::max( exchangetime, exchangetimemodifier * ( unloadcount / parameters.UnLoadSpeed + loadcount / parameters.LoadSpeed ) );
|
||||
exchangetime = std::max( exchangetime, vehicle->LoadExchangeTime() );
|
||||
}
|
||||
}
|
||||
vehicle = vehicle->Next();
|
||||
|
||||
Reference in New Issue
Block a user