修复了SCAN策略中遇到公交车停下后本来前进方向丢失的问题
This commit is contained in:
parent
96961c91c9
commit
6e79af8b06
|
@ -176,13 +176,13 @@ int main()
|
||||||
direction = SCANDirection(target_query, direction);
|
direction = SCANDirection(target_query, direction);
|
||||||
|
|
||||||
// 处理下一个需要处理的请求就在脚底下的情况
|
// 处理下一个需要处理的请求就在脚底下的情况
|
||||||
if(target_query != NULL && direction == BUS_STOP && target_query->node == the_bus->rail_node_pos)
|
if(target_query != NULL && target_query->node == the_bus->rail_node_pos)
|
||||||
{
|
{
|
||||||
while (target_query != NULL && direction == BUS_STOP && target_query->node == the_bus->rail_node_pos)
|
while (target_query != NULL && target_query->node == the_bus->rail_node_pos)
|
||||||
{
|
{
|
||||||
DeleteQuery(target_query);
|
DeleteQuery(target_query);
|
||||||
target_query = SCANGetQuery(direction);
|
target_query = SSTFGetQuery();
|
||||||
direction = SCANDirection(target_query, direction);
|
direction = SSTFDirection(target_query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RunBus(direction);
|
RunBus(direction);
|
||||||
|
|
|
@ -71,4 +71,19 @@ int SCANDirection(bus_query_t *query, int orientation);
|
||||||
* @return 服务的请求指针
|
* @return 服务的请求指针
|
||||||
*/
|
*/
|
||||||
bus_query_t *SCANBTWQuery();
|
bus_query_t *SCANBTWQuery();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FCFS策略的控制函数
|
||||||
|
*/
|
||||||
|
void FCFSControl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SSTF策略的控制函数
|
||||||
|
*/
|
||||||
|
void SSTFControl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SCAN策略的控制函数
|
||||||
|
*/
|
||||||
|
void SCANControl();
|
||||||
#endif //AUTO_PILOT_BUS_CONTROLLER_H
|
#endif //AUTO_PILOT_BUS_CONTROLLER_H
|
||||||
|
|
4
main.c
4
main.c
|
@ -87,9 +87,9 @@ int main()
|
||||||
direction = SSTFDirection(target_query);
|
direction = SSTFDirection(target_query);
|
||||||
|
|
||||||
// 处理下一个需要处理的请求就在脚底下的情况
|
// 处理下一个需要处理的请求就在脚底下的情况
|
||||||
if(target_query != NULL && direction == BUS_STOP && target_query->node == the_bus->rail_node_pos)
|
if(target_query != NULL && target_query->node == the_bus->rail_node_pos)
|
||||||
{
|
{
|
||||||
while (target_query != NULL && direction == BUS_STOP && target_query->node == the_bus->rail_node_pos)
|
while (target_query != NULL && target_query->node == the_bus->rail_node_pos)
|
||||||
{
|
{
|
||||||
DeleteQuery(target_query);
|
DeleteQuery(target_query);
|
||||||
target_query = SSTFGetQuery();
|
target_query = SSTFGetQuery();
|
||||||
|
|
|
@ -238,10 +238,6 @@ int SCANDirection(bus_query_t *query, int orientation)
|
||||||
{
|
{
|
||||||
return BUS_COUNTER_CLOCK_WISE;
|
return BUS_COUNTER_CLOCK_WISE;
|
||||||
}
|
}
|
||||||
else if(distance == 0)
|
|
||||||
{
|
|
||||||
return BUS_STOP;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return BUS_CLOCK_WISE;
|
return BUS_CLOCK_WISE;
|
||||||
|
@ -261,10 +257,6 @@ int SCANDirection(bus_query_t *query, int orientation)
|
||||||
return BUS_CLOCK_WISE;
|
return BUS_CLOCK_WISE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(distance == 0)
|
|
||||||
{
|
|
||||||
return BUS_STOP;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return orientation;
|
return orientation;
|
||||||
|
@ -292,3 +284,18 @@ bus_query_t *SCANBTWQuery()
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FCFSControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSTFControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCANControl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user