yy1717
2020-03-25 b73f32bc8ad86a7bb5f0739ac0fd7aa4c04cce98
加减档
13个文件已修改
2个文件已添加
271 ■■■■■ 已修改文件
lib/src/main/cpp/CMakeLists.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/driver_test.cpp 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_module/rtk.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_platform/platform.cpp 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/park_edge.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/stop_and_start.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/turn_a90.cpp 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/dummy_light.cpp 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/dummy_light.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/operate_gear.cpp 169 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/operate_gear.h 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/road_exam.cpp 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/road_exam.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/stop_car.cpp 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/stop_car.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/CMakeLists.txt
@@ -42,6 +42,7 @@
        test_items2/through_something.cpp
        test_items2/drive_straight.cpp
        test_items2/stop_car.cpp
        test_items2/operate_gear.cpp
        rtk_module/rtk.cpp
        rtk_module/virtual_rtk.cpp
lib/src/main/cpp/driver_test.cpp
@@ -551,6 +551,9 @@
    if (start == 0) {
        DEBUG("结束考试");
        TerminateRoadExam();
        CurrExamMapIndex = -1;
        ExamStart = false;
        MA_SendExamStatus(0, 0);
@@ -813,7 +816,7 @@
    if (ReadCarStatus(ENGINE_START) == ENGINE_START_ACTIVE) {
        if (!engineStart) {
            engineStart = true;
            if (ReadCarStatus(GEAR) != 'N') {
            if (ReadCarStatus(GEAR) != GEAR_N) {
                // 不是空挡点火,不合格
                if (ExamType == TEST_TYPE_AREA)
                    AddExamFault(3, rtkTime);
lib/src/main/cpp/rtk_module/rtk.cpp
@@ -200,7 +200,7 @@
        }*/
        if (RxBufLen > 0) {
#if 0
#if 1
            const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen);
            if(ptr != RxBuf) {
                memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf));
lib/src/main/cpp/rtk_platform/platform.cpp
@@ -23,6 +23,7 @@
#include "../driver_test.h"
#include "../test_common/car_sensor.h"
#include "../test_items2/stop_car.h"
#include "../test_items2/operate_gear.h"
#define PARSE_BUFF_SIZE         4096
@@ -434,6 +435,7 @@
    if (events & PLAY_TTS_DONE_EVT) {
        DummyLightTTSDone(*((int *)data));
        StopCarTTSDone(*((int *)data));
        OperateGearTTSDone(*((int *)data));
    }
}
lib/src/main/cpp/test_items/park_edge.cpp
@@ -9,6 +9,7 @@
#include "../common/apptimer.h"
#include "../native-lib.h"
#include "../utils/xconvert.h"
#include "../test_common/car_sensor.h"
#include <vector>
#include <cstdlib>
@@ -136,7 +137,7 @@
                    }
                    // 在这里检查转向灯状态
                    if (true) {
                    if (ReadCarStatus(TURN_SIGNAL_LAMP) != LEFT_TURN_LIGHT) {
                        // 不开转向灯,扣10分
                        AddExamFault(25, rtkTime);
                        DEBUG("未开启转向灯");
lib/src/main/cpp/test_items/stop_and_start.cpp
@@ -11,6 +11,7 @@
#include "../jni_log.h"
#include "../common/apptimer.h"
#include "../utils/xconvert.h"
#include "../test_common/car_sensor.h"
#define DEBUG(fmt, args...)     LOGD("<stop_and_start> <%s>: " fmt, __func__, ##args)
@@ -121,7 +122,7 @@
            }
            // 检查是否拉住手刹
            if (true) {
            if (ReadCarStatus(HAND_BREAK) != BREAK_ACTIVE) {
                AddExamFault(19, rtkTime);
                DEBUG("没拉手刹");
            }
lib/src/main/cpp/test_items/turn_a90.cpp
@@ -9,6 +9,7 @@
#include "../jni_log.h"
#include "../utils/xconvert.h"
#include "../defs.h"
#include "../test_common/car_sensor.h"
#include <vector>
#include <cstdlib>
@@ -96,14 +97,20 @@
    if (az >= 30) {
        if (!turnLeftFinished) {
            char turn_direct;
            if((( ((int)heading) + 360 - enterAreaHeading) % 360) < 180) {
                DEBUG("右转");
                turn_direct = 'R';
            } else {
                DEBUG("左转");
                turn_direct = 'L';
            }
            // 转向灯未开启,扣10分
            AddExamFault(30, rtkTime);
            DEBUG("转向灯未开启");
            if ((turn_direct == 'R' && ReadCarStatus(TURN_SIGNAL_LAMP) != RIGHT_TURN_LIGHT) ||
                    (turn_direct == 'L' && ReadCarStatus(TURN_SIGNAL_LAMP) != LEFT_TURN_LIGHT)) {
                DEBUG("转向灯未开启");
                AddExamFault(30, rtkTime);
            }
        }
        turnLeftFinished = true;
    }
lib/src/main/cpp/test_items2/dummy_light.cpp
@@ -72,6 +72,12 @@
    }
}
void TerminateDummyLightExam(void)
{
    AppTimer_delete(DummyLightCheckActive);
    AppTimer_delete(ExamDummyLight);
}
static void DummyLightCheckActive(union sigval sig)
{
    int active = sig.sival_int;
lib/src/main/cpp/test_items2/dummy_light.h
@@ -31,5 +31,6 @@
void StartDummyLightExam(struct dummy_light_exam *ptr, int num, const struct RtkTime* rtkTime);
int ExecuteDummyLightExam(const struct RtkTime* rtkTime);
void DummyLightTTSDone(int id);
void TerminateDummyLightExam(void);
#endif //MYAPPLICATION2_DUMMY_LIGHT_H
lib/src/main/cpp/test_items2/operate_gear.cpp
New file
@@ -0,0 +1,169 @@
//
// Created by YY on 2020/3/25.
//
#include "operate_gear.h"
#include "../driver_test.h"
#include "../common/apptimer.h"
#include "../native-lib.h"
#include "../test_common/car_sensor.h"
#include "../jni_log.h"
#define DEBUG(fmt, args...)     LOGD("<operate_gear> <%s>: " fmt, __func__, ##args)
static int opGear;
static bool testing;
static int examTtsSeq = 0;
static int expectGear;
static int upDownShift;
static bool checkError;
static int opCnt = 0;
enum {
    START_GEAR,
    WAIT_TTS_END,
    TTS_END,
    WAITE_CHECK,
    CHECKED
};
static void CheckGear(union sigval sig);
void StartOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList) {
    if (index == -1)
        return;
    testing = true;
    opGear = START_GEAR;
    checkError = false;
    upDownShift = 0;
    opCnt = 0;
}
void TerminateOperateGearExam(void)
{
    AppTimer_delete(CheckGear);
}
int ExecuteOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car,
                       LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime) {
    DEBUG("opGear %d", opGear);
    if (opGear == START_GEAR) {
        int currGear = ReadCarStatus(GEAR);
        switch (currGear) {
            case GEAR_1: {
                opGear = WAIT_TTS_END;
                upDownShift = 1;
                expectGear = GEAR_2;
                examTtsSeq = PlayTTS("请加到二挡");
                break;
            }
            case GEAR_2: {
                opGear = WAIT_TTS_END;
                if (upDownShift == 0) {
                    upDownShift = 1;
                    expectGear = GEAR_3;
                    examTtsSeq = PlayTTS("请加到三挡");
                } else if (upDownShift == 1) {
                    upDownShift = -1;
                    expectGear = GEAR_1;
                    examTtsSeq = PlayTTS("请减到一挡");
                } else {
                    upDownShift = 1;
                    expectGear = GEAR_3;
                    examTtsSeq = PlayTTS("请加到三挡");
                }
                break;
            }
            case GEAR_3: {
                opGear = WAIT_TTS_END;
                if (upDownShift == 0) {
                    upDownShift = -1;
                    expectGear = GEAR_2;
                    examTtsSeq = PlayTTS("请减到二挡");
                } else if (upDownShift == 1) {
                    upDownShift = -1;
                    expectGear = GEAR_2;
                    examTtsSeq = PlayTTS("请减到二挡");
                } else {
                    upDownShift = 1;
                    expectGear = GEAR_4;
                    examTtsSeq = PlayTTS("请加到四挡");
                }
                break;
            }
            case GEAR_4: {
                opGear = WAIT_TTS_END;
                if (upDownShift == 0) {
                    upDownShift = -1;
                    expectGear = GEAR_3;
                    examTtsSeq = PlayTTS("请减到三挡");
                } else if (upDownShift == 1) {
                    upDownShift = -1;
                    expectGear = GEAR_3;
                    examTtsSeq = PlayTTS("请减到三挡");
                } else {
                    upDownShift = 1;
                    expectGear = GEAR_5;
                    examTtsSeq = PlayTTS("请加到五挡");
                }
                break;
            }
            case GEAR_5: {
                opGear = WAIT_TTS_END;
                upDownShift = -1;
                expectGear = GEAR_4;
                examTtsSeq = PlayTTS("请减到四挡");
                break;
            }
            default:
                // 未读到有效挡位,继续尝试
                break;
        }
    } else if (opGear == WAIT_TTS_END) {
    } else if (opGear == TTS_END) {
        opCnt++;
        opGear = WAITE_CHECK;
        checkError = false;
        AppTimer_delete(CheckGear);
        AppTimer_add(CheckGear, D_SEC(5));
    } else if (opGear == CHECKED) {
        if (checkError) {
            // 未按指令操作挡位,不合格
            DEBUG("未按指令操作挡位");
            AddExamFault(31, rtkTime);
        }
        if (opCnt < 2) {
            opGear = START_GEAR;
        } else {
            testing = false;
        }
    }
    return testing ? index : -1;
}
void OperateGearTTSDone(int id)
{
    DEBUG("OperateGearTTSDone %d", id);
    // 等语音播报完毕后计时
    if (id == examTtsSeq) {
        opGear = TTS_END;
    }
}
static void CheckGear(union sigval sig)
{
    AppTimer_delete(CheckGear);
    DEBUG("检测挡位 %d", expectGear);
    // 检查挡位
    if (ReadCarStatus(GEAR) != expectGear) {
        // 不执行指定挡位,不合格
        checkError = true;
    }
    opGear = CHECKED;
}
lib/src/main/cpp/test_items2/operate_gear.h
New file
@@ -0,0 +1,16 @@
//
// Created by YY on 2020/3/25.
//
#ifndef MYAPPLICATION2_OPERATE_GEAR_H
#define MYAPPLICATION2_OPERATE_GEAR_H
#include "../driver_test.h"
void StartOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList);
int ExecuteOperateGearExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car,
                           LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime);
