完成了SSTF和SCAN策略的控制函数及流程设计

修复了FCFS策略中连续在同一站的请求处理错误的bug
This commit is contained in:
2022-05-28 22:20:03 +08:00
parent d691021553
commit 4e773ac790
5 changed files with 159 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
#include "bus.h"
#include "math.h"
bus_t *the_bus = NULL;
void RunBus(int direction)
{
if(direction == BUS_CLOCK_WISE)//顺时针
@@ -11,21 +12,25 @@ void RunBus(int direction)
{
the_bus->distance--;
}
}
int GetBusPosition()
{
int a, b, c;
b = 0;
rail_node_t *p = rails;
a = the_bus->rail_node_pos->id;//指向站点的指针以及这个指针对应的站台id
while (p->id != a){
b += p->next_node_distance;
p = p->next_node;
}
c = b + (the_bus->distance);
return c;
}
int JudgeOnStation()
{
if (abs(the_bus->distance) == rails->last_node_distance)//表示逆时针

View File

@@ -48,3 +48,33 @@ bus_query_t *FCFSQuery()
{
return NULL;
}
bus_query_t *SSTFGetQuery()
{
return NULL;
}
int SSTFDirection(bus_query_t* target_query)
{
return BUS_STOP;
}
bus_query_t *SSTFBTWQuery()
{
return NULL;
}
bus_query_t *SCANGetQuery()
{
return NULL;
}
int SCANDirection(bus_query_t *target_query)
{
return BUS_STOP;
}
bus_query_t *SCANBTWQuery()
{
return NULL;
}