//
|
// Created by YY on 2020/8/20.
|
//
|
|
#include "car_start.h"
|
#include "../driver_test.h"
|
#include "../test_common/odo_graph.h"
|
#include "../native-lib.h"
|
#include "../test_common/car_sensor.h"
|
#include "road_exam.h"
|
#include "../jni_log.h"
|
#include "../common/apptimer.h"
|
|
#define DEBUG(fmt, args...) LOGD("<car_start> <%s>: " fmt, __func__, ##args)
|
|
static const int MAX_ENGINE_RPM = 2500;
|
static const double START_CAR_MOVE_DISTANCE = 10.0;
|
static const double START_CAR_CHECK_DOOR_DISTANCE = 1.0;
|
|
static double startCarMoveDistance;
|
static bool checkEngineRPM, checkStartCarSignal, checkDoor, handBreakActive;
|
|
void cb(int seq)
|
{
|
DEBUG("语音结束 %d", seq);
|
}
|
|
void CarStartInit(void)
|
{
|
startCarMoveDistance = ReadOdo();
|
checkEngineRPM = false;
|
checkStartCarSignal = false;
|
checkDoor = false;
|
handBreakActive = false;
|
int id = PlayTTS("请起步", cb);
|
|
DEBUG("语音开始 %d", id);
|
}
|
|
bool TestCarStart(const car_model *car, double speed, int moveDirect, const struct RtkTime *rtkTime)
|
{
|
car_sensor_value_t sensor;
|
double moveDistance = ReadOdo() - startCarMoveDistance;
|
|
DEBUG("起步行驶距离 %f", moveDistance);
|
|
if (!checkStartCarSignal && moveDirect == 1) {
|
checkStartCarSignal = true;
|
|
sensor = ReadCarSensorValue(TURN_SIGNAL_LAMP);
|
if (sensor.name == TURN_SIGNAL_LAMP) {
|
if (sensor.value != LEFT_TURN_LIGHT) {
|
DEBUG("变调未打灯!!");
|
// 没打灯,不合格
|
AddExamFault(13, rtkTime);
|
} else if (TimeGetDiff(rtkTime, &sensor.time) >= D_SEC(3)) {
|
DEBUG("转向灯时间不足");
|
// 不足3秒,不合格
|
AddExamFault(14, rtkTime);
|
}
|
}
|
}
|
|
if (moveDistance > START_CAR_MOVE_DISTANCE) {
|
sensor = ReadCarSensorValue(HAND_BREAK);
|
|
if (sensor.name == HAND_BREAK && sensor.value == BREAK_ACTIVE) {
|
DEBUG("Handbreak active move over 10m");
|
// 手刹拉起状态下,行驶了10米以上,不合格
|
AddExamFault(25, rtkTime);
|
} else if (handBreakActive) {
|
// 手刹拉起状态下,行驶了1米以上,扣10分
|
DEBUG("Handbreak active move over 1M");
|
AddExamFault(26, rtkTime);
|
}
|
|
PlayTTS("完成起步", NULL);
|
DEBUG("############# 完成起步 ############");
|
|
return false;
|
} else if (moveDistance >= START_CAR_CHECK_DOOR_DISTANCE) {
|
if (!checkDoor) {
|
checkDoor = true;
|
|
sensor = ReadCarSensorValue(DOOR);
|
if (sensor.name == DOOR && sensor.value == DOOR_OPEN) {
|
// 车门未完全关闭,不合格
|
DEBUG("车门未关闭");
|
AddExamFault(23, rtkTime);
|
}
|
|
sensor = ReadCarSensorValue(HAND_BREAK);
|
if (sensor.name == HAND_BREAK && sensor.value == BREAK_ACTIVE) {
|
handBreakActive = true;
|
}
|
}
|
}
|
|
if (ReadCarStatus(ENGINE_RPM) > MAX_ENGINE_RPM && !checkEngineRPM) {
|
// 转速超标,不合格
|
DEBUG("转速超标");
|
AddExamFault(29, rtkTime);
|
checkEngineRPM = true;
|
}
|
|
return true;
|
}
|