16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 01:39:19 +02:00

build 210408. door opening logic enhancements, door permit sound, door permit indicator cab control

This commit is contained in:
tmj-fstate
2021-04-09 13:36:43 +02:00
parent 716aefc2ed
commit 66bd63336b
7 changed files with 124 additions and 40 deletions

View File

@@ -252,6 +252,7 @@ enum sound {
attachheating = 1 << 13,
attachadapter = 1 << 14,
removeadapter = 1 << 15,
doorpermit = 1 << 16,
};
// customizable reset button
@@ -882,6 +883,7 @@ private:
// internal data
float auto_timer { -1.f }; // delay between activation of open state and closing state for automatic doors
float close_delay { 0.f }; // delay between activation of closing state and actual closing
float open_delay { 0.f }; // delay between activation of opening state and actual opening
float position { 0.f }; // current shift of the door from the closed position
float step_position { 0.f }; // current shift of the movable step from the retracted position
// ld outputs
@@ -897,6 +899,7 @@ private:
// config
control_t open_control { control_t::passenger };
float open_rate { 1.f };
float open_delay { 0.f };
control_t close_control { control_t::passenger };
float close_rate { 1.f };
float close_delay { 0.f };
@@ -1432,6 +1435,7 @@ public:
heat_data dizel_heat;
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 BrakeCtrlPos = -2; /*nastawa hamulca zespolonego*/
double BrakeCtrlPosR = 0.0; /*nastawa hamulca zespolonego - plynna dla FV4a*/
@@ -1868,6 +1872,7 @@ public:
bool AssignLoad( std::string const &Name, float const Amount = 0.f );
bool LoadingDone(double LSpeed, std::string const &Loadname);
bool PermitDoors( side const Door, bool const State = true, range_t const Notify = range_t::consist );
void PermitDoors_( side const Door, bool const State = true );
bool ChangeDoorPermitPreset( int const Change, range_t const Notify = range_t::consist );
bool PermitDoorStep( bool const State, range_t const Notify = range_t::consist );
bool ChangeDoorControlMode( bool const State, range_t const Notify = range_t::consist );

View File

@@ -8236,7 +8236,7 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
bool const initialstate { Doors.instances[Door].open_permit };
Doors.instances[ Door ].open_permit = State;
PermitDoors_( Door, State );
if( Notify != range_t::local ) {
@@ -8255,6 +8255,14 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
return ( Doors.instances[ Door ].open_permit != initialstate );
}
void TMoverParameters::PermitDoors_( side const Door, bool const State ) {
if( ( State ) && ( State != Doors.instances[ Door ].open_permit ) ) {
SetFlag( SoundFlag, sound::doorpermit );
}
Doors.instances[ Door ].open_permit = State;
}
bool TMoverParameters::ChangeDoorControlMode( bool const State, range_t const Notify ) {
auto const initialstate { Doors.remote_only };
@@ -8483,21 +8491,15 @@ TMoverParameters::update_doors( double const Deltatime ) {
// doors
if( true == door.is_opening ) {
// open door
if( ( TrainType == dt_EZT )
|| ( TrainType == dt_DMU ) ) {
// multi-unit vehicles typically open door only after unfolding the doorstep
if( ( false == door.step_unfolding ) // no wait if no doorstep
|| ( Doors.step_type == 2 ) ) { // no wait for rotating doorstep
if( ( false == door.step_unfolding ) // no wait if no doorstep
|| ( Doors.step_type == 2 ) ) { // no wait for rotating doorstep
door.open_delay += Deltatime;
if( door.open_delay > Doors.open_delay ) {
door.position = std::min<float>(
Doors.range,
door.position + Doors.open_rate * Deltatime );
}
}
else {
door.position = std::min<float>(
Doors.range,
door.position + Doors.open_rate * Deltatime );
}
door.close_delay = 0.f;
}
if( true == door.is_closing ) {
@@ -8508,6 +8510,7 @@ TMoverParameters::update_doors( double const Deltatime ) {
0.f,
door.position - Doors.close_rate * Deltatime );
}
door.open_delay = 0.f;
}
// doorsteps
if( door.step_unfolding ) {
@@ -9973,6 +9976,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
}
extract_value( Doors.open_rate, "OpenSpeed", line, "" );
extract_value( Doors.open_delay, "DoorOpenDelay", line, "" );
extract_value( Doors.close_rate, "CloseSpeed", line, "" );
extract_value( Doors.close_delay, "DoorCloseDelay", line, "" );
extract_value( Doors.range, "DoorMaxShiftL", line, "" );
@@ -10016,6 +10020,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
extract_value( MirrorMaxShift, "MirrorMaxShift", line, "" );
extract_value( MirrorVelClose, "MirrorVelClose", line, "");
extract_value( DoorsOpenWithPermitAfter, "DoorOpenWithPermit", line, "" );
}
void TMoverParameters::LoadFIZ_BuffCoupl( std::string const &line, int const Index ) {
@@ -11841,10 +11846,10 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
auto const right { 3 - left };
if( std::abs( static_cast<int>( CValue1 ) ) & right ) {
Doors.instances[ side::right ].open_permit = (CValue1 > 0);
PermitDoors_( side::right, ( CValue1 > 0 ) );
}
if( std::abs( static_cast<int>( CValue1 ) ) & left ) {
Doors.instances[ side::left ].open_permit = (CValue1 > 0);
PermitDoors_( side::left, ( CValue1 > 0 ) );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );