| | |
| | | static int CurrEnterMapIndex = -1; |
| | | |
| | | static int CurrExamStatus = EXAM_AREA_NONE; // 1 测试完成 0 测试中 -1 测试错误退出 |
| | | static int exam_dummy_light; |
| | | |
| | | static car_model *CarModel = NULL; |
| | | static car_model *CarModelPrev = NULL; |
| | |
| | | static struct dummy_light_exam *DummyLightContent; |
| | | static int DummyLightContentSize; |
| | | static bool engineRuning = false; |
| | | const int ENGINE_MIN_ROTATE = 200; |
| | | static bool engineStart = false; |
| | | static bool engineStartTimeout = false; |
| | | |
| | | #define MOV_AVG_SIZE 1 |
| | | #define RTK_BUFFER_SIZE 100 |
| | |
| | | static int RtkBufferNum = 0, RtkBufferIn = 0; |
| | | |
| | | static void DetectEnterOrExitMap(void); |
| | | static void EngineStartHold(union sigval sig); |
| | | static void ExecuteExam(const struct RtkTime* rtkTime); |
| | | static void ExecuteExam(double speed, int move, double azimuth, const struct RtkTime* rtkTime); |
| | | static uint32_t CalcTimeDiff(const rtk_info *a, const rtk_info *b); |
| | | static void ReadDriverExamPrimerTimeout(union sigval sig); |
| | |
| | | for (int i = 0; i < n; i++) { |
| | | DummyLightContent[i] = cfg[i]; |
| | | } |
| | | |
| | | StartDummyLightExam(DummyLightContent, DummyLightContentSize); |
| | | } |
| | | |
| | | void StartDriverExam(int start, int type) |
| | |
| | | reportSeatbeltEject = false; |
| | | |
| | | if (type == TEST_TYPE_ROAD_DUMMY_LIGHT) { |
| | | StartDummyLightExam(DummyLightContent, DummyLightContentSize); |
| | | exam_dummy_light = 0; |
| | | } |
| | | } |
| | | MA_SendExamStatus(1, 0); |
| | |
| | | |
| | | static void ExecuteExam(const struct RtkTime* rtkTime) |
| | | { |
| | | if (ReadCarStatus(ENGINE_RPM) < ENGINE_MIN_ROTATE) { |
| | | if (engineRuning) { |
| | | engineRuning = false; |
| | | if (ExamType == TEST_TYPE_AREA) { |
| | | // 熄火1次,扣10分 |
| | | AddExamFault(5, rtkTime); |
| | | } else { |
| | | AddExamFault(20, rtkTime); |
| | | } |
| | | } |
| | | } else { |
| | | engineRuning = true; |
| | | } |
| | | |
| | | if (ReadCarStatus(ENGINE_START) == ENGINE_START_ACTIVE) { |
| | | if (!engineStart) { |
| | | engineStart = true; |
| | | if (ReadCarStatus(SHIFT) != 'N') { |
| | | // 不是空挡点火,不合格 |
| | | if (ExamType == TEST_TYPE_AREA) |
| | | AddExamFault(3, rtkTime); |
| | | else |
| | | AddExamFault(4, rtkTime); |
| | | } |
| | | AppTimer_delete(EngineStartHold); |
| | | AppTimer_add(EngineStartHold, D_SEC(2)); |
| | | } |
| | | } else if (engineStart) { |
| | | engineStart = false; |
| | | AppTimer_delete(EngineStartHold); |
| | | } |
| | | |
| | | if (engineStartTimeout) { |
| | | engineStartTimeout = false; |
| | | |
| | | // 不及时松开启动开关,扣10分 |
| | | if (ExamType == TEST_TYPE_AREA) |
| | | AddExamFault(4, rtkTime); |
| | | } |
| | | |
| | | if (ExamType == TEST_TYPE_ROAD_DUMMY_LIGHT) { |
| | | if (exam_dummy_light == 0) { |
| | | StartDummyLightExam(DummyLightContent, DummyLightContentSize, rtkTime); |
| | | exam_dummy_light = 1; |
| | | // 汇报灯光考试开始 |
| | | } else if (exam_dummy_light == 1) { |
| | | exam_dummy_light = ExecuteDummyLightExam(rtkTime); |
| | | // 汇报灯光考试结束 |
| | | } |
| | | } |
| | | } |
| | | |
| | | static void ExecuteExam(double speed, int move, double azimuth, const struct RtkTime* rtkTime) |
| | |
| | | static void EngineStartHold(union sigval sig) { |
| | | AppTimer_delete(EngineStartHold); |
| | | |
| | | // 不及时松开启动开关,扣10分 |
| | | if (ReadSensor(SENSOR_ENGINE_START) == 1 && ExamStart) { |
| | | if (ExamType == TEST_TYPE_AREA) |
| | | AddExamFault(4, &rtkClock); |
| | | } |
| | | } |
| | | |
| | | void SensorChanged(int *sensorId, int *sensorValue, int num) |
| | | { |
| | | const int ENGINE_MIN_ROTATE = 200; |
| | | |
| | | for (int i = 0; i < num; ++i) { |
| | | switch (sensorId[i]) { |
| | | case SENSOR_SEATBELT: |
| | | break; |
| | | case SENSOR_ENGINE_START: |
| | | AppTimer_delete(EngineStartHold); |
| | | |
| | | if (sensorValue[i] == 1) { |
| | | if (ReadSensor(SENSOR_SHIFT_N) == 0) { |
| | | // 不是空挡点火,不合格 |
| | | if (ExamType == TEST_TYPE_AREA) |
| | | AddExamFault(3, &rtkClock); |
| | | else |
| | | AddExamFault(4, &rtkClock); |
| | | } |
| | | AppTimer_add(EngineStartHold, D_SEC(2)); |
| | | } |
| | | break; |
| | | case SENSOR_ENGINE_RPM: |
| | | if (sensorValue[i] < ENGINE_MIN_ROTATE) { |
| | | if (engineRuning) { |
| | | engineRuning = false; |
| | | if (ExamType == TEST_TYPE_AREA) { |
| | | // 熄火1次,扣10分 |
| | | AddExamFault(5, &rtkClock); |
| | | } else { |
| | | AddExamFault(20, &rtkClock); |
| | | } |
| | | } |
| | | } else { |
| | | engineRuning = true; |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | if (ReadCarStatus(ENGINE_START) == ENGINE_START_ACTIVE) { |
| | | engineStartTimeout = true; |
| | | } |
| | | } |
| | | |
| | |
| | | WriteCarStatus(MAIN_BEAM_LAMP, MAIN_BEAM_LIGHT); |
| | | } |
| | | |
| | | if (flashMainBeamCnt > 3) { // 亮-灭-亮-灭 |
| | | if (++flashMainBeamCnt > 3) { // 亮-灭-亮-灭 |
| | | WriteCarStatus(FLASH_BEAM_LAMP, FLASH_BEAM_LIGHT); |
| | | |
| | | AppTimer_delete(flashBeamLightClose); |
| | | AppTimer_add(flashBeamLightClose, D_SEC(5)); |
| | | } |
| | | |
| | | flashMainBeamCnt++; |
| | | AppTimer_delete(confirmFlashBeamLightLater); |
| | | AppTimer_add(confirmFlashBeamLightLater, D_SEC(3)); |
| | | break; |
| | |
| | | FLASH_BEAM_LAMP, |
| | | MAIN_BEAM_LAMP, |
| | | SEATBELT, |
| | | ENGINE_START, |
| | | CAR_STATUS_END |
| | | }; |
| | | |
| | | enum { |
| | | OFF_LIGHT = 0, |
| | | EJECT_SEATBELT = 0, |
| | | ENGINE_START_INACTIVE = 0, |
| | | HAZARD_LIGHTS, |
| | | LEFT_TURN_LIGHT, |
| | | RIGHT_TURN_LIGHT, |
| | |
| | | MAIN_BEAM_LIGHT, |
| | | FLASH_BEAM_LIGHT, |
| | | FOG_LIGHT, |
| | | INSERT_SEATBELT |
| | | INSERT_SEATBELT, |
| | | ENGINE_START_ACTIVE |
| | | }; |
| | | |
| | | void CarSensorInit(void); |
| | |
| | | |
| | | if (prevMoveDirect == 0) { |
| | | // 起步挂错挡,不合格 |
| | | if (ReadSensor(SENSOR_SHIFT_1) != 1) { |
| | | AddExamFault(19, rtkTime); |
| | | } |
| | | // if (ReadSensor(SENSOR_SHIFT_1) != 1) { |
| | | // AddExamFault(19, rtkTime); |
| | | // } |
| | | |
| | | // 起步没有关闭车门,不合格 |
| | | if (ReadSensor(SENSOR_DOOR) != 1) { |
| | | AddExamFault(23, rtkTime); |
| | | } |
| | | // if (ReadSensor(SENSOR_DOOR) != 1) { |
| | | // AddExamFault(23, rtkTime); |
| | | // } |
| | | |
| | | // 后滑判断 |
| | | |
| | |
| | | #include "dummy_light.h" |
| | | #include "../native-lib.h" |
| | | #include "../jni_log.h" |
| | | #include "../test_common/car_sensor.h" |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<dummy_light> <%s>: " fmt, __func__, ##args) |
| | | |
| | | static struct RtkTime currRtkTime; |
| | | static struct dummy_light_exam *content; |
| | | static int contentNum; |
| | | static int currContent; |
| | | static int checkCnt; |
| | | static bool turn_left_active, flash_beam_active; |
| | | |
| | | static void DummyLightCheckLight(union sigval sig); |
| | | static void DummyLightCheckActive(union sigval sig); |
| | | static void ExamDummyLight(union sigval sig); |
| | | |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num) |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num, const struct RtkTime* rtkTime) |
| | | { |
| | | DEBUG("StartDummyLightExam"); |
| | | content = ptr; |
| | | contentNum = num; |
| | | currContent = 0; |
| | | currRtkTime = *rtkTime; |
| | | |
| | | AppTimer_delete(DummyLightCheckLight); |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | AppTimer_delete(ExamDummyLight); |
| | | AppTimer_add(ExamDummyLight, D_SEC(2)); |
| | | } |
| | | |
| | | int ExecuteDummyLightExam(const struct RtkTime* rtkTime) |
| | | { |
| | | currRtkTime = *rtkTime; |
| | | return (currContent == contentNum)?2:1; |
| | | } |
| | | |
| | | void DummyLightTTSDone(int id) |
| | | { |
| | | DEBUG("DummyLightTTSDone %d", id); |
| | | |
| | | // 等语音播报完毕后计时 |
| | | if (id == 100) { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(3), id); |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(3), id); |
| | | } else if (id == 101) { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(1), id); |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(1), id); |
| | | } else if (id == OVERTAKE) { |
| | | checkCnt = 0; |
| | | turn_left_active = flash_beam_active = false; |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(1), id); |
| | | } else { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(5), id); |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(5), id); |
| | | } |
| | | } |
| | | |
| | | static void DummyLightCheckLight(union sigval sig) |
| | | static void DummyLightCheckActive(union sigval sig) |
| | | { |
| | | AppTimer_delete(DummyLightCheckLight); |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | |
| | | DEBUG("DummyLightCheckLight %d", sig.sival_int); |
| | | DEBUG("DummyLightCheckActive %d", sig.sival_int); |
| | | |
| | | switch (sig.sival_int) { |
| | | case DRIVE_AT_NIGHT: |
| | | case TURN_ON_MAIN_BEAM_LAMP: |
| | | if (ReadCarStatus(MAIN_BEAM_LAMP) != MAIN_BEAM_LIGHT) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | break; |
| | | case TURN_ON_DIPPED_LAMP: |
| | | case BRIDGE_MEET_CAR: |
| | | case FOLLOW_CAR: |
| | | if (ReadCarStatus(DIPPED_BEAM_LAMP) != DIPPED_BEAM_LIGHT) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | break; |
| | | case DRIVE_IN_FOG: |
| | | if (ReadCarStatus(FOG_LAMP) != FOG_LIGHT) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | break; |
| | | case THROUGE_CROSSWALK: |
| | | case THROUGE_CURVE: |
| | | case THROUGE_CROSSROADS: |
| | | if (ReadCarStatus(FLASH_BEAM_LAMP) != FLASH_BEAM_LIGHT) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | break; |
| | | case OVERTAKE: |
| | | if (++checkCnt < 5) { |
| | | if (!flash_beam_active) { |
| | | if (ReadCarStatus(TURN_SIGNAL_LAMP) == LEFT_TURN_LIGHT) { |
| | | turn_left_active = true; |
| | | } |
| | | } |
| | | if (turn_left_active) { |
| | | if (ReadCarStatus(FLASH_BEAM_LAMP) == FLASH_BEAM_LIGHT) { |
| | | flash_beam_active = true; |
| | | } |
| | | } |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(1), OVERTAKE); |
| | | return; |
| | | } else { |
| | | if (!flash_beam_active || !turn_left_active) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | } |
| | | break; |
| | | case CAR_FAULT: |
| | | case PARK_CAR_TEMP: |
| | | if (ReadCarStatus(TURN_SIGNAL_LAMP) != HAZARD_LIGHTS) { |
| | | AddExamFault(58, &currRtkTime); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | AppTimer_add(ExamDummyLight, D_SEC(1)); |
| | | } |
| | | |
| | | static void ExamDummyLight(union sigval sig) |
| | |
| | | |
| | | PlayTTS(content[currContent].tts, content[currContent].item); |
| | | currContent++; |
| | | AppTimer_add(ExamDummyLight, D_SEC(5)); |
| | | } |
| | | } |
| | |
| | | #ifndef MYAPPLICATION2_DUMMY_LIGHT_H |
| | | #define MYAPPLICATION2_DUMMY_LIGHT_H |
| | | |
| | | #include "../driver_test.h" |
| | | |
| | | enum { |
| | | TURN_ON_DIPPED_LAMP = 1, |
| | | DRIVE_AT_NIGHT, |
| | | BRIDGE_MEET_CAR, |
| | | TURN_ON_MAIN_BEAM_LAMP, |
| | | FOLLOW_CAR, |
| | | DRIVE_IN_FOG, |
| | | THROUGE_CROSSWALK, |
| | | CAR_FAULT, |
| | | THROUGE_CURVE, |
| | | THROUGE_CROSSROADS, |
| | | PARK_CAR_TEMP, |
| | | OVERTAKE |
| | | }; |
| | | |
| | | struct dummy_light_exam { |
| | | int item; |
| | | char tts[512]; |
| | | }; |
| | | |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num); |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num, const struct RtkTime* rtkTime); |
| | | int ExecuteDummyLightExam(const struct RtkTime* rtkTime); |
| | | void DummyLightTTSDone(int id); |
| | | |
| | | #endif //MYAPPLICATION2_DUMMY_LIGHT_H |