From a2838e056dd5b6b36b91fa93bd045a1c77350d73 Mon Sep 17 00:00:00 2001 From: maisvendoo Date: Wed, 2 Oct 2019 23:20:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE:=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=20=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D1=82=D0=B0=D0=B9=D0=BC=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cfg/init-data.xml | 4 +- scripts/patch-deploy.bat | 51 +++++++++++++++++++++++++ simulator/model/include/elapsed-timer.h | 37 ++++++++++++++++++ simulator/model/include/model.h | 9 ++++- simulator/model/src/elapsed-timer.cpp | 44 +++++++++++++++++++++ simulator/model/src/model.cpp | 17 +++++---- 6 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 scripts/patch-deploy.bat create mode 100644 simulator/model/include/elapsed-timer.h create mode 100644 simulator/model/src/elapsed-timer.cpp diff --git a/cfg/init-data.xml b/cfg/init-data.xml index 25b643dd..3494493d 100644 --- a/cfg/init-data.xml +++ b/cfg/init-data.xml @@ -7,11 +7,11 @@ 100 1 default - 10 + 20 true - 10 + 20 10240 diff --git a/scripts/patch-deploy.bat b/scripts/patch-deploy.bat new file mode 100644 index 00000000..2d6defa9 --- /dev/null +++ b/scripts/patch-deploy.bat @@ -0,0 +1,51 @@ +rem Создаем структуру каталогов игры + +mkdir %RRS_DEV_ROOT% +mkdir %RRS_DEV_ROOT%\bin +mkdir %RRS_DEV_ROOT%\lib +mkdir %RRS_DEV_ROOT%\modules +mkdir %RRS_DEV_ROOT%\plugins + +mkdir %RRS_DEV_ROOT%\cfg +mkdir %RRS_DEV_ROOT%\data +mkdir %RRS_DEV_ROOT%\routes +mkdir %RRS_DEV_ROOT%\fonts +mkdir %RRS_DEV_ROOT%\themes + +mkdir %RRS_DEV_ROOT%\sdk +mkdir %RRS_DEV_ROOT%\sdk\include + +rem Копируем бинарные файлы + +xcopy ..\..\bin\*.exe %RRS_DEV_ROOT%\bin\ +xcopy ..\..\lib\*.dll %RRS_DEV_ROOT%\bin\ +move %RRS_DEV_ROOT%\bin\rkf5.dll %RRS_DEV_ROOT%\lib\rkf5.dll +move %RRS_DEV_ROOT%\bin\rk4.dll %RRS_DEV_ROOT%\lib\rk4.dll + +xcopy ..\..\modules\*.dll %RRS_DEV_ROOT%\modules +xcopy ..\..\modules\vl60\*.dll %RRS_DEV_ROOT%\modules\vl60\ +xcopy ..\..\modules\passcar\*.dll %RRS_DEV_ROOT%\modules\passcar\ + +xcopy ..\..\plugins\*.dll %RRS_DEV_ROOT%\plugins + +rem Копируем конфиги + +xcopy ..\cfg\*.xml %RRS_DEV_ROOT%\cfg\ +del %RRS_DEV_ROOT%\cfg\control-panel.xml +xcopy ..\cfg\couplings\*.xml %RRS_DEV_ROOT%\cfg\couplings\ +xcopy ..\cfg\devices\*.xml %RRS_DEV_ROOT%\cfg\devices\ + +xcopy ..\cfg\main-resist\default.xml %RRS_DEV_ROOT%\cfg\main-resist\ +xcopy ..\cfg\main-resist\passcar.xml %RRS_DEV_ROOT%\cfg\main-resist\ +xcopy ..\cfg\main-resist\loco-resist.xml %RRS_DEV_ROOT%\cfg\main-resist\ + +xcopy ..\cfg\vehicles\vl60pk-1543\*.* %RRS_DEV_ROOT%\cfg\vehicles\vl60pk-1543\ +xcopy ..\cfg\vehicles\IMR_pass_rzd-11100\*.* %RRS_DEV_ROOT%\cfg\vehicles\IMR_pass_rzd-11100\ +xcopy ..\cfg\vehicles\IMR_pass_rzd-13819\*.* %RRS_DEV_ROOT%\cfg\vehicles\IMR_pass_rzd-13819\ +xcopy ..\cfg\vehicles\IMR_pass_rzd-16733\*.* %RRS_DEV_ROOT%\cfg\vehicles\IMR_pass_rzd-16733\ +xcopy ..\cfg\vehicles\IMR_pass_rzd-17669\*.* %RRS_DEV_ROOT%\cfg\vehicles\IMR_pass_rzd-17669\ +xcopy ..\cfg\vehicles\IMR_pass_rzd-25924\*.* %RRS_DEV_ROOT%\cfg\vehicles\IMR_pass_rzd-25924\ + +xcopy ..\cfg\trains\vl60pk-1543.xml %RRS_DEV_ROOT%\cfg\trains\ +xcopy ..\cfg\trains\vl60pk-1543-pass-train.xml %RRS_DEV_ROOT%\cfg\trains\ + diff --git a/simulator/model/include/elapsed-timer.h b/simulator/model/include/elapsed-timer.h new file mode 100644 index 00000000..07e9ca0f --- /dev/null +++ b/simulator/model/include/elapsed-timer.h @@ -0,0 +1,37 @@ +#ifndef ELAPSED_TIMER_H +#define ELAPSED_TIMER_H + +#include + +class ElapsedTimer : public QObject +{ + Q_OBJECT + +public: + + ElapsedTimer(QObject *parent = Q_NULLPTR); + + ~ElapsedTimer(); + + void setInterval(quint64 interval); + + void start(); + +signals: + + void process(); + +private: + + bool is_started; + + quint64 interval; + + QThread thread; + +private slots: + + void loop(); +}; + +#endif // ELAPSED_TIMER_H diff --git a/simulator/model/include/model.h b/simulator/model/include/model.h index 918e2eb0..131d2403 100644 --- a/simulator/model/include/model.h +++ b/simulator/model/include/model.h @@ -26,6 +26,7 @@ #include "filesystem.h" #include "log.h" #include "train.h" +#include "elapsed-timer.h" #include "server.h" @@ -132,6 +133,8 @@ public slots: QTimer controlTimer; + ElapsedTimer simTimer; + /// Log initialization void logInit(bool clear_log = false); @@ -164,7 +167,11 @@ public slots: void controlStep(double &control_time, const double control_delay); - void timerEvent(QTimerEvent *event); + //void timerEvent(QTimerEvent *event); + +private slots: + + void process(); }; #endif // MODEL_H diff --git a/simulator/model/src/elapsed-timer.cpp b/simulator/model/src/elapsed-timer.cpp new file mode 100644 index 00000000..e186ae97 --- /dev/null +++ b/simulator/model/src/elapsed-timer.cpp @@ -0,0 +1,44 @@ +#include "elapsed-timer.h" + +#include +#include +#include + +ElapsedTimer::ElapsedTimer(QObject *parent) : QObject(parent) + , is_started(false) + , interval(0) +{ + +} + +ElapsedTimer::~ElapsedTimer() +{ + +} + +void ElapsedTimer::setInterval(quint64 interval) +{ + this->interval = interval; +} + +void ElapsedTimer::start() +{ + is_started = true; + connect(&thread, &QThread::started, this, &ElapsedTimer::loop); + thread.start(); +} + +void ElapsedTimer::loop() +{ + QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, &ElapsedTimer::process, Qt::DirectConnection); + timer->setTimerType(Qt::PreciseTimer); + timer->start(static_cast(interval)); + + QEventLoop eventLoop; + + while (is_started) + { + eventLoop.processEvents(); + } +} diff --git a/simulator/model/src/model.cpp b/simulator/model/src/model.cpp index a0ad3e10..aa793dd8 100644 --- a/simulator/model/src/model.cpp +++ b/simulator/model/src/model.cpp @@ -119,7 +119,10 @@ void Model::start() { is_simulation_started = true; t = start_time; - this->startTimer(integration_time_interval, Qt::TimerType::PreciseTimer); + + connect(&simTimer, &ElapsedTimer::process, this, &Model::process, Qt::DirectConnection); + simTimer.setInterval(static_cast(integration_time_interval)); + simTimer.start(); } } @@ -500,15 +503,13 @@ void Model::controlStep(double &control_time, const double control_delay) //------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ -void Model::timerEvent(QTimerEvent *event) +void Model::process() { - Q_UNUSED(event) - // Feedback to viewer - sharedMemoryFeedback(); + //sharedMemoryFeedback(); double tau = 0; - double integration_time = static_cast(integration_time_interval) / 1000.0; + double integration_time = static_cast(integration_time_interval) / 1000.0; // Integrate all ODE in train motion model while ( (tau <= integration_time) && @@ -517,7 +518,7 @@ void Model::timerEvent(QTimerEvent *event) preStep(t); // Feedback to viewer - //sharedMemoryFeedback(); + sharedMemoryFeedback(); controlStep(control_time, control_delay); @@ -534,6 +535,6 @@ void Model::timerEvent(QTimerEvent *event) // Debug print, is allowed if (is_debug_print) - debugPrint(); + debugPrint(); }