mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 00:59:18 +02:00
control for e-p brake system, brake acting speed, departure signal, heating, door lock. Support for rear pantograph lowering button, all pantographs lowering button. Increased recognition of converter as a valid low voltage power source.
This commit is contained in:
356
command.cpp
356
command.cpp
@@ -17,6 +17,116 @@ http://mozilla.org/MPL/2.0/.
|
||||
namespace simulation {
|
||||
|
||||
command_queue Commands;
|
||||
commanddescription_sequence Commands_descriptions = {
|
||||
|
||||
{ "mastercontrollerincrease", command_target::vehicle },
|
||||
{ "mastercontrollerincreasefast", command_target::vehicle },
|
||||
{ "mastercontrollerdecrease", command_target::vehicle },
|
||||
{ "mastercontrollerdecreasefast", command_target::vehicle },
|
||||
{ "secondcontrollerincrease", command_target::vehicle },
|
||||
{ "secondcontrollerincreasefast", command_target::vehicle },
|
||||
{ "secondcontrollerdecrease", command_target::vehicle },
|
||||
{ "secondcontrollerdecreasefast", command_target::vehicle },
|
||||
{ "independentbrakeincrease", command_target::vehicle },
|
||||
{ "independentbrakeincreasefast", command_target::vehicle },
|
||||
{ "independentbrakedecrease", command_target::vehicle },
|
||||
{ "independentbrakedecreasefast", command_target::vehicle },
|
||||
{ "independentbrakebailoff", command_target::vehicle },
|
||||
{ "trainbrakeincrease", command_target::vehicle },
|
||||
{ "trainbrakedecrease", command_target::vehicle },
|
||||
{ "trainbrakecharging", command_target::vehicle },
|
||||
{ "trainbrakerelease", command_target::vehicle },
|
||||
{ "trainbrakefirstservice", command_target::vehicle },
|
||||
{ "trainbrakeservice", command_target::vehicle },
|
||||
{ "trainbrakefullservice", command_target::vehicle },
|
||||
{ "trainbrakeemergency", command_target::vehicle },
|
||||
/*
|
||||
const int k_AntiSlipping = 21;
|
||||
const int k_Sand = 22;
|
||||
*/
|
||||
{ "reverserincrease", command_target::vehicle },
|
||||
{ "reverserdecrease", command_target::vehicle },
|
||||
{ "linebreakertoggle", command_target::vehicle },
|
||||
/*
|
||||
const int k_Fuse = 26;
|
||||
*/
|
||||
{ "convertertoggle", command_target::vehicle },
|
||||
{ "compressortoggle", command_target::vehicle },
|
||||
{ "motoroverloadrelaythresholdtoggle", command_target::vehicle },
|
||||
{ "notchingrelaytoggle", command_target::vehicle },
|
||||
{ "epbrakecontroltoggle", command_target::vehicle },
|
||||
{ "brakeactingspeedincrease", command_target::vehicle },
|
||||
{ "brakeactingspeeddecrease", command_target::vehicle },
|
||||
/*
|
||||
const int k_BrakeProfile = 31;
|
||||
*/
|
||||
{ "alerteracknowledge", command_target::vehicle },
|
||||
/*
|
||||
const int k_Horn = 33;
|
||||
const int k_Horn2 = 34;
|
||||
const int k_FailedEngineCutOff = 35;
|
||||
*/
|
||||
{ "viewturn", command_target::entity },
|
||||
{ "movevector", command_target::entity },
|
||||
{ "moveleft", command_target::entity },
|
||||
{ "moveright", command_target::entity },
|
||||
{ "moveforward", command_target::entity },
|
||||
{ "moveback", command_target::entity },
|
||||
{ "moveup", command_target::entity },
|
||||
{ "movedown", command_target::entity },
|
||||
{ "moveleftfast", command_target::entity },
|
||||
{ "moverightfast", command_target::entity },
|
||||
{ "moveforwardfast", command_target::entity },
|
||||
{ "movebackfast", command_target::entity },
|
||||
{ "moveupfast", command_target::entity },
|
||||
{ "movedownfast", command_target::entity },
|
||||
/*
|
||||
const int k_CabForward = 42;
|
||||
const int k_CabBackward = 43;
|
||||
const int k_Couple = 44;
|
||||
const int k_DeCouple = 45;
|
||||
const int k_ProgramQuit = 46;
|
||||
// const int k_ProgramPause= 47;
|
||||
const int k_ProgramHelp = 48;
|
||||
*/
|
||||
{ "doortoggleleft", command_target::vehicle },
|
||||
{ "doortoggleright", command_target::vehicle },
|
||||
{ "departureannounce", command_target::vehicle },
|
||||
{ "doorlocktoggle", command_target::vehicle },
|
||||
{ "pantographtogglefront", command_target::vehicle },
|
||||
{ "pantographtogglerear", command_target::vehicle },
|
||||
{ "pantographlowerall", command_target::vehicle },
|
||||
{ "heatingtoggle", command_target::vehicle },
|
||||
/*
|
||||
// const int k_FreeFlyMode= 59;
|
||||
*/
|
||||
{ "headlighttoggleleft", command_target::vehicle },
|
||||
{ "headlighttoggleright", command_target::vehicle },
|
||||
{ "headlighttoggleupper", command_target::vehicle },
|
||||
{ "redmarkertoggleleft", command_target::vehicle },
|
||||
{ "redmarkertoggleright", command_target::vehicle },
|
||||
{ "headlighttogglerearleft", command_target::vehicle },
|
||||
{ "headlighttogglerearright", command_target::vehicle },
|
||||
{ "headlighttogglerearupper", command_target::vehicle },
|
||||
{ "redmarkertogglerearleft", command_target::vehicle },
|
||||
{ "redmarkertogglerearright", command_target::vehicle },
|
||||
/*
|
||||
const int k_SmallCompressor = 63;
|
||||
const int k_StLinOff = 64;
|
||||
const int k_CurrentNext = 65;
|
||||
const int k_Univ1 = 66;
|
||||
const int k_Univ2 = 67;
|
||||
const int k_Univ3 = 68;
|
||||
const int k_Univ4 = 69;
|
||||
const int k_EndSign = 70;
|
||||
const int k_Active = 71;
|
||||
*/
|
||||
{ "batterytoggle", command_target::vehicle }
|
||||
/*
|
||||
const int k_WalkMode = 73;
|
||||
int const k_DimHeadlights = 74;
|
||||
*/
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -50,242 +160,15 @@ command_queue::pop( command_data &Command, std::size_t const Recipient ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
command_relay::command_relay() {
|
||||
|
||||
m_targets = commandtarget_map{
|
||||
|
||||
{ user_command::mastercontrollerincrease, command_target::vehicle },
|
||||
{ user_command::mastercontrollerincreasefast, command_target::vehicle },
|
||||
{ user_command::mastercontrollerdecrease, command_target::vehicle },
|
||||
{ user_command::mastercontrollerdecreasefast, command_target::vehicle },
|
||||
{ user_command::secondcontrollerincrease, command_target::vehicle },
|
||||
{ user_command::secondcontrollerincreasefast, command_target::vehicle },
|
||||
{ user_command::secondcontrollerdecrease, command_target::vehicle },
|
||||
{ user_command::secondcontrollerdecreasefast, command_target::vehicle },
|
||||
{ user_command::independentbrakeincrease, command_target::vehicle },
|
||||
{ user_command::independentbrakeincreasefast, command_target::vehicle },
|
||||
{ user_command::independentbrakedecrease, command_target::vehicle },
|
||||
{ user_command::independentbrakedecreasefast, command_target::vehicle },
|
||||
{ user_command::independentbrakebailoff, command_target::vehicle },
|
||||
{ user_command::trainbrakeincrease, command_target::vehicle },
|
||||
{ user_command::trainbrakedecrease, command_target::vehicle },
|
||||
{ user_command::trainbrakecharging, command_target::vehicle },
|
||||
{ user_command::trainbrakerelease, command_target::vehicle },
|
||||
{ user_command::trainbrakefirstservice, command_target::vehicle },
|
||||
{ user_command::trainbrakeservice, command_target::vehicle },
|
||||
{ user_command::trainbrakefullservice, command_target::vehicle },
|
||||
{ user_command::trainbrakeemergency, command_target::vehicle },
|
||||
/*
|
||||
const int k_AntiSlipping = 21;
|
||||
const int k_Sand = 22;
|
||||
*/
|
||||
{ user_command::reverserincrease, command_target::vehicle },
|
||||
{ user_command::reverserdecrease, command_target::vehicle },
|
||||
{ user_command::linebreakertoggle, command_target::vehicle },
|
||||
/*
|
||||
const int k_Fuse = 26;
|
||||
*/
|
||||
{ user_command::convertertoggle, command_target::vehicle },
|
||||
{ user_command::compressortoggle, command_target::vehicle },
|
||||
{ user_command::motoroverloadrelaythresholdtoggle, command_target::vehicle },
|
||||
/*
|
||||
const int k_CurrentAutoRelay = 30;
|
||||
const int k_BrakeProfile = 31;
|
||||
*/
|
||||
{ user_command::alerteracknowledge, command_target::vehicle },
|
||||
/*
|
||||
const int k_Czuwak = 32;
|
||||
const int k_Horn = 33;
|
||||
const int k_Horn2 = 34;
|
||||
const int k_FailedEngineCutOff = 35;
|
||||
*/
|
||||
{ user_command::viewturn, command_target::entity },
|
||||
{ user_command::movevector, command_target::entity },
|
||||
{ user_command::moveleft, command_target::entity },
|
||||
{ user_command::moveright, command_target::entity },
|
||||
{ user_command::moveforward, command_target::entity },
|
||||
{ user_command::moveback, command_target::entity },
|
||||
{ user_command::moveup, command_target::entity },
|
||||
{ user_command::movedown, command_target::entity },
|
||||
{ user_command::moveleftfast, command_target::entity },
|
||||
{ user_command::moverightfast, command_target::entity },
|
||||
{ user_command::moveforwardfast, command_target::entity },
|
||||
{ user_command::movebackfast, command_target::entity },
|
||||
{ user_command::moveupfast, command_target::entity },
|
||||
{ user_command::movedownfast, command_target::entity },
|
||||
/*
|
||||
const int k_CabForward = 42;
|
||||
const int k_CabBackward = 43;
|
||||
const int k_Couple = 44;
|
||||
const int k_DeCouple = 45;
|
||||
const int k_ProgramQuit = 46;
|
||||
// const int k_ProgramPause= 47;
|
||||
const int k_ProgramHelp = 48;
|
||||
*/
|
||||
{ user_command::doortoggleleft, command_target::vehicle },
|
||||
{ user_command::doortoggleright, command_target::vehicle },
|
||||
/*
|
||||
const int k_DepartureSignal = 53;
|
||||
*/
|
||||
{ user_command::pantographtogglefront, command_target::vehicle },
|
||||
{ user_command::pantographtogglerear, command_target::vehicle },
|
||||
/*
|
||||
const int k_Heating = 58;
|
||||
// const int k_FreeFlyMode= 59;
|
||||
*/
|
||||
{ user_command::headlighttoggleleft, command_target::vehicle },
|
||||
{ user_command::headlighttoggleright, command_target::vehicle },
|
||||
{ user_command::headlighttoggleupper, command_target::vehicle },
|
||||
{ user_command::redmarkertoggleleft, command_target::vehicle },
|
||||
{ user_command::redmarkertoggleright, command_target::vehicle },
|
||||
{ user_command::headlighttogglerearleft, command_target::vehicle },
|
||||
{ user_command::headlighttogglerearright, command_target::vehicle },
|
||||
{ user_command::headlighttogglerearupper, command_target::vehicle },
|
||||
{ user_command::redmarkertogglerearleft, command_target::vehicle },
|
||||
{ user_command::redmarkertogglerearright, command_target::vehicle },
|
||||
/*
|
||||
const int k_SmallCompressor = 63;
|
||||
const int k_StLinOff = 64;
|
||||
const int k_CurrentNext = 65;
|
||||
const int k_Univ1 = 66;
|
||||
const int k_Univ2 = 67;
|
||||
const int k_Univ3 = 68;
|
||||
const int k_Univ4 = 69;
|
||||
const int k_EndSign = 70;
|
||||
const int k_Active = 71;
|
||||
*/
|
||||
{ user_command::batterytoggle, command_target::vehicle }
|
||||
/*
|
||||
const int k_WalkMode = 73;
|
||||
int const k_DimHeadlights = 74;
|
||||
*/
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_commandnames = {
|
||||
|
||||
"mastercontrollerincrease",
|
||||
"mastercontrollerincreasefast",
|
||||
"mastercontrollerdecrease",
|
||||
"mastercontrollerdecreasefast",
|
||||
"secondcontrollerincrease",
|
||||
"secondcontrollerincreasefast",
|
||||
"secondcontrollerdecrease",
|
||||
"secondcontrollerdecreasefast",
|
||||
"independentbrakeincrease",
|
||||
"independentbrakeincreasefast",
|
||||
"independentbrakedecrease",
|
||||
"independentbrakedecreasefast",
|
||||
"independentbrakebailoff",
|
||||
"trainbrakeincrease",
|
||||
"trainbrakedecrease",
|
||||
"trainbrakecharging",
|
||||
"trainbrakerelease",
|
||||
"trainbrakefirstservice",
|
||||
"trainbrakeservice",
|
||||
"trainbrakefullservice",
|
||||
"trainbrakeemergency",
|
||||
/*
|
||||
const int k_AntiSlipping = 21;
|
||||
const int k_Sand = 22;
|
||||
*/
|
||||
"reverserincrease",
|
||||
"reverserdecrease",
|
||||
"linebreakertoggle",
|
||||
/*
|
||||
const int k_Fuse = 26;
|
||||
*/
|
||||
"convertertoggle",
|
||||
"compressortoggle",
|
||||
"motoroverloadrelaythresholdtoggle",
|
||||
/*
|
||||
const int k_MaxCurrent = 29;
|
||||
const int k_CurrentAutoRelay = 30;
|
||||
const int k_BrakeProfile = 31;
|
||||
*/
|
||||
"alerteracknowledge",
|
||||
/*
|
||||
const int k_Czuwak = 32;
|
||||
const int k_Horn = 33;
|
||||
const int k_Horn2 = 34;
|
||||
const int k_FailedEngineCutOff = 35;
|
||||
*/
|
||||
"", //"viewturn",
|
||||
"", //"movevector",
|
||||
"", //"moveleft",
|
||||
"", //"moveright",
|
||||
"", //"moveforward",
|
||||
"", //"moveback",
|
||||
"", //"moveup",
|
||||
"", //"movedown",
|
||||
"", //"moveleftfast",
|
||||
"", //"moverightfast",
|
||||
"", //"moveforwardfast",
|
||||
"", //"movebackfast",
|
||||
"", //"moveupfast",
|
||||
"", //"movedownfast"
|
||||
/*
|
||||
const int k_CabForward = 42;
|
||||
const int k_CabBackward = 43;
|
||||
const int k_Couple = 44;
|
||||
const int k_DeCouple = 45;
|
||||
const int k_ProgramQuit = 46;
|
||||
// const int k_ProgramPause= 47;
|
||||
const int k_ProgramHelp = 48;
|
||||
*/
|
||||
"doortoggleleft",
|
||||
"doortoggleright",
|
||||
/*
|
||||
const int k_DepartureSignal = 53;
|
||||
*/
|
||||
"pantographtogglefront",
|
||||
"pantographtogglerear",
|
||||
/*
|
||||
const int k_Heating = 58;
|
||||
// const int k_FreeFlyMode= 59;
|
||||
*/
|
||||
"headlighttoggleleft",
|
||||
"headlighttoggleright",
|
||||
"headlighttoggleupper",
|
||||
"redmarkertoggleleft",
|
||||
"redmarkertoggleright",
|
||||
"headlighttogglerearleft",
|
||||
"headlighttogglerearright",
|
||||
"headlighttogglerearupper",
|
||||
"redmarkertogglerearleft",
|
||||
"redmarkertogglerearright",
|
||||
/*
|
||||
const int k_SmallCompressor = 63;
|
||||
const int k_StLinOff = 64;
|
||||
const int k_CurrentNext = 65;
|
||||
const int k_Univ1 = 66;
|
||||
const int k_Univ2 = 67;
|
||||
const int k_Univ3 = 68;
|
||||
const int k_Univ4 = 69;
|
||||
const int k_EndSign = 70;
|
||||
const int k_Active = 71;
|
||||
*/
|
||||
"batterytoggle"
|
||||
/*
|
||||
const int k_WalkMode = 73;
|
||||
int const k_DimHeadlights = 74;
|
||||
*/
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
command_relay::post( user_command const Command, std::uint64_t const Param1, std::uint64_t const Param2, int const Action, std::uint16_t const Recipient ) const {
|
||||
|
||||
auto const &lookup = m_targets.find( Command );
|
||||
if( lookup == m_targets.end() ) {
|
||||
// shouldn't be really needed but, eh
|
||||
return;
|
||||
}
|
||||
if( ( lookup->second == command_target::vehicle )
|
||||
auto const &command = simulation::Commands_descriptions[ static_cast<std::size_t>( Command ) ];
|
||||
if( ( command.target == command_target::vehicle )
|
||||
&& ( true == FreeFlyModeFlag )
|
||||
&& ( false == DebugModeFlag ) ) {
|
||||
// don't pass vehicle commands if the user isn't in one, unless we're in debug mode
|
||||
&& ( ( false == DebugModeFlag )
|
||||
&& ( true == Global::RealisticControlMode ) ) ) {
|
||||
// in realistic control mode don't pass vehicle commands if the user isn't in one, unless we're in debug mode
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -296,20 +179,19 @@ command_relay::post( user_command const Command, std::uint64_t const Param1, std
|
||||
Param1,
|
||||
Param2,
|
||||
Timer::GetDeltaTime() },
|
||||
static_cast<std::size_t>( lookup->second ) | Recipient );
|
||||
static_cast<std::size_t>( command.target ) | Recipient );
|
||||
|
||||
#ifdef _DEBUG
|
||||
if( Action != GLFW_RELEASE ) {
|
||||
// key was pressed or is still held
|
||||
auto const &commandname = m_commandnames.at( static_cast<std::size_t>( Command ) );
|
||||
if( false == commandname.empty() ) {
|
||||
WriteLog( "Command issued: " + commandname );
|
||||
if( false == command.name.empty() ) {
|
||||
WriteLog( "Command issued: " + command.name );
|
||||
}
|
||||
}
|
||||
/*
|
||||
else {
|
||||
// key was released (but we don't log this)
|
||||
WriteLog( "Key released: " + m_commandnames.at( static_cast<std::size_t>( Command ) ) );
|
||||
WriteLog( "Key released: " + m_command.name );
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user