16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 17:29:18 +02:00
This commit is contained in:
Królik Uszasty
2022-04-10 00:36:54 +02:00
14 changed files with 479 additions and 304 deletions

View File

@@ -256,6 +256,18 @@ enum relay_t {
electrodynamicbrakesoverload = 1 << 7,
};
// functions during activation/deactivation
enum activation {
emergencybrake = 1 << 0,
mirrors = 1 << 1,
pantographsup = 1 << 2,
redmarkers = 1 << 3,
doorpermition = 1 << 4,
springbrakeon = 1 << 5,
springbrakeoff = 1 << 6,
neutraldirection = 1 << 7,
};
//szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType
//zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT)
// TODO: convert to enums, they're used as specific checks anyway
@@ -903,6 +915,7 @@ private:
float step_position { 0.f }; // current shift of the movable step from the retracted position
// ld outputs
bool is_closed { true }; // the door is fully closed
bool is_door_closed { true }; // the door is fully closed, step doesn't matter
bool is_closing { false }; // the door is currently closing
bool is_opening { false }; // the door is currently opening
bool is_open { false }; // the door is fully open
@@ -1367,6 +1380,7 @@ public:
#endif
double MirrorMaxShift { 90.0 };
double MirrorVelClose { 5.0 };
bool MirrorForbidden{ false }; /*czy jest pozwolenie na otworzenie lusterek (przycisk)*/
bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/
bool SpeedCtrl = false; /*czy jest tempomat*/
speed_control SpeedCtrlUnit; /*parametry tempomatu*/
@@ -1459,6 +1473,7 @@ public:
std::array<cooling_fan, 2> MotorBlowers;
door_data Doors;
float DoorsOpenWithPermitAfter { -1.f }; // remote open if permit button is held for specified time. NOTE: separate from door data as its cab control thing
int DoorsPermitLightBlinking { 0 }; //when the doors permit signal light is blinking
int BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
@@ -1523,6 +1538,11 @@ public:
int MainCtrlMaxDirChangePos { 0 }; // can't change reverser state with master controller set above this position
int CabActive = 0; //numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
int CabOccupied = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController
bool CabMaster = false; //czy pojazd jest nadrzędny w składzie
inline bool IsCabMaster() { return ((CabActive == CabOccupied) && CabMaster); } //czy aktualna kabina jest na pewno tą, z której można sterować
bool AutomaticCabActivation = true; //czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
int InactiveCabFlag = 0; //co sie dzieje przy dezaktywacji kabiny
bool InactiveCabPantsCheck = false; //niech DynamicObject sprawdzi pantografy
double LastSwitchingTime = 0.0; /*czas ostatniego przelaczania czegos*/
int WarningSignal = 0; // 0: nie trabi, 1,2,4: trabi
bool DepartureSignal = false; /*sygnal odjazdu*/
@@ -1728,6 +1748,8 @@ public:
void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation);
bool CabActivisation( bool const Enforce = false );
bool CabDeactivisation( bool const Enforce = false );
bool CabActivisationAuto( bool const Enforce = false );
bool CabDeactivisationAuto( bool const Enforce = false );
/*! funkcje zwiekszajace/zmniejszajace nastawniki*/
/*! glowny nastawnik:*/

View File

