mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Conversion to cpp 20
This commit is contained in:
@@ -7,10 +7,9 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
trainingcard_panel::trainingcard_panel()
|
||||
: ui_panel("Raport szkolenia", false)
|
||||
trainingcard_panel::trainingcard_panel() : ui_panel("Raport szkolenia", false)
|
||||
{
|
||||
//size = {400, 500};
|
||||
// size = {400, 500};
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -58,21 +57,25 @@ void trainingcard_panel::save_thread_func()
|
||||
std::fstream input("report_template.html", std::ios_base::in | std::ios_base::binary);
|
||||
|
||||
std::string in_line;
|
||||
while (std::getline(input, in_line)) {
|
||||
while (std::getline(input, in_line))
|
||||
{
|
||||
const std::string magic("{{CONTENT}}");
|
||||
if (in_line.compare(0, magic.size(), magic) == 0) {
|
||||
if (in_line.compare(0, magic.size(), magic) == 0)
|
||||
{
|
||||
temp << "<div><b>Miejsce: </b>" << (std::string(place.c_str())) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Data: </b>" << (date) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Czas: </b>" << (from) << " - " << (to) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Imię (imiona) i nazwisko szkolonego: </b>" << (trainee_name) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Data urodzenia: </b>" << (trainee_birthdate) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Firma: </b>" << (trainee_company) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Imię i nazwisko instruktora: </b>" << (instructor_name) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Odcinek trasy: </b>" << (track_segment) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Imię i nazwisko instruktora: </b>" << (instructor_name) << "</div><br />" << std::endl;
|
||||
temp << "<div><b>Odcinek trasy: </b>" << (track_segment) << "</div><br />" << std::endl;
|
||||
if (distance > 0.0f)
|
||||
temp << "<div><b>Przebyta odległość: </b>" << std::round(distance) << " km</div><br />" << std::endl;
|
||||
temp << "<div><b>Uwagi: </b><br />" << (remarks) << "</div>" << std::endl;
|
||||
} else {
|
||||
temp << "<div><b>Przebyta odległość: </b>" << std::round(distance) << " km</div><br />" << std::endl;
|
||||
temp << "<div><b>Uwagi: </b><br />" << (remarks) << "</div>" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp << in_line;
|
||||
}
|
||||
}
|
||||
@@ -85,37 +88,42 @@ void trainingcard_panel::save_thread_func()
|
||||
|
||||
void trainingcard_panel::render_contents()
|
||||
{
|
||||
if (ImGui::BeginPopupModal("Zapisywanie danych")) {
|
||||
if (ImGui::BeginPopupModal("Zapisywanie danych"))
|
||||
{
|
||||
ImGui::SetWindowSize(ImVec2(-1, -1));
|
||||
int s = state.load();
|
||||
|
||||
if (s == 1) {
|
||||
if (s == 1)
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
clear();
|
||||
}
|
||||
|
||||
if (s < 1) {
|
||||
if (s < 1)
|
||||
{
|
||||
if (s == 0)
|
||||
ImGui::TextUnformatted("Error occured please contact with administrator!");
|
||||
if (s == -1)
|
||||
ImGui::TextUnformatted("The recording of the training has not been archived, please do not start the next training before manually archiving the file!");
|
||||
|
||||
if (ImGui::Button("OK")) {
|
||||
if (ImGui::Button("OK"))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (s == 2)
|
||||
ImGui::TextUnformatted(u8"Proszę czekać, trwa archiwizacja nagrania...");
|
||||
ImGui::TextUnformatted("Proszę czekać, trwa archiwizacja nagrania...");
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if (start_time_wall) {
|
||||
if (start_time_wall)
|
||||
{
|
||||
std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
std::string rep = u8"Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday)
|
||||
+ " " + std::to_string(tm->tm_hour) + ":" + std::to_string(tm->tm_min);
|
||||
std::string rep = "Czas rozpoczęcia: " + std::to_string(tm->tm_year + 1900) + "-" + std::to_string(tm->tm_mon + 1) + "-" + std::to_string(tm->tm_mday) + " " + std::to_string(tm->tm_hour) +
|
||||
":" + std::to_string(tm->tm_min);
|
||||
ImGui::TextUnformatted(rep.c_str());
|
||||
}
|
||||
|
||||
@@ -146,22 +154,27 @@ void trainingcard_panel::render_contents()
|
||||
ImGui::TextUnformatted("Uwagi");
|
||||
ImGui::InputTextMultiline("##remarks", &remarks[0], remarks.size(), ImVec2(-1.0f, 200.0f));
|
||||
|
||||
if (!start_time_wall) {
|
||||
if (ImGui::Button("Rozpocznij szkolenie")) {
|
||||
if (!start_time_wall)
|
||||
{
|
||||
if (ImGui::Button("Rozpocznij szkolenie"))
|
||||
{
|
||||
start_time_wall = std::time(nullptr);
|
||||
std::tm *tm = std::localtime(&(*start_time_wall));
|
||||
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday)
|
||||
+ std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" + std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
|
||||
recording_timestamp = std::to_string(tm->tm_year + 1900) + std::to_string(tm->tm_mon + 1) + std::to_string(tm->tm_mday) + std::to_string(tm->tm_hour) + std::to_string(tm->tm_min) + "_" +
|
||||
std::string(trainee_name.c_str()) + "_" + std::string(instructor_name.c_str());
|
||||
|
||||
int ret = StartRecording();
|
||||
if (ret != 1) {
|
||||
if (ret != 1)
|
||||
{
|
||||
state.store(ret);
|
||||
ImGui::OpenPopup("Zapisywanie danych");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ImGui::Button(u8"Zakończ szkolenie")) {
|
||||
else
|
||||
{
|
||||
if (ImGui::Button("Zakończ szkolenie"))
|
||||
{
|
||||
state.store(2);
|
||||
if (simulation::Trains.sequence().size() > 0)
|
||||
distance = simulation::Trains.sequence()[0]->Dynamic()->MoverParameters->DistCounter;
|
||||
|
||||
@@ -5,27 +5,26 @@
|
||||
#include "Driver.h"
|
||||
#include "Train.h"
|
||||
|
||||
ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle)
|
||||
: ui_panel(std::string(STR("Vehicle parameters")) + ": " + vehicle, false), m_vehicle_name(vehicle)
|
||||
ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle) : ui_panel(std::string(STR("Vehicle parameters")) + ": " + vehicle, false), m_vehicle_name(vehicle)
|
||||
{
|
||||
vehicle_mini = GfxRenderer->Fetch_Texture("vehicle_mini");
|
||||
vehicle_mini = GfxRenderer->Fetch_Texture("vehicle_mini");
|
||||
}
|
||||
|
||||
void screen_window_callback(ImGuiSizeCallbackData *data) {
|
||||
auto config = static_cast<const global_settings::pythonviewport_config*>(data->UserData);
|
||||
void screen_window_callback(ImGuiSizeCallbackData *data)
|
||||
{
|
||||
auto config = static_cast<const global_settings::pythonviewport_config *>(data->UserData);
|
||||
data->DesiredSize.y = data->DesiredSize.x * (float)config->size.y / (float)config->size.x;
|
||||
}
|
||||
|
||||
void ui::vehicleparams_panel::draw_infobutton(const char *str, ImVec2 pos, const ImVec4 color)
|
||||
{
|
||||
if (pos.x != -1.0f) {
|
||||
if (pos.x != -1.0f)
|
||||
{
|
||||
ImVec2 window_size = ImGui::GetWindowSize();
|
||||
|
||||
ImGuiStyle &style = ImGui::GetStyle();
|
||||
ImVec2 text_size = ImGui::CalcTextSize(str);
|
||||
ImVec2 button_size = ImVec2(
|
||||
text_size.x + style.FramePadding.x * 2.0f,
|
||||
text_size.y + style.FramePadding.y * 2.0f);
|
||||
ImVec2 button_size = ImVec2(text_size.x + style.FramePadding.x * 2.0f, text_size.y + style.FramePadding.y * 2.0f);
|
||||
|
||||
pos.x = pos.x * window_size.x / 512.0f - button_size.x / 2.0f;
|
||||
pos.y = pos.y * window_size.y / 118.0f - button_size.y / 2.0f;
|
||||
@@ -52,7 +51,7 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover)
|
||||
if (vehicle_mini == null_handle)
|
||||
return;
|
||||
|
||||
auto &tex = GfxRenderer->Texture(vehicle_mini);
|
||||
auto &tex = GfxRenderer->Texture(vehicle_mini);
|
||||
tex.create();
|
||||
|
||||
ImVec2 size = ImGui::GetContentRegionAvail();
|
||||
@@ -61,12 +60,12 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover)
|
||||
|
||||
if (ImGui::BeginChild("mini", ImVec2(x, y)))
|
||||
{
|
||||
ImGui::Image(reinterpret_cast<void*>(tex.get_id()), ImVec2(x, y), ImVec2(0, 1), ImVec2(1, 0));
|
||||
ImGui::Image(reinterpret_cast<void *>(tex.get_id()), ImVec2(x, y), ImVec2(0, 1), ImVec2(1, 0));
|
||||
|
||||
if (mover.Pantographs[end::rear].is_active)
|
||||
draw_infobutton(u8"╨╨╨", ImVec2(126, 10));
|
||||
if (mover.Pantographs[end::front].is_active)
|
||||
draw_infobutton(u8"╨╨╨", ImVec2(290, 10));
|
||||
if (mover.Pantographs[end::rear].is_active)
|
||||
draw_infobutton("╨╨╨", ImVec2(126, 10));
|
||||
if (mover.Pantographs[end::front].is_active)
|
||||
draw_infobutton("╨╨╨", ImVec2(290, 10));
|
||||
|
||||
if (mover.Battery)
|
||||
draw_infobutton(STR_C("bat."), ImVec2(120, 55));
|
||||
@@ -99,24 +98,28 @@ void ui::vehicleparams_panel::draw_mini(const TMoverParameters &mover)
|
||||
void ui::vehicleparams_panel::render_contents()
|
||||
{
|
||||
TDynamicObject *vehicle_ptr = simulation::Vehicles.find(m_vehicle_name);
|
||||
if (!vehicle_ptr) {
|
||||
if (!vehicle_ptr)
|
||||
{
|
||||
is_open = false;
|
||||
return;
|
||||
}
|
||||
|
||||
TTrain *train_ptr = simulation::Trains.find(m_vehicle_name);
|
||||
if (train_ptr) {
|
||||
if (train_ptr)
|
||||
{
|
||||
const TTrain::screenentry_sequence &screens = train_ptr->get_screens();
|
||||
|
||||
for (const auto &viewport : Global.python_viewports) {
|
||||
for (auto const &entry : screens) {
|
||||
if (entry.script != viewport.surface)
|
||||
for (const auto &viewport : Global.python_viewports)
|
||||
{
|
||||
for (auto const &entry : screens)
|
||||
{
|
||||
if (entry.script != viewport.surface)
|
||||
continue;
|
||||
|
||||
std::string window_name = STR("Screen") + "##" + viewport.surface;
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(2500, 2500), screen_window_callback,
|
||||
const_cast<global_settings::pythonviewport_config*>(&viewport));
|
||||
if (ImGui::Begin(window_name.c_str())) {
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(200, 200), ImVec2(2500, 2500), screen_window_callback, const_cast<global_settings::pythonviewport_config *>(&viewport));
|
||||
if (ImGui::Begin(window_name.c_str()))
|
||||
{
|
||||
float aspect = (float)viewport.size.y / viewport.size.x;
|
||||
|
||||
glm::mat3 proj = glm::translate(glm::scale(glm::mat3(), 1.0f / viewport.scale), viewport.offset);
|
||||
@@ -126,7 +129,7 @@ void ui::vehicleparams_panel::render_contents()
|
||||
|
||||
ImVec2 size = ImGui::GetContentRegionAvail();
|
||||
|
||||
ImGui::Image(reinterpret_cast<void*>(entry.rt->shared_tex), size, ImVec2(uv0.x, uv0.y), ImVec2(uv1.x, uv1.y));
|
||||
ImGui::Image(reinterpret_cast<void *>(entry.rt->shared_tex), size, ImVec2(uv0.x, uv0.y), ImVec2(uv1.x, uv1.y));
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -139,178 +142,137 @@ void ui::vehicleparams_panel::render_contents()
|
||||
std::vector<text_line> lines;
|
||||
std::array<char, 1024> buffer;
|
||||
|
||||
auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) };
|
||||
auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric };
|
||||
auto const isdieselenginepowered{(mover.EngineType == TEngineType::DieselElectric) || (mover.EngineType == TEngineType::DieselEngine)};
|
||||
auto const isdieselinshuntmode{mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric};
|
||||
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"),
|
||||
// devices
|
||||
( mover.Battery ? 'B' : '.' ),
|
||||
( mover.Mains ? 'M' : '.' ),
|
||||
( mover.FuseFlag ? '!' : '.' ),
|
||||
( mover.Pantographs[end::rear].is_active ? ( mover.PantRearVolt > 0.0 ? 'O' : 'o' ) : '.' ),
|
||||
( mover.Pantographs[end::front].is_active ? ( mover.PantFrontVolt > 0.0 ? 'P' : 'p' ) : '.' ),
|
||||
( mover.PantPressLockActive ? '!' : ( mover.PantPressSwitchActive ? '*' : '.' ) ),
|
||||
( mover.WaterPump.is_active ? 'W' : ( false == mover.WaterPump.breaker ? '-' : ( mover.WaterPump.is_enabled ? 'w' : '.' ) ) ),
|
||||
( true == mover.WaterHeater.is_damaged ? '!' : ( mover.WaterHeater.is_active ? 'H' : ( false == mover.WaterHeater.breaker ? '-' : ( mover.WaterHeater.is_enabled ? 'h' : '.' ) ) ) ),
|
||||
( mover.FuelPump.is_active ? 'F' : ( mover.FuelPump.is_enabled ? 'f' : '.' ) ),
|
||||
( mover.OilPump.is_active ? 'O' : ( mover.OilPump.is_enabled ? 'o' : '.' ) ),
|
||||
( false == mover.ConverterAllowLocal ? '-' : ( mover.ConverterAllow ? ( mover.ConverterFlag ? 'X' : 'x' ) : '.' ) ),
|
||||
( mover.ConvOvldFlag ? '!' : '.' ),
|
||||
( mover.CompressorFlag ? 'C' : ( false == mover.CompressorAllowLocal ? '-' : ( ( mover.CompressorAllow || mover.CompressorStart == start_t::automatic ) ? 'c' : '.' ) ) ),
|
||||
( mover.CompressorGovernorLock ? '!' : '.' ),
|
||||
"",
|
||||
std::string( isdieselenginepowered ? STR(" oil pressure: ") + to_string( mover.OilPump.pressure, 2 ) : "" ).c_str(),
|
||||
// power transfers
|
||||
mover.Couplers[ end::front ].power_high.voltage,
|
||||
mover.Couplers[ end::front ].power_high.current,
|
||||
std::string( mover.Couplers[ end::front ].power_high.is_local ? "" : "-" ).c_str(),
|
||||
std::string( vehicle.DirectionGet() ? ":<<:" : ":>>:" ).c_str(),
|
||||
std::string( mover.Couplers[ end::rear ].power_high.is_local ? "" : "-" ).c_str(),
|
||||
mover.Couplers[ end::rear ].power_high.voltage,
|
||||
mover.Couplers[ end::rear ].power_high.current );
|
||||
std::snprintf(buffer.data(), buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"),
|
||||
// devices
|
||||
(mover.Battery ? 'B' : '.'), (mover.Mains ? 'M' : '.'), (mover.FuseFlag ? '!' : '.'), (mover.Pantographs[end::rear].is_active ? (mover.PantRearVolt > 0.0 ? 'O' : 'o') : '.'),
|
||||
(mover.Pantographs[end::front].is_active ? (mover.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (mover.PantPressLockActive ? '!' : (mover.PantPressSwitchActive ? '*' : '.')),
|
||||
(mover.WaterPump.is_active ? 'W' : (false == mover.WaterPump.breaker ? '-' : (mover.WaterPump.is_enabled ? 'w' : '.'))),
|
||||
(true == mover.WaterHeater.is_damaged ? '!' : (mover.WaterHeater.is_active ? 'H' : (false == mover.WaterHeater.breaker ? '-' : (mover.WaterHeater.is_enabled ? 'h' : '.')))),
|
||||
(mover.FuelPump.is_active ? 'F' : (mover.FuelPump.is_enabled ? 'f' : '.')), (mover.OilPump.is_active ? 'O' : (mover.OilPump.is_enabled ? 'o' : '.')),
|
||||
(false == mover.ConverterAllowLocal ? '-' : (mover.ConverterAllow ? (mover.ConverterFlag ? 'X' : 'x') : '.')), (mover.ConvOvldFlag ? '!' : '.'),
|
||||
(mover.CompressorFlag ? 'C' : (false == mover.CompressorAllowLocal ? '-' : ((mover.CompressorAllow || mover.CompressorStart == start_t::automatic) ? 'c' : '.'))),
|
||||
(mover.CompressorGovernorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(mover.OilPump.pressure, 2) : "").c_str(),
|
||||
// power transfers
|
||||
mover.Couplers[end::front].power_high.voltage, mover.Couplers[end::front].power_high.current, std::string(mover.Couplers[end::front].power_high.is_local ? "" : "-").c_str(),
|
||||
std::string(vehicle.DirectionGet() ? ":<<:" : ":>>:").c_str(), std::string(mover.Couplers[end::rear].power_high.is_local ? "" : "-").c_str(),
|
||||
mover.Couplers[end::rear].power_high.voltage, mover.Couplers[end::rear].power_high.current);
|
||||
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C("Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, cooling fans: %.0f+%.0f"),
|
||||
// controllers
|
||||
mover.MainCtrlPos,
|
||||
mover.MainCtrlActualPos,
|
||||
std::string( isdieselinshuntmode ? to_string( mover.AnPos, 2 ) + STR(" (shunt mode)") : std::to_string( mover.ScndCtrlPos ) + "(" + std::to_string( mover.ScndCtrlActualPos ) + ")" ).c_str(),
|
||||
// engine
|
||||
mover.EnginePower,
|
||||
std::abs( mover.TrainType == dt_EZT ? mover.ShowCurrent( 0 ) : mover.Im ),
|
||||
// revolutions
|
||||
std::abs( mover.enrot ) * 60,
|
||||
std::abs( mover.nrot ) * mover.Transmision.Ratio * 60,
|
||||
mover.RventRot * 60,
|
||||
std::abs( mover.MotorBlowers[end::front].revolutions ),
|
||||
std::abs( mover.MotorBlowers[end::rear].revolutions ),
|
||||
mover.dizel_heat.rpmw,
|
||||
mover.dizel_heat.rpmw2 );
|
||||
std::snprintf(buffer.data(), buffer.size(),
|
||||
STR_C("Controllers:\n master: %d(%d), secondary: %s\nEngine output: %.1f, current: %.0f\nRevolutions:\n engine: %.0f, motors: %.0f\n engine fans: %.0f, motor fans: %.0f+%.0f, "
|
||||
"cooling fans: %.0f+%.0f"),
|
||||
// controllers
|
||||
mover.MainCtrlPos, mover.MainCtrlActualPos,
|
||||
std::string(isdieselinshuntmode ? to_string(mover.AnPos, 2) + STR(" (shunt mode)") : std::to_string(mover.ScndCtrlPos) + "(" + std::to_string(mover.ScndCtrlActualPos) + ")").c_str(),
|
||||
// engine
|
||||
mover.EnginePower, std::abs(mover.TrainType == dt_EZT ? mover.ShowCurrent(0) : mover.Im),
|
||||
// revolutions
|
||||
std::abs(mover.enrot) * 60, std::abs(mover.nrot) * mover.Transmision.Ratio * 60, mover.RventRot * 60, std::abs(mover.MotorBlowers[end::front].revolutions),
|
||||
std::abs(mover.MotorBlowers[end::rear].revolutions), mover.dizel_heat.rpmw, mover.dizel_heat.rpmw2);
|
||||
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
|
||||
if( isdieselenginepowered ) {
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"),
|
||||
mover.dizel_heat.Ts,
|
||||
mover.dizel_heat.To,
|
||||
mover.dizel_heat.temperatura1,
|
||||
( mover.WaterCircuitsLink ? '-' : '|' ),
|
||||
mover.dizel_heat.temperatura2 );
|
||||
if (isdieselenginepowered)
|
||||
{
|
||||
std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), mover.dizel_heat.Ts, mover.dizel_heat.To, mover.dizel_heat.temperatura1,
|
||||
(mover.WaterCircuitsLink ? '-' : '|'), mover.dizel_heat.temperatura2);
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
}
|
||||
|
||||
std::string brakedelay;
|
||||
{
|
||||
std::vector<std::pair<int, std::string>> delays {
|
||||
{ bdelay_G, "G" },
|
||||
{ bdelay_P, "P" },
|
||||
{ bdelay_R, "R" },
|
||||
{ bdelay_M, "+Mg" } };
|
||||
std::vector<std::pair<int, std::string>> delays{{bdelay_G, "G"}, {bdelay_P, "P"}, {bdelay_R, "R"}, {bdelay_M, "+Mg"}};
|
||||
|
||||
for( auto const &delay : delays ) {
|
||||
if( ( mover.BrakeDelayFlag & delay.first ) == delay.first ) {
|
||||
for (auto const &delay : delays)
|
||||
{
|
||||
if ((mover.BrakeDelayFlag & delay.first) == delay.first)
|
||||
{
|
||||
brakedelay += delay.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C("Brakes:\n train: %.2f, independent: %.2f, mode: %d, delay: %s, load flag: %d\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f"),
|
||||
// brakes
|
||||
mover.fBrakeCtrlPos,
|
||||
mover.LocalBrakePosA,
|
||||
mover.BrakeOpModeFlag,
|
||||
brakedelay.c_str(),
|
||||
mover.LoadFlag,
|
||||
// cylinders
|
||||
mover.BrakePress,
|
||||
mover.LocBrakePress,
|
||||
mover.Hamulec->GetBrakeStatus(),
|
||||
// pipes
|
||||
mover.PipePress,
|
||||
mover.BrakeCtrlPos2,
|
||||
mover.ScndPipePress,
|
||||
mover.CntrlPipePress,
|
||||
// tanks
|
||||
mover.Hamulec->GetBRP(),
|
||||
mover.Compressor,
|
||||
mover.Hamulec->GetCRP() );
|
||||
std::snprintf(buffer.data(), buffer.size(),
|
||||
STR_C("Brakes:\n train: %.2f, independent: %.2f, mode: %d, delay: %s, load flag: %d\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n "
|
||||
"brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f"),
|
||||
// brakes
|
||||
mover.fBrakeCtrlPos, mover.LocalBrakePosA, mover.BrakeOpModeFlag, brakedelay.c_str(), mover.LoadFlag,
|
||||
// cylinders
|
||||
mover.BrakePress, mover.LocBrakePress, mover.Hamulec->GetBrakeStatus(),
|
||||
// pipes
|
||||
mover.PipePress, mover.BrakeCtrlPos2, mover.ScndPipePress, mover.CntrlPipePress,
|
||||
// tanks
|
||||
mover.Hamulec->GetBRP(), mover.Compressor, mover.Hamulec->GetCRP());
|
||||
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
|
||||
if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) {
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C(" pantograph: %.2f%cMT"),
|
||||
mover.PantPress,
|
||||
( mover.bPantKurek3 ? '-' : '|' ) );
|
||||
if (mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector)
|
||||
{
|
||||
std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), mover.PantPress, (mover.bPantKurek3 ? '-' : '|'));
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
}
|
||||
|
||||
std::snprintf(
|
||||
buffer.data(), buffer.size(),
|
||||
STR_C("Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]"),
|
||||
// forces
|
||||
mover.Ft * 0.001f * ( mover.CabActive ? mover.CabActive : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive : 1 ) + 0.001f,
|
||||
mover.Fb * 0.001f,
|
||||
mover.Adhesive( mover.RunningTrack.friction ),
|
||||
( mover.SlippingWheels ? " (!)" : "" ),
|
||||
// acceleration
|
||||
mover.AccSVBased,
|
||||
mover.AccN + 0.001f,
|
||||
std::string( std::abs( mover.RunningShape.R ) > 10000.0 ? "~0" : to_string( mover.RunningShape.R, 0 ) ).c_str(),
|
||||
// velocity
|
||||
vehicle.GetVelocity(),
|
||||
mover.DistCounter,
|
||||
// position
|
||||
vehicle.GetPosition().x,
|
||||
vehicle.GetPosition().y,
|
||||
vehicle.GetPosition().z );
|
||||
std::snprintf(buffer.data(), buffer.size(),
|
||||
STR_C("Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: "
|
||||
"[%.2f, %.2f, %.2f]"),
|
||||
// forces
|
||||
mover.Ft * 0.001f *
|
||||
(mover.CabActive ? mover.CabActive :
|
||||
vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive :
|
||||
1) +
|
||||
0.001f,
|
||||
mover.Fb * 0.001f, mover.Adhesive(mover.RunningTrack.friction), (mover.SlippingWheels ? " (!)" : ""),
|
||||
// acceleration
|
||||
mover.AccSVBased, mover.AccN + 0.001f, std::string(std::abs(mover.RunningShape.R) > 10000.0 ? "~0" : to_string(mover.RunningShape.R, 0)).c_str(),
|
||||
// velocity
|
||||
vehicle.GetVelocity(), mover.DistCounter,
|
||||
// position
|
||||
vehicle.GetPosition().x, vehicle.GetPosition().y, vehicle.GetPosition().z);
|
||||
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
|
||||
std::pair<double, double> TrainsetPowerMeter;
|
||||
std::pair<double, double> TrainsetPowerMeter;
|
||||
|
||||
TDynamicObject *vehicle_iter = vehicle_ptr;
|
||||
while (vehicle_iter) {
|
||||
if (vehicle_iter->Next())
|
||||
vehicle_iter = vehicle_iter->Next();
|
||||
else
|
||||
break;
|
||||
}
|
||||
TDynamicObject *vehicle_iter = vehicle_ptr;
|
||||
while (vehicle_iter)
|
||||
{
|
||||
if (vehicle_iter->Next())
|
||||
vehicle_iter = vehicle_iter->Next();
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
while (vehicle_iter) {
|
||||
TrainsetPowerMeter.first += vehicle_iter->MoverParameters->EnergyMeter.first;
|
||||
TrainsetPowerMeter.second += vehicle_iter->MoverParameters->EnergyMeter.second;
|
||||
vehicle_iter = vehicle_iter->Prev();
|
||||
}
|
||||
while (vehicle_iter)
|
||||
{
|
||||
TrainsetPowerMeter.first += vehicle_iter->MoverParameters->EnergyMeter.first;
|
||||
TrainsetPowerMeter.second += vehicle_iter->MoverParameters->EnergyMeter.second;
|
||||
vehicle_iter = vehicle_iter->Prev();
|
||||
}
|
||||
|
||||
if (TrainsetPowerMeter.first != 0.0 || TrainsetPowerMeter.second != 0.0) {
|
||||
std::snprintf(buffer.data(), buffer.size(), STR_C("Electricity usage:\n drawn: %.1f kWh\n returned: %.1f kWh\n balance: %.1f kWh"),
|
||||
TrainsetPowerMeter.first, -TrainsetPowerMeter.second, TrainsetPowerMeter.first + TrainsetPowerMeter.second);
|
||||
if (TrainsetPowerMeter.first != 0.0 || TrainsetPowerMeter.second != 0.0)
|
||||
{
|
||||
std::snprintf(buffer.data(), buffer.size(), STR_C("Electricity usage:\n drawn: %.1f kWh\n returned: %.1f kWh\n balance: %.1f kWh"), TrainsetPowerMeter.first, -TrainsetPowerMeter.second,
|
||||
TrainsetPowerMeter.first + TrainsetPowerMeter.second);
|
||||
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
}
|
||||
ImGui::TextUnformatted(buffer.data());
|
||||
}
|
||||
|
||||
draw_mini(mover);
|
||||
|
||||
if (ImGui::Button(STR_C("Radiostop")))
|
||||
m_relay.post(user_command::radiostopsend, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition());
|
||||
m_relay.post(user_command::radiostopsend, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition());
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(STR_C("Stop and repair")))
|
||||
m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(STR_C("Reset position"))) {
|
||||
if (ImGui::Button(STR_C("Reset position")))
|
||||
{
|
||||
std::string payload = vehicle_ptr->name() + '%' + vehicle_ptr->initial_track->name();
|
||||
m_relay.post(user_command::consistteleport, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &payload);
|
||||
m_relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
@@ -330,7 +292,8 @@ void ui::vehicleparams_panel::render_contents()
|
||||
if (ImGui::IsItemDeactivated())
|
||||
m_relay.post(user_command::consistreleaser, 0.0, 0.0, GLFW_RELEASE, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
|
||||
if (vehicle_ptr->MoverParameters->V < 0.01) {
|
||||
if (vehicle_ptr->MoverParameters->V < 0.01)
|
||||
{
|
||||
if (ImGui::Button(STR_C("Move +500m")))
|
||||
m_relay.post(user_command::dynamicmove, 500.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
|
||||
ImGui::SameLine();
|
||||
|
||||
Reference in New Issue
Block a user