From 6e79af8b069d681f449f64d3208e098b5f4b9006 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 5 Jun 2022 20:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86SCAN=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E4=B8=AD=E9=81=87=E5=88=B0=E5=85=AC=E4=BA=A4=E8=BD=A6?= =?UTF-8?q?=E5=81=9C=E4=B8=8B=E5=90=8E=E6=9C=AC=E6=9D=A5=E5=89=8D=E8=BF=9B?= =?UTF-8?q?=E6=96=B9=E5=90=91=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- all_test/main.c | 8 ++++---- include/controller.h | 15 +++++++++++++++ main.c | 4 ++-- src/controller.c | 23 +++++++++++++++-------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/all_test/main.c b/all_test/main.c index 5bf9cf9..c090d95 100644 --- a/all_test/main.c +++ b/all_test/main.c @@ -176,13 +176,13 @@ int main() 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); - target_query = SCANGetQuery(direction); - direction = SCANDirection(target_query, direction); + target_query = SSTFGetQuery(); + direction = SSTFDirection(target_query); } } RunBus(direction); diff --git a/include/controller.h b/include/controller.h index ae88926..a39e79a 100644 --- a/include/controller.h +++ b/include/controller.h @@ -71,4 +71,19 @@ int SCANDirection(bus_query_t *query, int orientation); * @return 服务的请求指针 */ bus_query_t *SCANBTWQuery(); + +/** + * FCFS策略的控制函数 + */ +void FCFSControl(); + +/** + * SSTF策略的控制函数 + */ +void SSTFControl(); + +/** + * SCAN策略的控制函数 + */ +void SCANControl(); #endif //AUTO_PILOT_BUS_CONTROLLER_H diff --git a/main.c b/main.c index 29e83d2..0f90dbb 100644 --- a/main.c +++ b/main.c @@ -87,9 +87,9 @@ int main() 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); target_query = SSTFGetQuery(); diff --git a/src/controller.c b/src/controller.c index a68a362..6354cb7 100644 --- a/src/controller.c +++ b/src/controller.c @@ -238,10 +238,6 @@ int SCANDirection(bus_query_t *query, int orientation) { return BUS_COUNTER_CLOCK_WISE; } - else if(distance == 0) - { - return BUS_STOP; - } else { return BUS_CLOCK_WISE; @@ -261,10 +257,6 @@ int SCANDirection(bus_query_t *query, int orientation) return BUS_CLOCK_WISE; } } - else if(distance == 0) - { - return BUS_STOP; - } else { return orientation; @@ -291,4 +283,19 @@ bus_query_t *SCANBTWQuery() }//遍历请求链表,判断是否有可以顺便处理的请求 return NULL; +} + +void FCFSControl() +{ + +} + +void SSTFControl() +{ + +} + +void SCANControl() +{ + } \ No newline at end of file