@@ -697,7 +697,9 @@ bool TMoverParameters::DirectionForward()
{
if( false == EIMDirectionChangeAllow() ) { return false; }
if ((MainCtrlPosNo > 0) && (DirActive < 1))
if ((MainCtrlPosNo > 0)
&& (DirActive < 1)
&& ( (CabActive != 0) || ( (InactiveCabFlag & activation::neutraldirection) == 0) ) )
{
++DirActive;
DirAbsolute = DirActive * CabActive;
@@ -2848,12 +2850,24 @@ bool TMoverParameters::CabActivisation( bool const Enforce )
{
CabActive = CabOccupied; // sterowanie jest z kabiny z obsadą
DirAbsolute = DirActive * CabActive;
CabMaster = true;
SecuritySystem.set_enabled(true); // activate the alerter TODO: make it part of control based cab selection
SendCtrlToNext("CabActivisation", 1, CabActive);
SendCtrlToNext("Direction", DirAbsolute, CabActive);
if (InactiveCabFlag & activation::springbrakeoff)
{
SpringBrakeActivate(false);
}
}
return OK;
}
bool TMoverParameters::CabActivisationAuto(bool const Enforce)
{
bool OK = AutomaticCabActivation ? CabActivisation(Enforce) : false;
return OK;
}
// *************************************************************************************************
// Q: 20160710
// wyłączenie rozrządu
@@ -2862,11 +2876,31 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce )
{
bool OK = false;
OK = Enforce || (CabActive == CabOccupied); // o ile obsada jest w kabinie ze sterowaniem
OK = Enforce || IsCabMaster(); // o ile obsada jest w kabinie ze sterowaniem
if (OK)
{
if (InactiveCabFlag & activation::springbrakeon)
{
SpringBrakeActivate(true);
}
if (InactiveCabFlag & activation::pantographsup)
{
InactiveCabPantsCheck = true;
}
if (InactiveCabFlag & activation::doorpermition)
{
PermitDoors(side::right, true, range_t::consist);
PermitDoors(side::left, true, range_t::consist);
}
if (InactiveCabFlag & activation::neutraldirection)
{
DirActive = 0;
SendCtrlToNext("Direction", 0, CabActive);
}
CabActive = 0;
DirAbsolute = DirActive * CabActive;
CabMaster = false;
DepartureSignal = false; // nie buczeć z nieaktywnej kabiny
SecuritySystem.set_enabled(false); // deactivate alerter TODO: make it part of control based cab selection
@@ -2875,6 +2909,12 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce )
return OK;
}
bool TMoverParameters::CabDeactivisationAuto(bool const Enforce)
{
bool OK = AutomaticCabActivation ? CabDeactivisation(Enforce) : false;
return OK;
}
// *************************************************************************************************
// Q: 20160710
// Siła napędzająca drezynę po naciśnięciu wajhy
@@ -3155,7 +3195,9 @@ bool TMoverParameters::DirectionBackward(void)
{
return true;
}
if ((MainCtrlPosNo > 0) && (DirActive > -1))
if ((MainCtrlPosNo > 0)
&& (DirActive > -1)
&& ( (CabActive != 0) || ( (InactiveCabFlag & activation::neutraldirection) == 0) ) )
{
if (EngineType == TEngineType::WheelsDriven)
--CabActive;
@@ -4466,6 +4508,8 @@ void TMoverParameters::UpdatePipePressure(double dt)
// (if it's supposed to be broken coupler, such event sets alarmchainflag instead when appropriate)
|| ( true == TestFlag( EngDmgFlag, 32 ) )
*/
|| ( ( 0 == CabActive )
&& ( InactiveCabFlag & activation::emergencybrake ) )
|| ( ( SpringBrakeDriveEmergencyVel >= 0 )
&& ( Vel > SpringBrakeDriveEmergencyVel )
&& ( SpringBrake.IsActive ) ) ) {
@@ -7214,8 +7258,11 @@ void TMoverParameters::CheckEIMIC(double dt)
BrakeLevelSet(UniCtrlList[MainCtrlPosNo].mode); //bottom clamping
if (BrakeCtrlPos > UniCtrlList[0].mode)
BrakeLevelSet(UniCtrlList[0].mode); //top clamping
while (BrakeCtrlPos > UniCtrlList[MainCtrlPos].mode) DecMainCtrl(1); //find nearest position
while (BrakeCtrlPos < UniCtrlList[MainCtrlPos].mode) IncMainCtrl(1); //find nearest position
if (IsCabMaster())
{
while (BrakeCtrlPos > UniCtrlList[MainCtrlPos].mode) DecMainCtrl(1); //find nearest position
while (BrakeCtrlPos < UniCtrlList[MainCtrlPos].mode) IncMainCtrl(1); //find nearest position
}
}
else //controller was moved
BrakeLevelSet(UniCtrlList[MainCtrlPos].mode);
@@ -7266,7 +7313,8 @@ void TMoverParameters::CheckEIMIC(double dt)
auto const eimicpowerenabled {
( ( true == Mains ) || ( Power == 0.0 ) )
&& ( !SpringBrake.IsActive || !SpringBrakeCutsOffDrive )
&& ( !LockPipe ) };
&& ( !LockPipe )
&& ( DirAbsolute != 0 ) };
auto const eimicdoorenabled {
(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)
};
@@ -8538,6 +8586,7 @@ TMoverParameters::update_doors( double const Deltatime ) {
door.is_closed =
( door.position <= 0.f )
&& ( door.step_position <= 0.f );
door.is_door_closed = (door.position <= 0.f);
door.local_open = door.local_open && ( false == door.is_open ) && ( ( false == Doors.permit_needed ) || door.open_permit );
door.remote_open = ( door.remote_open || Doors.remote_only ) && ( false == door.is_open ) && ( ( false == Doors.permit_needed ) || door.open_permit );
@@ -10138,6 +10187,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
extract_value( MirrorVelClose, "MirrorVelClose", line, "");
extract_value( DoorsOpenWithPermitAfter, "DoorOpenWithPermit", line, "" );
extract_value( DoorsPermitLightBlinking, "DoorsPermitLightBlinking", line, "" );
}
void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Index ) {
@@ -10413,6 +10463,9 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
0;
extract_value( BackwardsBranchesAllowed, "BackwardsBranchesAllowed", line, "" );
extract_value( AutomaticCabActivation, "AutomaticCabActivation", line, "" );
extract_value( InactiveCabFlag, "InactiveCabFlag", line, "" );
extract_value( StopBrakeDecc, "SBD", line, "" );
extract_value( ReleaseParkingBySpringBrake, "ReleaseParkingBySpringBrake", line, "" );
extract_value( ReleaseParkingBySpringBrakeWhenDoorIsOpen, "ReleaseParkingBySpringBrakeWhenDoorIsOpen", line, "" );
@@ -11917,6 +11970,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
}
}
DirAbsolute = DirActive * CabActive;
CabMaster = false;
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "AutoRelaySwitch")