将tick的持续时间设置了全局常量

This commit is contained in:
jackfiled 2022-07-01 16:38:07 +08:00
parent 10505c38b4
commit 21af2c0311
5 changed files with 19 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include "railsModel.h" #include "railsModel.h"
#include "queryModel.h" #include "queryModel.h"
#include "busModel.h" #include "busModel.h"
#include "Settings.h"
class BusStrategyBase : public QObject class BusStrategyBase : public QObject
{ {

13
include/Settings.h Normal file
View File

@ -0,0 +1,13 @@
//
// Created by ricardo on 2022/7/1.
//
#ifndef AUTO_BUS_GUI_SETTINGS_H
#define AUTO_BUS_GUI_SETTINGS_H
class Settings
{
public:
const static int tick = 2000;
};
#endif //AUTO_BUS_GUI_SETTINGS_H

View File

@ -86,13 +86,13 @@ void BusStrategyBase::GetBusDirectionSlot()
switch (bus_model->direction) switch (bus_model->direction)
{ {
case BUS_CLOCK_WISE: case BUS_CLOCK_WISE:
duration = bus_model->rail_pos->next_node_distance / bus_model->velocity * 1000; duration = bus_model->rail_pos->next_node_distance / bus_model->velocity * Settings::tick;
break; break;
case BUS_COUNTER_CLOCK_WISE: case BUS_COUNTER_CLOCK_WISE:
duration = bus_model->rail_pos->last_node_distance / bus_model->velocity * 1000; duration = bus_model->rail_pos->last_node_distance / bus_model->velocity * Settings::tick;
break; break;
case BUS_STOP: case BUS_STOP:
duration = 1000; duration = Settings::tick;
break; break;
} }

View File

@ -13,7 +13,7 @@
#include "centralwidget.h" #include "centralwidget.h"
#include "BusStrategyBase.h" #include "BusStrategyBase.h"
#include "StrategyFactory.h" #include "StrategyFactory.h"
#include "Settings.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui namespace Ui
@ -87,10 +87,6 @@ public slots:
void BeginBusTimerSlot([[maybe_unused]] int direction, int duration); void BeginBusTimerSlot([[maybe_unused]] int direction, int duration);
private: private:
/**
*
*/
const int tick = 1000;
/** /**
* UI控件 * UI控件

View File

@ -153,7 +153,7 @@ void MainWindow::BeginThread()
void MainWindow::BeginTickTimerSlot() void MainWindow::BeginTickTimerSlot()
{ {
tick_timer->setInterval(tick); tick_timer->setInterval(Settings::tick);
tick_timer->start(); tick_timer->start();
} }