From cea2a94fc97e79897cdfd217be8250c075974a1a Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期日, 07 二月 2021 17:55:42 +0800
Subject: [PATCH] 坡起限制条件和手刹起步全阶段生效.

---
 lib/src/main/cpp/driver_test.cpp |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp
index 9e0f000..00e93e5 100644
--- a/lib/src/main/cpp/driver_test.cpp
+++ b/lib/src/main/cpp/driver_test.cpp
@@ -38,6 +38,7 @@
 #include "test_items2/road_exam.h"
 #include "test_items/area_exam.h"
 #include "test_items2/prepare.h"
+#include "test_common/odo_graph.h"
 
 #define DEBUG(fmt, args...)     LOGD("<driver_test> <%s>: " fmt, __func__, ##args)
 
@@ -891,14 +892,49 @@
 
 static void ExecuteExam(double speed, int move, double azimuth, const struct RtkTime* rtkTime)
 {
+    static bool rec = false;
+    static bool handBreakActive = false, handBreakActive2 = false;
+    static double startCarMoveDistance;
+    static int prevMove = 0;
+
     if (move != 0) {
         if (ReadCarStatus(SEATBELT) == EJECT_SEATBELT && !reportSeatbeltEject) {
             DEBUG("涓嶇郴瀹夊叏甯�");
             reportSeatbeltEject = true;
             AddExamFault(ExamType == TEST_TYPE_AREA? 10101: 30101, rtkTime);
         }
+        if (rec) {
+            if (!handBreakActive2 && ReadOdo() - startCarMoveDistance >= examParam.start_car_limit_distance) {
+                handBreakActive2 = true;
+
+                if (ExamType == TEST_TYPE_ROAD_DUMMY_LIGHT || ExamType == TEST_TYPE_ROAD_TRUE_LIGHT) {
+                    if (ReadCarStatus(HAND_BREAK) == BREAK_ACTIVE) {
+                        DEBUG("Handbreak active move over 10m");
+                        // 鎵嬪埞鎷夎捣鐘舵�佷笅锛岃椹朵簡10绫充互涓婏紝涓嶅悎鏍�
+                        AddExamFault(40205, rtkTime);
+                    } else if (handBreakActive) {
+                        // 鎵嬪埞鎷夎捣鐘舵�佷笅锛岃椹朵簡1绫充互涓婏紝鎵�10鍒�
+                        DEBUG("Handbreak active move over 1M");
+                        AddExamFault(40206, rtkTime);
+                    }
+                }
+            } else if (!handBreakActive && ReadOdo() - startCarMoveDistance >= examParam.open_door_drive_allow_distance && ReadCarStatus(HAND_BREAK) == BREAK_ACTIVE) {
+                handBreakActive = true;
+
+                if (ExamType == TEST_TYPE_AREA) {
+                    DEBUG("Handbreak active move over 1M");
+                    AddExamFault(10107, rtkTime);
+                }
+            }
+        }
+    } else if (!rec || prevMove != 0) {          // 璁板綍鍋滆溅鐐�
+        rec = true;
+        handBreakActive = handBreakActive2 = false;
+        startCarMoveDistance = ReadOdo();
     }
 
+    prevMove = move;
+
     if (ExamType != TEST_TYPE_AREA) {
         if (exam_dummy_light == 4 || ExamType == TEST_TYPE_ROAD_TRUE_LIGHT || ExamType == TEST_TYPE_ROAD_CALIBRATE) {
             TestRoadGeneral(RoadMap, CarModel, CarModelList, speed, move, rtkTime);

--
Gitblit v1.8.0