// // Created by YY on 2020/8/21. // #include "overtake.h" #include "../native-lib.h" #include "../jni_log.h" #include "../test_common/odo_graph.h" #include "../driver_test.h" #define DEBUG(fmt, args...) LOGD(" <%s>: " fmt, __func__, ##args) static double maxMoveDistance; static int setup; static int originalLane; static void TtsBack(int seq) { maxMoveDistance = ReadOdo(); setup = 1; } void StartOvertakeExam(int ori_lane) { DEBUG("超越前方车辆"); PlayTTS("请超越前方车辆", TtsBack); setup = 0; originalLane = ori_lane; } bool TestOvertake(int currLane, const struct RtkTime *rtkTime) { if (setup == 0) { return true; } if (setup == 1) { if (originalLane == currLane) { } else if (currLane + 1 == originalLane) { setup = 2; originalLane = currLane; } else { DEBUG("右侧超车"); AddExamFault(3, rtkTime); return false; } } else if (setup == 2) { if (originalLane == currLane) { } else if (currLane == originalLane + 1) { PlayTTS("完成超车", NULL); return false; } else { DEBUG("超车违规变道"); AddExamFault(3, rtkTime); return false; } } if (ReadOdo() - maxMoveDistance > 150) { // 超车未完成 DEBUG("超车固定距离内未完成"); AddExamFault(3, rtkTime); return false; } return true; }