void OperateGearTTSDone(int id);
void TerminateOperateGearExam(void);
#endif //MYAPPLICATION2_OPERATE_GEAR_H
lib/src/main/cpp/test_items2/road_exam.cpp
@@ -14,6 +14,7 @@
#include "../master/comm_if.h"
#include "drive_straight.h"
#include "stop_car.h"
#include "operate_gear.h"
#include <vector>
#include <list>
@@ -40,6 +41,7 @@
static bool occurCrashRedLine;
static bool occurCrashGreenLine;
static bool occurOverSpeed;
static bool occurSecondBreak;
static int checkCrashGreenTimeout;
static char carIntersectionOfGreenLine;
static int currTurnSignalStatus;
@@ -66,9 +68,13 @@
static int startCar;
static int currExamMapIndex;
static bool checkDoor = false;
static bool handBreakActive = false;
static bool reportRPMOver = false;
static const int MAX_ENGINE_RPM = 2500;
static const double START_CAR_MOVE_DISTANCE = 0.5;//10.0;
static const double START_CAR_CHECK_DOOR_DISTANCE = 0.1;//1.0;
static const double START_CAR_MOVE_DISTANCE = 10.0;
static const double START_CAR_CHECK_DOOR_DISTANCE = 1.0;
static const uint32_t GEAR_N_SLIDE_TIMEOUT = D_SEC(5);
static const uint32_t GEAR_ERROR_TIMEOUT = D_SEC(15);
static const uint32_t STOP_CAR_TIME = D_SEC(2);
@@ -97,6 +103,7 @@
    occurCrashRedLine = false;
    occurCrashGreenLine = false;
    occurOverSpeed = false;
    occurSecondBreak = false;
    checkCrashGreenTimeout = 0;
    carIntersectionOfGreenLine = 0;
