16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 13:59:19 +02:00

compartment lighting vehicle subsystem, submodel diffuse impact on ambient lighting, minor gfx renderer bug fixes, minor ai logic tweaks

This commit is contained in:
tmj-fstate
2020-03-01 03:09:55 +01:00
parent e4502217e5
commit 642b8fb623
26 changed files with 485 additions and 130 deletions

View File

@@ -756,6 +756,13 @@ private:
bool is_active { false }; // device is working
};
struct basic_light : public basic_device {
// config
float dimming { 1.0f }; // light strength multiplier
// ld outputs
float intensity { 0.0f }; // current light strength
};
struct cooling_fan : public basic_device {
// config
float speed { 0.f }; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative
@@ -1315,6 +1322,11 @@ public:
bool CompressorTankValve{ false }; // indicates excessive pressure is vented from compressor tank directly and instantly
start_t CompressorStart{ start_t::manual }; // whether the compressor is started manually, or another way
start_t PantographCompressorStart{ start_t::manual };
basic_valve PantsValve;
std::array<basic_pantograph, 2> Pantographs;
bool PantAllDown { false };
double PantFrontVolt = 0.0; //pantograf pod napieciem? 'Winger 160404
double PantRearVolt = 0.0;
// TODO converter parameters, for when we start cleaning up mover parameters
start_t ConverterStart{ start_t::manual }; // whether converter is started manually, or by other means
float ConverterStartDelay{ 0.0f }; // delay (in seconds) before the converter is started, once its activation conditions are met
@@ -1506,11 +1518,6 @@ public:
bool DoorRightOpened = false;
double DoorRightOpenTimer{ -1.0 }; // right door closing timer for automatic door type
#endif
basic_valve PantsValve;
std::array<basic_pantograph, 2> Pantographs;
bool PantAllDown { false };
double PantFrontVolt = 0.0; //pantograf pod napieciem? 'Winger 160404
double PantRearVolt = 0.0;
// TODO: move these switch types where they belong, cabin definition
std::string PantSwitchType;
std::string ConvSwitchType;
@@ -1519,6 +1526,7 @@ public:
bool Heating = false; //ogrzewanie 'Winger 020304
bool HeatingAllow { false }; // heating switch // TODO: wrap heating in a basic device
int DoubleTr = 1; //trakcja ukrotniona - przedni pojazd 'Winger 160304
basic_light CompartmentLights;
bool PhysicActivation = true;
@@ -1674,6 +1682,8 @@ public:
bool OilPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // oil pump state toggle
bool MotorBlowersSwitch( bool State, end const Side, range_t const Notify = range_t::consist ); // traction motor fan state toggle
bool MotorBlowersSwitchOff( bool State, end const Side, range_t const Notify = range_t::consist ); // traction motor fan state toggle
bool CompartmentLightsSwitch( bool State, range_t const Notify = range_t::consist ); // compartment lights state toggle
bool CompartmentLightsSwitchOff( bool State, range_t const Notify = range_t::consist ); // compartment lights state toggle
bool MainSwitch( bool const State, range_t const Notify = range_t::consist );/*! wylacznik glowny*/
void MainSwitch_( bool const State );
bool ConverterSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl przetwornicy*/
@@ -1691,6 +1701,7 @@ public:
void OilPumpCheck( double const Timestep );
void MotorBlowersCheck( double const Timestep );
void PantographsCheck( double const Timestep );
void LightsCheck( double const Timestep );
bool FuseOn(void); //bezpiecznik nadamiary
bool FuseFlagCheck(void) const; // sprawdzanie flagi nadmiarowego
void FuseOff(void); // wylaczenie nadmiarowego

View File

@@ -1439,6 +1439,8 @@ void TMoverParameters::compute_movement_( double const Deltatime ) {
}
// heating
HeatingCheck( Deltatime );
// lighting
LightsCheck( Deltatime );
UpdateBrakePressure(Deltatime);
UpdatePipePressure(Deltatime);
@@ -1902,6 +1904,35 @@ void TMoverParameters::PantographsCheck( double const Timestep ) {
}
}
void TMoverParameters::LightsCheck( double const Timestep ) {
auto const lowvoltagepower { (
( ConverterFlag )
|| ( ( ( Couplers[ end::front ].CouplingFlag & coupling::permanent ) != 0 ) && ( Couplers[ end::front ].Connected->ConverterFlag ) )
|| ( ( ( Couplers[ end::rear ].CouplingFlag & coupling::permanent ) != 0 ) && ( Couplers[ end::rear ].Connected->ConverterFlag ) ) ) };
auto &light { CompartmentLights };
light.is_active = (
// TODO: bind properly power source when ld is in place
( Battery || lowvoltagepower ) // power source
&& ( false == light.is_disabled )
&& ( ( true == light.is_active )
|| ( light.start_type == start_t::manual ?
light.is_enabled :
true ) ) );
light.intensity =
( light.is_active ?
1.0f :
0.0f )
// TODO: bind properly power source when ld is in place
* ( lowvoltagepower ? 1.0f :
Battery ? 0.5f :
0.0f )
* light.dimming;
}
double TMoverParameters::ShowCurrent(int AmpN) const
{ // Odczyt poboru prądu na podanym amperomierzu
switch (EngineType)
@@ -3151,6 +3182,55 @@ bool TMoverParameters::MotorBlowersSwitchOff( bool State, end const Side, range_
return ( fan.is_disabled != initialstate );
}
bool TMoverParameters::CompartmentLightsSwitch( bool State, range_t const Notify ) {
if( CompartmentLights.start_type == start_t::automatic ) {
// automatic lights ignore 'manual' state commands
return false;
}
bool const initialstate { CompartmentLights.is_enabled };
CompartmentLights.is_enabled = State;
if( Notify != range_t::local ) {
SendCtrlToNext(
"CompartmentLightsSwitch",
( CompartmentLights.is_enabled ? 1 : 0 ),
CabActive,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return ( CompartmentLights.is_enabled != initialstate );
}
// water pump state toggle
bool TMoverParameters::CompartmentLightsSwitchOff( bool State, range_t const Notify ) {
if( CompartmentLights.start_type == start_t::automatic ) {
// automatic lights ignore 'manual' state commands
return false;
}
bool const initialstate { CompartmentLights.is_disabled };
CompartmentLights.is_disabled = State;
if( Notify != range_t::local ) {
SendCtrlToNext(
"CompartmentLightsSwitchOff",
( CompartmentLights.is_disabled ? 1 : 0 ),
CabActive,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return ( CompartmentLights.is_disabled != initialstate );
}
// *************************************************************************************************
// Q: 20160713
// włączenie / wyłączenie obwodu głownego
@@ -9758,6 +9838,15 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
lookup->second :
start_t::manual;
}
// compartment lights
{
auto lookup = starts.find( extract_value( "CompartmentLightsStart", line ) );
CompartmentLights.start_type =
lookup != starts.end() ?
lookup->second :
start_t::automatic;
}
}
void TMoverParameters::LoadFIZ_Blending(std::string const &line) {
@@ -11042,6 +11131,22 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if( Command == "CompartmentLightsSwitch" ) {
if( CompartmentLights.start_type != start_t::automatic ) {
// automatic lights ignore 'manual' state commands
CompartmentLights.is_enabled = ( CValue1 == 1 );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if( Command == "CompartmentLightsSwitchOff" ) {
if( CompartmentLights.start_type != start_t::automatic ) {
// automatic lights ignore 'manual' state commands
CompartmentLights.is_disabled = ( CValue1 == 1 );
}
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "MainSwitch")
{
MainSwitch_( CValue1 > 0.0 );