mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
security system magnet interaction enhancement, vehicle startup check tweak
This commit is contained in:
@@ -78,6 +78,7 @@ enum class TCommandType
|
||||
cm_OutsideStation,
|
||||
// cm_Shunt, // unused?
|
||||
cm_EmergencyBrake,
|
||||
cm_SecuritySystemMagnet,
|
||||
cm_Command // komenda pobierana z komórki
|
||||
};
|
||||
|
||||
|
||||
40
Driver.cpp
40
Driver.cpp
@@ -271,6 +271,9 @@ void TSpeedPos::CommandCheck()
|
||||
case TCommandType::cm_EmergencyBrake:
|
||||
fVelNext = -1;
|
||||
break;
|
||||
case TCommandType::cm_SecuritySystemMagnet:
|
||||
fVelNext = -1;
|
||||
break;
|
||||
default:
|
||||
// inna komenda w evencie skanowanym powoduje zatrzymanie i wysłanie tej komendy
|
||||
// nie manewrowa, nie przystanek, nie zatrzymać na SBL
|
||||
@@ -880,6 +883,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
eSignNext = nullptr;
|
||||
IsAtPassengerStop = false;
|
||||
IsScheduledPassengerStopVisible = false;
|
||||
mvOccupied->SecuritySystem.SHPLock = false;
|
||||
// te flagi są ustawiane tutaj, w razie potrzeby
|
||||
iDrivigFlags &= ~(moveTrackEnd | moveSwitchFound | moveSemaphorFound | /*moveSpeedLimitFound*/ moveStopPointFound );
|
||||
|
||||
@@ -1404,9 +1408,29 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
|
||||
SemNextStopIndex = -1; // jeśli minęliśmy semafor od ograniczenia to go kasujemy ze zmiennej sprawdzającej dla skanowania w przód
|
||||
}
|
||||
switch( Point.evEvent->input_command() ) {
|
||||
// TBD, TODO: expand emergency_brake handling to a more generic security system signal
|
||||
case TCommandType::cm_EmergencyBrake: {
|
||||
pVehicle->RadioStop();
|
||||
Point.Clear(); // signal received, deactivate
|
||||
return true;
|
||||
}
|
||||
case TCommandType::cm_SecuritySystemMagnet: {
|
||||
// NOTE: magnet induction calculation presumes the driver is located in the front vehicle
|
||||
// TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first
|
||||
auto const magnetlocation { pVehicles[ end::front ]->MoverParameters->SecuritySystem.MagnetLocation };
|
||||
if( Point.fDist < -( magnetlocation ) ) {
|
||||
mvOccupied->SecuritySystem.SHPLock |= ( !AIControllFlag ); // don't make life difficult for the ai, but a human driver is a fair game
|
||||
PutCommand(
|
||||
Point.evEvent->input_text(),
|
||||
Point.evEvent->input_value( 1 ),
|
||||
Point.evEvent->input_value( 2 ),
|
||||
nullptr );
|
||||
}
|
||||
if( Point.fDist < -( magnetlocation + 0.5 ) ) {
|
||||
Point.Clear(); // magnet passed, deactivate
|
||||
mvOccupied->SecuritySystem.SHPLock = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
@@ -1415,6 +1439,19 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
|
||||
}
|
||||
// check signals ahead
|
||||
if( Point.fDist > 0.0 ) {
|
||||
// bail out early for signals which activate when passed
|
||||
// TBD: make it an event method?
|
||||
switch( Point.evEvent->input_command() ) {
|
||||
case TCommandType::cm_EmergencyBrake: {
|
||||
return true;
|
||||
}
|
||||
case TCommandType::cm_SecuritySystemMagnet: {
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( Point.IsProperSemaphor( OrderCurrentGet() ) ) {
|
||||
// special rule for cars: ignore stop signals at distance too short to come to a stop
|
||||
@@ -2793,7 +2830,8 @@ bool TController::PrepareEngine()
|
||||
&& ( true == IsAnyConverterEnabled )
|
||||
&& ( true == IsAnyCompressorEnabled )
|
||||
&& ( ( mvControlling->ScndPipePress > 4.5 ) || ( mvControlling->VeselVolume == 0.0 ) )
|
||||
&& ( ( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) || ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) ) );
|
||||
&& ( ( static_cast<int>( mvOccupied->fBrakeCtrlPos ) == static_cast<int>( mvOccupied->Handle->GetPos( bh_RP ) ) )
|
||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) );
|
||||
}
|
||||
|
||||
if( true == isready ) {
|
||||
|
||||
@@ -740,6 +740,10 @@ putvalues_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad )
|
||||
m_input.command_type = TCommandType::cm_OutsideStation;
|
||||
m_passive = true; // ma być skanowny, aby AI nie przekraczało W5
|
||||
}
|
||||
else if( token == "CabSignal" ) {
|
||||
m_input.command_type = TCommandType::cm_SecuritySystemMagnet;
|
||||
m_passive = true;
|
||||
}
|
||||
else {
|
||||
m_input.command_type = TCommandType::cm_Unknown;
|
||||
}
|
||||
|
||||
@@ -664,6 +664,8 @@ struct TSecuritySystem
|
||||
int NextVelocityAllowed; /*predkosc pokazywana przez sygnalizacje kabinowa*/
|
||||
bool RadioStop; // czy jest RadioStop
|
||||
bool PoweredUp { false }; // helper, for detection of power state change
|
||||
bool SHPLock{ false }; // prevents tps reset when true
|
||||
double MagnetLocation { 0.0 }; // placement of tps magnet, as offset from vehicle front
|
||||
|
||||
inline bool is_beeping() const {
|
||||
return TestFlag( Status, s_SHPalarm );
|
||||
|
||||
@@ -2664,6 +2664,7 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce )
|
||||
DirAbsolute = DirActive * CabActive;
|
||||
DepartureSignal = false; // nie buczeć z nieaktywnej kabiny
|
||||
SecuritySystem.Status = s_off; // deactivate alerter TODO: make it part of control based cab selection
|
||||
SecuritySystem.SHPLock = false;
|
||||
|
||||
SendCtrlToNext("CabActivisation", 0, CabOccupied); // CabActive==0!
|
||||
}
|
||||
@@ -2827,18 +2828,18 @@ void TMoverParameters::SSReset(void)
|
||||
SetFlag(SecuritySystem.Status, -s_aware);
|
||||
SetFlag(SecuritySystem.Status, -s_CAalarm);
|
||||
SetFlag(SecuritySystem.Status, -s_CAebrake);
|
||||
// EmergencyBrakeFlag = false; //YB-HN
|
||||
SecuritySystem.VelocityAllowed = -1;
|
||||
}
|
||||
else if (TestFlag(SecuritySystem.Status, s_active))
|
||||
{
|
||||
SecuritySystem.SystemBrakeSHPTimer = 0;
|
||||
SecuritySystem.SystemSoundSHPTimer = 0;
|
||||
SetFlag(SecuritySystem.Status, -s_active);
|
||||
SetFlag(SecuritySystem.Status, -s_SHPalarm);
|
||||
SetFlag(SecuritySystem.Status, -s_SHPebrake);
|
||||
// EmergencyBrakeFlag = false; //YB-HN
|
||||
SecuritySystem.VelocityAllowed = -1;
|
||||
if( false == SecuritySystem.SHPLock ) {
|
||||
SecuritySystem.SystemBrakeSHPTimer = 0;
|
||||
SecuritySystem.SystemSoundSHPTimer = 0;
|
||||
SetFlag( SecuritySystem.Status, -s_active );
|
||||
SetFlag( SecuritySystem.Status, -s_SHPalarm );
|
||||
SetFlag( SecuritySystem.Status, -s_SHPebrake );
|
||||
SecuritySystem.VelocityAllowed = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10542,7 +10543,7 @@ void TMoverParameters::LoadFIZ_Security( std::string const &line ) {
|
||||
extract_value( SecuritySystem.SoundSignalDelay, "SoundSignalDelay", line, "" );
|
||||
extract_value( SecuritySystem.EmergencyBrakeDelay, "EmergencyBrakeDelay", line, "" );
|
||||
extract_value( SecuritySystem.RadioStop, "RadioStop", line, "" );
|
||||
|
||||
extract_value( SecuritySystem.MagnetLocation, "MagnetLocation", line, "" );
|
||||
extract_value( EmergencyBrakeWarningSignal, "EmergencyBrakeWarningSignal", line, "" );
|
||||
}
|
||||
|
||||
@@ -11487,9 +11488,6 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
|
||||
BrakeDelay[b] = BrakeDelay[b] * (2.5 + Random(0.0, 0.2)) / 3.0;
|
||||
}
|
||||
|
||||
if (TrainType == dt_ET22)
|
||||
CompressorPower = 0;
|
||||
|
||||
Hamulec->Init(PipePress, HighPipePress, LowPipePress, BrakePress, BrakeDelayFlag);
|
||||
/*
|
||||
ScndPipePress = Compressor;
|
||||
@@ -11505,6 +11503,13 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// security system
|
||||
// by default place the magnet in the vehicle centre
|
||||
if( SecuritySystem.MagnetLocation == 0 ) {
|
||||
SecuritySystem.MagnetLocation = Dim.L / 2 - 0.25;
|
||||
}
|
||||
SecuritySystem.MagnetLocation = clamp( SecuritySystem.MagnetLocation, 0.0, Dim.L );
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,10 @@ TCommandType TMemCell::CommandCheck()
|
||||
eCommand = TCommandType::cm_EmergencyBrake;
|
||||
bCommand = false;
|
||||
}
|
||||
else if( szText == "CabSignal" ) {
|
||||
eCommand = TCommandType::cm_SecuritySystemMagnet;
|
||||
bCommand = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
eCommand = TCommandType::cm_Unknown; // ciąg nierozpoznany (nie jest komendą)
|
||||
|
||||
Reference in New Issue
Block a user