@@ -116,14 +123,22 @@
    currExamMapIndex = -1;
    startCar = START_CAR_NOT_DO;
    checkDoor = false;
    handBreakActive = false;
    reportRPMOver = false;
}
void TerminateRoadExam(void)
{
    TerminateDummyLightExam();
    TerminateStopCarExam();
    TerminateOperateGearExam();
}
static void TestRoadStartCar(const car_model *car, double speed, int moveDirect, const struct RtkTime *rtkTime)
{
    double moveDistance;
    static bool checkDoor = false;
    static bool handBreakActive = false;
    static bool reportRPMOver = false;
    if (startCar == START_CAR_NOT_DO) {
        startPoint = car->basePoint;
@@ -186,6 +201,18 @@
        }
    } else {
        occurOverSpeed = false;
    }
    // 副刹车检测
    if (ReadCarStatus(SECOND_BREAK) == BREAK_ACTIVE) {
        // 副刹车踩下,不合格
        if (!occurSecondBreak) {
            DEBUG("副刹车动作了");
            occurSecondBreak = true;
            AddExamFault(17, rtkTime);
        }
    } else {
        occurSecondBreak = false;
    }
    // 挡位匹配检测
@@ -327,7 +354,6 @@
            currTurnSignalStatus = ReadCarStatus(TURN_SIGNAL_LAMP);
            break;
    }
    // 检查是否持续转向
    char turnDirect = CheckCarTurn(CarModelList);
