mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 09:59:18 +02:00
basic motor blowers implementation
This commit is contained in:
223
Train.cpp
223
Train.cpp
@@ -266,6 +266,9 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::compressorenable, &TTrain::OnCommand_compressorenable },
|
||||
{ user_command::compressordisable, &TTrain::OnCommand_compressordisable },
|
||||
{ user_command::compressortogglelocal, &TTrain::OnCommand_compressortogglelocal },
|
||||
{ user_command::motorblowerstogglefront, &TTrain::OnCommand_motorblowerstogglefront },
|
||||
{ user_command::motorblowerstogglerear, &TTrain::OnCommand_motorblowerstogglerear },
|
||||
{ user_command::motorblowersdisableall, &TTrain::OnCommand_motorblowersdisableall },
|
||||
{ user_command::motorconnectorsopen, &TTrain::OnCommand_motorconnectorsopen },
|
||||
{ user_command::motorconnectorsclose, &TTrain::OnCommand_motorconnectorsclose },
|
||||
{ user_command::motordisconnect, &TTrain::OnCommand_motordisconnect },
|
||||
@@ -2770,6 +2773,191 @@ void TTrain::OnCommand_compressortogglelocal( TTrain *Train, command_data const
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
// currently there's no off button so we always try to turn it on
|
||||
OnCommand_motorblowersenablefront( Train, Command );
|
||||
}
|
||||
else {
|
||||
// two-state switch
|
||||
if( Command.action == GLFW_RELEASE ) { return; }
|
||||
|
||||
if( false == Train->mvControlled->MotorBlowers[side::front].is_enabled ) {
|
||||
// turn on
|
||||
OnCommand_motorblowersenablefront( Train, Command );
|
||||
}
|
||||
else {
|
||||
//turn off
|
||||
OnCommand_motorblowersdisablefront( Train, Command );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowersenablefront( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersFrontButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( true, side::front );
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersFrontButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( false, side::front );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// two-state switch, only cares about press events
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersFrontButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( true, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::front );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowersdisablefront( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersFrontButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
// currently there's no disable return type switch
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// two-state switch, only cares about press events
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersFrontButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( false, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::front );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowerstogglerear( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
// currently there's no off button so we always try to turn it on
|
||||
OnCommand_motorblowersenablerear( Train, Command );
|
||||
}
|
||||
else {
|
||||
// two-state switch
|
||||
if( Command.action == GLFW_RELEASE ) { return; }
|
||||
|
||||
if( false == Train->mvControlled->MotorBlowers[ side::rear ].is_enabled ) {
|
||||
// turn on
|
||||
OnCommand_motorblowersenablerear( Train, Command );
|
||||
}
|
||||
else {
|
||||
//turn off
|
||||
OnCommand_motorblowersdisablerear( Train, Command );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( true, side::rear );
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( false, side::rear );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// two-state switch, only cares about press events
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( true, side::rear );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::rear );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersRearButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
// currently there's no disable return type switch
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// two-state switch, only cares about press events
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitch( false, side::rear );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::rear );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_REPEAT ) { return; }
|
||||
|
||||
if( Train->ggMotorBlowersAllOffButton.type() == TGaugeType::push ) {
|
||||
// impulse switch
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersAllOffButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::rear );
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersAllOffButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::rear );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// two-state switch, only cares about press events
|
||||
// NOTE: generally this switch doesn't come in two-state form
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
if( Train->ggMotorBlowersAllOffButton.GetDesiredValue() < 0.5f ) {
|
||||
// switch is off, activate
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( true, side::rear );
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 1.f, Train->dsbSwitch );
|
||||
}
|
||||
else {
|
||||
// deactivate
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::front );
|
||||
Train->mvControlled->MotorBlowersSwitchOff( false, side::rear );
|
||||
// visual feedback
|
||||
Train->ggMotorBlowersRearButton.UpdateValue( 0.f, Train->dsbSwitch );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -5043,7 +5231,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggWater1TempB.Update();
|
||||
}
|
||||
if( ggOilPressB.SubModel ) {
|
||||
ggOilPressB.UpdateValue( tmp->MoverParameters->OilPump.pressure_present );
|
||||
ggOilPressB.UpdateValue( tmp->MoverParameters->OilPump.pressure );
|
||||
ggOilPressB.Update();
|
||||
}
|
||||
}
|
||||
@@ -5344,7 +5532,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
btLampkaRearRightEndLight.Turn( ( mvOccupied->iLights[ side::rear ] & light::redmarker_right ) != 0 );
|
||||
// others
|
||||
btLampkaMalfunction.Turn( mvControlled->dizel_heat.PA );
|
||||
btLampkaMotorBlowers.Turn( mvControlled->RventRot > 0.1 );
|
||||
btLampkaMotorBlowers.Turn( ( mvControlled->MotorBlowers[ side::front ].is_active ) && ( mvControlled->MotorBlowers[ side::rear ].is_active ) );
|
||||
}
|
||||
else {
|
||||
// wylaczone
|
||||
@@ -5704,6 +5892,9 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggWaterCircuitsLinkButton.Update();
|
||||
ggFuelPumpButton.Update();
|
||||
ggOilPumpButton.Update();
|
||||
ggMotorBlowersFrontButton.Update();
|
||||
ggMotorBlowersRearButton.Update();
|
||||
ggMotorBlowersAllOffButton.Update();
|
||||
//------
|
||||
}
|
||||
// wyprowadzenie sygnałów dla haslera na PoKeys (zaznaczanie na taśmie)
|
||||
@@ -6927,6 +7118,9 @@ void TTrain::clear_cab_controls()
|
||||
ggWaterCircuitsLinkButton.Clear();
|
||||
ggFuelPumpButton.Clear();
|
||||
ggOilPumpButton.Clear();
|
||||
ggMotorBlowersFrontButton.Clear();
|
||||
ggMotorBlowersRearButton.Clear();
|
||||
ggMotorBlowersAllOffButton.Clear();
|
||||
|
||||
btLampkaPrzetw.Clear();
|
||||
btLampkaPrzetwB.Clear();
|
||||
@@ -7271,6 +7465,26 @@ void TTrain::set_cab_controls() {
|
||||
1.0 :
|
||||
0.0 );
|
||||
}
|
||||
// traction motor fans
|
||||
if( ggMotorBlowersFrontButton.type() != TGaugeType::push ) {
|
||||
ggMotorBlowersFrontButton.PutValue(
|
||||
mvControlled->MotorBlowers[side::front].is_enabled ?
|
||||
1.0 :
|
||||
0.0 );
|
||||
}
|
||||
if( ggMotorBlowersRearButton.type() != TGaugeType::push ) {
|
||||
ggMotorBlowersRearButton.PutValue(
|
||||
mvControlled->MotorBlowers[side::rear].is_enabled ?
|
||||
1.0 :
|
||||
0.0 );
|
||||
}
|
||||
if( ggMotorBlowersAllOffButton.type() != TGaugeType::push ) {
|
||||
ggMotorBlowersAllOffButton.PutValue(
|
||||
( mvControlled->MotorBlowers[side::front].is_disabled
|
||||
|| mvControlled->MotorBlowers[ side::front ].is_disabled ) ?
|
||||
1.0 :
|
||||
0.0 );
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -7465,6 +7679,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "fuelpump_sw:", ggFuelPumpButton },
|
||||
{ "oilpump_sw:", ggOilPumpButton },
|
||||
{ "oilpressb:", ggOilPressB },
|
||||
{ "motorblowersfront_sw:", ggMotorBlowersFrontButton },
|
||||
{ "motorblowersrear_sw:", ggMotorBlowersRearButton },
|
||||
{ "motorblowersalloff_sw:", ggMotorBlowersAllOffButton },
|
||||
{ "radio_sw:", ggRadioButton },
|
||||
{ "radiochannel_sw:", ggRadioChannelSelector },
|
||||
{ "radiochannelprev_sw:", ggRadioChannelPrevious },
|
||||
@@ -7630,7 +7847,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
// oil pressure
|
||||
auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna gałka
|
||||
gauge.Load( Parser, DynamicObject, DynamicObject->mdKabina, nullptr );
|
||||
gauge.AssignFloat( &mvControlled->OilPump.pressure_present );
|
||||
gauge.AssignFloat( &mvControlled->OilPump.pressure );
|
||||
}
|
||||
else if( Label == "oiltemp:" ) {
|
||||
// oil temperature
|
||||
|
||||
Reference in New Issue
Block a user