将tick的持续时间设置了全局常量
This commit is contained in:
parent
10505c38b4
commit
21af2c0311
|
@ -11,6 +11,7 @@
|
|||
#include "railsModel.h"
|
||||
#include "queryModel.h"
|
||||
#include "busModel.h"
|
||||
#include "Settings.h"
|
||||
|
||||
class BusStrategyBase : public QObject
|
||||
{
|
||||
|
|
13
include/Settings.h
Normal file
13
include/Settings.h
Normal 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
|
|
@ -86,13 +86,13 @@ void BusStrategyBase::GetBusDirectionSlot()
|
|||
switch (bus_model->direction)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
case BUS_STOP:
|
||||
duration = 1000;
|
||||
duration = Settings::tick;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "centralwidget.h"
|
||||
#include "BusStrategyBase.h"
|
||||
#include "StrategyFactory.h"
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui
|
||||
|
@ -87,10 +87,6 @@ public slots:
|
|||
void BeginBusTimerSlot([[maybe_unused]] int direction, int duration);
|
||||
|
||||
private:
|
||||
/**
|
||||
* 设置一时刻的长度,单位毫秒
|
||||
*/
|
||||
const int tick = 1000;
|
||||
|
||||
/**
|
||||
* UI控件
|
||||
|
|
|
@ -153,7 +153,7 @@ void MainWindow::BeginThread()
|
|||
|
||||
void MainWindow::BeginTickTimerSlot()
|
||||
{
|
||||
tick_timer->setInterval(tick);
|
||||
tick_timer->setInterval(Settings::tick);
|
||||
|
||||
tick_timer->start();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user