mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 17:29:18 +02:00
cooling fan cab control, dedicated tempomat cab control, minor vehicle preparation ai logic tweaks, minor timetable ui panel tweaks
This commit is contained in:
@@ -2521,6 +2521,10 @@ bool TController::PrepareEngine()
|
||||
mvOccupied->MotorBlowersSwitch( true, end::front );
|
||||
mvOccupied->MotorBlowersSwitchOff( false, end::rear );
|
||||
mvOccupied->MotorBlowersSwitch( true, end::rear );
|
||||
// enable train brake if it's off
|
||||
if( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_NP ) ) {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -976,12 +976,13 @@ public:
|
||||
double TUHEX_Sum2 = 750; /*nastawa2 sterownika hamowania ED*/
|
||||
double TUHEX_Sum3 = 750; /*nastawa3 sterownika hamowania ED*/
|
||||
int TUHEX_Stages = 0; /*liczba stopni hamowania ED*/
|
||||
|
||||
// TODO: wrap resistor fans variables and state into a device
|
||||
int RVentType = 0; /*0 - brak, 1 - jest, 2 - automatycznie wlaczany*/
|
||||
double RVentnmax = 1.0; /*maks. obroty wentylatorow oporow rozruchowych*/
|
||||
double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/
|
||||
double RVentSpeed { 0.5 }; //rozpedzanie sie wentylatora obr/s^2}
|
||||
double RVentMinI { 50.0 }; //przy jakim pradzie sie wylaczaja}
|
||||
bool RVentForceOn { false }; // forced activation switch
|
||||
int CompressorPower = 1; // 0: main circuit, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 3: diesel engine, 4: converter of unit in front, 5: converter of unit behind
|
||||
int SmallCompressorPower = 0; /*Winger ZROBIC*/
|
||||
bool Trafo = false; /*pojazd wyposażony w transformator*/
|
||||
|
||||
@@ -4400,8 +4400,9 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
switch( RVentType ) {
|
||||
|
||||
case 1: { // manual
|
||||
if( ( ActiveDir != 0 )
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) {
|
||||
if( ( true == RVentForceOn )
|
||||
|| ( ( ActiveDir != 0 )
|
||||
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) ) {
|
||||
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
@@ -4423,9 +4424,12 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
* RVentSpeed * dt;
|
||||
}
|
||||
else if( ( DynamicBrakeType == dbrake_automatic )
|
||||
&& ( true == DynamicBrakeFlag ) ) {
|
||||
&& ( true == DynamicBrakeFlag ) ) {
|
||||
RventRot += ( RVentnmax * motorcurrent / ImaxLo - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else if( RVentForceOn ) {
|
||||
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
|
||||
}
|
||||
else {
|
||||
RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt );
|
||||
}
|
||||
|
||||
69
Train.cpp
69
Train.cpp
@@ -170,6 +170,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::secondcontrollerdecreasefast, &TTrain::OnCommand_secondcontrollerdecreasefast },
|
||||
{ user_command::secondcontrollerset, &TTrain::OnCommand_secondcontrollerset },
|
||||
{ user_command::notchingrelaytoggle, &TTrain::OnCommand_notchingrelaytoggle },
|
||||
{ user_command::tempomattoggle, &TTrain::OnCommand_tempomattoggle },
|
||||
{ user_command::mucurrentindicatorothersourceactivate, &TTrain::OnCommand_mucurrentindicatorothersourceactivate },
|
||||
{ user_command::independentbrakeincrease, &TTrain::OnCommand_independentbrakeincrease },
|
||||
{ user_command::independentbrakeincreasefast, &TTrain::OnCommand_independentbrakeincreasefast },
|
||||
@@ -262,6 +263,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::motorblowerstogglefront, &TTrain::OnCommand_motorblowerstogglefront },
|
||||
{ user_command::motorblowerstogglerear, &TTrain::OnCommand_motorblowerstogglerear },
|
||||
{ user_command::motorblowersdisableall, &TTrain::OnCommand_motorblowersdisableall },
|
||||
{ user_command::coolingfanstoggle, &TTrain::OnCommand_coolingfanstoggle },
|
||||
{ user_command::motorconnectorsopen, &TTrain::OnCommand_motorconnectorsopen },
|
||||
{ user_command::motorconnectorsclose, &TTrain::OnCommand_motorconnectorsclose },
|
||||
{ user_command::motordisconnect, &TTrain::OnCommand_motordisconnect },
|
||||
@@ -931,6 +933,45 @@ void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &C
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_tempomattoggle( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggScndCtrlButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
if( Command.action == GLFW_RELEASE ) {
|
||||
// just move the button back to default position
|
||||
// visual feedback
|
||||
Train->ggScndCtrlButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
return;
|
||||
}
|
||||
// glfw_press
|
||||
if( Train->mvControlled->ScndCtrlPos == 0 ) {
|
||||
// turn on if needed
|
||||
Train->mvControlled->IncScndCtrl( 1 );
|
||||
}
|
||||
// visual feedback
|
||||
Train->ggScndCtrlButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
}
|
||||
else {
|
||||
// two-state switch
|
||||
if( Command.action == GLFW_RELEASE ) { return; }
|
||||
|
||||
if( Train->mvControlled->ScndCtrlPos == 0 ) {
|
||||
// turn on
|
||||
Train->mvControlled->IncScndCtrl( 1 );
|
||||
// visual feedback
|
||||
Train->ggScndCtrlButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
}
|
||||
else {
|
||||
//turn off
|
||||
Train->mvControlled->DecScndCtrl( 2 );
|
||||
// visual feedback
|
||||
Train->ggScndCtrlButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Train->ggNextCurrentButton.SubModel == nullptr ) {
|
||||
@@ -3059,6 +3100,13 @@ void TTrain::OnCommand_motorblowersdisableall( TTrain *Train, command_data const
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_coolingfanstoggle( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action != GLFW_PRESS ) { return; }
|
||||
|
||||
Train->mvControlled->RVentForceOn = ( !Train->mvControlled->RVentForceOn );
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
// TODO: don't rely on presense of 3d model to determine presence of the switch
|
||||
@@ -5189,10 +5237,10 @@ bool TTrain::Update( double const Deltatime )
|
||||
fPress[i][0] = p->MoverParameters->BrakePress;
|
||||
fPress[i][1] = p->MoverParameters->PipePress;
|
||||
fPress[i][2] = p->MoverParameters->ScndPipePress;
|
||||
bDoors[i][1] = ( false == p->MoverParameters->Doors.instances[ side::left ].is_closed );
|
||||
bDoors[i][2] = ( false == p->MoverParameters->Doors.instances[ side::right ].is_closed );
|
||||
bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.0 );
|
||||
bDoors[i][4] = ( p->MoverParameters->Doors.instances[ side::right ].step_position > 0.0 );
|
||||
bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f );
|
||||
bDoors[i][2] = ( p->MoverParameters->Doors.instances[ side::right ].position > 0.f );
|
||||
bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.f );
|
||||
bDoors[i][4] = ( p->MoverParameters->Doors.instances[ side::right ].step_position > 0.f );
|
||||
bDoors[i][0] = ( bDoors[i][1] || bDoors[i][2] );
|
||||
iDoorNo[i] = p->iAnimType[ANIM_DOORS];
|
||||
iUnits[i] = iUnitNo;
|
||||
@@ -5868,6 +5916,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
dsbNastawnikBocz );
|
||||
ggScndCtrl.Update();
|
||||
}
|
||||
ggScndCtrlButton.Update();
|
||||
if (ggDirKey.SubModel) {
|
||||
if (mvControlled->TrainType != dt_EZT)
|
||||
ggDirKey.UpdateValue(
|
||||
@@ -7193,6 +7242,7 @@ void TTrain::clear_cab_controls()
|
||||
ggMainCtrl.Clear();
|
||||
ggMainCtrlAct.Clear();
|
||||
ggScndCtrl.Clear();
|
||||
ggScndCtrlButton.Clear();
|
||||
ggDirKey.Clear();
|
||||
ggBrakeCtrl.Clear();
|
||||
ggLocalBrake.Clear();
|
||||
@@ -7661,6 +7711,13 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
1.f :
|
||||
0.f );
|
||||
}
|
||||
// tempomat
|
||||
if( ggScndCtrlButton.type() != TGaugeType::push ) {
|
||||
ggScndCtrlButton.PutValue(
|
||||
( mvControlled->ScndCtrlPos > 0 ) ?
|
||||
1.f :
|
||||
0.f );
|
||||
}
|
||||
|
||||
// we reset all indicators, as they're set during the update pass
|
||||
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
|
||||
@@ -7919,6 +7976,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "cablight_sw:", ggCabLightButton },
|
||||
{ "cablightdim_sw:", ggCabLightDimButton },
|
||||
{ "battery_sw:", ggBatteryButton },
|
||||
{ "tempomat_sw:", ggScndCtrlButton },
|
||||
{ "universal0:", ggUniversals[ 0 ] },
|
||||
{ "universal1:", ggUniversals[ 1 ] },
|
||||
{ "universal2:", ggUniversals[ 2 ] },
|
||||
@@ -7940,7 +7998,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
}
|
||||
// TODO: move viable dedicated gauges to the automatic array
|
||||
std::unordered_map<std::string, bool *> const autoboolgauges = {
|
||||
{ "doorstep_sw:", &mvOccupied->Doors.step_enabled }
|
||||
{ "doorstep_sw:", &mvOccupied->Doors.step_enabled },
|
||||
{ "coolingfans_sw:", &mvControlled->RVentForceOn }
|
||||
};
|
||||
{
|
||||
auto lookup = autoboolgauges.find( Label );
|
||||
|
||||
4
Train.h
4
Train.h
@@ -169,6 +169,7 @@ class TTrain
|
||||
static void OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_tempomattoggle( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command );
|
||||
@@ -265,6 +266,7 @@ class TTrain
|
||||
static void OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_coolingfanstoggle( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_motorconnectorsclose( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_motordisconnect( TTrain *Train, command_data const &Command );
|
||||
@@ -379,7 +381,7 @@ public: // reszta może by?publiczna
|
||||
TGauge ggMainCtrl;
|
||||
TGauge ggMainCtrlAct;
|
||||
TGauge ggScndCtrl;
|
||||
TGauge ggScndCtrlButton; // NOTE: not used?
|
||||
TGauge ggScndCtrlButton;
|
||||
TGauge ggDirKey;
|
||||
TGauge ggBrakeCtrl;
|
||||
TGauge ggLocalBrake;
|
||||
|
||||
@@ -224,7 +224,9 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "batterydisable", command_target::vehicle },
|
||||
{ "motorblowerstogglefront", command_target::vehicle },
|
||||
{ "motorblowerstogglerear", command_target::vehicle },
|
||||
{ "motorblowersdisableall", command_target::vehicle }
|
||||
{ "motorblowersdisableall", command_target::vehicle },
|
||||
{ "coolingfanstoggle", command_target::vehicle },
|
||||
{ "tempomattoggle", command_target::vehicle }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -218,6 +218,8 @@ enum class user_command {
|
||||
motorblowerstogglefront,
|
||||
motorblowerstogglerear,
|
||||
motorblowersdisableall,
|
||||
coolingfanstoggle,
|
||||
tempomattoggle,
|
||||
|
||||
none = -1
|
||||
};
|
||||
|
||||
@@ -227,7 +227,8 @@ driverkeyboard_input::default_bindings() {
|
||||
{ user_command::motorblowerstogglefront, GLFW_KEY_N | keymodifier::shift },
|
||||
{ user_command::motorblowerstogglerear, GLFW_KEY_M | keymodifier::shift },
|
||||
{ user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control }
|
||||
|
||||
// coolingfanstoggle
|
||||
// tempomattoggle
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -494,6 +494,9 @@ drivermouse_input::default_bindings() {
|
||||
{ "shuntmodepower:", {
|
||||
user_command::secondcontrollerincrease,
|
||||
user_command::secondcontrollerdecrease } },
|
||||
{ "tempomat_sw:", {
|
||||
user_command::tempomattoggle,
|
||||
user_command::none } },
|
||||
{ "dirkey:", {
|
||||
user_command::reverserincrease,
|
||||
user_command::reverserdecrease } },
|
||||
@@ -552,6 +555,9 @@ drivermouse_input::default_bindings() {
|
||||
{ "motorblowersalloff_sw:", {
|
||||
user_command::motorblowersdisableall,
|
||||
user_command::none } },
|
||||
{ "coolingfans_sw:", {
|
||||
user_command::coolingfanstoggle,
|
||||
user_command::none } },
|
||||
{ "main_off_bt:", {
|
||||
user_command::linebreakeropen,
|
||||
user_command::none } },
|
||||
|
||||
@@ -238,12 +238,14 @@ timetable_panel::update() {
|
||||
{ // current time
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
locale::strings[ locale::string::driver_timetable_time ].c_str(),
|
||||
locale::strings[ locale::string::driver_timetable_header ].c_str(),
|
||||
40, 40,
|
||||
locale::strings[ locale::string::driver_timetable_name ].c_str(),
|
||||
time.wHour,
|
||||
time.wMinute,
|
||||
time.wSecond );
|
||||
|
||||
text_lines.emplace_back( m_buffer.data(), Global.UITextColor );
|
||||
title = m_buffer.data();
|
||||
}
|
||||
|
||||
auto *vehicle { (
|
||||
|
||||
@@ -56,8 +56,8 @@ init() {
|
||||
"Drive according to signals and timetable",
|
||||
"Bank consist ahead",
|
||||
|
||||
"%-*.*s Time: %d:%02d:%02d", // HACK: some manual padding to account for longer 'time' equivalent in polish version
|
||||
"Timetable",
|
||||
"Time: %d:%02d:%02d",
|
||||
"(no timetable)",
|
||||
"Consist weight: %d t (specified) %d t (actual)\nConsist length: %d m",
|
||||
|
||||
@@ -84,6 +84,7 @@ init() {
|
||||
"master controller",
|
||||
"second controller",
|
||||
"shunt mode power",
|
||||
"tempomat",
|
||||
"reverser",
|
||||
"train brake",
|
||||
"independent brake",
|
||||
@@ -104,6 +105,7 @@ init() {
|
||||
"motor blowers A",
|
||||
"motor blowers B",
|
||||
"all motor blowers",
|
||||
"cooling fans",
|
||||
"line breaker",
|
||||
"line breaker",
|
||||
"alerter",
|
||||
@@ -219,8 +221,8 @@ init() {
|
||||
"Prowadzic sklad wedlug sygnalow i rozkladu",
|
||||
"Popychac sklad z przodu",
|
||||
|
||||
"%-*.*s Godzina: %d:%02d:%02d",
|
||||
"Rozklad jazdy",
|
||||
"Godzina: %d:%02d:%02d",
|
||||
"(brak rozkladu)",
|
||||
"Brutto: %d t (rozkladowe) %d t (rzeczywiste)\nDlugosc pociagu: %d m",
|
||||
|
||||
@@ -247,6 +249,7 @@ init() {
|
||||
"nastawnik jazdy",
|
||||
"nastawnik dodatkowy",
|
||||
"sterowanie analogowe",
|
||||
"tempomat",
|
||||
"nastawnik kierunku",
|
||||
"hamulec zespolony",
|
||||
"hamulec pomocniczy",
|
||||
@@ -267,6 +270,7 @@ init() {
|
||||
"wentylatory silnikow trakcyjnych A",
|
||||
"wentylatory silnikow trakcyjnych B",
|
||||
"wszystkie wentylatory silnikow trakcyjnych",
|
||||
"wentylatory oporow rozruchowych",
|
||||
"wylacznik szybki",
|
||||
"wylacznik szybki",
|
||||
"czuwak",
|
||||
@@ -363,6 +367,7 @@ init() {
|
||||
"jointctrl:",
|
||||
"scndctrl:",
|
||||
"shuntmodepower:",
|
||||
"tempomat_sw:",
|
||||
"dirkey:",
|
||||
"brakectrl:",
|
||||
"localbrake:",
|
||||
@@ -383,6 +388,7 @@ init() {
|
||||
"motorblowersfront_sw:",
|
||||
"motorblowersrear_sw:",
|
||||
"motorblowersalloff_sw:",
|
||||
"coolingfans_sw:",
|
||||
"main_off_bt:",
|
||||
"main_on_bt:",
|
||||
"security_reset_bt:",
|
||||
|
||||
@@ -46,7 +46,7 @@ enum string {
|
||||
driver_scenario_bank,
|
||||
|
||||
driver_timetable_header,
|
||||
driver_timetable_time,
|
||||
driver_timetable_name,
|
||||
driver_timetable_notimetable,
|
||||
driver_timetable_consistdata,
|
||||
|
||||
@@ -73,6 +73,7 @@ enum string {
|
||||
cab_jointctrl,
|
||||
cab_scndctrl,
|
||||
cab_shuntmodepower,
|
||||
cab_tempomat,
|
||||
cab_dirkey,
|
||||
cab_brakectrl,
|
||||
cab_localbrake,
|
||||
@@ -93,6 +94,7 @@ enum string {
|
||||
cab_motorblowersfront_sw,
|
||||
cab_motorblowersrear_sw,
|
||||
cab_motorblowersalloff_sw,
|
||||
cab_coolingfans_sw,
|
||||
cab_main_off_bt,
|
||||
cab_main_on_bt,
|
||||
cab_security_reset_bt,
|
||||
|
||||
Reference in New Issue
Block a user