Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implot graphing library dependency. Update imgui dependency. Add … #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ project("eu07")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -Wformat")
#set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -fsanitize=address -fsanitize=undefined")



set(CMAKE_CXX_STANDARD 17)
include_directories("."
"Console"
Expand All @@ -39,6 +41,19 @@ file(GLOB HEADERS "*.h"
"network/backend/*.h"
"widgets/*.h"
"launcher/*.h"

"imgui/imconfig.h"
"imgui/imgui.h"
"imgui/imgui_impl_glfw.h"
"imgui/imgui_impl_opengl3.h"
"imgui/imgui_impl_opengl3_loader.h"
"imgui/imgui_internal.h"
"imgui/implot.h"
"imgui/implot_internal.h"
"imgui/imstb_rectpack.h"
"imgui/imstb_textedit.h"
"imgui/imstb_truetype.h"

"extras/*.h")

if (APPLE)
Expand Down Expand Up @@ -182,11 +197,14 @@ set(SOURCES
"gl/pbo.cpp"
"gl/query.cpp"

"imgui/imgui_tables.cpp"
"imgui/imgui.cpp"
"imgui/imgui_demo.cpp"
"imgui/imgui_draw.cpp"
"imgui/imgui_widgets.cpp"
"imgui/imgui_impl_glfw.cpp"
"imgui/implot_items.cpp"
"imgui/implot.cpp"

"stb/stb_image.c"

Expand Down Expand Up @@ -373,7 +391,7 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0")
if (USE_PCH)
target_precompile_headers(${PROJECT_NAME} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>")
set_source_files_properties("ref/glad/src/glad.c" "ref/dds-ktx/src/dds-ktx.c" "stb/stb_image.c"
"imgui/imgui.cpp" "imgui/imgui_demo.cpp" "imgui/imgui_draw.cpp" "imgui/imgui_widgets.cpp" "imgui/imgui_impl_glfw.cpp"
"imgui/imgui.cpp" "imgui/imgui_demo.cpp" "imgui/imgui_draw.cpp" "imgui/imgui_widgets.cpp" "imgui/imgui_impl_glfw.cpp" "imgui/implot_items.cpp" "imgui/implot.cpp"
PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE)
endif()
endif()
Expand Down
21 changes: 20 additions & 1 deletion DynObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,14 @@ class TDynamicObject { // klasa pojazdu
// locates potential vehicle connected with specific coupling type and satisfying supplied predicate
template <typename Predicate_>
auto find_vehicle( coupling const Coupling, Predicate_ const Predicate ) -> TDynamicObject *;

TDynamicObject * FindPowered();
TDynamicObject * FindPantographCarrier();
template <typename UnaryFunction_>

template <typename UnaryFunction_>
void for_each_from_first( coupling const Coupling, UnaryFunction_ const Function );

template <typename UnaryFunction_>
void for_each( coupling const Coupling, UnaryFunction_ const Function );
void ParamSet(int what, int into);
// zapytanie do AI, po którym segmencie skrzyżowania jechać
Expand Down Expand Up @@ -856,6 +861,20 @@ TDynamicObject::find_vehicle( coupling const Coupling, Predicate_ const Predicat
return nullptr;
}

template <typename UnaryFunction_>
void
TDynamicObject::for_each_from_first( coupling const Coupling, UnaryFunction_ const Function ) {
auto *vehicle { this };

//first the most previous vehicle.
while (vehicle->Prev(Coupling) != nullptr) {vehicle = vehicle->Prev(Coupling);}

//Apply the fn from the front to back.
Function(vehicle);
while((vehicle = vehicle->Next(Coupling)) != nullptr) {Function( vehicle );}

}

template <typename UnaryFunction_>
void
TDynamicObject::for_each( coupling const Coupling, UnaryFunction_ const Function ) {
Expand Down
8 changes: 7 additions & 1 deletion McZapkie/Oerlikon_ESt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,17 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza
// sprawdzanie stanu
// if ((BrakeStatus and 1)=1)and(BCP>0.25)then
if (((VVP + 0.01 + BCP / BVM) < (CVP - 0.05)) && (Przys_blok))
BrakeStatus |= ( b_on | b_hld ); // hamowanie stopniowe;
BrakeStatus |= ( b_on | b_hld | b_ctrl ); // hamowanie stopniowe;
else if ((VVP - 0.01 + (BCP - 0.1) / BVM) > (CVP - 0.05))
BrakeStatus &= ~( b_on | b_hld ); // luzowanie;
else if ((VVP + BCP / BVM) > (CVP - 0.05))
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
else if (((VVP + (BCP - 0.1) / BVM) < (CVP - 0.05)) && (BCP > 0.25)) // zatrzymanie luzowania
BrakeStatus |= b_hld;

if (VVP > CVP)
BrakeStatus &= ~b_ctrl;

if( ( BrakeStatus & b_hld ) == 0 )
SoundFlag |= sf_CylU;

Expand All @@ -373,6 +376,9 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza
Zamykajacy = true;
else if ((VVP - 0.6) < MPP)
Zamykajacy = false;

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;

}

void TNESt3::CheckReleaser(double const dt) // odluzniacz
Expand Down
1 change: 1 addition & 0 deletions McZapkie/Oerlikon_ESt.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class TNESt3 : public TBrake {
void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
virtual void ForceEmptiness() /*override*/; // wymuszenie bycia pustym
void SetLBP(double const P); // cisnienie z hamulca pomocniczego
char* GetKindCStr() override {return "TNESt3";}
};

extern double d2A( double const d );
Expand Down
71 changes: 55 additions & 16 deletions McZapkie/hamulce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,27 @@ int TBrake::GetSoundFlag()
return result;
}

std::string TBrake::GetBrakeStatusStr()
{
std::string ret = std::string();
bool empty = true;

if (BrakeStatus & b_chrg ) {if (!empty) {ret.append(", ");} ret.append("b_chrg" ); empty = false;}
if (BrakeStatus & b_ctrl ) {if (!empty) {ret.append(", ");} ret.append("b_ctrl" ); empty = false;}
if (BrakeStatus & b_off ) {if (!empty) {ret.append(", ");} ret.append("b_off" ); empty = false;}
if (BrakeStatus & b_hld ) {if (!empty) {ret.append(", ");} ret.append("b_hld" ); empty = false;}
if (BrakeStatus & b_on ) {if (!empty) {ret.append(", ");} ret.append("b_on" ); empty = false;}
if (BrakeStatus & b_rfl ) {if (!empty) {ret.append(", ");} ret.append("b_rfl" ); empty = false;}
if (BrakeStatus & b_rls ) {if (!empty) {ret.append(", ");} ret.append("b_rls" ); empty = false;}
if (BrakeStatus & b_ep ) {if (!empty) {ret.append(", ");} ret.append("b_ep" ); empty = false;}
if (BrakeStatus & b_asb ) {if (!empty) {ret.append(", ");} ret.append("b_asb" ); empty = false;}
if (BrakeStatus & b_asb_unbrake ) {if (!empty) {ret.append(", ");} ret.append("b_asb_unbrake"); empty = false;}
if (BrakeStatus & b_dmg ) {if (!empty) {ret.append(", ");} ret.append("b_dmg" ); empty = false;}


return ret;
}

void TBrake::SetASBP( double const Press )
{
ASBP = Press;
Expand Down Expand Up @@ -465,15 +486,15 @@ double TWest::GetPF( double const PP, double const dt, double const Vel )

if ((BrakeStatus & b_hld) == b_hld)
if ((VVP + 0.03 < BVP))
BrakeStatus |= b_on;
BrakeStatus |= (b_on | b_ctrl);
else if ((VVP > BVP + 0.1))
BrakeStatus &= ~(b_on | b_hld);
BrakeStatus &= ~(b_on | b_hld | b_ctrl);
else if ((VVP > BVP))
BrakeStatus &= ~b_on;
else
;
else if ((VVP + 0.25 < BVP))
BrakeStatus |= (b_on | b_hld);
BrakeStatus |= (b_on | b_hld | b_ctrl);

if (((BrakeStatus & b_hld) == b_off) && (!DCV))
dv = PF(0, CVP, 0.0068 * SizeBC) * dt;
Expand Down Expand Up @@ -534,6 +555,9 @@ double TWest::GetPF( double const PP, double const dt, double const Vel )
ValveRes->Act();
BrakeCyl->Act();
BrakeRes->Act();

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;

return dv - dV1;
}

Expand Down Expand Up @@ -596,7 +620,7 @@ void TESt::CheckReleaser( double const dt )
// odluzniacz
if ((BrakeStatus & b_rls) == b_rls)
if ((CVP - VVP < 0))
BrakeStatus &= ~b_rls;
BrakeStatus &= ~(b_rls | b_ctrl);
else
{
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
Expand All @@ -616,7 +640,7 @@ void TESt::CheckState( double const BCP, double &dV1 ) {

if( ( VVP + 0.003 + BCP / BVM ) < CVP ) {
// hamowanie stopniowe
BrakeStatus |= b_on;
BrakeStatus |= (b_on | b_ctrl);
}
else {
if( ( VVP + BCP / BVM ) > CVP ) {
Expand All @@ -625,7 +649,7 @@ void TESt::CheckState( double const BCP, double &dV1 ) {
}
if( ( VVP - 0.003 + ( BCP - 0.1 ) / BVM ) > CVP ) {
// luzowanie
BrakeStatus &= ~( b_on | b_hld );
BrakeStatus &= ~( b_on | b_hld | b_ctrl);
}
}
}
Expand All @@ -648,13 +672,17 @@ void TESt::CheckState( double const BCP, double &dV1 ) {
SoundFlag |= sf_Acc;
ValveRes->Act();
}
BrakeStatus |= ( b_on | b_hld );
BrakeStatus |= ( b_on | b_hld | b_ctrl);
}
}

if ((VVP > CVP) && ~(BrakeStatus & (b_on | b_hld))) BrakeStatus &= ~b_ctrl;

if( ( BrakeStatus & b_hld ) == 0 ) {
SoundFlag |= sf_CylU;
}

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;
}

double TESt::CVs( double const BP )
Expand Down Expand Up @@ -1088,7 +1116,7 @@ double TESt4R::GetPF( double const PP, double const dt, double const Vel )
ImplsRes->Flow(-dv);
// przeplyw ZP <-> rozdzielacz
temp = BVs(BCP);
if ((BVP < VVP - 0.05)) // or((PP<CVP)and(CVP<PP-0.1)
if ((BVP < VVP - 0.08)) // or((PP<CVP)and(CVP<PP-0.1)
dv = PF(BVP, VVP, 0.02 * SizeBR * temp / 1.87) * dt;
else
dv = 0;
Expand Down Expand Up @@ -1276,11 +1304,11 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
if( ( ( BrakeStatus & b_hld ) == b_hld ) && ( BCP > 0.25 ) ) {
if( ( VVP + 0.003 + BCP / BVM < CVP ) ) {
// hamowanie stopniowe
BrakeStatus |= b_on;
BrakeStatus |= (b_on | b_ctrl);
}
else if( ( VVP - 0.003 + ( BCP - 0.1 ) / BVM > CVP ) ) {
// luzowanie
BrakeStatus &= ~( b_on | b_hld );
BrakeStatus &= ~( b_on | b_hld | b_ctrl);
}
else if( ( VVP + BCP / BVM > CVP ) ) {
// zatrzymanie napelaniania
Expand All @@ -1293,7 +1321,7 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
{
SoundFlag |= sf_Acc;
}
BrakeStatus |= (b_on | b_hld);
BrakeStatus |= (b_on | b_hld | b_ctrl);
}
else if( ( VVP + ( BCP - 0.1 ) / BVM < CVP )
&& ( ( CVP - VVP ) * BVM > 0.25 )
Expand Down Expand Up @@ -1410,6 +1438,10 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
CntrlRes->Act();
// LBP:=ValveRes->P();
// ValveRes.CreatePress(ImplsRes->P());

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;
if ((VVP > CVP) && ~(BrakeStatus & (b_on | b_hld))) BrakeStatus &= ~b_ctrl;

return result;
}

Expand Down Expand Up @@ -1704,20 +1736,23 @@ void TCV1::CheckState( double const BCP, double &dV1 )
// sprawdzanie stanu
if ((BrakeStatus & b_hld) == b_hld)
if ((VVP + 0.003 + BCP / BVM < CVP))
BrakeStatus |= b_on; // hamowanie stopniowe;
BrakeStatus |= (b_on | b_ctrl); // hamowanie stopniowe;
else if ((VVP - 0.003 + BCP * 1.0 / BVM > CVP))
BrakeStatus &= ~( b_on | b_hld ); // luzowanie;
BrakeStatus &= ~( b_on | b_hld | b_ctrl); // luzowanie;
else if ((VVP + BCP * 1.0 / BVM > CVP))
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
else
;
else if ((VVP + 0.10 < CVP) && (BCP < 0.1)) // poczatek hamowania
{
BrakeStatus |= ( b_on | b_hld );
BrakeStatus |= ( b_on | b_hld | b_ctrl);
dV1 = 1.25;
}
else if ((VVP + BCP / BVM < CVP) && (BCP > 0.25)) // zatrzymanie luzowanie
BrakeStatus |= b_hld;

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;
if ((VVP > CVP) && ~(BrakeStatus & (b_on | b_hld))) BrakeStatus &= ~b_ctrl;
}

double TCV1::CVs(double const BP)
Expand Down Expand Up @@ -1990,7 +2025,7 @@ void TKE::CheckState( double const BCP, double &dV1 )

if( ( VVP + 0.003 + BCP / BVM ) < CVP ) {
// hamowanie stopniowe;
BrakeStatus |= b_on;
BrakeStatus |= (b_on | b_ctrl);
}
else {
if( ( VVP + BCP / BVM ) > CVP ) {
Expand Down Expand Up @@ -2022,10 +2057,14 @@ void TKE::CheckState( double const BCP, double &dV1 )
SoundFlag |= sf_Acc;
ValveRes->Act();
}
BrakeStatus |= ( b_on | b_hld );
BrakeStatus |= ( b_on | b_hld | b_ctrl);
}
}

if (BVP < VVP - 0.08) BrakeStatus |= b_chrg; else BrakeStatus &=~b_chrg;
if ((VVP > CVP) && ~(BrakeStatus & (b_on | b_hld))) BrakeStatus &= ~b_ctrl;


if( ( BrakeStatus & b_hld ) == 0 ) {
SoundFlag |= sf_CylU;
}
Expand Down
Loading