mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 09:19:18 +02:00
Fixed animation of inverter control buttons and added coupling flag for this
This commit is contained in:
@@ -1305,6 +1305,7 @@ public:
|
|||||||
int InvertersNo = 0; // number of inverters
|
int InvertersNo = 0; // number of inverters
|
||||||
double InvertersRatio = 0.0;
|
double InvertersRatio = 0.0;
|
||||||
std::vector<inverter> Inverters; //all inverters
|
std::vector<inverter> Inverters; //all inverters
|
||||||
|
int InverterControlCouplerFlag = 4; //which coupling flag is necessary to controll inverters
|
||||||
/* -dla pojazdów z blendingiem EP/ED (MED) */
|
/* -dla pojazdów z blendingiem EP/ED (MED) */
|
||||||
double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED
|
double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED
|
||||||
double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED
|
double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED
|
||||||
|
|||||||
@@ -10835,7 +10835,8 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
|
|||||||
extract_value( eimc[ eimc_p_abed ], "abed", Input, "" );
|
extract_value( eimc[ eimc_p_abed ], "abed", Input, "" );
|
||||||
extract_value( eimc[ eimc_p_eped ], "edep", Input, "" );
|
extract_value( eimc[ eimc_p_eped ], "edep", Input, "" );
|
||||||
extract_value( EIMCLogForce, "eimclf", Input, "" );
|
extract_value( EIMCLogForce, "eimclf", Input, "" );
|
||||||
extract_value( InvertersNo, "InvNo", Input, "");
|
extract_value( InvertersNo, "InvNo", Input, "" );
|
||||||
|
extract_value( InverterControlCouplerFlag, "InvCtrCplFlag", Input, "" );
|
||||||
|
|
||||||
extract_value( Flat, "Flat", Input, "");
|
extract_value( Flat, "Flat", Input, "");
|
||||||
|
|
||||||
|
|||||||
71
Train.cpp
71
Train.cpp
@@ -5197,7 +5197,8 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command
|
|||||||
if (Command.action == GLFW_PRESS) {
|
if (Command.action == GLFW_PRESS) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// 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);
|
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
|
||||||
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
|
int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag;
|
||||||
|
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag);
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
||||||
@@ -5213,7 +5214,7 @@ void TTrain::OnCommand_inverterenable(TTrain *Train, command_data const &Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
p = (kier ? p->NextC(4) : p->PrevC(4));
|
p = (kier ? p->NextC(flag) : p->PrevC(flag));
|
||||||
}
|
}
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggInverterEnableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
|
Train->ggInverterEnableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
|
||||||
@@ -5233,7 +5234,8 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman
|
|||||||
if (Command.action == GLFW_PRESS) {
|
if (Command.action == GLFW_PRESS) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// 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);
|
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
|
||||||
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
|
int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag;
|
||||||
|
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag);
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
||||||
@@ -5249,7 +5251,7 @@ void TTrain::OnCommand_inverterdisable(TTrain *Train, command_data const &Comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
p = (kier ? p->NextC(4) : p->PrevC(4));
|
p = (kier ? p->NextC(flag) : p->PrevC(flag));
|
||||||
}
|
}
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggInverterDisableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
|
Train->ggInverterDisableButtons[itemindex].UpdateValue(1.0, Train->dsbSwitch);
|
||||||
@@ -5269,7 +5271,8 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command
|
|||||||
if (Command.action == GLFW_PRESS) {
|
if (Command.action == GLFW_PRESS) {
|
||||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
// 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);
|
bool kier = (Train->DynamicObject->DirectionGet() * Train->mvOccupied->CabOccupied > 0);
|
||||||
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, 4);
|
int flag = Train->DynamicObject->MoverParameters->InverterControlCouplerFlag;
|
||||||
|
TDynamicObject *p = Train->DynamicObject->GetFirstDynamic(Train->mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag);
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
||||||
@@ -5277,6 +5280,8 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command
|
|||||||
if (itemindex < p->MoverParameters->InvertersNo)
|
if (itemindex < p->MoverParameters->InvertersNo)
|
||||||
{
|
{
|
||||||
p->MoverParameters->Inverters[itemindex].Activate = !p->MoverParameters->Inverters[itemindex].Activate;
|
p->MoverParameters->Inverters[itemindex].Activate = !p->MoverParameters->Inverters[itemindex].Activate;
|
||||||
|
// visual feedback
|
||||||
|
Train->ggInverterToggleButtons[itemindex].UpdateValue(p->MoverParameters->Inverters[itemindex].Activate ? 1.0 : 0.0, Train->dsbSwitch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -5285,15 +5290,8 @@ void TTrain::OnCommand_invertertoggle(TTrain *Train, command_data const &Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
p = (kier ? p->NextC(4) : p->PrevC(4));
|
p = (kier ? p->NextC(flag) : p->PrevC(flag));
|
||||||
}
|
}
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -7576,6 +7574,15 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
for( auto &universal : ggUniversals ) {
|
for( auto &universal : ggUniversals ) {
|
||||||
universal.Update();
|
universal.Update();
|
||||||
}
|
}
|
||||||
|
for (auto &item : ggInverterEnableButtons) {
|
||||||
|
item.Update();
|
||||||
|
}
|
||||||
|
for (auto &item : ggInverterDisableButtons) {
|
||||||
|
item.Update();
|
||||||
|
}
|
||||||
|
for (auto &item : ggInverterToggleButtons) {
|
||||||
|
item.Update();
|
||||||
|
}
|
||||||
for( auto &relayresetbutton : ggRelayResetButtons ) {
|
for( auto &relayresetbutton : ggRelayResetButtons ) {
|
||||||
relayresetbutton.Update();
|
relayresetbutton.Update();
|
||||||
}
|
}
|
||||||
@@ -8849,6 +8856,15 @@ void TTrain::clear_cab_controls()
|
|||||||
for( auto &universal : ggUniversals ) {
|
for( auto &universal : ggUniversals ) {
|
||||||
universal.Clear();
|
universal.Clear();
|
||||||
}
|
}
|
||||||
|
for (auto &item : ggInverterEnableButtons) {
|
||||||
|
item.Clear();
|
||||||
|
}
|
||||||
|
for (auto &item : ggInverterDisableButtons) {
|
||||||
|
item.Clear();
|
||||||
|
}
|
||||||
|
for (auto &item : ggInverterToggleButtons) {
|
||||||
|
item.Clear();
|
||||||
|
}
|
||||||
for( auto &relayresetbutton : ggRelayResetButtons ) {
|
for( auto &relayresetbutton : ggRelayResetButtons ) {
|
||||||
relayresetbutton.Clear();
|
relayresetbutton.Clear();
|
||||||
}
|
}
|
||||||
@@ -9348,6 +9364,35 @@ void TTrain::set_cab_controls( int const Cab ) {
|
|||||||
}
|
}
|
||||||
// radio
|
// radio
|
||||||
ggRadioVolumeSelector.PutValue( Global.RadioVolume );
|
ggRadioVolumeSelector.PutValue( Global.RadioVolume );
|
||||||
|
|
||||||
|
//finding each inverter - not so optimal, but action ins performed only during changing cabin
|
||||||
|
bool kier = (DynamicObject->DirectionGet() * mvOccupied->CabOccupied > 0);
|
||||||
|
int flag = DynamicObject->MoverParameters->InverterControlCouplerFlag;
|
||||||
|
int itemstart = 0;
|
||||||
|
for (auto &item : ggInverterToggleButtons) //for each button
|
||||||
|
{
|
||||||
|
int itemindex = itemstart;
|
||||||
|
itemstart++;
|
||||||
|
TDynamicObject *p = DynamicObject->GetFirstDynamic(mvOccupied->CabOccupied < 0 ? end::rear : end::front, flag);
|
||||||
|
while (p)
|
||||||
|
{
|
||||||
|
if (p->MoverParameters->eimc[eimc_p_Pmax] > 1)
|
||||||
|
{
|
||||||
|
if (itemindex < p->MoverParameters->InvertersNo)
|
||||||
|
{
|
||||||
|
// visual feedback
|
||||||
|
ggInverterToggleButtons[itemindex].PutValue(p->MoverParameters->Inverters[itemindex].Activate ? 1.0 : 0.0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemindex -= p->MoverParameters->InvertersNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
p = (kier ? p->NextC(flag) : p->PrevC(flag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// we reset all indicators, as they're set during the update pass
|
// we reset all indicators, as they're set during the update pass
|
||||||
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
|
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
|
||||||
|
|||||||
Reference in New Issue
Block a user