auto_bus/include/BusStrategyBase.h

143 lines
2.6 KiB
C
Raw Normal View History

//
// Created by ricardo on 2022/6/27.
//
#ifndef AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H
#define AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H
#include "QObject"
#include "QString"
#include "QTimer"
#include "railsModel.h"
#include "queryModel.h"
#include "busModel.h"
#include "Settings.h"
2022-07-09 10:11:35 +08:00
/**
*
*/
class BusStrategyBase : public QObject
{
Q_OBJECT
public:
/**
*
*/
RailsModel *rails_model;
/**
*
*/
QueryModel *query_model;
/**
*
*/
BusModel *bus_model;
/**
*
*/
int bus_tick;
/**
*
*/
int strategy;
BusStrategyBase();
~BusStrategyBase() override;
/**
*
* @return
*/
virtual int GetBusDirection() = 0;
/**
*
* @return
*/
virtual bus_query_t *GetTargetQuery() = 0;
/**
2022-06-28 21:15:50 +08:00
* 便
* @return
*/
2022-06-28 21:15:50 +08:00
virtual bus_query_t *HandleBTWQuery() = 0;
signals:
/**
*
* @param query
*/
2022-06-28 21:15:50 +08:00
void DeleteQuerySignal(int query_type, int node_id);
/**
*
* @param string
*/
void PrintStateSignal(QString string);
2022-06-28 21:15:50 +08:00
/**
*
* @param direction
* @param duration
*/
void BusRunningSignal(int direction, int duration);
public slots:
2022-06-28 21:15:50 +08:00
/**
*
* @param query_type
* @param node_id ID
*/
void AppendQuerySlot(int query_type, int node_id);
/**
*
*/
void BusBeginSlot();
/**
*
*/
void BusEndSlot();
/**
* tick事件的槽函数
*/
void OneTickSlot(int remaining_time);
/**
*
*/
2022-06-28 21:15:50 +08:00
void OnStopSlot();
private:
/**
*
*/
int status = BUS_END;
/**
*
* @return
*/
QString PrintState(int remaining_time) const;
/**
*
*/
void DetermineBusStatus();
/**
*
*/
2022-06-28 21:15:50 +08:00
void HandleQuery();
};
#endif //AUTO_BUS_GUI_BUS_CONTROLLER_BASE_H