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

build 200701. additional coupler sounds, ep brake state exposed to uart interface, line breaker state cab indicator variant

This commit is contained in:
tmj-fstate
2020-07-02 20:00:07 +02:00
parent 92379deff5
commit fccb1c6c16
7 changed files with 188 additions and 40 deletions

View File

@@ -4625,25 +4625,38 @@ void TDynamicObject::RenderSounds() {
.play( sound_flags::exclusive ); .play( sound_flags::exclusive );
} }
} }
// attach/detach sounds
// TODO: dedicated sound for each connection type if( ( coupler.sounds & sound::attachcoupler ) != 0 ) {
// until then, play legacy placeholders: couplersounds.attach_coupler.play();
if( ( coupler.sounds & ( sound::attachcoupler | sound::attachcontrol | sound::attachgangway ) ) != 0 ) {
m_couplersounds[ couplerindex ].dsbCouplerAttach.play();
} }
if( ( coupler.sounds & ( sound::attachbrakehose | sound::attachmainhose | sound::attachheating ) ) != 0 ) { if( ( coupler.sounds & sound::attachbrakehose ) != 0 ) {
m_couplersounds[ couplerindex ].dsbCouplerDetach.play(); couplersounds.attach_brakehose.play();
}
if( ( coupler.sounds & sound::attachmainhose ) != 0 ) {
couplersounds.attach_mainhose.play();
}
if( ( coupler.sounds & sound::attachcontrol ) != 0 ) {
couplersounds.attach_control.play();
}
if( ( coupler.sounds & sound::attachgangway ) != 0 ) {
couplersounds.attach_gangway.play();
}
if( ( coupler.sounds & sound::attachheating ) != 0 ) {
couplersounds.attach_heating.play();
} }
if( true == TestFlag( coupler.sounds, sound::detachall ) ) { if( true == TestFlag( coupler.sounds, sound::detachall ) ) {
// TODO: dedicated disconnect sounds couplersounds.detach_coupler.play();
m_couplersounds[ couplerindex ].dsbCouplerAttach.play(); couplersounds.detach_brakehose.play();
m_couplersounds[ couplerindex ].dsbCouplerDetach.play(); couplersounds.detach_mainhose.play();
couplersounds.detach_control.play();
couplersounds.detach_gangway.play();
couplersounds.detach_heating.play();
} }
if( true == TestFlag( coupler.sounds, sound::attachadapter ) ) { if( true == TestFlag( coupler.sounds, sound::attachadapter ) ) {
m_couplersounds[ couplerindex ].dsbAdapterAttach.play(); couplersounds.dsbAdapterAttach.play();
} }
if( true == TestFlag( coupler.sounds, sound::removeadapter ) ) { if( true == TestFlag( coupler.sounds, sound::removeadapter ) ) {
m_couplersounds[ couplerindex ].dsbAdapterRemove.play(); couplersounds.dsbAdapterRemove.play();
} }
++couplerindex; ++couplerindex;
@@ -5999,21 +6012,110 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
} }
// coupler sounds // coupler sounds
else if( token == "couplerattach:" ) { else if( token == "couplerattach:" ) {
// laczenie: sound_source soundtemplate { sound_placement::external };
sound_source couplerattach { sound_placement::external }; soundtemplate.deserialize( parser, sound_type::single );
couplerattach.deserialize( parser, sound_type::single ); soundtemplate.owner( this );
couplerattach.owner( this );
for( auto &couplersounds : m_couplersounds ) { for( auto &couplersounds : m_couplersounds ) {
couplersounds.dsbCouplerAttach = couplerattach; couplersounds.attach_coupler = soundtemplate;
}
}
else if( token == "brakehoseattach:" ) {
// laczenie:
sound_source soundtemplate { sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.attach_brakehose = soundtemplate;
}
}
else if( token == "mainhoseattach:" ) {
// laczenie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.attach_mainhose = soundtemplate;
}
}
else if( token == "controlattach:" ) {
// laczenie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.attach_control = soundtemplate;
}
}
else if( token == "gangwayattach:" ) {
// laczenie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.attach_gangway = soundtemplate;
}
}
else if( token == "heatingattach:" ) {
// laczenie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.attach_heating = soundtemplate;
} }
} }
else if( token == "couplerdetach:" ) { else if( token == "couplerdetach:" ) {
// rozlaczanie: // rozlaczanie:
sound_source couplerdetach { sound_placement::external }; sound_source soundtemplate { sound_placement::external };
couplerdetach.deserialize( parser, sound_type::single ); soundtemplate.deserialize( parser, sound_type::single );
couplerdetach.owner( this ); soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) { for( auto &couplersounds : m_couplersounds ) {
couplersounds.dsbCouplerDetach = couplerdetach; couplersounds.detach_coupler = soundtemplate;
}
}
else if( token == "brakehosedetach:" ) {
// rozlaczanie:
sound_source soundtemplate { sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.detach_brakehose = soundtemplate;
}
}
else if( token == "mainhosedetach:" ) {
// rozlaczanie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.detach_mainhose = soundtemplate;
}
}
else if( token == "controldetach:" ) {
// rozlaczanie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.detach_control = soundtemplate;
}
}
else if( token == "gangwaydetach:" ) {
// rozlaczanie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.detach_gangway = soundtemplate;
}
}
else if( token == "heatingdetach:" ) {
// rozlaczanie:
sound_source soundtemplate{ sound_placement::external };
soundtemplate.deserialize( parser, sound_type::single );
soundtemplate.owner( this );
for( auto &couplersounds : m_couplersounds ) {
couplersounds.detach_heating = soundtemplate;
} }
} }
else if( token == "couplerstretch:" ) { else if( token == "couplerstretch:" ) {
@@ -6182,13 +6284,13 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
} }
// couplers // couplers
for( auto &couplersounds : m_couplersounds ) { for( auto &couplersounds : m_couplersounds ) {
if( true == couplersounds.dsbCouplerAttach.empty() ) { if( true == couplersounds.attach_coupler.empty() ) {
couplersounds.dsbCouplerAttach.deserialize( "couplerattach_default", sound_type::single ); couplersounds.attach_coupler.deserialize( "couplerattach_default", sound_type::single );
couplersounds.dsbCouplerAttach.owner( this ); couplersounds.attach_coupler.owner( this );
} }
if( true == couplersounds.dsbCouplerDetach.empty() ) { if( true == couplersounds.detach_coupler.empty() ) {
couplersounds.dsbCouplerDetach.deserialize( "couplerdetach_default", sound_type::single ); couplersounds.detach_coupler.deserialize( "couplerdetach_default", sound_type::single );
couplersounds.dsbCouplerDetach.owner( this ); couplersounds.detach_coupler.owner( this );
} }
if( true == couplersounds.dsbCouplerStretch.empty() ) { if( true == couplersounds.dsbCouplerStretch.empty() ) {
couplersounds.dsbCouplerStretch.deserialize( "couplerstretch_default", sound_type::single ); couplersounds.dsbCouplerStretch.deserialize( "couplerstretch_default", sound_type::single );
@@ -6261,8 +6363,18 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
} }
// couplers // couplers
auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * 0.5f } }; auto const frontcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * 0.5f } };
m_couplersounds[ end::front ].dsbCouplerAttach.offset( frontcoupleroffset ); m_couplersounds[ end::front ].attach_coupler.offset( frontcoupleroffset );
m_couplersounds[ end::front ].dsbCouplerDetach.offset( frontcoupleroffset ); m_couplersounds[ end::front ].attach_brakehose.offset( frontcoupleroffset );
m_couplersounds[ end::front ].attach_mainhose.offset( frontcoupleroffset );
m_couplersounds[ end::front ].attach_control.offset( frontcoupleroffset );
m_couplersounds[ end::front ].attach_gangway.offset( frontcoupleroffset );
m_couplersounds[ end::front ].attach_heating.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_coupler.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_brakehose.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_mainhose.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_control.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_gangway.offset( frontcoupleroffset );
m_couplersounds[ end::front ].detach_heating.offset( frontcoupleroffset );
m_couplersounds[ end::front ].dsbCouplerStretch.offset( frontcoupleroffset ); m_couplersounds[ end::front ].dsbCouplerStretch.offset( frontcoupleroffset );
m_couplersounds[ end::front ].dsbCouplerStretch_loud.offset( frontcoupleroffset ); m_couplersounds[ end::front ].dsbCouplerStretch_loud.offset( frontcoupleroffset );
m_couplersounds[ end::front ].dsbBufferClamp.offset( frontcoupleroffset ); m_couplersounds[ end::front ].dsbBufferClamp.offset( frontcoupleroffset );
@@ -6270,8 +6382,18 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
m_couplersounds[ end::front ].dsbAdapterAttach.offset( frontcoupleroffset ); m_couplersounds[ end::front ].dsbAdapterAttach.offset( frontcoupleroffset );
m_couplersounds[ end::front ].dsbAdapterRemove.offset( frontcoupleroffset ); m_couplersounds[ end::front ].dsbAdapterRemove.offset( frontcoupleroffset );
auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * -0.5f } }; auto const rearcoupleroffset { glm::vec3{ 0.f, 1.f, MoverParameters->Dim.L * -0.5f } };
m_couplersounds[ end::rear ].dsbCouplerAttach.offset( rearcoupleroffset ); m_couplersounds[ end::rear ].attach_coupler.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].dsbCouplerDetach.offset( rearcoupleroffset ); m_couplersounds[ end::rear ].attach_brakehose.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].attach_mainhose.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].attach_control.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].attach_gangway.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].attach_heating.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_coupler.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_brakehose.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_mainhose.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_control.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_gangway.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].detach_heating.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].dsbCouplerStretch.offset( rearcoupleroffset ); m_couplersounds[ end::rear ].dsbCouplerStretch.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].dsbCouplerStretch_loud.offset( rearcoupleroffset ); m_couplersounds[ end::rear ].dsbCouplerStretch_loud.offset( rearcoupleroffset );
m_couplersounds[ end::rear ].dsbBufferClamp.offset( rearcoupleroffset ); m_couplersounds[ end::rear ].dsbBufferClamp.offset( rearcoupleroffset );

