mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 200406. power relay cab indicators logic tweak, cab update logic tweak, compartment lights logic tweak, automatic coupling crash workaround, pantograph power draw fix
This commit is contained in:
2
Driver.h
2
Driver.h
@@ -446,8 +446,8 @@ private:
|
||||
// consist
|
||||
// methods
|
||||
public:
|
||||
bool CheckVehicles( TOrders user = Wait_for_orders );
|
||||
private:
|
||||
bool CheckVehicles(TOrders user = Wait_for_orders);
|
||||
bool PrepareEngine();
|
||||
bool ReleaseEngine();
|
||||
void Doors(bool const Open, int const Side = 0);
|
||||
|
||||
55
DynObj.cpp
55
DynObj.cpp
@@ -664,7 +664,12 @@ TDynamicObject::toggle_lights() {
|
||||
|
||||
if( true == SectionLightsActive ) {
|
||||
// switch all lights off...
|
||||
MoverParameters->BatterySwitch( false );
|
||||
for( auto §ion : Sections ) {
|
||||
auto const sectionname { section.compartment->pName };
|
||||
if( sectionname.rfind( "cab", 0 ) != 0 ) {
|
||||
section.light_level = 0.0;
|
||||
}
|
||||
}
|
||||
SectionLightsActive = false;
|
||||
}
|
||||
else {
|
||||
@@ -684,7 +689,6 @@ TDynamicObject::toggle_lights() {
|
||||
section.light_level = ( Random() < 0.75 ? 0.75f : 0.15f );
|
||||
}
|
||||
}
|
||||
MoverParameters->BatterySwitch( true );
|
||||
SectionLightsActive = true;
|
||||
}
|
||||
}
|
||||
@@ -2848,14 +2852,19 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
// couplers
|
||||
if( ( MoverParameters->Couplers[ 0 ].CouplingFlag != coupling::faux )
|
||||
&& ( MoverParameters->Couplers[ 1 ].CouplingFlag != coupling::faux ) ) {
|
||||
|
||||
MoverParameters->InsideConsist = true;
|
||||
}
|
||||
else {
|
||||
|
||||
MoverParameters->InsideConsist = false;
|
||||
}
|
||||
//
|
||||
// HACK: we're using sound event to detect whether vehicle was connected to another
|
||||
if( TestFlag( MoverParameters->AIFlag, sound::attachcoupler ) ) {
|
||||
auto *driver{ ctOwner ? ctOwner : Mechanik };
|
||||
if( driver != nullptr ) {
|
||||
driver->CheckVehicles( Connect );
|
||||
}
|
||||
SetFlag( MoverParameters->AIFlag, -sound::attachcoupler );
|
||||
}
|
||||
|
||||
// napiecie sieci trakcyjnej
|
||||
// Ra 15-01: przeliczenie poboru prądu powinno być robione wcześniej, żeby na
|
||||
@@ -3448,11 +3457,35 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
+ MoverParameters->TotalCurrent; // prąd pobierany przez pojazd - bez sensu z tym (TotalCurrent)
|
||||
// TotalCurrent to bedzie prad nietrakcyjny (niezwiazany z napedem)
|
||||
// fCurrent+=fabs(MoverParameters->Voltage)*1e-6; //prąd płynący przez woltomierz, rozładowuje kondensator orgromowy 4µF
|
||||
/*
|
||||
double fPantCurrent = fCurrent; // normalnie cały prąd przez jeden pantograf
|
||||
if (iAnimType[ANIM_PANTS] > 1) // a jeśli są dwa pantografy //Ra 1014-11: proteza, trzeba zrobić sensowniej
|
||||
if (pants[0].fParamPants->hvPowerWire &&
|
||||
pants[1].fParamPants->hvPowerWire) // i oba podłączone do drutów
|
||||
if (iAnimType[ANIM_PANTS] > 1) { // a jeśli są dwa pantografy //Ra 1014-11: proteza, trzeba zrobić sensowniej
|
||||
if (pants[0].fParamPants->hvPowerWire && pants[1].fParamPants->hvPowerWire) { // i oba podłączone do drutów
|
||||
fPantCurrent = fCurrent * 0.5; // to dzielimy prąd równo na oba (trochę bez sensu, ale lepiej tak niż podwoić prąd)
|
||||
}
|
||||
}
|
||||
*/
|
||||
// test whether more than one pantograph touches the wire
|
||||
// NOTE: we're duplicating lot of code from below
|
||||
// TODO: clean this up
|
||||
auto activepantographs { 0 };
|
||||
for( int idx = 0; idx < iAnimType[ ANIM_PANTS ]; ++idx ) {
|
||||
auto const *pantograph { pants[ idx ].fParamPants };
|
||||
if( Global.bLiveTraction == false ) {
|
||||
if( pantograph->PantWys >= 1.2 ) {
|
||||
++activepantographs;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( ( pantograph->hvPowerWire != nullptr )
|
||||
&& ( true == MoverParameters->Pantographs[ end::front ].is_active )
|
||||
&& ( pantograph->PantTraction - pantograph->PantWys < 0.01 ) ) { // tolerancja niedolegania
|
||||
++activepantographs;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto const fPantCurrent { fCurrent / std::max( 1, activepantographs ) };
|
||||
|
||||
for (int i = 0; i < iAnimType[ANIM_PANTS]; ++i)
|
||||
{ // pętla po wszystkich pantografach
|
||||
p = pants[i].fParamPants;
|
||||
@@ -3773,9 +3806,9 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
|
||||
// compartment lights
|
||||
// if the vehicle has a controller, we base the light state on state of the controller otherwise we check the vehicle itself
|
||||
if( ( ctOwner != nullptr ? ctOwner->Controlling()->Battery != SectionLightsActive :
|
||||
Mechanik != nullptr ? false : // don't touch lights in a stand-alone manned vehicle
|
||||
MoverParameters->CompartmentLights.is_active == true ) ) { // without controller switch the lights off
|
||||
if( ( ctOwner != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active :
|
||||
Mechanik != nullptr ? SectionLightsActive != MoverParameters->CompartmentLights.is_active :
|
||||
SectionLightsActive ) ) { // without controller switch the lights off
|
||||
toggle_lights();
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +284,7 @@ static int const eimc_f_Uzh = 8;
|
||||
static int const eimc_f_DU = 9;
|
||||
static int const eimc_f_I0 = 10;
|
||||
static int const eimc_f_cfu = 11;
|
||||
static int const eimc_f_cfuH = 12;
|
||||
static int const eimc_p_F0 = 13;
|
||||
static int const eimc_p_a1 = 14;
|
||||
static int const eimc_p_Pmax = 15;
|
||||
@@ -1304,6 +1305,7 @@ public:
|
||||
std::array<neighbour_data, 2> Neighbours; // potential collision sources
|
||||
bool EventFlag = false; /*!o true jesli cos nietypowego sie wydarzy*/
|
||||
int SoundFlag = 0; /*!o patrz stale sound_ */
|
||||
int AIFlag{ 0 }; // HACK: events of interest for consist owner
|
||||
double DistCounter = 0.0; /*! licznik kilometrow */
|
||||
double V = 0.0; //predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
|
||||
double Vel = 0.0; //moduł prędkości w [km/h], używany przez AI
|
||||
|
||||
@@ -1923,7 +1923,7 @@ void TMoverParameters::PantographsCheck( double const Timestep ) {
|
||||
|
||||
void TMoverParameters::LightsCheck( double const Timestep ) {
|
||||
|
||||
auto const lowvoltagepower { (
|
||||
auto const converterpower { (
|
||||
( ConverterFlag )
|
||||
|| ( ( ( Couplers[ end::front ].CouplingFlag & coupling::permanent ) != 0 ) && ( Couplers[ end::front ].Connected->ConverterFlag ) )
|
||||
|| ( ( ( Couplers[ end::rear ].CouplingFlag & coupling::permanent ) != 0 ) && ( Couplers[ end::rear ].Connected->ConverterFlag ) ) ) };
|
||||
@@ -1932,7 +1932,7 @@ void TMoverParameters::LightsCheck( double const Timestep ) {
|
||||
|
||||
light.is_active = (
|
||||
// TODO: bind properly power source when ld is in place
|
||||
( Battery || lowvoltagepower ) // power source
|
||||
( Battery || converterpower ) // power source
|
||||
&& ( false == light.is_disabled )
|
||||
&& ( ( true == light.is_active )
|
||||
|| ( light.start_type == start_t::manual ?
|
||||
@@ -1944,7 +1944,7 @@ void TMoverParameters::LightsCheck( double const Timestep ) {
|
||||
1.0f :
|
||||
0.0f )
|
||||
// TODO: bind properly power source when ld is in place
|
||||
* ( lowvoltagepower ? 1.0f :
|
||||
* ( converterpower ? 1.0f :
|
||||
Battery ? 0.5f :
|
||||
0.0f )
|
||||
* light.dimming;
|
||||
@@ -4602,15 +4602,14 @@ void TMoverParameters::ComputeTotalForce(double dt) {
|
||||
Fb = BrakeForce(RunningTrack);
|
||||
// poslizg
|
||||
auto Fwheels { FTrain - Fb * Sign( V ) };
|
||||
if( ( Vel > 0.001 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
|
||||
if( ( Vel > 0.1 ) // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test
|
||||
&& ( std::abs(Fwheels) > TotalMassxg * Adhesive( RunningTrack.friction ) ) ) {
|
||||
SlippingWheels = true;
|
||||
}
|
||||
double temp_nrot = nrot;
|
||||
if (true == SlippingWheels) {
|
||||
|
||||
temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) *
|
||||
Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot);
|
||||
temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) * Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot);
|
||||
if (Sign(nrot * M_PI * WheelDiameter - V)*Sign(temp_nrot * M_PI * WheelDiameter - V) < 0)
|
||||
{
|
||||
SlippingWheels = false;
|
||||
@@ -4960,8 +4959,13 @@ double TMoverParameters::CouplerForce( int const End, double dt ) {
|
||||
&& ( coupler.type() == othercoupler.type() )
|
||||
&& ( coupler.CouplingFlag == coupling::faux ) ) {
|
||||
// sprzeganie wagonow z samoczynnymi sprzegami
|
||||
if( Attach( End, otherend, othervehicle, ( coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag ) ) ) {
|
||||
SetFlag( AIFlag, sound::attachcoupler );
|
||||
}
|
||||
/*
|
||||
coupler.CouplingFlag = ( coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag );
|
||||
SetFlag( coupler.sounds, sound::attachcoupler );
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5201,11 +5205,11 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
case TEngineType::DieselElectric: {
|
||||
// TODO: move this to the auto relay check when the electric engine code paths are unified
|
||||
StLinFlag &= MotorConnectorsCheck();
|
||||
StLinFlag &= ( MainCtrlActualPos > 0 );
|
||||
StLinFlag |= (
|
||||
( MainCtrlActualPos == 0 )
|
||||
&& ( TrainType != dt_EZT ?
|
||||
MainCtrlPowerPos() == 1 :
|
||||
MainCtrlPowerPos() > 0 ) );
|
||||
( Mains )
|
||||
&& ( MainCtrlActualPos == 0 )
|
||||
&& ( MainCtrlPowerPos() > 0 ) );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -5847,8 +5851,10 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
else
|
||||
tmp = eimc[eimc_f_Uzmax];
|
||||
|
||||
auto f_cfu { DynamicBrakeFlag ? eimc[eimc_f_cfuH] : eimc[eimc_f_cfu] };
|
||||
|
||||
eimv[eimv_Uzsmax] = Min0R(EngineVoltage - eimc[eimc_f_DU], tmp);
|
||||
eimv[eimv_fkr] = eimv[eimv_Uzsmax] / eimc[eimc_f_cfu];
|
||||
eimv[eimv_fkr] = eimv[eimv_Uzsmax] / f_cfu;
|
||||
if( (eimv_pr < 0 ) ) {
|
||||
eimv[ eimv_Pmax ] = eimc[ eimc_p_Ph ];
|
||||
}
|
||||
@@ -5866,7 +5872,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
eimv[ eimv_fkr ] / std::max(
|
||||
abs( enrot ) * eimc[ eimc_s_p ] + eimc[ eimc_s_dfmax ] * eimv[ eimv_ks ],
|
||||
eimc[ eimc_s_dfmax ] ) )
|
||||
* eimc[ eimc_f_cfu ]
|
||||
* f_cfu
|
||||
/ eimc[ eimc_s_cfu ] )
|
||||
* ( eimc[ eimc_s_dfmax ] * eimc[ eimc_s_dfic ] * eimc[ eimc_s_cim ] )
|
||||
* Transmision.Ratio * NPoweredAxles * 2.0 / WheelDiameter;
|
||||
@@ -5908,7 +5914,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
// eimv[eimv_U]:=Max0R(eimv[eimv_Uzsmax],Min0R(eimc[eimc_f_cfu]*eimv[eimv_fp],eimv[eimv_Uzsmax]));
|
||||
// eimv[eimv_pole]:=eimv[eimv_U]/(eimv[eimv_fp]*eimc[eimc_s_cfu]);
|
||||
if ((abs(eimv[eimv_fp]) <= eimv[eimv_fkr]))
|
||||
eimv[eimv_pole] = eimc[eimc_f_cfu] / eimc[eimc_s_cfu];
|
||||
eimv[eimv_pole] = f_cfu / eimc[eimc_s_cfu];
|
||||
else
|
||||
eimv[eimv_pole] = eimv[eimv_Uzsmax] / eimc[eimc_s_cfu] / abs(eimv[eimv_fp]);
|
||||
eimv[eimv_U] = eimv[eimv_pole] * eimv[eimv_fp] * eimc[eimc_s_cfu];
|
||||
@@ -10248,6 +10254,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
|
||||
extract_value( eimc[ eimc_f_DU ], "DU", Input, "" );
|
||||
extract_value( eimc[ eimc_f_I0 ], "I0", Input, "" );
|
||||
extract_value( eimc[ eimc_f_cfu ], "fcfu", Input, "" );
|
||||
extract_value( eimc[ eimc_f_cfuH ], "fcfuH", Input, to_string(eimc[eimc_f_cfu]));
|
||||
extract_value( eimc[ eimc_p_F0 ], "F0", Input, "" );
|
||||
extract_value( eimc[ eimc_p_a1 ], "a1", Input, "" );
|
||||
extract_value( eimc[ eimc_p_Pmax ], "Pmax", Input, "" );
|
||||
|
||||
@@ -26,6 +26,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "scene.h"
|
||||
#include "Train.h"
|
||||
#include "application.h"
|
||||
#include "Logs.h"
|
||||
|
||||
namespace simulation {
|
||||
|
||||
@@ -267,6 +268,10 @@ void state_manager::process_commands() {
|
||||
else {
|
||||
delete train;
|
||||
train = nullptr;
|
||||
if( targetvehicle->name() == Global.local_start_vehicle ) {
|
||||
ErrorLog( "Failed to initialize player train, \"" + Global.local_start_vehicle + "\"" );
|
||||
Global.local_start_vehicle = "ghostview";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user