Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HCSR04new SSH1106-alan
handleTasks.cpp
00001 #include "mbed.h" 00002 #include "platform/mbed_thread.h" 00003 #include "Thread_Handle.h" 00004 #include "HCSR04.h" 00005 #include "main.h" 00006 #include "handleTasks.h" 00007 #include "rtc.h" 00008 #define carMaxnum 200 00009 #define sensorDist 95 //mm 00010 int carNum = 0; 00011 int carState = nothing; //car state 00012 00013 //cont car number and print to PC 00014 void countCarnum() 00015 { 00016 if(carState == carIn || carState == carOverSpeed_in) { 00017 carNum++; 00018 if (carNum >= carMaxnum) carNum = carMaxnum ; 00019 //printf("carNum =%d \n\n",carNum); 00020 return; 00021 } 00022 00023 if(carState == carOut || carState == carOverSpeed_out) { 00024 carNum--; 00025 if (carNum <= 0) carNum= 0 ; 00026 //printf("carNum =%d \n\n",carNum); 00027 return; 00028 } 00029 00030 if(carState == carHeadback_out || carState == carHeadback_in) { 00031 //printf("car is heading back \n\n"); 00032 return; 00033 } 00034 00035 00036 } 00037 //display car current state by OLED 00038 void oled_carStateDisplay() 00039 { 00040 switch(carState) { //depend on time to check the state of car 00041 case carIn: // car in 00042 ssh1106.writeText_format(0,4, font_5x8, "car in "); 00043 break; 00044 case nothing: //nothing 00045 break; 00046 case carOverSpeed_in: //overSpeed 00047 ssh1106.writeText_format(0,4, font_5x8, "car Over speed in "); 00048 break; 00049 case carHeadback_in: //headBack 00050 ssh1106.writeText_format(0,4, font_5x8, "car head back in "); 00051 break; 00052 case wrong: //error people or animals 00053 ssh1106.writeText_format(0,4, font_5x8, "wrong maybe people "); 00054 break; 00055 case carOut: // car in 00056 ssh1106.writeText_format(0,4, font_5x8, "car Out "); 00057 break; 00058 case carOverSpeed_out: //overSpeed 00059 ssh1106.writeText_format(0,4, font_5x8, "car overspeed Out "); 00060 break; 00061 case carHeadback_out: //headBack 00062 ssh1106.writeText_format(0,4, font_5x8, "car headback Out "); 00063 break; 00064 } 00065 00066 } 00067 //display car state in to PC 00068 void display_carState_in() 00069 { 00070 switch(get_carStage_in()) { //depend on time to check the state of car 00071 case carIn: // car in 00072 //printf("carStage = car in\n\n"); 00073 carState = carIn; 00074 break; 00075 case nothing: //nothing 00076 00077 break; 00078 case carOverSpeed_in: //overSpeed 00079 carState = carOverSpeed_in; 00080 //printf("carStage = carOverSpeed_in\n\n"); 00081 break; 00082 case carHeadback_in: //headBack 00083 carState = carHeadback_in; 00084 //printf("carStage = carHeadback_in\n\n"); 00085 break; 00086 case wrong: //error people or animals 00087 //printf("carStage = wrong\n\n"); 00088 break; 00089 } 00090 00091 } 00092 00093 //display car state in to PC 00094 void display_carState_out() 00095 { 00096 switch(get_carStage_out()) { //depend on time to check the state of car 00097 case carOut: // car in 00098 //printf("carStage = car Out\n\n"); 00099 carState = carOut; 00100 break; 00101 case nothing: //nothing 00102 00103 break; 00104 case carOverSpeed_out: //overSpeed 00105 carState = carOverSpeed_out; 00106 //printf("carStage = carOverSpeed_out\n\n"); 00107 break; 00108 case carHeadback_out: //headBack 00109 //printf("tttttttttttttiiiiiiiiiiin-min-1 = %d \n\n", Usensor1.time_in_min); 00110 //printf("tttttttttttttiiiiiiiiiiin-sec-1 = %d \n\n", Usensor1.time_in_sec); 00111 //printf("tttttttttttttiiiiiiiiiiin-min-0 = %d \n\n", Usensor0.time_in_min); 00112 //printf("tttttttttttttiiiiiiiiiiin-sec-0 = %d \n\n", Usensor0.time_in_sec); 00113 //printf("carStage = carHeadback_out\n\n"); 00114 carState = carHeadback_out; 00115 break; 00116 case wrong: //error people or animals 00117 //printf("carStage = wrong\n\n"); 00118 break; 00119 } 00120 } 00121 //get car state to single chip (in check) 00122 void carState_check_in() 00123 { 00124 if(carState == carOut || carState == carOverSpeed_out || carState == carHeadback_out)return ; 00125 if(Usensor0.dist < 80 && Usensor1.dist > 80) { // if car is in and car isnt out, make sure car is in 00126 Usensor0.time_in_min = p_tm->tm_min; 00127 Usensor0.time_in_sec = p_tm->tm_sec; 00128 //printf("#############################\n\n"); 00129 // printf("dist1-------------------------- = %d \n\n", Usensor1.dist); 00130 //printf("iiiiiiiiiiin-min-0 = %d \n\n", Usensor0.time_in_min); 00131 //printf("iiiiiiiiiiin-sec-0 = %d \n\n", Usensor0.time_in_sec); 00132 while(Usensor1.dist > 80) { // waiting for car pass sensor 1 00133 if(Usensor1.dist > 80 && Usensor0.dist > 80) { //if car is headbacking break this while, tell system car is headbacking 00134 // 确保车辆是倒车的 00135 Usensor0.time_in_min = 1; 00136 Usensor0.time_in_sec = 1; 00137 Usensor1.time_in_min = 0; 00138 Usensor1.time_in_sec = 0; 00139 //carState = carHeadback_in; 00140 return ; //倒车 00141 } 00142 thread_sleep_for(1); 00143 } 00144 //printf("dist0-------------------------- = %d \n\n", Usensor0.dist); 00145 Usensor1.time_in_min = p_tm->tm_min; 00146 Usensor1.time_in_sec = p_tm->tm_sec; 00147 //printf("iiiiiiiiiiin-min-1 = %d \n\n", Usensor1.time_in_min); 00148 //printf("iiiiiiiiiiin-sec-1 = %d \n\n", Usensor1.time_in_sec); 00149 00150 while(Usensor0.dist < 80) { //make sure car is outing sensor 0 00151 thread_sleep_for(1); 00152 if(Usensor0.dist > 80 && Usensor1.dist > 80) { 00153 // 确保车辆是倒车的 00154 Usensor0.time_in_min = 1; 00155 Usensor0.time_in_sec = 1; 00156 Usensor1.time_in_min = 0; 00157 Usensor1.time_in_sec = 0; 00158 return ; 00159 } 00160 00161 } 00162 Usensor0.time_out_min = p_tm->tm_min; 00163 Usensor0.time_out_sec = p_tm->tm_sec; 00164 //printf("oooooooooout-min-0 = %d \n\n", Usensor0.time_out_min); 00165 //printf("oooooooooout-sec-0 = %d \n\n", Usensor0.time_out_sec); 00166 00167 00168 while(Usensor1.dist < 80) { //make sure car is outing sensor 1 00169 thread_sleep_for(1); 00170 } 00171 Usensor1.time_out_min = p_tm->tm_min; 00172 Usensor1.time_out_sec = p_tm->tm_sec; 00173 //printf("oooooooooout-min-1 = %d \n\n", Usensor1.time_out_min); 00174 //printf("oooooooooout-sec-1 = %d \n\n", Usensor1.time_out_sec); 00175 //printf("#############################\n\n"); 00176 } 00177 } 00178 00179 //get car state to single chip (out check) 00180 void carState_check_out() 00181 { 00182 if(carState == carIn || carState == carOverSpeed_in || carState == carHeadback_in)return ; 00183 if(Usensor1.dist < 80 && Usensor0.dist > 80) { // if car is in and car isnt out, make sure car is in 00184 Usensor1.time_in_min = p_tm->tm_min; 00185 Usensor1.time_in_sec = p_tm->tm_sec; 00186 //printf("#############################\n\n"); 00187 // printf("dist1-------------------------- = %d \n\n", Usensor1.dist); 00188 //printf("iiiiiiiiiiin-min-1 = %d \n\n", Usensor1.time_in_min); 00189 //printf("iiiiiiiiiiin-sec-1 = %d \n\n", Usensor1.time_in_sec); 00190 while(Usensor0.dist > 80) { // waiting for car pass sensor 1 00191 if(Usensor0.dist > 80 && Usensor1.dist > 80) { //if car is headbacking break this while, tell system car is headbacking 00192 // 确保车辆是倒车的 00193 Usensor1.time_in_min = 1; 00194 Usensor1.time_in_sec = 1; 00195 Usensor0.time_in_min = 0; 00196 Usensor0.time_in_sec = 0; 00197 00198 //carState = carHeadback_in; 00199 return ; //倒车 00200 } 00201 thread_sleep_for(1); 00202 } 00203 //printf("dist0-------------------------- = %d \n\n", Usensor0.dist); 00204 Usensor0.time_in_min = p_tm->tm_min; 00205 Usensor0.time_in_sec = p_tm->tm_sec; 00206 //printf("iiiiiiiiiiin-min-0 = %d \n\n", Usensor0.time_in_min); 00207 //printf("iiiiiiiiiiin-sec-0 = %d \n\n", Usensor0.time_in_sec); 00208 00209 while(Usensor1.dist < 80) { //make sure car is outing sensor 0 00210 thread_sleep_for(1); 00211 if(Usensor1.dist > 80 && Usensor0.dist > 80) { 00212 // 确保车辆是倒车的 00213 Usensor1.time_in_min = 1; 00214 Usensor1.time_in_sec = 1; 00215 Usensor0.time_in_min = 0; 00216 Usensor0.time_in_sec = 0; 00217 return ; 00218 } 00219 00220 } 00221 Usensor1.time_out_min = p_tm->tm_min; 00222 Usensor1.time_out_sec = p_tm->tm_sec; 00223 //printf("oooooooooout-min-1 = %d \n\n", Usensor1.time_out_min); 00224 //printf("oooooooooout-sec-1 = %d \n\n", Usensor1.time_out_sec); 00225 00226 00227 while(Usensor0.dist < 80) { //make sure car is outing sensor 1 00228 thread_sleep_for(1); 00229 } 00230 Usensor0.time_out_min = p_tm->tm_min; 00231 Usensor0.time_out_sec = p_tm->tm_sec; 00232 //printf("oooooooooout-min-0 = %d \n\n", Usensor0.time_out_min); 00233 //printf("oooooooooout-sec-0 = %d \n\n", Usensor0.time_out_sec); 00234 //printf("#############################\n\n"); 00235 } 00236 } 00237 00238 //method - get car state (in) 00239 int get_carStage_in() 00240 { 00241 if((Usensor1.time_in_min + Usensor0.time_in_min + Usensor1.time_in_sec + Usensor0.time_in_sec + Usensor1.time_out_min + Usensor0.time_out_min + Usensor1.time_out_sec + Usensor0.time_out_sec) == 0) 00242 return nothing; 00243 if((Usensor1.time_in_min - Usensor0.time_in_min) > 0) { //计算分钟 车子进 00244 if((Usensor0.time_out_min - Usensor1.time_in_min) > 0) { //计算分钟 车子进 00245 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { //计算分钟 车子进 00246 return carIn; 00247 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { //计算秒 车子进 还需要套娃 00248 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { //计算秒 车子进 00249 return carIn; 00250 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { //计算秒 车子进 超速 00251 return carOverSpeed_in; 00252 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { //计算秒 车子出 00253 return wrong; 00254 } 00255 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { //计算分钟 车子出 00256 return wrong; //先放着 有可能是59分进入 01分出 00257 } 00258 } else if((Usensor0.time_out_min - Usensor1.time_in_min) == 0) { //计算秒 车子进 00259 if((Usensor0.time_out_sec - Usensor1.time_in_sec) > 0) { //计算秒 车子进 00260 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { //车子进 00261 return carIn; //有可能 59分进 01 分出 00262 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { //计算秒 车子进 00263 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { // 车子进 00264 return carIn; 00265 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { // 车子太快 00266 return carOverSpeed_in; 00267 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { // 车子出 00268 return wrong; 00269 } 00270 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { //计算秒 车子出 00271 return wrong; ////////////////////////////////////// 00272 } 00273 00274 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) == 0) { //计算秒 车子没动or太快了 00275 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { //计算秒 车子进 00276 return carIn; 00277 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { //计算秒 车子进 00278 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { //计算秒 车子进 00279 return carIn; 00280 } 00281 if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { // 车子超速 00282 return carOverSpeed_in; 00283 } 00284 if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { // 车子出 00285 return wrong; 00286 } 00287 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { //计算秒 车子进 00288 return wrong; 00289 } 00290 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) < 0) { //计算秒 车子出 00291 return carHeadback_in; 00292 } 00293 } else if((Usensor0.time_out_min - Usensor1.time_in_min) < 0) { //计算分钟 车子出 00294 return carHeadback_in; 00295 } 00296 } else if((Usensor1.time_in_min - Usensor0.time_in_min) == 0) { //计算秒 车子进 00297 if((Usensor1.time_in_sec - Usensor0.time_in_sec) > 0) { //计算秒 车子进 00298 if((Usensor0.time_out_min - Usensor1.time_in_min) > 0) { 00299 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00300 return carIn; 00301 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00302 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00303 return carIn; 00304 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { 00305 return carOverSpeed_in; 00306 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00307 return wrong; 00308 } 00309 } else if((Usensor1.time_out_min - Usensor0.time_out_min < 0 )) { 00310 return wrong; 00311 } 00312 } else if((Usensor0.time_out_min - Usensor1.time_in_min) == 0) { 00313 if((Usensor0.time_out_sec - Usensor1.time_in_sec) > 0) { 00314 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00315 return carIn; 00316 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00317 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00318 return carIn; 00319 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { 00320 return carOverSpeed_in; 00321 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00322 return wrong; 00323 } 00324 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { 00325 return wrong; 00326 } 00327 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) == 0) { 00328 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00329 return carIn; 00330 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00331 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00332 return carIn; 00333 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { 00334 return carOverSpeed_in; 00335 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00336 return wrong; 00337 } 00338 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { 00339 return wrong; 00340 } 00341 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) < 0) { 00342 return carHeadback_in; 00343 } 00344 } else if((Usensor0.time_out_min - Usensor1.time_in_min) < 0) { 00345 return carHeadback_in; 00346 } 00347 } else if((Usensor1.time_in_sec - Usensor0.time_in_sec) == 0) { // 计算秒 车子没动 00348 if((Usensor0.time_out_min - Usensor1.time_in_min) > 0) { 00349 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00350 return carIn; 00351 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00352 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00353 return carIn; 00354 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) == 0) { 00355 return carOverSpeed_in; 00356 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00357 return wrong; 00358 } 00359 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { 00360 return wrong; 00361 } 00362 } else if((Usensor0.time_out_min - Usensor1.time_in_min) == 0) { 00363 if((Usensor0.time_out_sec - Usensor1.time_in_sec) > 0) { 00364 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00365 return carIn; 00366 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00367 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00368 return carIn; 00369 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { 00370 return carOverSpeed_in; 00371 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00372 return wrong; 00373 } 00374 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { 00375 return wrong; 00376 } 00377 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) == 0) { 00378 if((Usensor1.time_out_min - Usensor0.time_out_min) > 0) { 00379 return carIn; 00380 } else if((Usensor1.time_out_min - Usensor0.time_out_min) == 0) { 00381 if((Usensor1.time_out_sec - Usensor0.time_out_sec) > 0) { 00382 return carIn; 00383 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) == 0) { 00384 return carOverSpeed_in; 00385 } else if((Usensor1.time_out_sec - Usensor0.time_out_sec) < 0) { 00386 return wrong; 00387 } 00388 } else if((Usensor1.time_out_min - Usensor0.time_out_min) < 0) { 00389 return wrong; 00390 } 00391 } else if((Usensor0.time_out_sec - Usensor1.time_in_sec) < 0) { 00392 return carHeadback_in; 00393 } 00394 } else if((Usensor0.time_out_min - Usensor1.time_in_min) < 0) { 00395 return carHeadback_in; 00396 } 00397 } else if((Usensor1.time_in_sec - Usensor0.time_in_sec) < 0) { // 计算秒 车子出 00398 return carHeadback_in; //先放着 有可能是59分进入 01分出 00399 00400 } 00401 } else if((Usensor1.time_in_min - Usensor0.time_in_min) < 0) { //计算分钟 车子出 00402 return carHeadback_in; //先放着 有可能是59分进入 01分出 00403 } 00404 return 0; 00405 } 00406 //method - get car state (out) 00407 int get_carStage_out() 00408 { 00409 if(carState == carIn || carState == carOverSpeed_in || carState == carHeadback_in)return nothing;//当车进入,超速进入 或者 倒车进入的时候 不执行车辆out检测 00410 if((Usensor0.time_in_min + Usensor1.time_in_min + Usensor0.time_in_sec + Usensor1.time_in_sec + Usensor0.time_out_min + Usensor1.time_out_min + Usensor0.time_out_sec + Usensor1.time_out_sec) == 0) 00411 return nothing; 00412 if((Usensor0.time_in_min - Usensor1.time_in_min) > 0) { //计算分钟 车子进 00413 if((Usensor1.time_out_min - Usensor0.time_in_min) > 0) { //计算分钟 车子进 00414 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { //计算分钟 车子进 00415 return carOut; 00416 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { //计算秒 车子进 还需要套娃 00417 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { //计算秒 车子进 00418 return carOut; 00419 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { //计算秒 车子进 超速 00420 return carOverSpeed_out; 00421 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { //计算秒 车子出 00422 return wrong; 00423 } 00424 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { //计算分钟 车子出 00425 return wrong; //先放着 有可能是59分进入 10分出 00426 } 00427 } else if((Usensor1.time_out_min - Usensor0.time_in_min) == 0) { //计算秒 车子进 00428 if((Usensor1.time_out_sec - Usensor0.time_in_sec) > 0) { //计算秒 车子进 00429 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { //车子进 00430 return carOut; //有可能 59分进 10 分出 00431 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { //计算秒 车子进 00432 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { // 车子进 00433 return carOut; 00434 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { // 车子太快 00435 return carOverSpeed_out; 00436 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { // 车子出 00437 return wrong; 00438 } 00439 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { //计算秒 车子出 00440 return wrong; ////////////////////////////////////// 00441 } 00442 00443 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) == 0) { //计算秒 车子没动or太快了 00444 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { //计算秒 车子进 00445 return carOut; 00446 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { //计算秒 车子进 00447 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { //计算秒 车子进 00448 return carOut; 00449 } 00450 if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { // 车子超速 00451 return carOverSpeed_out; 00452 } 00453 if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { // 车子出 00454 return wrong; 00455 } 00456 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { //计算秒 车子进 00457 return wrong; 00458 } 00459 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) < 0) { //计算秒 车子出 00460 return carHeadback_out; 00461 } 00462 } else if((Usensor1.time_out_min - Usensor0.time_in_min) < 0) { //计算分钟 车子出 00463 return carHeadback_out; 00464 } 00465 } else if((Usensor0.time_in_min - Usensor1.time_in_min) == 0) { //计算秒 车子进 00466 if((Usensor0.time_in_sec - Usensor1.time_in_sec) > 0) { //计算秒 车子进 00467 if((Usensor1.time_out_min - Usensor0.time_in_min) > 0) { 00468 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00469 return carOut; 00470 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00471 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00472 return carOut; 00473 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { 00474 return carOverSpeed_out; 00475 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00476 return wrong; 00477 } 00478 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00479 return wrong; 00480 } 00481 } else if((Usensor1.time_out_min - Usensor0.time_in_min) == 0) { 00482 if((Usensor1.time_out_sec - Usensor0.time_in_sec) > 0) { 00483 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00484 return carOut; 00485 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00486 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00487 return carOut; 00488 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { 00489 return carOverSpeed_out; 00490 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00491 return wrong; 00492 } 00493 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00494 return wrong; 00495 } 00496 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) == 0) { 00497 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00498 return carOut; 00499 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00500 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00501 return carOut; 00502 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { 00503 return carOverSpeed_out; 00504 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00505 return wrong; 00506 } 00507 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00508 return wrong; 00509 } 00510 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) < 0) { 00511 return carHeadback_out; 00512 } 00513 } else if((Usensor1.time_out_min - Usensor0.time_in_min) < 0) { 00514 return carHeadback_out; 00515 } 00516 } else if((Usensor0.time_in_sec - Usensor1.time_in_sec) == 0) { // 计算秒 车子没动 00517 if((Usensor1.time_out_min - Usensor0.time_in_min) > 0) { 00518 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00519 return carOut; 00520 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00521 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00522 return carOut; 00523 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) == 0) { 00524 return carOverSpeed_out; 00525 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00526 return wrong; 00527 } 00528 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00529 return wrong; 00530 } 00531 } else if((Usensor1.time_out_min - Usensor0.time_in_min) == 0) { 00532 if((Usensor1.time_out_sec - Usensor0.time_in_sec) > 0) { 00533 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00534 return carOut; 00535 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00536 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00537 return carOut; 00538 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { 00539 return carOverSpeed_out; 00540 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00541 return wrong; 00542 } 00543 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00544 return wrong; 00545 } 00546 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) == 0) { 00547 if((Usensor0.time_out_min - Usensor1.time_out_min) > 0) { 00548 return carOut; 00549 } else if((Usensor0.time_out_min - Usensor1.time_out_min) == 0) { 00550 if((Usensor0.time_out_sec - Usensor1.time_out_sec) > 0) { 00551 return carOut; 00552 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) == 0) { 00553 return carOverSpeed_out; 00554 } else if((Usensor0.time_out_sec - Usensor1.time_out_sec) < 0) { 00555 return wrong; 00556 } 00557 } else if((Usensor0.time_out_min - Usensor1.time_out_min) < 0) { 00558 return wrong; 00559 } 00560 } else if((Usensor1.time_out_sec - Usensor0.time_in_sec) < 0) { 00561 return carHeadback_out; 00562 } 00563 } else if((Usensor1.time_out_min - Usensor0.time_in_min) < 0) { 00564 return carHeadback_out; 00565 } 00566 } else if((Usensor0.time_in_sec - Usensor1.time_in_sec) < 0) { // 计算秒 车子出 00567 return carHeadback_out; //先放着 有可能是59分进入 10分出 00568 00569 } 00570 } else if((Usensor0.time_in_min - Usensor1.time_in_min) < 0) { //计算分钟 车子出 00571 return carHeadback_out; //先放着 有可能是59分进入 10分出 00572 } 00573 return 0; 00574 } 00575
Generated on Wed Jul 27 2022 08:19:38 by
