16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-23 08:39:18 +02:00

Added commands and buttons for disabling inverters; mass and brake res. press for python; train guard opening doors before departure; small fix for AI

This commit is contained in:
Królik Uszasty
2022-02-01 20:23:36 +01:00
parent 1ed4c98cad
commit e787e5d815
7 changed files with 446 additions and 23 deletions

View File

@@ -1097,7 +1097,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
bool bool
TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance ) { TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, double const Signaldistance ) {
// stop points are irrelevant when not in one of the basic modes // stop points are irrelevant when not in one of the basic modes
if( ( OrderCurrentGet() & ( /*Shunt | Loose_shunt |*/ Obey_train | Bank ) ) == 0 ) { return true; } if( ( OrderCurrentGet() & ( Shunt | Loose_shunt | Obey_train | Bank ) ) == 0 ) { return true; }
// jeśli przystanek, trzeba obsłużyć wg rozkładu // jeśli przystanek, trzeba obsłużyć wg rozkładu
iDrivigFlags |= moveStopPointFound; iDrivigFlags |= moveStopPointFound;
// first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them // first 19 chars of the command is expected to be "PassengerStopPoint:" so we skip them
@@ -1340,9 +1340,13 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub
} }
return true; // nie analizować prędkości return true; // nie analizować prędkości
} // koniec startu z zatrzymania } // koniec startu z zatrzymania
else { else {
cue_action( locale::string::driver_hint_waitdeparturetime ); cue_action(locale::string::driver_hint_waitdeparturetime);
} if (TrainParams.IsTimeToGo(simulation::Time.data().wHour, simulation::Time.data().wMinute + simulation::Time.data().wSecond*0.0167 + 0.1)) { //if is less than 6 sec to departure
iDrivigFlags |= moveGuardOpenDoor;
GuardOpenDoor();
}
}
} // koniec obsługi początkowych stacji } // koniec obsługi początkowych stacji
else { else {
// jeśli dojechaliśmy do końca rozkładu // jeśli dojechaliśmy do końca rozkładu
@@ -6909,6 +6913,7 @@ TController::UpdateObeyTrain() {
&& ( VelDesired > 0.0 ) ) { && ( VelDesired > 0.0 ) ) {
// komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania
iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać
iDrivigFlags &= ~moveGuardOpenDoor; // nie trzeba już otwierać drzwi
if( false == tsGuardSignal.empty() ) { if( false == tsGuardSignal.empty() ) {
tsGuardSignal.stop(); tsGuardSignal.stop();
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy bezpośrednim // w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy bezpośrednim
@@ -7002,6 +7007,29 @@ TController::UpdateConnect() {
} }
} }
void
TController::GuardOpenDoor() {
if ((iDrivigFlags & moveGuardOpenDoor) != 0) {
auto *vehicle{ pVehicles[end::front] };
while (vehicle != nullptr && vehicle->MoverParameters->Doors.range == 0) {
vehicle = vehicle->Next();
}
if (vehicle->MoverParameters->Doors.range > 0) {
auto const lewe = (vehicle->DirectionGet() > 0) ? 1 : 2;
auto const prawe = 3 - lewe;
if (m_lastexchangeplatforms & lewe) {
vehicle->MoverParameters->OperateDoors(side::left, true, range_t::local);
}
if (m_lastexchangeplatforms & prawe) {
vehicle->MoverParameters->OperateDoors(side::right, true, range_t::local);
}
}
else {
iDrivigFlags &= ~moveGuardOpenDoor;
}
}
}
int int
TController::unit_count( int const Threshold ) const { TController::unit_count( int const Threshold ) const {

View File

@@ -64,7 +64,8 @@ enum TMovementStatus
moveDoorOpened = 0x20000, // drzwi zostały otwarte - doliczyć czas na zamknięcie moveDoorOpened = 0x20000, // drzwi zostały otwarte - doliczyć czas na zamknięcie
movePushPull = 0x40000, // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku movePushPull = 0x40000, // zmiana czoła przez zmianę kabiny - nie odczepiać przy zmianie kierunku
moveSignalFound = 0x80000, // na drodze skanowania został znaleziony semafor moveSignalFound = 0x80000, // na drodze skanowania został znaleziony semafor
moveStopPointFound = 0x100000 // stop point detected ahead moveStopPointFound = 0x100000, // stop point detected ahead
moveGuardOpenDoor = 0x200000 // time for opening a door before departure
/* /*
moveSemaphorWasElapsed = 0x100000, // minięty został semafor moveSemaphorWasElapsed = 0x100000, // minięty został semafor
moveTrainInsideStation = 0x200000, // pociąg między semaforem a rozjazdami lub następnym semaforem moveTrainInsideStation = 0x200000, // pociąg między semaforem a rozjazdami lub następnym semaforem
@@ -325,6 +326,7 @@ private:
void UpdateChangeDirection(); void UpdateChangeDirection();
void UpdateLooseShunt(); void UpdateLooseShunt();
void UpdateObeyTrain(); void UpdateObeyTrain();
void GuardOpenDoor();
void pick_optimal_speed( double const Range ); void pick_optimal_speed( double const Range );
void adjust_desired_speed_for_obstacles(); void adjust_desired_speed_for_obstacles();
void adjust_desired_speed_for_limits(); void adjust_desired_speed_for_limits();

234
Train.cpp
View File

@@ -90,6 +90,9 @@ bool TTrain::screen_entry::deserialize_mapping( cParser &Input ) {
else if( key == "target:" ) { else if( key == "target:" ) {
target = Input.getToken<std::string>(); target = Input.getToken<std::string>();
} }
else if (key == "updatetime:") {
updatetime = Input.getToken<int>();
}
else if( key == "parameters:" ) { else if( key == "parameters:" ) {
parameters = dictionary_source( Input.getToken<std::string>() ); parameters = dictionary_source( Input.getToken<std::string>() );
} }
@@ -450,6 +453,42 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::speedcontrolbutton7, &TTrain::OnCommand_speedcontrolbutton }, { user_command::speedcontrolbutton7, &TTrain::OnCommand_speedcontrolbutton },
{ user_command::speedcontrolbutton8, &TTrain::OnCommand_speedcontrolbutton }, { user_command::speedcontrolbutton8, &TTrain::OnCommand_speedcontrolbutton },
{ user_command::speedcontrolbutton9, &TTrain::OnCommand_speedcontrolbutton }, { user_command::speedcontrolbutton9, &TTrain::OnCommand_speedcontrolbutton },
{ user_command::inverterenable1, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable2, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable3, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable4, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable5, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable6, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable7, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable8, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable9, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable10, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable11, &TTrain::OnCommand_inverterenable },
{ user_command::inverterenable12, &TTrain::OnCommand_inverterenable },
{ user_command::inverterdisable1, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable2, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable3, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable4, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable5, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable6, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable7, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable8, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable9, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable10, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable11, &TTrain::OnCommand_inverterdisable },
{ user_command::inverterdisable12, &TTrain::OnCommand_inverterdisable },
{ user_command::invertertoggle1, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle2, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle3, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle4, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle5, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle6, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle7, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle8, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle9, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle10, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle11, &TTrain::OnCommand_invertertoggle },
{ user_command::invertertoggle12, &TTrain::OnCommand_invertertoggle },
}; };
std::vector<std::string> const TTrain::fPress_labels = { std::vector<std::string> const TTrain::fPress_labels = {
@@ -499,7 +538,7 @@ TTrain::TTrain() {
for ( int i = 0; i < 20; ++i ) for ( int i = 0; i < 20; ++i )
{ {
for ( int j = 0; j < 4; ++j ) for ( int j = 0; j < 6; ++j )
fPress[i][j] = 0.0; fPress[i][j] = 0.0;
bBrakes[i][0] = bBrakes[i][1] = false; bBrakes[i][0] = bBrakes[i][1] = false;
} }
@@ -671,7 +710,7 @@ dictionary_source *TTrain::GetTrainState( dictionary_source const &Extraparamete
char const *TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" }; char const *TXTT[ 10 ] = { "fd", "fdt", "fdb", "pd", "pdt", "pdb", "itothv", "1", "2", "3" };
char const *TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" }; char const *TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" };
char const *TXTD[ 10 ] = { "enrot", "nrot", "fill_des", "fill_real", "clutch_des", "clutch_real", "water_temp", "oil_press", "engine_temp", "retarder_fill" }; char const *TXTD[ 10 ] = { "enrot", "nrot", "fill_des", "fill_real", "clutch_des", "clutch_real", "water_temp", "oil_press", "engine_temp", "retarder_fill" };
char const *TXTP[ 4 ] = { "bc", "bp", "sp", "cp" }; char const *TXTP[ 6 ] = { "bc", "bp", "sp", "cp", "rp", "mass" };
char const *TXTB[ 2 ] = { "spring_active", "spring_shutoff" }; char const *TXTB[ 2 ] = { "spring_active", "spring_shutoff" };
for( int j = 0; j < 10; ++j ) for( int j = 0; j < 10; ++j )
dict->insert( ( "eimp_t_" + std::string( TXTT[ j ] ) ), fEIMParams[ 0 ][ j ] ); dict->insert( ( "eimp_t_" + std::string( TXTT[ j ] ) ), fEIMParams[ 0 ][ j ] );
@@ -724,7 +763,7 @@ dictionary_source *TTrain::GetTrainState( dictionary_source const &Extraparamete
p = (kier ? p->NextC(4) : p->PrevC(4)); p = (kier ? p->NextC(4) : p->PrevC(4));
} }
for( int i = 0; i < 20; ++i ) { for( int i = 0; i < 20; ++i ) {
for( int j = 0; j < 4; ++j ) { for( int j = 0; j < 6; ++j ) {
dict->insert( ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ), fPress[ i ][ j ] ); dict->insert( ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ), fPress[ i ][ j ] );
} }
for ( int j = 0; j < 2; ++j) { for ( int j = 0; j < 2; ++j) {
@@ -5150,7 +5189,115 @@ void TTrain::OnCommand_speedcontrolbutton(TTrain *Train, command_data const &Com
} }
}; };
void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command) {
auto itemindex = static_cast<int>(Command.command) - static_cast<int>(user_command::inverterenable1);
auto &item = Train->ggInverterEnableButtons[itemindex];
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
while (p)
{
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
{
if (itemindex < p->MoverParameters->InvertersNo)
{
p->MoverParameters->Inverters[itemindex].Activate = true;
break;
}
else
{
itemindex -= p->MoverParameters->InvertersNo;
}
}
p = (kier ? p->NextC(4) : p->PrevC(4));
}
// visual feedback
Train->ggInverterEnableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggInverterEnableButtons[itemindex].UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Command) {
auto itemindex = static_cast<int>(Command.command) - static_cast<int>(user_command::inverterdisable1);
auto &item = Train->ggInverterDisableButtons[itemindex];
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
while (p)
{
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
{
if (itemindex < p->MoverParameters->InvertersNo)
{
p->MoverParameters->Inverters[itemindex].Activate = false;
break;
}
else
{
itemindex -= p->MoverParameters->InvertersNo;
}
}
p = (kier ? p->NextC(4) : p->PrevC(4));
}
// visual feedback
Train->ggInverterDisableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggInverterDisableButtons[itemindex].UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command) {
auto itemindex = static_cast<int>(Command.command) - static_cast<int>(user_command::invertertoggle1);
auto &item = Train->ggInverterToggleButtons[itemindex];
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
while (p)
{
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
{
if (itemindex < p->MoverParameters->InvertersNo)
{
p->MoverParameters->Inverters[itemindex].Activate = !p->MoverParameters->Inverters[itemindex].Activate;
break;
}
else
{
itemindex -= p->MoverParameters->InvertersNo;
}
}
p = (kier ? p->NextC(4) : p->PrevC(4));
}
// visual feedback
Train->ggInverterToggleButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggInverterToggleButtons[itemindex].UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_doorlocktoggle(TTrain *Train, command_data const &Command) {
if( Train->ggDoorSignallingButton.SubModel == nullptr ) { if( Train->ggDoorSignallingButton.SubModel == nullptr ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
@@ -6425,6 +6572,8 @@ bool TTrain::Update( double const Deltatime )
fPress[i][1] = p->MoverParameters->PipePress; fPress[i][1] = p->MoverParameters->PipePress;
fPress[i][2] = p->MoverParameters->ScndPipePress; fPress[i][2] = p->MoverParameters->ScndPipePress;
fPress[i][3] = p->MoverParameters->CntrlPipePress; fPress[i][3] = p->MoverParameters->CntrlPipePress;
fPress[i][4] = p->MoverParameters->Hamulec->GetBRP();
fPress[i][5] = (p->MoverParameters->TotalMass - p->MoverParameters->Mred) * 0.001;
bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive; bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive;
bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff; bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff;
bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f ); bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f );
@@ -6513,6 +6662,8 @@ bool TTrain::Update( double const Deltatime )
= fPress[i][1] = fPress[i][1]
= fPress[i][2] = fPress[i][2]
= fPress[i][3] = fPress[i][3]
= fPress[i][4]
= fPress[i][5]
= 0; = 0;
bDoors[i][0] bDoors[i][0]
= bDoors[i][1] = bDoors[i][1]
@@ -7488,19 +7639,26 @@ bool TTrain::Update( double const Deltatime )
} }
} }
// screens // screens
fScreenTimer += Deltatime; // fScreenTimer += Deltatime;
if( ( this == simulation::Train ) // no point in drawing screens for vehicles other than our own if( ( this == simulation::Train ) // no point in drawing screens for vehicles other than our own
&& ( Global.PythonScreenUpdateRate > 0 ) && ( Global.PythonScreenUpdateRate > 0 )
&& ( fScreenTimer > std::max( fScreenUpdateRate, Global.PythonScreenUpdateRate ) * 0.001f )
&& ( false == FreeFlyModeFlag ) ) { // don't bother if we're outside && ( false == FreeFlyModeFlag ) ) { // don't bother if we're outside
fScreenTimer = 0.f; // fScreenTimer = 0.f;
for( auto &screen : m_screens ) { for( auto &screen : m_screens ) {
auto *state_dict = GetTrainState( screen.parameters ); if (screen.updatetimecounter >= 0)
/* {
state_dict->insert("touches", *screen.touch_list); screen.updatetimecounter += Deltatime;
screen.touch_list->clear(); }
*/ if (screen.updatetimecounter > screen.updatetime)
Application.request( { screen.script, state_dict, screen.rt } ); {
auto *state_dict = GetTrainState(screen.parameters);
/*
state_dict->insert("touches", *screen.touch_list);
screen.touch_list->clear();
*/
Application.request({ screen.script, state_dict, screen.rt });
screen.updatetimecounter = screen.updatetime > 0 ? 0 : -1;
}
} }
} }
// sounds // sounds
@@ -8306,6 +8464,18 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
// && ( token != "cab1definition:" ) // && ( token != "cab1definition:" )
// && ( token != "cab2definition:" ) // && ( token != "cab2definition:" )
&& ( token != "cab0definition:" ) ); && ( token != "cab0definition:" ) );
for (auto &screen : m_screens)
{
if (screen.updatetime > 0) {
screen.updatetime = std::max((int)screen.updatetime, Global.PythonScreenUpdateRate) * 0.001;
}
if (screen.updatetime == 0) {
screen.updatetime = std::max(Global.PythonScreenUpdateRate, fScreenUpdateRate) * 0.001;
}
if (screen.updatetime < -1) {
screen.updatetime = -screen.updatetime * 0.001;
}
}
} }
else else
{ {
@@ -9474,7 +9644,43 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "universal6:", ggUniversals[ 6 ] }, { "universal6:", ggUniversals[ 6 ] },
{ "universal7:", ggUniversals[ 7 ] }, { "universal7:", ggUniversals[ 7 ] },
{ "universal8:", ggUniversals[ 8 ] }, { "universal8:", ggUniversals[ 8 ] },
{ "universal9:", ggUniversals[ 9 ] } { "universal9:", ggUniversals[ 9 ] },
{ "inverterenable1_bt:", ggInverterEnableButtons[0] },
{ "inverterenable2_bt:", ggInverterEnableButtons[1] },
{ "inverterenable3_bt:", ggInverterEnableButtons[2] },
{ "inverterenable4_bt:", ggInverterEnableButtons[3] },
{ "inverterenable5_bt:", ggInverterEnableButtons[4] },
{ "inverterenable6_bt:", ggInverterEnableButtons[5] },
{ "inverterenable7_bt:", ggInverterEnableButtons[6] },
{ "inverterenable8_bt:", ggInverterEnableButtons[7] },
{ "inverterenable9_bt:", ggInverterEnableButtons[8] },
{ "inverterenable10_bt:", ggInverterEnableButtons[9] },
{ "inverterenable11_bt:", ggInverterEnableButtons[10] },
{ "inverterenable12_bt:", ggInverterEnableButtons[11] },
{ "inverterdisable1_bt:", ggInverterDisableButtons[0] },
{ "inverterdisable2_bt:", ggInverterDisableButtons[1] },
{ "inverterdisable3_bt:", ggInverterDisableButtons[2] },
{ "inverterdisable4_bt:", ggInverterDisableButtons[3] },
{ "inverterdisable5_bt:", ggInverterDisableButtons[4] },
{ "inverterdisable6_bt:", ggInverterDisableButtons[5] },
{ "inverterdisable7_bt:", ggInverterDisableButtons[6] },
{ "inverterdisable8_bt:", ggInverterDisableButtons[7] },
{ "inverterdisable9_bt:", ggInverterDisableButtons[8] },
{ "inverterdisable10_bt:", ggInverterDisableButtons[9] },
{ "inverterdisable11_bt:", ggInverterDisableButtons[10] },
{ "inverterdisable12_bt:", ggInverterDisableButtons[11] },
{ "invertertoggle1_bt:", ggInverterToggleButtons[0] },
{ "invertertoggle2_bt:", ggInverterToggleButtons[1] },
{ "invertertoggle3_bt:", ggInverterToggleButtons[2] },
{ "invertertoggle4_bt:", ggInverterToggleButtons[3] },
{ "invertertoggle5_bt:", ggInverterToggleButtons[4] },
{ "invertertoggle6_bt:", ggInverterToggleButtons[5] },
{ "invertertoggle7_bt:", ggInverterToggleButtons[6] },
{ "invertertoggle8_bt:", ggInverterToggleButtons[7] },
{ "invertertoggle9_bt:", ggInverterToggleButtons[8] },
{ "invertertoggle10_bt:", ggInverterToggleButtons[9] },
{ "invertertoggle11_bt:", ggInverterToggleButtons[10] },
{ "invertertoggle12_bt:", ggInverterToggleButtons[11] },
}; };
{ {
auto const lookup { gauges.find( Label ) }; auto const lookup { gauges.find( Label ) };

12
Train.h
View File

@@ -128,6 +128,8 @@ class TTrain {
std::string script; std::string script;
std::string target; std::string target;
double updatetime = 0;
double updatetimecounter = 0;
std::shared_ptr<python_rt> rt; std::shared_ptr<python_rt> rt;
/* /*
std::unique_ptr<python_screen_viewer> viewer; std::unique_ptr<python_screen_viewer> viewer;
@@ -453,6 +455,9 @@ class TTrain {
static void OnCommand_speedcontrolpowerincrease(TTrain *Train, command_data const &Command); static void OnCommand_speedcontrolpowerincrease(TTrain *Train, command_data const &Command);
static void OnCommand_speedcontrolpowerdecrease(TTrain *Train, command_data const &Command); static void OnCommand_speedcontrolpowerdecrease(TTrain *Train, command_data const &Command);
static void OnCommand_speedcontrolbutton(TTrain *Train, command_data const &Command); static void OnCommand_speedcontrolbutton(TTrain *Train, command_data const &Command);
static void OnCommand_inverterenable(TTrain *Train, command_data const &Command);
static void OnCommand_inverterdisable(TTrain *Train, command_data const &Command);
static void OnCommand_invertertoggle(TTrain *Train, command_data const &Command);
@@ -575,6 +580,9 @@ public: // reszta może by?publiczna
std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table
std::array<TGauge, 3> ggRelayResetButtons; // NOTE: temporary arrangement until we have dynamically built control table std::array<TGauge, 3> ggRelayResetButtons; // NOTE: temporary arrangement until we have dynamically built control table
std::array<TGauge, 12> ggInverterEnableButtons; // NOTE: temporary arrangement until we have dynamically built control table
std::array<TGauge, 12> ggInverterDisableButtons; // NOTE: temporary arrangement until we have dynamically built control table
std::array<TGauge, 12> ggInverterToggleButtons; // NOTE: temporary arrangement until we have dynamically built control table
TGauge ggInstrumentLightButton; TGauge ggInstrumentLightButton;
TGauge ggDashboardLightButton; TGauge ggDashboardLightButton;
@@ -788,7 +796,7 @@ private:
float fConverterTimer; // hunter-261211: dla przekaznika float fConverterTimer; // hunter-261211: dla przekaznika
float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem
float fCzuwakTestTimer; // hunter-091012: do testu czuwaka float fCzuwakTestTimer; // hunter-091012: do testu czuwaka
float fScreenTimer { 0.f }; // float fScreenTimer { 0.f };
int fScreenUpdateRate { 0 }; // vehicle specific python screen update rate override int fScreenUpdateRate { 0 }; // vehicle specific python screen update rate override
bool CAflag { false }; // hunter-131211: dla osobnego zbijania CA i SHP bool CAflag { false }; // hunter-131211: dla osobnego zbijania CA i SHP
@@ -835,7 +843,7 @@ private:
bool m_couplingdisconnect { false }; bool m_couplingdisconnect { false };
public: public:
float fPress[20][4]; // cisnienia dla wszystkich czlonow float fPress[20][6]; // cisnienia dla wszystkich czlonow
bool bBrakes[20][2]; // zalaczenie i dzialanie hamulcow bool bBrakes[20][2]; // zalaczenie i dzialanie hamulcow
static std::vector<std::string> const fPress_labels; static std::vector<std::string> const fPress_labels;
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych

View File

@@ -282,7 +282,42 @@ commanddescription_sequence Commands_descriptions = {
{ "speedcontrolbutton7", command_target::vehicle }, { "speedcontrolbutton7", command_target::vehicle },
{ "speedcontrolbutton8", command_target::vehicle }, { "speedcontrolbutton8", command_target::vehicle },
{ "speedcontrolbutton9", command_target::vehicle }, { "speedcontrolbutton9", command_target::vehicle },
{ "inverterenable1", command_target::vehicle },
{ "inverterenable2", command_target::vehicle },
{ "inverterenable3", command_target::vehicle },
{ "inverterenable4", command_target::vehicle },
{ "inverterenable5", command_target::vehicle },
{ "inverterenable6", command_target::vehicle },
{ "inverterenable7", command_target::vehicle },
{ "inverterenable8", command_target::vehicle },
{ "inverterenable9", command_target::vehicle },
{ "inverterenable10", command_target::vehicle },
{ "inverterenable11", command_target::vehicle },
{ "inverterenable12", command_target::vehicle },
{ "inverterdisable1", command_target::vehicle },
{ "inverterdisable2", command_target::vehicle },
{ "inverterdisable3", command_target::vehicle },
{ "inverterdisable4", command_target::vehicle },
{ "inverterdisable5", command_target::vehicle },
{ "inverterdisable6", command_target::vehicle },
{ "inverterdisable7", command_target::vehicle },
{ "inverterdisable8", command_target::vehicle },
{ "inverterdisable9", command_target::vehicle },
{ "inverterdisable10", command_target::vehicle },
{ "inverterdisable11", command_target::vehicle },
{ "inverterdisable12", command_target::vehicle },
{ "invertertoggle1", command_target::vehicle },
{ "invertertoggle2", command_target::vehicle },
{ "invertertoggle3", command_target::vehicle },
{ "invertertoggle4", command_target::vehicle },
{ "invertertoggle5", command_target::vehicle },
{ "invertertoggle6", command_target::vehicle },
{ "invertertoggle7", command_target::vehicle },
{ "invertertoggle8", command_target::vehicle },
{ "invertertoggle9", command_target::vehicle },
{ "invertertoggle10", command_target::vehicle },
{ "invertertoggle11", command_target::vehicle },
{ "invertertoggle12", command_target::vehicle },
{ "globalradiostop", command_target::simulation }, { "globalradiostop", command_target::simulation },
{ "timejump", command_target::simulation }, { "timejump", command_target::simulation },
{ "timejumplarge", command_target::simulation }, { "timejumplarge", command_target::simulation },

View File

@@ -273,7 +273,42 @@ enum class user_command {
speedcontrolbutton7, speedcontrolbutton7,
speedcontrolbutton8, speedcontrolbutton8,
speedcontrolbutton9, speedcontrolbutton9,
inverterenable1,
inverterenable2,
inverterenable3,
inverterenable4,
inverterenable5,
inverterenable6,
inverterenable7,
inverterenable8,
inverterenable9,
inverterenable10,
inverterenable11,
inverterenable12,
inverterdisable1,
inverterdisable2,
inverterdisable3,
inverterdisable4,
inverterdisable5,
inverterdisable6,
inverterdisable7,
inverterdisable8,
inverterdisable9,
inverterdisable10,
inverterdisable11,
inverterdisable12,
invertertoggle1,
invertertoggle2,
invertertoggle3,
invertertoggle4,
invertertoggle5,
invertertoggle6,
invertertoggle7,
invertertoggle8,
invertertoggle9,
invertertoggle10,
invertertoggle11,
invertertoggle12,
globalradiostop, globalradiostop,
timejump, timejump,
timejumplarge, timejumplarge,

View File

@@ -954,6 +954,115 @@ drivermouse_input::default_bindings() {
{ "speedbutton9:",{ { "speedbutton9:",{
user_command::speedcontrolbutton9, user_command::speedcontrolbutton9,
user_command::none } }, user_command::none } },
{ "inverterenable1_bt:",{
user_command::inverterenable1,
user_command::none } },
{ "inverterenable2_bt:",{
user_command::inverterenable2,
user_command::none } },
{ "inverterenable3_bt:",{
user_command::inverterenable3,
user_command::none } },
{ "inverterenable4_bt:",{
user_command::inverterenable4,
user_command::none } },
{ "inverterenable5_bt:",{
user_command::inverterenable5,
user_command::none } },
{ "inverterenable6_bt:",{
user_command::inverterenable6,
user_command::none } },
{ "inverterenable7_bt:",{
user_command::inverterenable7,
user_command::none } },
{ "inverterenable8_bt:",{
user_command::inverterenable8,
user_command::none } },
{ "inverterenable9_bt:",{
user_command::inverterenable9,
user_command::none } },
{ "inverterenable10_bt:",{
user_command::inverterenable10,
user_command::none } },
{ "inverterenable11_bt:",{
user_command::inverterenable11,
user_command::none } },
{ "inverterenable12_bt:",{
user_command::inverterenable12,
user_command::none } },
{ "inverterdisable1_bt:",{
user_command::inverterdisable1,
user_command::none } },
{ "inverterdisable2_bt:",{
user_command::inverterdisable2,
user_command::none } },
{ "inverterdisable3_bt:",{
user_command::inverterdisable3,
user_command::none } },
{ "inverterdisable4_bt:",{
user_command::inverterdisable4,
user_command::none } },
{ "inverterdisable5_bt:",{
user_command::inverterdisable5,
user_command::none } },
{ "inverterdisable6_bt:",{
user_command::inverterdisable6,
user_command::none } },
{ "inverterdisable7_bt:",{
user_command::inverterdisable7,
user_command::none } },
{ "inverterdisable8_bt:",{
user_command::inverterdisable8,
user_command::none } },
{ "inverterdisable9_bt:",{
user_command::inverterdisable9,
user_command::none } },
{ "inverterdisable10_bt:",{
user_command::inverterdisable10,
user_command::none } },
{ "inverterdisable11_bt:",{
user_command::inverterdisable11,
user_command::none } },
{ "inverterdisable12_bt:",{
user_command::inverterdisable12,
user_command::none } },
{ "invertertoggle1_bt:",{
user_command::invertertoggle1,
user_command::none } },
{ "invertertoggle2_bt:",{
user_command::invertertoggle2,
user_command::none } },
{ "invertertoggle3_bt:",{
user_command::invertertoggle3,
user_command::none } },
{ "invertertoggle4_bt:",{
user_command::invertertoggle4,
user_command::none } },
{ "invertertoggle5_bt:",{
user_command::invertertoggle5,
user_command::none } },
{ "invertertoggle6_bt:",{
user_command::invertertoggle6,
user_command::none } },
{ "invertertoggle7_bt:",{
user_command::invertertoggle7,
user_command::none } },
{ "invertertoggle8_bt:",{
user_command::invertertoggle8,
user_command::none } },
{ "invertertoggle9_bt:",{
user_command::invertertoggle9,
user_command::none } },
{ "invertertoggle10_bt:",{
user_command::invertertoggle10,
user_command::none } },
{ "invertertoggle11_bt:",{
user_command::invertertoggle11,
user_command::none } },
{ "invertertoggle12_bt:",{
user_command::invertertoggle12,
user_command::none } },
}; };
} }