mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
ground relay start method, motor connector logic fixes, ai door control logic fix, user vehicle initialization fix
This commit is contained in:
14
Driver.cpp
14
Driver.cpp
@@ -3950,6 +3950,7 @@ void TController::Doors( bool const Open, int const Side ) {
|
||||
&& ( false == doors_open() ) ) {
|
||||
// the doors are already closed and we don't have to revoke control permit, we can skip all hard work
|
||||
iDrivigFlags &= ~moveDoorOpened;
|
||||
return;
|
||||
}
|
||||
|
||||
if( AIControllFlag ) {
|
||||
@@ -4089,6 +4090,19 @@ bool TController::PutCommand( std::string NewCommand, double NewValue1, double N
|
||||
else
|
||||
{ // inicjacja pierwszego przystanku i pobranie jego nazwy
|
||||
// HACK: clear the potentially set door state flag to ensure door get opened if applicable
|
||||
if( true == AIControllFlag ) {
|
||||
// simplified door closing procedure, to sync actual door state with the door state flag
|
||||
// NOTE: this may result in visually ugly quick switch between closing and opening the doors, but eh
|
||||
if( ( pVehicle->MoverParameters->Doors.close_control == control_t::driver )
|
||||
|| ( pVehicle->MoverParameters->Doors.close_control == control_t::mixed ) ) {
|
||||
pVehicle->MoverParameters->OperateDoors( side::right, false );
|
||||
pVehicle->MoverParameters->OperateDoors( side::left, false );
|
||||
}
|
||||
if( pVehicle->MoverParameters->Doors.permit_needed ) {
|
||||
pVehicle->MoverParameters->PermitDoors( side::right, false );
|
||||
pVehicle->MoverParameters->PermitDoors( side::left, false );
|
||||
}
|
||||
}
|
||||
iDrivigFlags &= ~( moveDoorOpened );
|
||||
|
||||
TrainParams.UpdateMTable( simulation::Time, TrainParams.NextStationName );
|
||||
|
||||
@@ -1469,6 +1469,7 @@ public:
|
||||
bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/
|
||||
bool ConvOvldFlag = false; /*! nadmiarowy przetwornicy i ogrzewania*/
|
||||
bool GroundRelay { true }; // switches off to protect against damage from earths
|
||||
start_t GroundRelayStart { start_t::manual }; // relay activation method
|
||||
bool StLinFlag = false; /*!o styczniki liniowe*/
|
||||
bool StLinSwitchOff{ false }; // state of the button forcing motor connectors open
|
||||
bool ResistorsFlag = false; /*!o jazda rezystorowa*/
|
||||
@@ -1569,7 +1570,7 @@ public:
|
||||
double FrictConst2d= 0.0;
|
||||
double TotalMassxg = 0.0; /*TotalMass*g*/
|
||||
|
||||
double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego
|
||||
double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego
|
||||
bool bPantKurek3 = true; // kurek trójdrogowy (pantografu): true=połączenie z ZG, false=połączenie z małą sprężarką // domyślnie zbiornik pantografu połączony jest ze zbiornikiem głównym
|
||||
bool PantAutoValve { false }; // type of installed pantograph compressor valve
|
||||
int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać
|
||||
|
||||
@@ -691,7 +691,7 @@ void TMoverParameters::UpdatePantVolume(double dt) {
|
||||
&& ( ( PantographCompressorStart == start_t::automatic )
|
||||
|| ( PantographCompressorStart == start_t::manualwithautofallback ) ) );
|
||||
|
||||
auto const lowvoltagepower { Battery | ConverterFlag };
|
||||
auto const lowvoltagepower { Battery || ConverterFlag };
|
||||
PantCompFlag &= lowvoltagepower;
|
||||
|
||||
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // tylko jeśli pantografujący
|
||||
@@ -1501,11 +1501,16 @@ void TMoverParameters::MainsCheck( double const Deltatime ) {
|
||||
|
||||
void TMoverParameters::LowVoltagePowerCheck( double const Deltatime ) {
|
||||
|
||||
auto const lowvoltagepower { Battery | ConverterFlag };
|
||||
auto const lowvoltagepower { Battery || ConverterFlag };
|
||||
|
||||
switch( EngineType ) {
|
||||
case TEngineType::ElectricSeriesMotor: {
|
||||
GroundRelay &= lowvoltagepower;
|
||||
if( GroundRelayStart != start_t::manual ) {
|
||||
// NOTE: we're ignoring intricaties of battery and converter types as they're unlikely to be used
|
||||
// TODO: generic check method which takes these into account
|
||||
GroundRelay |= lowvoltagepower;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -5204,12 +5209,12 @@ 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 |= (
|
||||
( Mains )
|
||||
&& ( MainCtrlActualPos == 0 )
|
||||
&& ( MainCtrlPowerPos() > 0 ) );
|
||||
&& ( false == StLinFlag )
|
||||
&& ( MainCtrlPowerPos() == 1 ) );
|
||||
StLinFlag &= MotorConnectorsCheck();
|
||||
StLinFlag &= ( MainCtrlPowerPos() > 0 );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -5372,8 +5377,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
tempUmax = DElist[MainCtrlPosNo].Umax * std::min(eimic_positive, rpmratio);
|
||||
tempPmax = DElist[MainCtrlPosNo].GenPower * std::min(eimic_positive, rpmratio);
|
||||
tmp = tempPmax;
|
||||
// NOTE: Mains in this context is working diesel engine
|
||||
if ((true == Mains) && (MainCtrlPowerPos() > 0))
|
||||
if (true == StLinFlag)
|
||||
{
|
||||
|
||||
if (tmpV < (Vhyp * tempPmax / DElist[MainCtrlPosNo].GenPower))
|
||||
@@ -5399,7 +5403,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
}
|
||||
else
|
||||
if( true == ShuntMode ) {
|
||||
if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
|
||||
if( true == StLinFlag ) {
|
||||
EngineVoltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) );
|
||||
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output
|
||||
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
|
||||
@@ -5433,7 +5437,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower;
|
||||
// stosunek mocy teraz do mocy max
|
||||
// NOTE: Mains in this context is working diesel engine
|
||||
if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
|
||||
if( true == StLinFlag ) {
|
||||
|
||||
if( tmpV < ( Vhyp * power / DElist[ MainCtrlPosNo ].GenPower ) ) {
|
||||
// czy na czesci prostej, czy na hiperboli
|
||||
@@ -5536,9 +5540,9 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
EngineVoltage = 0;
|
||||
|
||||
// przekazniki bocznikowania, kazdy inny dla kazdej pozycji
|
||||
if ((IsMainCtrlNoPowerPos()) || (ShuntMode) || (false==Mains))
|
||||
if( ( false == StLinFlag ) || ( ShuntMode ) ) {
|
||||
ScndCtrlPos = 0;
|
||||
|
||||
}
|
||||
else {
|
||||
if( AutoRelayFlag ) {
|
||||
|
||||
@@ -6114,6 +6118,7 @@ bool TMoverParameters::RelayReset( int const Relays ) {
|
||||
|
||||
if( TestFlag( Relays, relay_t::maincircuitground ) ) {
|
||||
if( ( ( EngineType == TEngineType::ElectricSeriesMotor ) || ( EngineType == TEngineType::DieselElectric ) )
|
||||
&& ( ( GroundRelayStart == start_t::manual ) || ( GroundRelayStart == start_t::manualwithautofallback ) )
|
||||
&& ( IsMainCtrlNoPowerPos() )
|
||||
&& ( ScndCtrlPos == 0 )
|
||||
&& ( DirActive != 0 )
|
||||
@@ -8053,9 +8058,8 @@ TMoverParameters::update_doors( double const Deltatime ) {
|
||||
// revoke permit if...
|
||||
door.open_permit =
|
||||
( true == door.open_permit ) // ...we already have one...
|
||||
&& ( ( false == Doors.permit_presets.empty() ) // ...there's no permit preset switch...
|
||||
|| ( ( false == Doors.is_locked ) // ...and the door lock is engaged...
|
||||
&& ( false == door.remote_close ) ) );// ...or about to be closed
|
||||
&& ( false == Doors.is_locked ) // ...and the door lock is engaged...
|
||||
&& ( false == door.remote_close );// ...or about to be closed
|
||||
|
||||
door.is_open =
|
||||
( door.position >= Doors.range )
|
||||
@@ -9961,7 +9965,16 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
lookup->second :
|
||||
start_t::automatic; // legacy behaviour
|
||||
}
|
||||
|
||||
// ground relay
|
||||
{
|
||||
auto lookup = starts.find( extract_value( "GroundRelayStart", line ) );
|
||||
GroundRelayStart = (
|
||||
lookup != starts.end() ?
|
||||
lookup->second :
|
||||
( TrainType == dt_EZT ?
|
||||
start_t::automatic :
|
||||
start_t::manual ) );
|
||||
}
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_Blending(std::string const &line) {
|
||||
|
||||
@@ -219,6 +219,9 @@ void state_manager::process_commands() {
|
||||
|
||||
if (commanddata.command == user_command::entervehicle) {
|
||||
// przesiadka do innego pojazdu
|
||||
if( commanddata.payload == "ghostview" ) {
|
||||
continue;
|
||||
}
|
||||
// NOTE: because malformed scenario can have vehicle name duplicates we first try to locate vehicle in world, with name search as fallback
|
||||
TDynamicObject *targetvehicle = std::get<TDynamicObject *>( simulation::Region->find_vehicle( commanddata.location, 50, false, false ) );
|
||||
if( ( targetvehicle == nullptr ) || ( targetvehicle->name() != commanddata.payload ) ) {
|
||||
|
||||
Reference in New Issue
Block a user