| | |
| | | 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; |
| | | } |
| | | } |
| | | |