2022-05-04 22:44:47 +08:00
|
|
|
|
#ifndef AUTO_PILOT_BUS_BUS_H
|
|
|
|
|
#define AUTO_PILOT_BUS_BUS_H
|
|
|
|
|
|
2022-05-06 11:55:30 +08:00
|
|
|
|
#include "define.h"
|
2022-05-04 22:44:47 +08:00
|
|
|
|
#include "rail.h"
|
2022-05-06 11:55:30 +08:00
|
|
|
|
#include "query.h"
|
2022-05-04 22:44:47 +08:00
|
|
|
|
|
2022-05-13 11:41:00 +08:00
|
|
|
|
struct bus {
|
2022-05-04 22:44:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* 指向站点的指针
|
|
|
|
|
*/
|
|
|
|
|
rail_node_t* rail_node_pos;
|
|
|
|
|
/**
|
|
|
|
|
* 当前行进的距离
|
|
|
|
|
*/
|
|
|
|
|
int distance;
|
2022-05-13 11:41:00 +08:00
|
|
|
|
};
|
2022-05-04 22:44:47 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 表示公交车的结构体
|
|
|
|
|
*/
|
|
|
|
|
typedef struct bus bus_t;
|
|
|
|
|
|
2022-05-18 18:44:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* 全局的公交车变量
|
|
|
|
|
*/
|
2022-05-20 08:52:58 +08:00
|
|
|
|
extern bus_t *the_bus;
|
2022-05-18 18:44:21 +08:00
|
|
|
|
|
2022-05-06 11:55:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* 每个时刻使公交车前进
|
|
|
|
|
* @param direction 公交车前进的方向
|
|
|
|
|
*/
|
2022-05-20 13:55:48 +08:00
|
|
|
|
void RunBus(int direction);
|
2022-05-06 11:55:30 +08:00
|
|
|
|
|
2022-05-20 13:55:48 +08:00
|
|
|
|
/**
|
|
|
|
|
* 判断公交车是否到站
|
2022-06-03 21:28:52 +08:00
|
|
|
|
* @return BUS_TRUE为到站,BUS_FALSE为未到站
|
2022-05-20 13:55:48 +08:00
|
|
|
|
*/
|
|
|
|
|
int JudgeOnStation();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获得公交车当前所在的位置
|
|
|
|
|
* @return 公交车当前所在的位置
|
|
|
|
|
*/
|
|
|
|
|
int GetBusPosition();
|
2022-06-03 21:28:52 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 给出在指定的方向下,指定的请求于公交车当前位置的距离
|
|
|
|
|
* @param query 指定的请求
|
|
|
|
|
* @param orientation 指定的方向 BUS_CLOCK_WISE BUS_COUNTER_CLOCK_WISE
|
|
|
|
|
* @return 距离
|
|
|
|
|
*/
|
|
|
|
|
int GetQueryDistance(bus_query_t *query, int orientation);
|
2022-05-04 22:44:47 +08:00
|
|
|
|
#endif //AUTO_PILOT_BUS_BUS_H
|