yy1717
2020-03-20 3a48a0de38910517352557510882f2ff4d8436ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Created by YY on 2020/3/20.
//
 
#include "through_something.h"
#include "../driver_test.h"
#include "../Geometry.h"
#include "../native-lib.h"
#include "../jni_log.h"
#include "../test_common/car_sensor.h"
#include "road_exam.h"
 
#define DEBUG(fmt, args...)     LOGD("<through_something> <%s>: " fmt, __func__, ##args)
 
static const double LASTEST_BREAK_POINT = 30.0;
static const double DISTANCE_STOP_CAR_TO_STOP_LINE = 5.0;
 
static int breakActive;
static int stopActive;
 
void StartThroughExam(int index, LIST_ROAD_MAP &RoadMapList)
{
    if (index == -1)
        return;
    DEBUG("进入路考子地图 index = %d id = %d item = %d", index, RoadMapList[index].id, RoadMapList[index].type);
    if (!RoadMapList[index].tts.empty()) {
        PlayTTS(RoadMapList[index].tts.c_str(), 0);
    }
    breakActive = 0;
    stopActive = 0;
}
 
int ExecuteThroughExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car,
        LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime)
{
    PointF p1, p2;
 
    double distance2StopLine = DistanceOf(car->carXY[car->axial[AXIAL_FRONT]],
                                          RoadMapList[index].stopLine);
    p1.X = RoadMapList[index].stopLine.X1;
    p1.Y = RoadMapList[index].stopLine.Y1;
    p2.X = RoadMapList[index].stopLine.X2;
    p2.Y = RoadMapList[index].stopLine.Y2;
 
    if (IntersectionOfLine(p1, p2, car->carXY[car->axial[AXIAL_FRONT]]) == -1) {
        distance2StopLine = -distance2StopLine;
    }
 
    // 距离停止线30米前是否有刹车动作
    if (breakActive == 0) {
        if (distance2StopLine >= LASTEST_BREAK_POINT) {
            if (ReadCarStatus(BREAK) == BREAK_ACTIVE) {
                breakActive = 1;
            }
        } else {
            breakActive = -1;
            // 不按规定减速,不合格
            DEBUG("不踩下刹车,不合格");
            switch (RoadMapList[index].type) {
                case THROUGH_INTERSECTION_MAP:
                    AddExamFault(41, rtkTime);
                    break;
                case TURN_LEFT_MAP:
                    AddExamFault(43, rtkTime);
                    break;
                case TURN_RIGHT_MAP:
                    AddExamFault(46, rtkTime);
                    break;
                case THROUGH_ZEBRA_CROSSING_MAP:
                    AddExamFault(48, rtkTime);
                    break;
                case THROUGH_SCHOOL_MAP:
                    AddExamFault(49, rtkTime);
                    break;
                case THROUGH_BUS_STATION_MAP:
                    AddExamFault(50, rtkTime);
                    break;
                default:
                    break;
            }
        }
    }
 
    // 有停止标记的,是否停车(停止线5米内有停车动作)
    if (RoadMapList[index].flagStop != 0 && stopActive == 0) {
        if (distance2StopLine < 0.0) {
            // 不停车瞭望,不合格
            DEBUG("不停车瞭望");
            switch (RoadMapList[index].type) {
                case THROUGH_INTERSECTION_MAP:
                    AddExamFault(42, rtkTime);
                    break;
                case TURN_LEFT_MAP:
                    AddExamFault(44, rtkTime);
                    break;
                case TURN_RIGHT_MAP:
                    AddExamFault(47, rtkTime);
                    break;
                default:
                    break;
            }
        } else if (distance2StopLine < DISTANCE_STOP_CAR_TO_STOP_LINE) {
            if (moveDirect == 0) {
                stopActive = 1;
            }
        }
    }
 
    if (ExitSonArea(index, RoadMapList, car))
        return -1;
 
    return index;
}