修复了一些函数调用错误
合并了all_bus_test中的main函数
This commit is contained in:
parent
4e773ac790
commit
6c36e7fbf8
|
@ -82,7 +82,6 @@ int main()
|
|||
// 如果到站,处理请求和
|
||||
if(JudgeOnStation() == BUS_TRUE)
|
||||
{
|
||||
direction = FCFSDirection();
|
||||
finished_query = FCFSQuery();
|
||||
|
||||
if(finished_query != NULL) // 有请求就处理请求
|
||||
|
@ -93,6 +92,9 @@ int main()
|
|||
DeleteQuery(finished_query);
|
||||
finished_query = FCFSQuery();
|
||||
}
|
||||
|
||||
// 请求处理完再进行方向的判断
|
||||
direction = FCFSDirection();
|
||||
}
|
||||
else //如果没有请求就继续前进
|
||||
{
|
||||
|
@ -105,10 +107,83 @@ int main()
|
|||
}
|
||||
break;
|
||||
case BUS_SSTF:
|
||||
// 如果没有指定的请求就获得指定的请求
|
||||
if(target_query == NULL)
|
||||
{
|
||||
target_query = SSTFGetQuery();
|
||||
direction = SSTFDirection(target_query);
|
||||
}
|
||||
|
||||
if(JudgeOnStation() == BUS_TRUE)
|
||||
{
|
||||
// 如果到达目标的站点
|
||||
if(the_bus->rail_node_pos == target_query->node)
|
||||
{
|
||||
DeleteQuery(target_query);
|
||||
target_query = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
target_query = SSTFBTWQuery();
|
||||
if(target_query != NULL)
|
||||
{
|
||||
while (target_query != NULL)
|
||||
{
|
||||
DeleteQuery(target_query);
|
||||
target_query = SSTFBTWQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RunBus(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RunBus(direction);
|
||||
}
|
||||
break;
|
||||
case BUS_SCAN:
|
||||
// 如果没有指定的请求就获得指定的请求
|
||||
if(target_query == NULL)
|
||||
{
|
||||
target_query = SCANGetQuery();
|
||||
direction = SCANDirection(target_query);
|
||||
}
|
||||
|
||||
if(JudgeOnStation() == BUS_TRUE)
|
||||
{
|
||||
// 如果到达目标的站点
|
||||
if(the_bus->rail_node_pos == target_query->node)
|
||||
{
|
||||
DeleteQuery(target_query);
|
||||
target_query = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
target_query = SCANBTWQuery();
|
||||
if(target_query != NULL)
|
||||
{
|
||||
while (target_query != NULL)
|
||||
{
|
||||
DeleteQuery(target_query);
|
||||
target_query = SCANBTWQuery();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RunBus(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RunBus(direction);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// 这个分支只是为了符合代码规范而存在,理论上不会用到这个分支
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
4
main.c
4
main.c
|
@ -125,7 +125,7 @@ int main()
|
|||
if(target_query == NULL)
|
||||
{
|
||||
target_query = SCANGetQuery();
|
||||
direction = SSTFDirection(target_query);
|
||||
direction = SCANDirection(target_query);
|
||||
}
|
||||
|
||||
if(JudgeOnStation() == BUS_TRUE)
|
||||
|
@ -138,7 +138,7 @@ int main()
|
|||
}
|
||||
else
|
||||
{
|
||||
target_query = SCANGetQuery();
|
||||
target_query = SCANBTWQuery();
|
||||
if(target_query != NULL)
|
||||
{
|
||||
while (target_query != NULL)
|
||||
|
|
Loading…
Reference in New Issue
Block a user