leak rate as .fiz parameter, support for low and high horn buttons, brake .fiz parsing fix

This commit is contained in:
tmj-fstate
2017-04-24 14:37:19 +02:00
parent e84f4f53fd
commit da65fb7fac
4 changed files with 46 additions and 13 deletions

View File

@@ -659,6 +659,7 @@ public:
double CompressorSpeed = 0.0;
/*cisnienie wlaczania, zalaczania sprezarki, wydajnosc sprezarki*/
TBrakeDelayTable BrakeDelay; /*opoznienie hamowania/odhamowania t/o*/
double AirLeakRate{ 0.01 }; // base rate of air leak from brake system components ( 0.001 = 1 l/sec )
int BrakeCtrlPosNo = 0; /*ilosc pozycji hamulca*/
/*nastawniki:*/
int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/

View File

@@ -2843,8 +2843,7 @@ void TMoverParameters::UpdateBrakePressure(double dt)
// *************************************************************************************************
void TMoverParameters::CompressorCheck(double dt)
{
// TODO: expose leak rate as a parameter to the .fiz file
CompressedVolume = std::max( 0.0, CompressedVolume - dt * 0.001 ); // nieszczelności: 0.001=1l/s
CompressedVolume = std::max( 0.0, CompressedVolume - dt * AirLeakRate * 0.1 ); // nieszczelności: 0.001=1l/s
// if (CompressorSpeed>0.0) then //ten warunek został sprawdzony przy wywołaniu funkcji
if (VeselVolume > 0)
@@ -2968,8 +2967,10 @@ void TMoverParameters::CompressorCheck(double dt)
// *************************************************************************************************
void TMoverParameters::UpdatePipePressure(double dt)
{
// TODO: expose leak rate as a parameter to the .fiz file
PipePress = std::max( 0.0, PipePress - dt * 0.001 ); // nieszczelności: 0.001=1l/s
if( PipePress > 1.0 ) {
Pipe->Flow( -(PipePress)* AirLeakRate * dt );
Pipe->Act();
}
const double LBDelay = 100;
const double kL = 0.5;
@@ -3187,8 +3188,10 @@ void TMoverParameters::UpdatePipePressure(double dt)
// *************************************************************************************************
void TMoverParameters::UpdateScndPipePressure(double dt)
{
// TODO: expose leak rate as a parameter to the .fiz file
ScndPipePress = std::max( 0.0, ScndPipePress - dt * 0.001 ); // nieszczelności: 0.001=0.1l/s
if( ScndPipePress > 1.0 ) {
Pipe2->Flow( -(ScndPipePress)* AirLeakRate * dt );
Pipe2->Act();
}
const double Spz = 0.5067;
TMoverParameters *c;
@@ -6494,6 +6497,11 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
lookup->second :
1;
}
if( true == extract_value( AirLeakRate, "AirLeakRate", line, "" ) ) {
// the parameter is provided in form of a multiplier, where 1.0 means the default rate of 0.001
AirLeakRate *= 0.01;
}
}
void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
@@ -6705,8 +6713,10 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
}
// mbpm
extract_value( MBPM, "MaxBPMass", line, "" );
// MBPM *= 1000;
if( true == extract_value( MBPM, "MaxBPMass", line, "" ) ) {
// NOTE: only convert the value from tons to kilograms if the entry is present in the config file
MBPM *= 1000.0;
}
// asbtype
std::string asb;

View File

@@ -2742,7 +2742,8 @@ void TTrain::OnCommand_departureannounce( TTrain *Train, command_data const &Com
void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Command ) {
if( Train->ggHornButton.SubModel == nullptr ) {
if( ( Train->ggHornButton.SubModel == nullptr )
&& ( Train->ggHornLowButton.SubModel == nullptr ) ) {
if( Command.action == GLFW_PRESS ) {
WriteLog( "Horn button is missing, or wasn't defined" );
}
@@ -2759,11 +2760,13 @@ void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Comma
Train->mvControlled->WarningSignal &= ~2;
}
// audio feedback
if( Train->ggHornButton.GetValue() > -0.5 ) {
if( ( Train->ggHornButton.GetValue() > -0.5 )
|| ( Train->ggHornLowButton.GetValue() < 0.5 ) ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
Train->ggHornButton.UpdateValue( -1.0 );
Train->ggHornLowButton.UpdateValue( 1.0 );
}
}
else if( Command.action == GLFW_RELEASE ) {
@@ -2771,17 +2774,20 @@ void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Comma
// NOTE: we turn off both low and high horn, due to unreliability of release event when shift key is involved
Train->mvControlled->WarningSignal &= ~( 1 | 2 );
// audio feedback
if( Train->ggHornButton.GetValue() < -0.5 ) {
if( ( Train->ggHornButton.GetValue() < -0.5 )
|| ( Train->ggHornLowButton.GetValue() > 0.5 ) ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
Train->ggHornButton.UpdateValue( 0.0 );
Train->ggHornLowButton.UpdateValue( 0.0 );
}
}
void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Command ) {
if( Train->ggHornButton.SubModel == nullptr ) {
if( ( Train->ggHornButton.SubModel == nullptr )
&& ( Train->ggHornHighButton.SubModel == nullptr ) ) {
if( Command.action == GLFW_PRESS ) {
WriteLog( "Horn button is missing, or wasn't defined" );
}
@@ -2803,6 +2809,7 @@ void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Comm
}
// visual feedback
Train->ggHornButton.UpdateValue( 1.0 );
Train->ggHornHighButton.UpdateValue( 1.0 );
}
}
else if( Command.action == GLFW_RELEASE ) {
@@ -2815,6 +2822,7 @@ void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Comm
}
// visual feedback
Train->ggHornButton.UpdateValue( 0.0 );
Train->ggHornButton.UpdateValue( 0.0 );
}
}
@@ -7399,6 +7407,8 @@ bool TTrain::Update( double const Deltatime )
ggSignallingButton.Update();
ggNextCurrentButton.Update();
ggHornButton.Update();
ggHornLowButton.Update();
ggHornHighButton.Update();
ggUniversal1Button.Update();
ggUniversal2Button.Update();
ggUniversal3Button.Update();
@@ -8169,6 +8179,8 @@ void TTrain::clear_cab_controls()
ggSandButton.Clear();
ggAntiSlipButton.Clear();
ggHornButton.Clear();
ggHornLowButton.Clear();
ggHornHighButton.Clear();
ggNextCurrentButton.Clear();
ggUniversal1Button.Clear();
ggUniversal2Button.Clear();
@@ -8759,7 +8771,15 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
// dzwignia syreny
ggHornButton.Load(Parser, DynamicObject->mdKabina);
}
else if (Label == "fuse_bt:")
else if( Label == "hornlow_bt:" ) {
// dzwignia syreny
ggHornLowButton.Load( Parser, DynamicObject->mdKabina );
}
else if( Label == "hornhigh_bt:" ) {
// dzwignia syreny
ggHornHighButton.Load( Parser, DynamicObject->mdKabina );
}
else if( Label == "fuse_bt:" )
{
// bezp. nadmiarowy
ggFuseButton.Load(Parser, DynamicObject->mdKabina);

View File

@@ -261,6 +261,8 @@ public: // reszta może by?publiczna
// ABu 090305 - syrena i prad nastepnego czlonu
TGauge ggHornButton;
TGauge ggHornLowButton;
TGauge ggHornHighButton;
TGauge ggNextCurrentButton;
// ABu 090305 - uniwersalne przyciski
TGauge ggUniversal1Button;