View File

@@ -312,8 +312,19 @@ private:
}; };
struct coupler_sounds { struct coupler_sounds {
sound_source dsbCouplerAttach { sound_placement::external }; // moved from cab // TBD: change to an array with index-based access for easier initialization?
sound_source dsbCouplerDetach { sound_placement::external }; // moved from cab sound_source attach_coupler { sound_placement::external };
sound_source attach_brakehose { sound_placement::external };
sound_source attach_mainhose { sound_placement::external };
sound_source attach_control { sound_placement::external };
sound_source attach_gangway { sound_placement::external };
sound_source attach_heating { sound_placement::external };
sound_source detach_coupler { sound_placement::external };
sound_source detach_brakehose { sound_placement::external };
sound_source detach_mainhose { sound_placement::external };
sound_source detach_control { sound_placement::external };
sound_source detach_gangway { sound_placement::external };
sound_source detach_heating { sound_placement::external };
sound_source dsbCouplerStretch { sound_placement::external }; // moved from cab sound_source dsbCouplerStretch { sound_placement::external }; // moved from cab
sound_source dsbCouplerStretch_loud { sound_placement::external }; sound_source dsbCouplerStretch_loud { sound_placement::external };
sound_source dsbBufferClamp { sound_placement::external }; // moved from cab sound_source dsbBufferClamp { sound_placement::external }; // moved from cab

View File

@@ -1492,7 +1492,9 @@ void TMoverParameters::MainsCheck( double const Deltatime ) {
if( true == maincircuitpowersupply ) { if( true == maincircuitpowersupply ) {
// all is well // all is well
if( MainsInitTimeCountdown > 0.0 ) { if( MainsInitTimeCountdown >= 0.0 ) {
// NOTE: we ensure main circuit readiness meets condition MainsInitTimeCountdown < 0
// this allows for simpler rejection of cases where MainsInitTime == 0
MainsInitTimeCountdown -= Deltatime; MainsInitTimeCountdown -= Deltatime;
} }
} }

View File

@@ -735,8 +735,9 @@ TTrain::get_state() const {
{ fHCurrent[ ( mvControlled->TrainType & dt_EZT ) ? 0 : 1 ], fHCurrent[ 2 ], fHCurrent[ 3 ] }, { fHCurrent[ ( mvControlled->TrainType & dt_EZT ) ? 0 : 1 ], fHCurrent[ 2 ], fHCurrent[ 3 ] },
ggLVoltage.GetValue(), ggLVoltage.GetValue(),
mvOccupied->DistCounter, mvOccupied->DistCounter,
RadioChannel(), static_cast<std::uint8_t>( RadioChannel() ),
btLampkaSpringBrakeActive.GetValue() btLampkaSpringBrakeActive.GetValue(),
btLampkaNapNastHam.GetValue(),
}; };
} }
@@ -6457,6 +6458,12 @@ bool TTrain::Update( double const Deltatime )
|| ( true == mvControlled->Mains ) ) ? || ( true == mvControlled->Mains ) ) ?
false : false :
true ) ); true ) );
btLampkaMainBreakerBlinkingIfReady.Turn(
( ( (m_linebreakerstate == 2)
|| (true == mvControlled->Mains)
|| ( ( mvControlled->MainsInitTimeCountdown < 0.0 ) && ( simulation::Time.data().wMilliseconds > 500 ) ) ) ?
true :
false ) );
btLampkaPrzetw.Turn( mvOccupied->Power110vIsAvailable ); btLampkaPrzetw.Turn( mvOccupied->Power110vIsAvailable );
btLampkaPrzetwOff.Turn( false == mvOccupied->Power110vIsAvailable ); btLampkaPrzetwOff.Turn( false == mvOccupied->Power110vIsAvailable );
@@ -6618,6 +6625,7 @@ bool TTrain::Update( double const Deltatime )
btLampkaWylSzybki.Turn( false ); btLampkaWylSzybki.Turn( false );
btLampkaWylSzybkiOff.Turn( false ); btLampkaWylSzybkiOff.Turn( false );
btLampkaMainBreakerReady.Turn( false ); btLampkaMainBreakerReady.Turn( false );
btLampkaMainBreakerBlinkingIfReady.Turn( false );
btLampkaWysRozr.Turn( false ); btLampkaWysRozr.Turn( false );
btLampkaOpory.Turn( false ); btLampkaOpory.Turn( false );
btLampkaStyczn.Turn( false ); btLampkaStyczn.Turn( false );
@@ -8395,6 +8403,7 @@ void TTrain::clear_cab_controls()
btLampkaWylSzybkiB.Clear(); btLampkaWylSzybkiB.Clear();
btLampkaWylSzybkiBOff.Clear(); btLampkaWylSzybkiBOff.Clear();
btLampkaMainBreakerReady.Clear(); btLampkaMainBreakerReady.Clear();
btLampkaMainBreakerBlinkingIfReady.Clear();
btLampkaBezoporowa.Clear(); btLampkaBezoporowa.Clear();
btLampkaBezoporowaB.Clear(); btLampkaBezoporowaB.Clear();
btLampkaMaxSila.Clear(); btLampkaMaxSila.Clear();
@@ -8821,6 +8830,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
{ "i-mainbreakeroff:", btLampkaWylSzybkiOff }, { "i-mainbreakeroff:", btLampkaWylSzybkiOff },
{ "i-mainbreakerboff:", btLampkaWylSzybkiBOff }, { "i-mainbreakerboff:", btLampkaWylSzybkiBOff },
{ "i-mainbreakerready:", btLampkaMainBreakerReady }, { "i-mainbreakerready:", btLampkaMainBreakerReady },
{ "i-mainbreakerblinking:", btLampkaMainBreakerBlinkingIfReady },
{ "i-vent_ovld:", btLampkaNadmWent }, { "i-vent_ovld:", btLampkaNadmWent },
{ "i-comp_ovld:", btLampkaNadmSpr }, { "i-comp_ovld:", btLampkaNadmSpr },
{ "i-resistors:", btLampkaOpory }, { "i-resistors:", btLampkaOpory },

