2022-06-11 19:05:06 +08:00
|
|
|
|
//
|
|
|
|
|
// Created by ricardo on 2022/6/10.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef AUTO_BUS_GUI_BUS_MODEL_H
|
|
|
|
|
#define AUTO_BUS_GUI_BUS_MODEL_H
|
|
|
|
|
|
|
|
|
|
#include "railsModel.h"
|
|
|
|
|
#include "queryModel.h"
|
|
|
|
|
#include "define.h"
|
|
|
|
|
|
2022-06-25 16:35:07 +08:00
|
|
|
|
#include "QObject"
|
2022-06-26 13:57:45 +08:00
|
|
|
|
#include "QDebug"
|
2022-06-27 13:18:50 +08:00
|
|
|
|
#include "QTimer"
|
2022-06-11 19:05:06 +08:00
|
|
|
|
|
2022-06-25 16:35:07 +08:00
|
|
|
|
/**
|
2022-06-27 13:18:50 +08:00
|
|
|
|
* 公交车模型类
|
2022-06-25 16:35:07 +08:00
|
|
|
|
*/
|
2022-06-27 13:18:50 +08:00
|
|
|
|
class BusModel
|
2022-06-11 19:05:06 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
rail_node_t *rail_pos;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-06-27 13:18:50 +08:00
|
|
|
|
* 公交车前进的速度
|
2022-06-11 19:05:06 +08:00
|
|
|
|
*/
|
2022-06-27 13:18:50 +08:00
|
|
|
|
const int velocity = 1;
|
2022-06-11 19:05:06 +08:00
|
|
|
|
|
2022-06-17 11:25:02 +08:00
|
|
|
|
/**
|
|
|
|
|
* 当前前进的方向
|
|
|
|
|
*/
|
|
|
|
|
int direction;
|
|
|
|
|
|
2022-06-28 09:57:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* 当前指定处理的请求
|
|
|
|
|
*/
|
|
|
|
|
bus_query_t *target_query;
|
|
|
|
|
|
2022-06-27 13:18:50 +08:00
|
|
|
|
explicit BusModel();
|
2022-06-25 16:35:07 +08:00
|
|
|
|
|
2022-06-27 13:18:50 +08:00
|
|
|
|
~BusModel();
|
2022-06-25 16:35:07 +08:00
|
|
|
|
|
2022-06-17 12:18:43 +08:00
|
|
|
|
/**
|
2022-06-27 13:18:50 +08:00
|
|
|
|
* 重置公交车
|
|
|
|
|
* @param head 轨道的头节点位置
|
2022-06-17 12:18:43 +08:00
|
|
|
|
*/
|
2022-06-27 13:18:50 +08:00
|
|
|
|
void ResetBus(rail_node_t *head);
|
2022-06-17 12:18:43 +08:00
|
|
|
|
|
2022-06-28 18:44:55 +08:00
|
|
|
|
double GetBusPosition(int remaining_time);
|
2022-06-17 11:25:02 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 给出在指定的方向下,指定的请求于公交车当前位置的距离
|
|
|
|
|
* @param query 指定的请求
|
|
|
|
|
* @param orientation 指定的方向 BUS_CLOCK_WISE BUS_COUNTER_CLOCK_WISE
|
|
|
|
|
* @return 距离
|
|
|
|
|
*/
|
|
|
|
|
int GetQueryDistance(bus_query_t *query, int orientation) const;
|
|
|
|
|
|
2022-06-27 13:18:50 +08:00
|
|
|
|
private:
|
2022-06-17 11:25:02 +08:00
|
|
|
|
/**
|
2022-06-27 13:18:50 +08:00
|
|
|
|
* 轨道的头节点
|
2022-06-17 12:18:43 +08:00
|
|
|
|
*/
|
2022-06-27 13:18:50 +08:00
|
|
|
|
rail_node_t *rail_head;
|
2022-06-11 19:05:06 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //AUTO_BUS_GUI_BUS_MODEL_H
|