Create GUI Branch

This commit is contained in:
2022-06-10 19:52:43 +08:00
parent 1dad2ed57a
commit 2eb368ddfa
349 changed files with 297 additions and 107159 deletions

View File

@@ -1,54 +0,0 @@
#ifndef AUTO_PILOT_BUS_BUS_H
#define AUTO_PILOT_BUS_BUS_H
#include "define.h"
#include "rail.h"
#include "query.h"
struct bus {
/**
* 指向站点的指针
*/
rail_node_t* rail_node_pos;
/**
* 当前行进的距离
*/
int distance;
};
/**
* 表示公交车的结构体
*/
typedef struct bus bus_t;
/**
* 全局的公交车变量
*/
extern bus_t *the_bus;
/**
* 每个时刻使公交车前进
* @param direction 公交车前进的方向
*/
void RunBus(int direction);
/**
* 判断公交车是否到站
* @return BUS_TRUE为到站BUS_FALSE为未到站
*/
int JudgeOnStation();
/**
* 获得公交车当前所在的位置
* @return 公交车当前所在的位置
*/
int GetBusPosition();
/**
* 给出在指定的方向下,指定的请求于公交车当前位置的距离
* @param query 指定的请求
* @param orientation 指定的方向 BUS_CLOCK_WISE BUS_COUNTER_CLOCK_WISE
* @return 距离
*/
int GetQueryDistance(bus_query_t *query, int orientation);
#endif //AUTO_PILOT_BUS_BUS_H

View File

@@ -1,38 +0,0 @@
//
// Created by ricardo on 2022/5/6.
//
#ifndef AUTO_PILOT_BUS_BUS_IO_H
#define AUTO_PILOT_BUS_BUS_IO_H
#include "rail.h"
#include "query.h"
#include "define.h"
#include "controller.h"
#include "string.h"
#include "stdio.h"
/**
* 读取配置文件,创建轨道链表,同时读取需要使用的策略
* @return 指向轨道链表的指针
*/
rail_node_t* ReadConfigFile();
/**
* 读取标准输入流中的输入
* @param inputString 输入的字符串
* @return 当前读取的状态
*/
int ReadInput(char* inputString);
/**
* 打印当前的状态
*/
void PrintState();
/**
* 打印当前状态的函数供all_test使用在oj上有问题
* @param str 需要打印的内容
*/
void PrintStateInner(char *str);
#endif //AUTO_PILOT_BUS_BUS_IO_H

View File

@@ -1,75 +0,0 @@
//
// Created by ricardo on 2022/5/6.
//
#ifndef AUTO_PILOT_BUS_CONTROLLER_H
#define AUTO_PILOT_BUS_CONTROLLER_H
#include "stdlib.h"
#include "rail.h"
#include "query.h"
#include "bus.h"
/**
* 当前正在处理的请求
*/
extern bus_query_t *target_query;
/**
* 当前选择的策略
*/
extern int chosen_strategy;
/**
* 在先来先服务策略下应该前进的方向
* @return 前进的方向
*/
int FCFSDirection();
/**
* 在先来先服务策略下给出处理的请求
* @return 需要处理的请求
*/
bus_query_t *FCFSQuery();
/**
* 获得在SSTF策略下应该处理的请求
* @return 指向需要处理的请求的指针
*/
bus_query_t *SSTFGetQuery();
/**
* 根据指定的请求获得前进的方向,也就是前往指定的请求最近的方向
* 在SSTF策略中使用
* @param query 指定完成的请求
* @return 前进的方向
*/
int SSTFDirection(bus_query_t* query);
/**
* 在当前站上可以顺便服务的请求
* @param direction 当前公交车前进的方向
* @return 服务的请求指针
*/
bus_query_t *SSTFBTWQuery(int direction);
/**
* 获得在SCAN策略下应该处理的请求
* @return 指向需要处理的请求的指针
*/
bus_query_t *SCANGetQuery(int direction);
/**
* 根据指定的请求获得前进的方向
* 在SCAN策略中使用
* @param query 指定完成的请求
* @return 前进的方向
*/
int SCANDirection(bus_query_t *query, int orientation);
/**
* 在当前站上可以顺便服务的请求
* @return 服务的请求指针
*/
bus_query_t *SCANBTWQuery();
#endif //AUTO_PILOT_BUS_CONTROLLER_H

