From 635ea8bdfa5d35841a839361cd91d38f137b546c Mon Sep 17 00:00:00 2001 From: nvhaizi1 Date: Thu, 19 May 2022 22:39:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86ReadInput=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bus_io.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/bus_io.c b/src/bus_io.c index 27fb895..b79100a 100644 --- a/src/bus_io.c +++ b/src/bus_io.c @@ -2,3 +2,36 @@ // Created by ricardo on 2022/5/6. // #include "bus_io.h" +#include "define.h" + +int ReadInput(char* inputString) +{ + + char src[20]; + int num; + sscanf(inputString,"%[a-z] %d",src,&num); + if (0 == strcmp("clock",src)) + { + return IO_CLOCK; + } + else if (0 == strcmp("counterclockwise",src)) + { + bus_query_t *CreateQuery(BUS_COUNTER_CLOCK_WISE, FindNode(num)); + return IO_READING; + } + else if (0 == strcmp("clockwise",src)) + { + bus_query_t *CreateQuery(BUS_CLOCK_WISE,FindNode(num)); + return IO_READING; + } + else if (0 == strcmp("target",src)) + { + bus_query_t *CreateQuery(BUS_TARGET,FindNode(num)); + return IO_READING; + } + else if (0 == strcmp("end",src)) + { + return IO_END; + } + +}