View File

@@ -107,8 +107,9 @@ class TTrain {
std::array<float, 3> hv_current; std::array<float, 3> hv_current;
float lv_voltage; float lv_voltage;
double distance; double distance;
int radio_channel; std::uint8_t radio_channel;
bool springbrake_active; std::uint8_t springbrake_active;
std::uint8_t epbrake_enabled;
}; };
struct screen_entry { struct screen_entry {
@@ -611,6 +612,7 @@ public: // reszta może by?publiczna
TButton btLampkaWylSzybki; TButton btLampkaWylSzybki;
TButton btLampkaWylSzybkiOff; TButton btLampkaWylSzybkiOff;
TButton btLampkaMainBreakerReady; TButton btLampkaMainBreakerReady;
TButton btLampkaMainBreakerBlinkingIfReady;
TButton btLampkaNadmWent; TButton btLampkaNadmWent;
TButton btLampkaNadmSpr; // TODO: implement TButton btLampkaNadmSpr; // TODO: implement
// yB: drugie lampki dla EP05 i ET42 // yB: drugie lampki dla EP05 i ET42

View File

@@ -354,7 +354,8 @@ void uart_input::poll()
SPLIT_INT16(tacho), SPLIT_INT16(tacho),
//byte 2 //byte 2
(uint8_t)( (uint8_t)(
trainstate.ventilator_overload << 1 trainstate.epbrake_enabled << 0
| trainstate.ventilator_overload << 1
| trainstate.motor_overload_threshold << 2), | trainstate.motor_overload_threshold << 2),
//byte 3 //byte 3
(uint8_t)( (uint8_t)(

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 20 #define VERSION_MAJOR 20
#define VERSION_MINOR 630 #define VERSION_MINOR 701
#define VERSION_REVISION 0 #define VERSION_REVISION 0