将tick的持续时间设置了全局常量
This commit is contained in:
parent
10505c38b4
commit
21af2c0311
|
@ -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
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)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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控件
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user