@@ -491,6 +517,8 @@
                StartDriveStraightExam(currExamMapIndex, RoadMapList);
            } else if (RoadMapList[currExamMapIndex].type == STOP_CAR_MAP) {
                StartStopCarExam(currExamMapIndex, RoadMapList);
            } else if (RoadMapList[currExamMapIndex].type == OP_GEAER_MAP) {
                StartOperateGearExam(currExamMapIndex, RoadMapList);
            }
        }
    } else if (startCar == START_CAR_DONE) {
@@ -506,6 +534,9 @@
        } else if (RoadMapList[currExamMapIndex].type == STOP_CAR_MAP) {
            currExamMapIndex = ExecuteStopCarExam(currExamMapIndex, RoadMapList, car,
                                                        CarModelList, speed, moveDirect, rtkTime);
        } else if (RoadMapList[currExamMapIndex].type == OP_GEAER_MAP) {
            currExamMapIndex = ExecuteOperateGearExam(currExamMapIndex, RoadMapList, car,
                                   CarModelList, speed, moveDirect, rtkTime);
        }
        if (currExamMapIndex == -1) {
lib/src/main/cpp/test_items2/road_exam.h
@@ -28,6 +28,7 @@
void Rtk2DriveTimer(struct drive_timer &tm, const struct RtkTime *rtkTime);
void InitRoadExam(void);
void TerminateRoadExam(void);
void TestRoadGeneral(LIST_ROAD_MAP &RoadMapList, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime);
bool ExitSonArea(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car);
bool CrashSonRedLine(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car, LIST_CAR_MODEL &CarModelList);
lib/src/main/cpp/test_items2/stop_car.cpp
@@ -61,13 +61,18 @@
void StopCarTTSDone(int id)
{
    DEBUG("DummyLightTTSDone %d", id);
    DEBUG("StopCarTTSDone %d", id);
    // 等语音播报完毕后计时
    if (id == examTtsSeq) {
        ttsPlayEnd = 1;
    }
}
void TerminateStopCarExam(void)
{
    AppTimer_delete(PlayTTSTimeout);
}
int ExecuteStopCarExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car,
                             LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime) {
    if (ttsPlayEnd == 1) {
lib/src/main/cpp/test_items2/stop_car.h
@@ -11,5 +11,6 @@
void StopCarTTSDone(int id);
int ExecuteStopCarExam(int index, LIST_ROAD_MAP &RoadMapList, const car_model *car,
                       LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime);
void TerminateStopCarExam(void);
#endif //MYAPPLICATION2_STOP_CAR_H