2022-05-04 22:44:47 +08:00
|
|
|
|
#ifndef AUTO_PILOT_BUS_RAIL_H
|
|
|
|
|
#define AUTO_PILOT_BUS_RAIL_H
|
2022-05-13 11:41:00 +08:00
|
|
|
|
#include "stdlib.h"
|
2022-05-04 22:44:47 +08:00
|
|
|
|
|
2022-05-13 11:41:00 +08:00
|
|
|
|
struct rail_node {
|
2022-05-04 22:44:47 +08:00
|
|
|
|
/**
|
|
|
|
|
* 站点的编号
|
|
|
|
|
*/
|
|
|
|
|
int id;
|
|
|
|
|
/**
|
|
|
|
|
* 距离上一个站点的距离
|
|
|
|
|
*/
|
|
|
|
|
int last_node_distance;
|
|
|
|
|
/**
|
|
|
|
|
* 距离下一个站点的距离
|
|
|
|
|
*/
|
|
|
|
|
int next_node_distance;
|
|
|
|
|
/**
|
|
|
|
|
* 指向上一个站点的指针
|
|
|
|
|
*/
|
|
|
|
|
struct rail_node* last_node;
|
|
|
|
|
/**
|
|
|
|
|
* 指向下一个站点的指针
|
|
|
|
|
*/
|
|
|
|
|
struct rail_node* next_node;
|
2022-05-13 11:41:00 +08:00
|
|
|
|
};
|
2022-05-04 22:44:47 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 表示轨道上的一个站点的结构体
|
|
|
|
|
*/
|
|
|
|
|
typedef struct rail_node rail_node_t;
|
|
|
|
|
|
2022-05-12 15:32:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* 全局的轨道链表头节点,也就是第一个公交站
|
|
|
|
|
*/
|
2022-05-17 20:22:29 +08:00
|
|
|
|
extern rail_node_t *rails;
|
2022-05-06 11:55:30 +08:00
|
|
|
|
|
2022-06-03 21:28:52 +08:00
|
|
|
|
/**
|
|
|
|
|
* 轨道的总长度
|
|
|
|
|
*/
|
|
|
|
|
extern int all_distance;
|
|
|
|
|
|
2022-05-18 18:44:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* 全局的计时器
|
|
|
|
|
*/
|
|
|
|
|
extern int bus_time;
|
|
|
|
|
|
2022-05-06 11:55:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* 查找指定编号的站点指针
|
2022-05-18 17:31:34 +08:00
|
|
|
|
* @param head 轨道的头节点地址
|
2022-05-06 11:55:30 +08:00
|
|
|
|
* @param id 需要查找的站点编号
|
|
|
|
|
* @return 需要查找站点指针
|
|
|
|
|
*/
|
2022-05-18 17:31:34 +08:00
|
|
|
|
rail_node_t *FindNode(rail_node_t *head, int id);
|
2022-05-17 20:22:29 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建轨道列表
|
|
|
|
|
* @param length 站点之间的距离
|
|
|
|
|
* @param node_num 站点的个数
|
|
|
|
|
* @return 指向首站的指针
|
|
|
|
|
*/
|
|
|
|
|
rail_node_t *CreateRails(int length, int node_num);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 释放分配的内存空间
|
|
|
|
|
* @param railNode 轨道链表的头节点
|
|
|
|
|
*/
|
2022-05-18 18:44:21 +08:00
|
|
|
|
void FreeRails(rail_node_t *head);
|
2022-05-08 11:48:04 +08:00
|
|
|
|
|
2022-05-18 18:44:21 +08:00
|
|
|
|
/**
|
|
|
|
|
* 时间走过一秒
|
|
|
|
|
*/
|
|
|
|
|
void AddTime();
|
2022-05-04 22:44:47 +08:00
|
|
|
|
#endif //AUTO_PILOT_BUS_RAIL_H
|