| | |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<dummy_light> <%s>: " fmt, __func__, ##args) |
| | | |
| | | enum { |
| | | TTS_NOT_START, |
| | | TTS_DOING, |
| | | TTS_DONE, |
| | | WAIT_OPERATE, |
| | | CHECK_OPERATE |
| | | }; |
| | | |
| | | 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 int examTtsSeq = 0; |
| | | static bool testing; |
| | | |
| | | static void DummyLightCheckActive(union sigval sig); |
| | | static void ExamDummyLight(union sigval sig); |
| | |
| | | DEBUG("StartDummyLightExam"); |
| | | content = ptr; |
| | | contentNum = num; |
| | | currContent = 0; |
| | | |
| | | currRtkTime = *rtkTime; |
| | | |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | for (int i = 0; i < contentNum; ++i) { |
| | | content[i].itemStatus = TTS_NOT_START; |
| | | } |
| | | testing = true; |
| | | AppTimer_delete(ExamDummyLight); |
| | | AppTimer_add(ExamDummyLight, D_SEC(2)); |
| | | } |
| | |
| | | int ExecuteDummyLightExam(const struct RtkTime* rtkTime) |
| | | { |
| | | currRtkTime = *rtkTime; |
| | | return (currContent == contentNum)?2:1; |
| | | return (testing)?1:2; |
| | | } |
| | | |
| | | void DummyLightTTSDone(int id) |
| | | { |
| | | DEBUG("DummyLightTTSDone %d", id); |
| | | // 等语音播报完毕后计时 |
| | | if (id == 100) { |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(3), id); |
| | | } else if (id == 101) { |
| | | 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(DummyLightCheckActive, D_SEC(5), id); |
| | | if (id == examTtsSeq) { |
| | | for (int i = 0; i < contentNum; ++i) { |
| | | if (content[i].itemStatus == TTS_DOING) { |
| | | content[i].itemStatus = TTS_DONE; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | AppTimer_add(ExamDummyLight, 100); |
| | | } |
| | | } |
| | | |
| | | static void DummyLightCheckActive(union sigval sig) |
| | | { |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | |
| | | DEBUG("DummyLightCheckActive %d", sig.sival_int); |
| | | DEBUG("DummyLightCheckActive item = %d", sig.sival_int); |
| | | |
| | | switch (sig.sival_int) { |
| | | case DRIVE_AT_NIGHT: |
| | |
| | | break; |
| | | } |
| | | |
| | | AppTimer_add(ExamDummyLight, D_SEC(1)); |
| | | for (int i = 0; i < contentNum; ++i) { |
| | | if (content[i].item == sig.sival_int) { |
| | | content[i].itemStatus = CHECK_OPERATE; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | AppTimer_add(ExamDummyLight, 500); |
| | | } |
| | | |
| | | static void ExamDummyLight(union sigval sig) |
| | | { |
| | | int i = 0; |
| | | AppTimer_delete(ExamDummyLight); |
| | | |
| | | if (currContent < contentNum) { |
| | | DEBUG("模拟灯光测试 %s", content[currContent].tts); |
| | | for (; i < contentNum; ++i) { |
| | | switch (content[i].itemStatus) { |
| | | case TTS_NOT_START: |
| | | content[i].itemStatus = TTS_DOING; |
| | | examTtsSeq = PlayTTS(content[i].tts); |
| | | // 等待TTS播放完毕 |
| | | return; |
| | | case TTS_DOING: |
| | | return; |
| | | case TTS_DONE: |
| | | content[i].itemStatus = WAIT_OPERATE; |
| | | |
| | | PlayTTS(content[currContent].tts, content[currContent].item); |
| | | currContent++; |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | if (content[i].item == OVERTAKE) { |
| | | checkCnt = 0; |
| | | turn_left_active = flash_beam_active = false; |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(1), content[i].item); |
| | | } |
| | | else if (content[i].item >= 100) |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(3), content[i].item); |
| | | else |
| | | AppTimer_add(DummyLightCheckActive, D_SEC(5), content[i].item); |
| | | return; |
| | | case WAIT_OPERATE: |
| | | return; |
| | | case CHECK_OPERATE: |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (i >= contentNum) { |
| | | testing = false; |
| | | } |
| | | } |