mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 01:39:19 +02:00
General logic fixes
This commit is contained in:
113
McZapkie/MOVER.h
113
McZapkie/MOVER.h
@@ -833,7 +833,8 @@ private:
|
||||
*/
|
||||
// basic approximation of a generic device
|
||||
// TBD: inheritance or composition?
|
||||
struct basic_device {
|
||||
struct basic_device
|
||||
{
|
||||
// config
|
||||
start_t start_type{start_t::manual};
|
||||
// ld inputs
|
||||
@@ -844,14 +845,16 @@ private:
|
||||
bool is_active{false}; // device is working
|
||||
};
|
||||
|
||||
struct basic_light : public basic_device {
|
||||
struct basic_light : public basic_device
|
||||
{
|
||||
// config
|
||||
float dimming{1.0f}; // light strength multiplier
|
||||
// ld outputs
|
||||
float intensity{0.0f}; // current light strength
|
||||
};
|
||||
|
||||
struct cooling_fan : public basic_device {
|
||||
struct cooling_fan : public basic_device
|
||||
{
|
||||
// config
|
||||
float speed{0.f}; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative
|
||||
float sustain_time{0.f}; // time of sustaining work of cooling fans after stop
|
||||
@@ -862,12 +865,14 @@ private:
|
||||
};
|
||||
|
||||
// basic approximation of a fuel pump
|
||||
struct fuel_pump : public basic_device {
|
||||
struct fuel_pump : public basic_device
|
||||
{
|
||||
// TODO: fuel consumption, optional automatic engine start after activation
|
||||
};
|
||||
|
||||
// basic approximation of an oil pump
|
||||
struct oil_pump : public basic_device {
|
||||
struct oil_pump : public basic_device
|
||||
{
|
||||
// config
|
||||
float pressure_minimum{0.f}; // lowest acceptable working pressure
|
||||
float pressure_maximum{0.65f}; // oil pressure at maximum engine revolutions
|
||||
@@ -880,21 +885,24 @@ private:
|
||||
};
|
||||
|
||||
// basic approximation of a water pump
|
||||
struct water_pump : public basic_device {
|
||||
struct water_pump : public basic_device
|
||||
{
|
||||
// ld inputs
|
||||
// TODO: move to breaker list in the basic device once implemented
|
||||
bool breaker{false}; // device is allowed to operate
|
||||
};
|
||||
|
||||
// basic approximation of a solenoid valve
|
||||
struct basic_valve : basic_device {
|
||||
struct basic_valve : basic_device
|
||||
{
|
||||
// config
|
||||
bool solenoid{true}; // requires electric power to operate
|
||||
bool spring{true}; // spring return or double acting actuator
|
||||
};
|
||||
|
||||
// basic approximation of a pantograph
|
||||
struct basic_pantograph {
|
||||
struct basic_pantograph
|
||||
{
|
||||
// ld inputs
|
||||
basic_valve valve; // associated pneumatic valve
|
||||
// ld outputs
|
||||
@@ -904,7 +912,8 @@ private:
|
||||
};
|
||||
|
||||
// basic approximation of doors
|
||||
struct basic_door {
|
||||
struct basic_door
|
||||
{
|
||||
// config
|
||||
// ld inputs
|
||||
bool open_permit{false}; // door can be opened
|
||||
@@ -928,7 +937,8 @@ private:
|
||||
bool step_unfolding{false}; // the doorstep is currently opening
|
||||
};
|
||||
|
||||
struct door_data {
|
||||
struct door_data
|
||||
{
|
||||
// config
|
||||
control_t open_control{control_t::passenger};
|
||||
float open_rate{1.f};
|
||||
@@ -963,9 +973,11 @@ private:
|
||||
bool is_locked{false};
|
||||
};
|
||||
|
||||
struct water_heater {
|
||||
struct water_heater
|
||||
{
|
||||
// config
|
||||
struct heater_config_t {
|
||||
struct heater_config_t
|
||||
{
|
||||
float temp_min{-1}; // lowest accepted temperature
|
||||
float temp_max{-1}; // highest accepted temperature
|
||||
} config;
|
||||
@@ -977,7 +989,8 @@ private:
|
||||
bool is_damaged{false}; // device is damaged
|
||||
};
|
||||
|
||||
struct heat_data {
|
||||
struct heat_data
|
||||
{
|
||||
// input, state of relevant devices
|
||||
bool cooling{false}; // TODO: user controlled device, implement
|
||||
// bool okienko { true }; // window in the engine compartment
|
||||
@@ -992,9 +1005,11 @@ private:
|
||||
double kfo{25.0};
|
||||
double kfo2{25.0};
|
||||
// system parts
|
||||
struct fluid_circuit_t {
|
||||
struct fluid_circuit_t
|
||||
{
|
||||
|
||||
struct circuit_config_t {
|
||||
struct circuit_config_t
|
||||
{
|
||||
float temp_min{-1}; // lowest accepted temperature
|
||||
float temp_max{-1}; // highest accepted temperature
|
||||
float temp_cooling{-1}; // active cooling activation point
|
||||
@@ -1005,9 +1020,7 @@ private:
|
||||
bool is_warm{false}; // fluid is too hot
|
||||
bool is_hot{false}; // fluid temperature crossed cooling threshold
|
||||
bool is_flowing{false}; // fluid is being pushed through the circuit
|
||||
} water,
|
||||
water_aux,
|
||||
oil;
|
||||
} water, water_aux, oil;
|
||||
// output, state of affected devices
|
||||
bool PA{false}; // malfunction flag
|
||||
float rpmw{0.0}; // current main circuit fan revolutions
|
||||
@@ -1030,7 +1043,8 @@ private:
|
||||
float powerfactor{1.0}; // coefficient of heat generation for engines other than su45
|
||||
};
|
||||
|
||||
struct spring_brake {
|
||||
struct spring_brake
|
||||
{
|
||||
std::shared_ptr<TReservoir> Cylinder;
|
||||
bool Activate{false}; // Input: switching brake on/off in exploitation - main valve/switch
|
||||
bool ShuttOff{true}; // Input: shutting brake off during failure - valve in pneumatic container
|
||||
@@ -1052,11 +1066,9 @@ private:
|
||||
double ValvePNBrakeArea{0.0}; // Conf: Area of bypass to brake cylinders
|
||||
|
||||
int MultiTractionCoupler{127}; // Conf: Coupling flag necessary for transmitting the command
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
double dMoveLen = 0.0;
|
||||
/*---opis lokomotywy, wagonu itp*/
|
||||
/*--opis serii--*/
|
||||
@@ -1099,7 +1111,8 @@ public:
|
||||
int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/
|
||||
int NAxles = 0; /*ilosc wszystkich osi j.w.*/
|
||||
int BearingType = 1; /*lozyska: 0 - slizgowe, 1 - toczne*/
|
||||
double ADist = 0.0; double BDist = 0.0; /*odlegosc osi oraz czopow skretu*/
|
||||
double ADist = 0.0;
|
||||
double BDist = 0.0; /*odlegosc osi oraz czopow skretu*/
|
||||
/*hamulce:*/
|
||||
int NBpA = 0; /*ilosc el. ciernych na os: 0 1 2 lub 4*/
|
||||
int SandCapacity = 0; /*zasobnik piasku [kg]*/
|
||||
@@ -1225,12 +1238,14 @@ public:
|
||||
double WindingRes = 0.0;
|
||||
double u = 0.0; // wspolczynnik tarcia yB wywalic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
double CircuitRes = 0.0; /*rezystancje silnika i obwodu*/
|
||||
int IminLo = 0; int IminHi = 0; /*prady przelacznika automatycznego rozruchu, uzywane tez przez ai_driver*/
|
||||
int IminLo = 0;
|
||||
int IminHi = 0; /*prady przelacznika automatycznego rozruchu, uzywane tez przez ai_driver*/
|
||||
int ImaxLo = 0; // maksymalny prad niskiego rozruchu
|
||||
int ImaxHi = 0; // maksymalny prad wysokiego rozruchu
|
||||
bool MotorOverloadRelayHighThreshold{false};
|
||||
double nmax = 0.0; /*maksymalna dop. ilosc obrotow /s*/
|
||||
double InitialCtrlDelay = 0.0; double CtrlDelay = 0.0; /* -//- -//- miedzy kolejnymi poz.*/
|
||||
double InitialCtrlDelay = 0.0;
|
||||
double CtrlDelay = 0.0; /* -//- -//- miedzy kolejnymi poz.*/
|
||||
double CtrlDownDelay = 0.0; /* -//- -//- przy schodzeniu z poz.*/ /*hunter-101012*/
|
||||
int FastSerialCircuit = 0; /*0 - po kolei zamyka styczniki az do osiagniecia szeregowej, 1 - natychmiastowe wejscie na szeregowa*/ /*hunter-111012*/
|
||||
int BackwardsBranchesAllowed = 1;
|
||||
@@ -1286,7 +1301,9 @@ public:
|
||||
double dizel_FuelConsumption = 0.0; /*współczynnik zużycia paliwa przeliczony do jednostek maszynowych, l/obrót*/
|
||||
double dizel_FuelConsumptionActual = 0.0; /*chwilowe spalanie paliwa w l/h*/
|
||||
double dizel_FuelConsumptedTotal = 0.0; /*ilość paliwa zużyta od początku symulacji, l*/
|
||||
double dizel_engageDia = 0.5; double dizel_engageMaxForce = 6000.0; double dizel_engagefriction = 0.5; /*parametry sprzegla*/
|
||||
double dizel_engageDia = 0.5;
|
||||
double dizel_engageMaxForce = 6000.0;
|
||||
double dizel_engagefriction = 0.5; /*parametry sprzegla*/
|
||||
double engagedownspeed = 0.9;
|
||||
double engageupspeed = 0.5;
|
||||
/*parametry przetwornika momentu*/
|
||||
@@ -1366,26 +1383,30 @@ public:
|
||||
double DCEMUED_EP_delay{0.0}; // opóźnienie włączenia hamulca EP przy hamowaniu ED - zwłoka wstępna
|
||||
|
||||
/*-dla wagonow*/
|
||||
struct load_attributes {
|
||||
struct load_attributes
|
||||
{
|
||||
std::string name; // name of the cargo
|
||||
float offset_min{0.f}; // offset applied to cargo model when load amount is 0
|
||||
|
||||
load_attributes() = default;
|
||||
load_attributes( std::string const &Name, float const Offsetmin ) :
|
||||
name( Name ), offset_min( Offsetmin )
|
||||
{}
|
||||
load_attributes(std::string const &Name, float const Offsetmin) : name(Name), offset_min(Offsetmin) {}
|
||||
};
|
||||
std::vector<load_attributes> LoadAttributes;
|
||||
float MaxLoad = 0.f; /*masa w T lub ilosc w sztukach - ladownosc*/
|
||||
double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/
|
||||
float LoadSpeed = 0.f; float UnLoadSpeed = 0.f;/*szybkosc na- i rozladunku jednostki/s*/
|
||||
float LoadSpeed = 0.f;
|
||||
float UnLoadSpeed = 0.f; /*szybkosc na- i rozladunku jednostki/s*/
|
||||
#ifdef EU07_USEOLDDOORCODE
|
||||
int DoorOpenCtrl = 0; int DoorCloseCtrl = 0; /*0: przez pasazera, 1: przez maszyniste, 2: samoczynne (zamykanie)*/
|
||||
int DoorOpenCtrl = 0;
|
||||
int DoorCloseCtrl = 0; /*0: przez pasazera, 1: przez maszyniste, 2: samoczynne (zamykanie)*/
|
||||
double DoorStayOpen = 0.0; /*jak dlugo otwarte w przypadku DoorCloseCtrl=2*/
|
||||
bool DoorClosureWarning = false; /*czy jest ostrzeganie przed zamknieciem*/
|
||||
bool DoorClosureWarningAuto = false; // departure signal plays automatically while door closing button is held down
|
||||
double DoorOpenSpeed = 1.0; double DoorCloseSpeed = 1.0; /*predkosc otwierania i zamykania w j.u. */
|
||||
double DoorMaxShiftL = 0.5; double DoorMaxShiftR = 0.5; double DoorMaxPlugShift = 0.1;/*szerokosc otwarcia lub kat*/
|
||||
double DoorOpenSpeed = 1.0;
|
||||
double DoorCloseSpeed = 1.0; /*predkosc otwierania i zamykania w j.u. */
|
||||
double DoorMaxShiftL = 0.5;
|
||||
double DoorMaxShiftR = 0.5;
|
||||
double DoorMaxPlugShift = 0.1; /*szerokosc otwarcia lub kat*/
|
||||
int DoorOpenMethod = 2; /*sposob otwarcia - 1: przesuwne, 2: obrotowe, 3: trójelementowe*/
|
||||
float DoorCloseDelay{0.f}; // delay (in seconds) before the door begin closing, once conditions to close are met
|
||||
double PlatformSpeed = 0.5; /*szybkosc stopnia*/
|
||||
@@ -1429,12 +1450,16 @@ public:
|
||||
bool TruckHunting{true}; // enable/disable truck hunting calculation
|
||||
/*! rotacja kol [obr/s]*/
|
||||
double EnginePower = 0.0; /*! chwilowa moc silnikow*/
|
||||
double dL = 0.0; double Fb = 0.0; double Ff = 0.0; /*przesuniecie, sila hamowania i tarcia*/
|
||||
double FTrain = 0.0; double FStand = 0.0; /*! sila pociagowa i oporow ruchu*/
|
||||
double dL = 0.0;
|
||||
double Fb = 0.0;
|
||||
double Ff = 0.0; /*przesuniecie, sila hamowania i tarcia*/
|
||||
double FTrain = 0.0;
|
||||
double FStand = 0.0; /*! sila pociagowa i oporow ruchu*/
|
||||
double FTotal = 0.0; /*! calkowita sila dzialajaca na pojazd*/
|
||||
double UnitBrakeForce = 0.0; /*!s siła hamowania przypadająca na jeden element*/
|
||||
double Ntotal = 0.0; /*!s siła nacisku klockow*/
|
||||
bool SlippingWheels = false; bool SandDose = false; /*! poslizg kol, sypanie piasku*/
|
||||
bool SlippingWheels = false;
|
||||
bool SandDose = false; /*! poslizg kol, sypanie piasku*/
|
||||
bool SandDoseManual = false; /*piaskowanie reczne*/
|
||||
bool SandDoseAuto = false; /*piaskowanie automatyczne*/
|
||||
bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/
|
||||
@@ -1517,7 +1542,6 @@ public:
|
||||
double LimPipePress = 0.0; /*stabilizator cisnienia*/
|
||||
double ActFlowSpeed = 0.0; /*szybkosc stabilizatora*/
|
||||
|
||||
|
||||
int DamageFlag = 0; // kombinacja bitowa stalych dtrain_* }
|
||||
int EngDmgFlag = 0; // kombinacja bitowa stalych usterek}
|
||||
int DerailReason = 0; // przyczyna wykolejenia
|
||||
@@ -1533,7 +1557,8 @@ public:
|
||||
|
||||
TTrackShape RunningShape; /*geometria toru po ktorym jedzie pojazd*/
|
||||
TTrackParam RunningTrack; /*parametry toru po ktorym jedzie pojazd*/
|
||||
double OffsetTrackH = 0.0; double OffsetTrackV = 0.0; /*przesuniecie poz. i pion. w/m osi toru*/
|
||||
double OffsetTrackH = 0.0;
|
||||
double OffsetTrackV = 0.0; /*przesuniecie poz. i pion. w/m osi toru*/
|
||||
|
||||
/*-zmienne dla lokomotyw*/
|
||||
bool Mains = false; /*polozenie glownego wylacznika*/
|
||||
@@ -1554,7 +1579,10 @@ public:
|
||||
int CabActive = 0; // numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
|
||||
int CabOccupied = 0; // numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController
|
||||
bool CabMaster = false; // czy pojazd jest nadrzędny w składzie
|
||||
inline bool IsCabMaster() { return ((CabActive == CabOccupied) && CabMaster); } //czy aktualna kabina jest na pewno tą, z której można sterować
|
||||
inline bool IsCabMaster()
|
||||
{
|
||||
return ((CabActive == CabOccupied) && CabMaster);
|
||||
} // czy aktualna kabina jest na pewno tą, z której można sterować
|
||||
bool AutomaticCabActivation = true; // czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny
|
||||
int InactiveCabFlag = 0; // co sie dzieje przy dezaktywacji kabiny
|
||||
bool InactiveCabPantsCheck = false; // niech DynamicObject sprawdzi pantografy
|
||||
@@ -1582,7 +1610,8 @@ public:
|
||||
// Ra: Im jest ujemny, jeśli lok jedzie w stronę sprzęgu 1
|
||||
// a ujemne powinien być przy odwróconej polaryzacji sieci...
|
||||
// w wielu miejscach jest używane abs(Im)
|
||||
int Imin = 0; int Imax = 0; /*prad przelaczania automatycznego rozruchu, prad bezpiecznika*/
|
||||
int Imin = 0;
|
||||
int Imax = 0; /*prad przelaczania automatycznego rozruchu, prad bezpiecznika*/
|
||||
double EngineVoltage = 0.0; // voltage supplied to engine
|
||||
int MainCtrlActualPos = 0; /*wskaznik RList*/
|
||||
int ScndCtrlActualPos = 0; /*wskaznik MotorParam*/
|
||||
@@ -1712,8 +1741,8 @@ public:
|
||||
// 3 - swiatla dlugie przyciemnione
|
||||
// 4 - swiatla dlugie normalne
|
||||
int modernDimmerState{0};
|
||||
bool modernContainOffPos = true;
|
||||
bool enableModernDimmer = false;
|
||||
bool modernContainOffPos{true};
|
||||
bool enableModernDimmer {false};
|
||||
|
||||
// Barwa reflektora
|
||||
int refR{255}; // Czerwony
|
||||
|
||||
@@ -9944,6 +9944,13 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
else
|
||||
result = false;
|
||||
|
||||
if (!modernContainOffPos)
|
||||
modernDimmerState = 1;
|
||||
if (!enableModernDimmer)
|
||||
{
|
||||
modernDimmerState = 2;
|
||||
}
|
||||
|
||||
WriteLog("CERROR: " + to_string(ConversionError) + ", SUCCES: " + to_string(result));
|
||||
return result;
|
||||
}
|
||||
@@ -11139,10 +11146,6 @@ void TMoverParameters::LoadFIZ_Switches( std::string const &Input ) {
|
||||
extract_value( UniversalResetButtonFlag[ 2 ], "RelayResetButton3", Input, "" );
|
||||
extract_value(enableModernDimmer, "ModernDimmer", Input, "");
|
||||
extract_value(modernContainOffPos, "ModernDimmerOffPosition", Input, "");
|
||||
if (!modernContainOffPos)
|
||||
modernDimmerState = 1;
|
||||
if (!enableModernDimmer)
|
||||
modernDimmerState = 2;
|
||||
// pantograph presets
|
||||
{
|
||||
auto &presets { PantsPreset.first };
|
||||
|
||||
26
Train.cpp
26
Train.cpp
@@ -4918,10 +4918,12 @@ void TTrain::OnCommand_endsignalstoggle( TTrain *Train, command_data const &Comm
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if (Train->DynamicObject->MoverParameters->enableModernDimmer)
|
||||
return;
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
if( false == Train->DynamicObject->DimHeadlights ) {
|
||||
if (Train->DynamicObject->MoverParameters->modernDimmerState == 2)
|
||||
{
|
||||
// turn on
|
||||
OnCommand_headlightsdimenable( Train, Command );
|
||||
}
|
||||
@@ -4934,6 +4936,8 @@ void TTrain::OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &C
|
||||
|
||||
void TTrain::OnCommand_headlightsdimenable( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if (Train->DynamicObject->MoverParameters->enableModernDimmer)
|
||||
return;
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
if( Train->ggDimHeadlightsButton.SubModel != nullptr ) {
|
||||
@@ -4950,13 +4954,18 @@ void TTrain::OnCommand_headlightsdimenable( TTrain *Train, command_data const &C
|
||||
|
||||
Train->DynamicObject->DimHeadlights = true;
|
||||
*/
|
||||
|
||||
Train->mvOccupied->modernDimmerState = 1; // ustawiamy modern dimmer na flage przyciemnienia
|
||||
WriteLog("Switch do 1");
|
||||
Train->DynamicObject->MoverParameters->modernDimmerState = 1; // ustawiamy modern dimmer na flage przyciemnienia
|
||||
Train->DynamicObject->RaLightsSet(Train->DynamicObject->MoverParameters->iLights[0],
|
||||
Train->DynamicObject->MoverParameters->iLights[1]
|
||||
); // aktualizacja swiatelek
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_headlightsdimdisable( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if (Train->DynamicObject->MoverParameters->enableModernDimmer) // nie wiem dlaczego to tak dziala ze jest odwrocona logika
|
||||
return;
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
if( Train->ggDimHeadlightsButton.SubModel != nullptr ) {
|
||||
@@ -4972,7 +4981,12 @@ void TTrain::OnCommand_headlightsdimdisable( TTrain *Train, command_data const &
|
||||
Train->DynamicObject->DimHeadlights = false;
|
||||
|
||||
*/
|
||||
Train->mvOccupied->modernDimmerState = 2; // ustawiamy modern dimmer na flage rozjasnienia
|
||||
WriteLog("Switch do 2");
|
||||
Train->DynamicObject->MoverParameters->modernDimmerState = 2; // ustawiamy modern dimmer na flage rozjasnienia
|
||||
Train->DynamicObject->RaLightsSet(
|
||||
Train->DynamicObject->MoverParameters->iLights[0],
|
||||
Train->DynamicObject->MoverParameters->iLights[1]
|
||||
); // aktualizacja swiatelek
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9816,7 +9830,7 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
ggRightLightButton.PutValue( -1.f );
|
||||
}
|
||||
}
|
||||
if( true == DynamicObject->DimHeadlights ) {
|
||||
if( 1 == DynamicObject->MoverParameters->modernDimmerState ) {
|
||||
ggDimHeadlightsButton.PutValue( 1.f );
|
||||
}
|
||||
// cab lights
|
||||
|
||||
Reference in New Issue
Block a user