16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 03:39:17 +02:00

build 170428. command propagation based on coupler type, minor bug fixes

This commit is contained in:
tmj-fstate
2017-04-28 18:37:36 +02:00
parent 3e000eae29
commit 59db98e726
4 changed files with 159 additions and 122 deletions

View File

@@ -2468,11 +2468,12 @@ bool TDynamicObject::Update(double dt, double dt1)
// Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5
if( true == MoverParameters->PantPressSwitchActive ) {
// opuszczenie pantografów przy niskim ciśnieniu
MoverParameters->PantFront( false, MoverParameters->TrainType == dt_EZT );
MoverParameters->PantRear( false, MoverParameters->TrainType == dt_EZT );
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
// pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage
if( MoverParameters->GetTrainsetVoltage() == 0.0 ) {
MoverParameters->MainSwitch( false, false );
if( MoverParameters->GetTrainsetVoltage() < 0.5 * MoverParameters->EnginePowerSource.MaxVoltage ) {
// TODO: check whether line breaker should be open EMU-wide
MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
}
// mark the pressure switch as spent
MoverParameters->PantPressSwitchActive = false;
@@ -2931,15 +2932,15 @@ bool TDynamicObject::Update(double dt, double dt1)
&& ( MoverParameters->EngineType != DieselEngine )
&& ( MoverParameters->EngineType != WheelsDriven ) )
{ // jeśli bateria wyłączona, a nie diesel ani drezyna reczna
if( MoverParameters->MainSwitch( false, MoverParameters->TrainType == dt_EZT ) ) {
if( MoverParameters->MainSwitch( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) {
// wyłączyć zasilanie
// NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists
MoverParameters->EventFlag = true;
// drop pantographs
// NOTE: this isn't universal behaviour
// TODO: have this dependant on .fiz-driven flag
MoverParameters->PantFront( false, MoverParameters->TrainType == dt_EZT );
MoverParameters->PantRear( false, MoverParameters->TrainType == dt_EZT );
MoverParameters->PantFront( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
}
}
if (MoverParameters->TrainType == dt_ET42)
@@ -4148,22 +4149,20 @@ void TDynamicObject::RenderSounds()
sConverter.TurnOff(MechInside, GetPosition());
sConverter.Update(MechInside, GetPosition());
}
if (MoverParameters->WarningSignal > 0)
{
if (TestFlag(MoverParameters->WarningSignal, 1))
sHorn1.TurnOn(MechInside, GetPosition());
else
sHorn1.TurnOff(MechInside, GetPosition());
if (TestFlag(MoverParameters->WarningSignal, 2))
sHorn2.TurnOn(MechInside, GetPosition());
else
sHorn2.TurnOff(MechInside, GetPosition());
if( TestFlag( MoverParameters->WarningSignal, 1 ) ) {
sHorn1.TurnOn( MechInside, GetPosition() );
}
else
{
sHorn1.TurnOff(MechInside, GetPosition());
sHorn2.TurnOff(MechInside, GetPosition());
else {
sHorn1.TurnOff( MechInside, GetPosition() );
}
if( TestFlag( MoverParameters->WarningSignal, 2 ) ) {
sHorn2.TurnOn( MechInside, GetPosition() );
}
else {
sHorn2.TurnOff( MechInside, GetPosition() );
}
if (MoverParameters->DoorClosureWarning)
{
if (MoverParameters->DepartureSignal) // NBMX sygnal odjazdu, MC: pod warunkiem ze jest

View File

@@ -149,6 +149,12 @@ enum coupling {
mainhose = 0x20,
heating = 0x40,
permanent = 0x80
};
/*! przesylanie komend sterujacych*/
enum command_range {
local,
unit,
consist
};
/*typ hamulca elektrodynamicznego*/
static int const dbrake_none = 0;
@@ -279,7 +285,8 @@ struct TCommand
std::string Command; /*komenda*/
double Value1 = 0.0; /*argumenty komendy*/
double Value2 = 0.0;
TLocation Location;
int Coupling{ ctrain_controll }; // coupler flag used to determine command propagation
TLocation Location;
};
/*tory*/
@@ -1012,11 +1019,11 @@ public:
/*! przesylanie komend sterujacych*/
bool SendCtrlBroadcast(std::string CtrlCommand, double ctrlvalue);
bool SendCtrlToNext(std::string CtrlCommand, double ctrlvalue, double dir);
bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2);
bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = ctrain_controll);
bool SetInternalCommand( std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = ctrain_controll );
double GetExternalCommand(std::string &Command);
bool RunCommand(std::string Command, double CValue1, double CValue2);
bool RunInternalCommand(void);
bool RunCommand( std::string Command, double CValue1, double CValue2, int const Couplertype = ctrain_controll );
bool RunInternalCommand();
void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation);
bool CabActivisation(void);
bool CabDeactivisation(void);
@@ -1088,7 +1095,7 @@ public:
/*--funkcje dla lokomotyw*/
bool DirectionBackward(void);/*! kierunek ruchu*/
bool MainSwitch( bool const State, bool const Multiunitcontrol = true );/*! wylacznik glowny*/
bool MainSwitch( bool const State, int const Notify = command_range::consist );/*! wylacznik glowny*/
bool ConverterSwitch(bool State);/*! wl/wyl przetwornicy*/
bool CompressorSwitch(bool State);/*! wl/wyl sprezarki*/
@@ -1116,8 +1123,8 @@ public:
bool AutoRelayCheck(void);//symulacja automatycznego rozruchu
bool ResistorsFlagCheck(void); //sprawdzenie kontrolki oporow rozruchowych NBMX
bool PantFront(bool const State, bool const Multiunitcontrol = true ); //obsluga pantografou przedniego
bool PantRear(bool const State, bool const Multiunitcontrol = true ); //obsluga pantografu tylnego
bool PantFront( bool const State, int const Notify = command_range::consist ); //obsluga pantografou przedniego
bool PantRear( bool const State, int const Notify = command_range::consist ); //obsluga pantografu tylnego
/*-funkcje typowe dla lokomotywy spalinowej z przekladnia mechaniczna*/
bool dizel_EngageSwitch(double state);

View File

@@ -744,9 +744,9 @@ void TMoverParameters::UpdatePantVolume(double dt)
if( ( true == PantPressSwitchActive )
&& ( PantPress < EnginePowerSource.CollectorParameters.MinPress ) ) {
// wywalenie szybkiego z powodu niskiego ciśnienia
if( GetTrainsetVoltage() < EnginePowerSource.CollectorParameters.MinV ) {
if( GetTrainsetVoltage() < 0.5 * EnginePowerSource.MaxVoltage ) {
// to jest trochę proteza; zasilanie członu może być przez sprzęg WN
if( MainSwitch( false, TrainType == dt_EZT ) ) {
if( MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) {
EventFlag = true;
}
}
@@ -1522,7 +1522,7 @@ void TMoverParameters::ConverterCheck()
{ // sprawdzanie przetwornicy
if( ( ConverterAllow )
&& ( ( Mains )
|| ( GetTrainsetVoltage() > 0.5 * EnginePowerSource.MaxVoltage ) ) ) {
|| ( GetTrainsetVoltage() > 0.5 * EnginePowerSource.MaxVoltage ) ) ) {
ConverterFlag = true;
}
else {
@@ -2271,7 +2271,7 @@ bool TMoverParameters::AntiSlippingButton(void)
// Q: 20160713
// włączenie / wyłączenie obwodu głownego
// *************************************************************************************************
bool TMoverParameters::MainSwitch( bool const State, bool const Multiunitcontrol )
bool TMoverParameters::MainSwitch( bool const State, int const Notify )
{
bool MS;
@@ -2285,17 +2285,25 @@ bool TMoverParameters::MainSwitch( bool const State, bool const Multiunitcontrol
{
if( Mains ) {
// jeśli był załączony
if( true == Multiunitcontrol ) {
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext( "MainSwitch", int( State ), CabNo );
SendCtrlToNext(
"MainSwitch", int( State ), CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
Mains = State;
if( Mains ) {
// jeśli został załączony
if( true == Multiunitcontrol ) {
// wyslanie po wlaczeniu albo przed wylaczeniem
SendCtrlToNext( "MainSwitch", int( State ), CabNo );
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext(
"MainSwitch", int( State ), CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
MS = true; // wartość zwrotna
@@ -4068,7 +4076,7 @@ double TMoverParameters::TractionForce(double dt)
if ( (std::max(GetTrainsetVoltage(), std::abs(Voltage)) < EnginePowerSource.CollectorParameters.MinV) ||
(std::max(GetTrainsetVoltage(), std::abs(Voltage)) * EnginePowerSource.CollectorParameters.OVP >
EnginePowerSource.CollectorParameters.MaxV))
if (MainSwitch(false, TrainType == dt_EZT)) // TODO: check whether we need to send this EMU-wide
if( MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ) ) // TODO: check whether we need to send this EMU-wide
EventFlag = true; // wywalanie szybkiego z powodu niewłaściwego napięcia
if (((DynamicBrakeType == dbrake_automatic) || (DynamicBrakeType == dbrake_switch)) &&
@@ -4355,7 +4363,7 @@ double TMoverParameters::TractionForce(double dt)
// nie wchodzić w funkcję bez potrzeby
if( ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) < EnginePowerSource.CollectorParameters.MinV )
|| ( std::max( std::abs( Voltage ), GetTrainsetVoltage() ) > EnginePowerSource.CollectorParameters.MaxV + 200 ) ) {
MainSwitch( false, TrainType == dt_EZT ); // TODO: check whether we need to send this EMU-wide
MainSwitch( false, ( TrainType == dt_EZT ? command_range::unit : command_range::local ) ); // TODO: check whether we need to send this EMU-wide
}
}
tmpV = abs(nrot) * (PI * WheelDiameter) * 3.6; //*DirAbsolute*eimc[eimc_s_p]; - do przemyslenia dzialanie pp
@@ -5069,7 +5077,7 @@ bool TMoverParameters::AutoRelayCheck(void)
// Q: 20160713
// Podnosi / opuszcza przedni pantograf. Returns: state of the pantograph after the operation
// *************************************************************************************************
bool TMoverParameters::PantFront(bool const State, bool const Multiunitcontrol)
bool TMoverParameters::PantFront( bool const State, int const Notify )
{
/*
if( ( true == Battery )
@@ -5079,14 +5087,24 @@ bool TMoverParameters::PantFront(bool const State, bool const Multiunitcontrol)
PantFrontUp = State;
if( State == true ) {
PantFrontStart = 0;
if( true == Multiunitcontrol ) {
SendCtrlToNext( "PantFront", 1, CabNo );
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext(
"PantFront", 1, CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
else {
PantFrontStart = 1;
if( true == Multiunitcontrol ) {
SendCtrlToNext( "PantFront", 0, CabNo );
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext(
"PantFront", 0, CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
}
@@ -5112,7 +5130,7 @@ bool TMoverParameters::PantFront(bool const State, bool const Multiunitcontrol)
// Q: 20160713
// Podnoszenie / opuszczanie pantografu tylnego
// *************************************************************************************************
bool TMoverParameters::PantRear(bool const State, bool const Multiunitcontrol)
bool TMoverParameters::PantRear( bool const State, int const Notify )
{
/*
if( ( true == Battery )
@@ -5122,14 +5140,24 @@ bool TMoverParameters::PantRear(bool const State, bool const Multiunitcontrol)
PantRearUp = State;
if( State == true ) {
PantRearStart = 0;
if( true == Multiunitcontrol ) {
SendCtrlToNext( "PantRear", 1, CabNo );
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext(
"PantRear", 1, CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
else {
PantRearStart = 1;
if( true == Multiunitcontrol ) {
SendCtrlToNext( "PantRear", 0, CabNo );
if( Notify != command_range::local ) {
// wysłanie wyłączenia do pozostałych?
SendCtrlToNext(
"PantRear", 0, CabNo,
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll ) );
}
}
}
@@ -7653,18 +7681,20 @@ bool TMoverParameters::SendCtrlBroadcast(std::string CtrlCommand, double ctrlval
// Q: 20160714
// Ustawienie komendy wraz z parametrami
// *************************************************************************************************
bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1,
double NewValue2)
bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype)
{
bool SIC;
if ((CommandIn.Command == NewCommand) && (CommandIn.Value1 == NewValue1) &&
(CommandIn.Value2 == NewValue2))
if( ( CommandIn.Command == NewCommand )
&& ( CommandIn.Value1 == NewValue1 )
&& ( CommandIn.Value2 == NewValue2 )
&& ( CommandIn.Coupling == Couplertype ) )
SIC = false;
else
{
CommandIn.Command = NewCommand;
CommandIn.Value1 = NewValue1;
CommandIn.Value2 = NewValue2;
CommandIn.Coupling = Couplertype;
SIC = true;
LastLoadChangeTime = 0; // zerowanie czasu (roz)ładowania
}
@@ -7676,7 +7706,7 @@ bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValu
// Q: 20160714
// wysyłanie komendy w kierunku dir (1=przód, -1=tył) do kolejnego pojazdu (jednego)
// *************************************************************************************************
bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue, double dir ) {
bool TMoverParameters::SendCtrlToNext( std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype ) {
bool OK;
int d; // numer sprzęgu w kierunku którego wysyłamy
@@ -7687,15 +7717,15 @@ bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue
if( OK ) {
// musi być wybrana niezerowa kabina
if( ( Couplers[ d ].Connected != nullptr )
&& ( TestFlag( Couplers[ d ].CouplingFlag, ctrain_controll ) ) ) {
&& ( TestFlag( Couplers[ d ].CouplingFlag, Couplertype ) ) ) {
if( Couplers[ d ].ConnectedNr != d ) {
// jeśli ten nastpęny jest zgodny z aktualnym
if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, dir ) )
if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, dir, Couplertype ) )
OK = ( Couplers[ d ].Connected->RunInternalCommand() && OK ); // tu jest rekurencja
}
else {
// jeśli następny jest ustawiony przeciwnie, zmieniamy kierunek
if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, -dir ) )
if( Couplers[ d ].Connected->SetInternalCommand( CtrlCommand, ctrlvalue, -dir, Couplertype ) )
OK = ( Couplers[ d ].Connected->RunInternalCommand() && OK ); // tu jest rekurencja
}
}
@@ -7714,7 +7744,7 @@ bool TMoverParameters::SendCtrlToNext( std::string CtrlCommand, double ctrlvalue
// Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może
// sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania
// jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę.
bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CValue2)
bool TMoverParameters::RunCommand( std::string Command, double CValue1, double CValue2, int const Couplertype )
{
bool OK;
std::string testload;
@@ -7724,7 +7754,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
{
if (MainCtrlPosNo >= floor(CValue1))
MainCtrlPos = static_cast<int>(floor(CValue1));
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "ScndCtrl")
{
@@ -7738,7 +7768,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
ScndCtrlActualPos = 0;
if (ScndCtrlPosNo >= floor(CValue1))
ScndCtrlPos = static_cast<int>(floor(CValue1));
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
/* else if command='BrakeCtrl' then
begin
@@ -7753,7 +7783,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
Hamulec->SetEPS(CValue1);
// fBrakeCtrlPos:=BrakeCtrlPos; //to powinnno być w jednym miejscu, aktualnie w C++!!!
BrakePressureActual = BrakePressureTable[BrakeCtrlPos];
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} // youby - odluzniacz hamulcow, przyda sie
else if (Command == "BrakeReleaser")
{
@@ -7770,13 +7800,13 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else
Mains = false;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "Direction")
{
ActiveDir = static_cast<int>(floor(CValue1));
DirAbsolute = ActiveDir * CabNo;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "CabActivisation")
{
@@ -7797,7 +7827,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
}
DirAbsolute = ActiveDir * CabNo;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "AutoRelaySwitch")
{
@@ -7805,7 +7835,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
AutoRelayFlag = true;
else
AutoRelayFlag = false;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "FuseSwitch")
{
@@ -7817,7 +7847,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
// if ((EngineType=ElectricSeriesMotor)or(EngineType=DieselElectric)) and not FuseFlag and
// (CValue1=0) and Mains then
// FuseFlag:=true;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "ConverterSwitch") /*NBMX*/
{
@@ -7825,7 +7855,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
ConverterAllow = true;
else if ((CValue1 == 0))
ConverterAllow = false;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "BatterySwitch") /*NBMX*/
{
@@ -7837,7 +7867,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
SecuritySystem.Status = SecuritySystem.Status || s_waiting; // aktywacja czuwaka
else
SecuritySystem.Status = 0; // wyłączenie czuwaka
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
// else if command='EpFuseSwitch' then {NBMX}
// begin
@@ -7851,7 +7881,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
CompressorAllow = true;
else if ((CValue1 == 0))
CompressorAllow = false;
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "DoorOpen") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
@@ -7869,7 +7899,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if ((CValue1 == 1) || (CValue1 == 3))
DoorRightOpened = true;
}
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "DoorClose") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
@@ -7887,7 +7917,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if ((CValue1 == 1) || (CValue1 == 3))
DoorRightOpened = false;
}
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "PantFront") /*Winger 160204*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
@@ -7932,7 +7962,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
PantRearStart = 1;
}
}
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "PantRear") /*Winger 160204, ABu 310105 i 030305*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
@@ -7977,7 +8007,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
PantFrontStart = 1;
}
}
OK = SendCtrlToNext(Command, CValue1, CValue2);
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "MaxCurrentSwitch")
{
@@ -8063,19 +8093,19 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
// Q: 20160714
// Uruchamia funkcję RunCommand aż do skutku. Jeśli będzie pozytywny to kasuje komendę.
// *************************************************************************************************
bool TMoverParameters::RunInternalCommand(void)
bool TMoverParameters::RunInternalCommand()
{
bool OK;
if (!CommandIn.Command.empty())
{
OK = RunCommand(CommandIn.Command, CommandIn.Value1, CommandIn.Value2);
if (OK)
OK = RunCommand( CommandIn.Command, CommandIn.Value1, CommandIn.Value2, CommandIn.Coupling );
if (OK) {
{
CommandIn.Command.clear(); // kasowanie bo rozkaz wykonany
CommandIn.Value1 = 0;
CommandIn.Value2 = 0;
CommandIn.Coupling = 0;
CommandIn.Location.X = 0;
CommandIn.Location.Y = 0;
CommandIn.Location.Z = 0;

View File

@@ -2783,7 +2783,7 @@ void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Comma
else if( Command.action == GLFW_RELEASE ) {
// turn off
// 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 );
Train->mvOccupied->WarningSignal &= ~( 1 | 2 );
// audio feedback
if( ( Train->ggHornButton.GetValue() < -0.5 )
|| ( Train->ggHornLowButton.GetValue() > 0.5 ) ) {
@@ -2826,14 +2826,14 @@ void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Comm
else if( Command.action == GLFW_RELEASE ) {
// turn off
// 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 );
Train->mvOccupied->WarningSignal &= ~( 1 | 2 );
// audio feedback
if( Train->ggHornButton.GetValue() > 0.5 ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
Train->ggHornButton.UpdateValue( 0.0 );
Train->ggHornButton.UpdateValue( 0.0 );
Train->ggHornHighButton.UpdateValue( 0.0 );
}
}
@@ -3507,45 +3507,6 @@ bool TTrain::Update( double const Deltatime )
DWORD stat;
double dt = Deltatime; // Timer::GetDeltaTime();
// catch cases where the power goes out, and the linebreaker state is left as closed
if( ( m_linebreakerstate == 1 )
&& ( false == mvControlled->Mains )
&& ( ggMainButton.GetValue() < 0.05 ) ) {
// crude way to catch cases where the main was knocked out and the user is trying to restart it
// because the state of the line breaker isn't changed to match, we need to do it here manually
m_linebreakerstate = 0;
}
// NOTE: crude way to have the pantographs go back up if they're dropped due to insufficient pressure etc
// TODO: rework it into something more elegant, when redoing the whole consist/unit/cab etc arrangement
if( ( mvControlled->Battery )
|| ( mvControlled->ConverterFlag ) ) {
if( ( false == mvControlled->PantFrontUp )
&& ( ggPantFrontButton.GetValue() > 0.95 ) ) {
mvControlled->PantFront( true );
}
if( ( false == mvControlled->PantRearUp )
&& ( ggPantRearButton.GetValue() > 0.95 ) ) {
mvControlled->PantRear( true );
}
}
/*
// NOTE: disabled while switch state isn't preserved while moving between compartments
// check whether we should raise the pantographs, based on volume in pantograph tank
if( mvControlled->PantPress > (
mvControlled->TrainType == dt_EZT ?
2.4 :
3.5 ) ) {
if( ( false == mvControlled->PantFrontUp )
&& ( ggPantFrontButton.GetValue() > 0.95 ) ) {
mvControlled->PantFront( true );
}
if( ( false == mvControlled->PantRearUp )
&& ( ggPantRearButton.GetValue() > 0.95 ) ) {
mvControlled->PantRear( true );
}
}
*/
if (DynamicObject->mdKabina)
{ // Ra: TODO: odczyty klawiatury/pulpitu nie
// powinny być uzależnione od istnienia modelu
@@ -3780,7 +3741,7 @@ bool TTrain::Update( double const Deltatime )
// TODO: check whether it should affect entire consist for EMU
// TODO: check whether it should happen if there's power supplied alternatively through hvcouplers
// TODO: potentially move this to the mover module, as there isn't much reason to have this dependent on the operator presence
mvControlled->MainSwitch( false, false );
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
}
}
@@ -3811,7 +3772,7 @@ bool TTrain::Update( double const Deltatime )
{
mvControlled->ConvOvldFlag = true;
if (mvControlled->TrainType != dt_EZT)
mvControlled->MainSwitch(false, mvControlled->TrainType == dt_EZT);
mvControlled->MainSwitch( false, ( mvControlled->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
}
else if( fConverterTimer >= fConverterPrzekaznik ) {
// changed switch from always true to take into account state of the compressor switch
@@ -5827,6 +5788,46 @@ bool TTrain::Update( double const Deltatime )
}
}
// catch cases where the power goes out, and the linebreaker state is left as closed
if( ( m_linebreakerstate == 1 )
&& ( false == mvControlled->Mains )
&& ( ggMainButton.GetValue() < 0.05 ) ) {
// crude way to catch cases where the main was knocked out and the user is trying to restart it
// because the state of the line breaker isn't changed to match, we need to do it here manually
m_linebreakerstate = 0;
}
// NOTE: crude way to have the pantographs go back up if they're dropped due to insufficient pressure etc
// TODO: rework it into something more elegant, when redoing the whole consist/unit/cab etc arrangement
if( ( mvControlled->Battery )
|| ( mvControlled->ConverterFlag ) ) {
if( ( false == mvControlled->PantFrontUp )
&& ( ggPantFrontButton.GetValue() >= 1.0 ) ) {
mvControlled->PantFront( true );
}
if( ( false == mvControlled->PantRearUp )
&& ( ggPantRearButton.GetValue() >= 1.0 ) ) {
mvControlled->PantRear( true );
}
}
/*
// NOTE: disabled while switch state isn't preserved while moving between compartments
// check whether we should raise the pantographs, based on volume in pantograph tank
if( mvControlled->PantPress > (
mvControlled->TrainType == dt_EZT ?
2.4 :
3.5 ) ) {
if( ( false == mvControlled->PantFrontUp )
&& ( ggPantFrontButton.GetValue() > 0.95 ) ) {
mvControlled->PantFront( true );
}
if( ( false == mvControlled->PantRearUp )
&& ( ggPantRearButton.GetValue() > 0.95 ) ) {
mvControlled->PantRear( true );
}
}
*/
m_updated = true;
return true; //(DynamicObject->Update(dt));
} // koniec update