View File

@@ -1,21 +0,0 @@
//
// Created by ricardo on 2022/5/6.
//
#ifndef AUTO_PILOT_BUS_DEFINE_H
#define AUTO_PILOT_BUS_DEFINE_H
#define BUS_CLOCK_WISE 0 // 顺时针
#define BUS_COUNTER_CLOCK_WISE 1 // 逆时针
#define BUS_TARGET 2 // 目标
#define BUS_STOP 2 // 停止
#define BUS_TRUE 1 // 真
#define BUS_FAlSE 0 // 假
#define IO_CLOCK 0 // 读取时钟指令
#define IO_READING 1 // 读取请求指令
#define IO_END 2 // 读取结束指令
#define BUS_FCFS 0 // 先来先服务
#define BUS_SSTF 1 // 最短寻找时间优先
#define BUS_SCAN 2 // 顺便服务
#endif //AUTO_PILOT_BUS_DEFINE_H

View File

@@ -1,57 +0,0 @@
//
// Created by ricardo on 2022/5/6.
//
#ifndef AUTO_PILOT_BUS_QUERY_H
#define AUTO_PILOT_BUS_QUERY_H
#include "stdlib.h"
#include "rail.h"
#include "define.h"
struct bus_query {
/**
* 请求产生的时间
*/
int time;
/**
* 请求的类型
*/
int type;
/**
* 请求产生/指向的站点
*/
rail_node_t *node;
/**
* 指向下一个请求的指针
*/
struct bus_query *next_node;
};
typedef struct bus_query bus_query_t;
/**
* 全局的请求链表头节点
*/
extern bus_query_t *queries;
/**
* 创建请求链表节点
* @param type 请求的类型
* @param node 请求产生/指向的站点
* @return 当前创建的链表节点地址
*/
bus_query_t *CreateQuery(int type, rail_node_t *node);
/**
* 删除请求
* @param target_query 需要删除的请求
*/
void DeleteQuery(bus_query_t *target_query);
/**
* 释放请求链表占据的空间
* @param head 请求链表的头节点
*/
void FreeQueries(bus_query_t *head);
#endif //AUTO_PILOT_BUS_QUERY_H

View File

@@ -1,74 +0,0 @@
#ifndef AUTO_PILOT_BUS_RAIL_H
#define AUTO_PILOT_BUS_RAIL_H
#include "stdlib.h"
struct rail_node {
/**
* 站点的编号
*/
int id;
/**
* 距离上一个站点的距离
*/
int last_node_distance;
/**
* 距离下一个站点的距离
*/
int next_node_distance;
/**
* 指向上一个站点的指针
*/
struct rail_node* last_node;
/**
* 指向下一个站点的指针
*/
struct rail_node* next_node;
};
/**
* 表示轨道上的一个站点的结构体
*/
typedef struct rail_node rail_node_t;
/**
* 全局的轨道链表头节点,也就是第一个公交站
*/
extern rail_node_t *rails;
/**
* 轨道的总长度
*/
extern int all_distance;
/**
* 全局的计时器
*/
extern int bus_time;
/**
* 查找指定编号的站点指针
* @param head 轨道的头节点地址
* @param id 需要查找的站点编号
* @return 需要查找站点指针
*/
rail_node_t *FindNode(rail_node_t *head, int id);
/**
* 创建轨道列表
* @param length 站点之间的距离
* @param node_num 站点的个数
* @return 指向首站的指针
*/
rail_node_t *CreateRails(int length, int node_num);
/**
* 释放分配的内存空间
* @param railNode 轨道链表的头节点
*/
void FreeRails(rail_node_t *head);
/**
* 时间走过一秒
*/
void AddTime();
#endif //AUTO_PILOT_BUS_RAIL_H