//// //// Created by xemon on 09.11.2021. //// #include #include "DeviceTesting.h" #include "UserInput.h" #include "EraGlonassMsd.h" #include "EraGlonassUveos.h" #define LOGGER env->logger #define LOG_SIGN "Тест. Пользв." uint16_t timeoutPresButton = 10000; void DeviceTesting_ErorEmergencyPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("emer_test_eror.mp3") } void DeviceTesting_ErorEmergencyNumberNotSetPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("incorrect_test_number.mp3") } void DeviceTesting_ErorEmergencyTempLocPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("tets_call_timeuot.mp3") } void DeviceTesting_EmergencySucsessPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("test_call_sucsess.mp3") } void DeviceTesting_ErorAddButtonPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("buttom.mp3") DEVTST_PLAY_SAMPLE("add_functions.mp3") } void DeviceTesting_ErorSosButtonPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("buttom.mp3") DEVTST_PLAY_SAMPLE("sos_call.mp3") } void DeviceTesting_ButtonSuccessPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("bip_button_ok.mp3") } void DeviceTesting_IgnitionSucsessPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("testing.mp3") DEVTST_PLAY_SAMPLE("ignition.mp3") DEVTST_PLAY_SAMPLE("successfully.mp3") DEVTST_PLAY_SAMPLE("done.mp3") } void DeviceTesting_IgnitionOffErrorPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("when_turned_off.mp3") DEVTST_PLAY_SAMPLE("ignition.mp3") } void DeviceTesting_IgnitionOnErrorPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("when_turned_on.mp3") DEVTST_PLAY_SAMPLE("ignition.mp3") } void DeviceTesting_ErorGreenIndicationPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("green_ind.mp3") } void DeviceTesting_ErorRedIndicationPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("red_ind.mp3") } void DeviceTesting_SucsessIndicationPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("testing.mp3") DEVTST_PLAY_SAMPLE("indicators.mp3") DEVTST_PLAY_SAMPLE("successfully.mp3") DEVTST_PLAY_SAMPLE("done.mp3") } void DeviceTesting_ErorMicPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("microphon.mp3") } void DeviceTesting_SucsessMicPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("testing.mp3") DEVTST_PLAY_SAMPLE("microphon.mp3") DEVTST_PLAY_SAMPLE("successfully.mp3") DEVTST_PLAY_SAMPLE("done.mp3") } void DeviceTesting_ErorSpeakerPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("error_testing.mp3") DEVTST_PLAY_SAMPLE("dinamics.mp3") } void DeviceTesting_SucsessSpeakerPlay(tDeviceTesting *env) { DEVTST_PLAY_SAMPLE("testing.mp3") DEVTST_PLAY_SAMPLE("dinamics.mp3") DEVTST_PLAY_SAMPLE("successfully.mp3") DEVTST_PLAY_SAMPLE("done.mp3") } bool DeviceTesting_WaitTestResult(tTestDescriptor *test, uint16_t value, uint32_t timeout) { uint32_t end = SystemGetMs() + timeout; while (SystemGetMs() < end) { DeviceTestsTable_MakeTest(test); if (test->result == value) { return true; } SystemDelayMs(1); } return false; } void DeviceTesting_ExitTestPlay(tDeviceTesting *env) { #if (AURUS_CAR_UI == 0) AudioPlayer_PlayToWait(env->audioPlayer, "era_mode.mp3", 3 * 1000); #endif } bool DeviceTesting_WaitAddButtonClick(tDeviceTesting *env, char *audioFileName, uint8_t audioFileLenght, uint32_t timeout, uint8_t value) { if(value != UIU_OFF) { UserIndication_Uiu(env->indication, value); } tUserInputButtonEvent buttonEvent = {0}; uint32_t end = SystemGetMs() + timeout; UserButtons_Clear(env->input); bool fl_onePlay = false; while (SystemGetMs() < end) { if(value != UIU_OFF) { UserIndication_Uiu(env->indication, value); } if(fl_onePlay == false){ AudioPlayer_PlayToEnd(env->audioPlayer, audioFileName, audioFileLenght, timeout); fl_onePlay = true; } UserButtons_GetNext(env->input, &buttonEvent, timeout); if (UserInputButtonEventIs(buttonEvent, UI_VIRT_BUTTON_ADDITIONAL, FALL)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Нажата \"Доп.Функции\"") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return true; } } SystemDelayMs(1); } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return false; } return false; } bool DeviceTesting_WaitSosButtonClick(tDeviceTesting *env, char *audioFileName, uint8_t audioFileLenght, uint32_t timeout) { uint32_t end = SystemGetMs() + timeout; UserButtons_Clear(env->input); bool fl_onePlay = false; while (SystemGetMs() < end) { if(fl_onePlay == false){ AudioPlayer_PlayToEnd(env->audioPlayer, audioFileName, audioFileLenght, timeout); fl_onePlay = true; } if (UserButtons_GetNext(env->input, &env->buttonEvent, timeout)) { if (UserInputButtonEventIs(env->buttonEvent, UI_VIRT_BUTTON_EMERGENCY, FALL)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Нажата \"SOS\"") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return true; } } } SystemDelayMs(1); } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return false; } return false; } bool DeviceTesting_TestAudioSpeaker(tDeviceTesting *env) { SystemDelayMs(50); LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест динамика") char audioFileName[] = "test_dinam.mp3"; DeviceTesting_ChekExit(env); if (!DeviceTesting_WaitAddButtonClick(env, audioFileName, sizeof(audioFileName)-1, timeoutPresButton, UIU_OFF)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("error_this_test.mp3") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return true; } } DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return false; } return false; } bool DeviceTesting_TestSpeakMic(tDeviceTesting *env) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Тестирование микрофона, ожидание контрольной фразы от оператора") DEVTST_PLAY_SAMPLE("micSpeakTestInputTestAudio.mp3") DEVTST_REC_TO_WAIT_SAMPLE("test_rec_name.wav") DEVTST_PLAY_SAMPLE("test_rec_name.wav") SystemDelayMs(50); DeviceTesting_ChekExit(env); char audioFileName[] = "submitSosButton.mp3"; if (!DeviceTesting_WaitSosButtonClick(env, audioFileName, sizeof(audioFileName)-1, timeoutPresButton)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("isError.mp3") if(!AudioPlayer_IsBusy(env->audioPlayer,0)){ return true; } } DEVTST_PLAY_SAMPLE("notError.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return false; } return false; } bool DeviceTesting_TestMic(tDeviceTesting *env) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Тестирование микрофона, ожидание контрольной фразы от оператора") DEVTST_PLAY_SAMPLE("mic_test_get.mp3") DEVTST_REC_TO_WAIT_SAMPLE("test_rec_name.wav") DEVTST_PLAY_SAMPLE("test_rec_name.wav") SystemDelayMs(50); DeviceTesting_ChekExit(env); char audioFileName[] = "mic_test_set.mp3"; if (!DeviceTesting_WaitAddButtonClick(env, audioFileName, sizeof(audioFileName)-1, timeoutPresButton, UIU_OFF)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("error_this_test.mp3") if(!AudioPlayer_IsBusy(env->audioPlayer,0)){ return true; } } DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return false; } return false; } bool DeviceTesting_Ignition(tDeviceTesting *env) { env->flagAcsessExitThread = SYSTEM_IS_BUSY; tTestDescriptor *currentTest; LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест зажигания") currentTest = DeviceTestsTable_GetModeTestStatic(&env->testsTable, DEVICE_TESTING_MODE_ALL, "IGNITION"); if (currentTest) { bool res = false; env->ignitionAddStatusRes = 0; LoggerInfoStatic(LOGGER, LOG_SIGN, "Запрос выключить зажигание") DEVTST_PLAY_SAMPLE("ign_of.mp3") DeviceTesting_ChekExit(env); if (!DeviceTesting_WaitTestResult(currentTest, DEVICE_TESTING_CODE_NOT_CONNECTED_OK, 10000)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") env->ignitionAddStatusRes = 1; DEVTST_PLAY_SAMPLE("error_this_test.mp3") res = true; } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") res = false; } DeviceTesting_ChekExit(env); LoggerInfoStatic(LOGGER, LOG_SIGN, "Запрос включить зажигание") DEVTST_PLAY_SAMPLE("ign_on.mp3") if (!DeviceTesting_WaitTestResult(currentTest, DEVICE_TESTING_CODE_CONNECTED, 10000)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") env->ignitionAddStatusRes = 2; DEVTST_PLAY_SAMPLE("error_this_test.mp3") res = true; } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if (env->ignitionAddStatusRes == 0 && res == false) { env->ignitionAddStatusRes = 0; } } SystemDelayMs(200); env->flagAcsessExitThread = SYSTEM_IS_FREE; if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } } SystemDelayMs(200); env->flagAcsessExitThread = SYSTEM_IS_FREE; return 0; } bool DeviceTesting_Indication(tDeviceTesting *env) { bool res = false; LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест индикатора") LoggerInfoStatic(LOGGER, LOG_SIGN, "Горит зеленый") LoggerInfoStatic(LOGGER, LOG_SIGN, "Ожидание подтверждения кнопкой доп. функций...") if(env->audioHintsMode != HINTS_MINIMAL){ DEVTST_PLAY_SAMPLE("test_gren_led.mp3") } DeviceTesting_ChekExit(env); char audioFileName[] = "gren_led_ok.mp3"; if (!DeviceTesting_WaitAddButtonClick(env, audioFileName,sizeof(audioFileName)-1, timeoutPresButton, UIU_GREEN)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("gren_led_error.mp3") env->indicationStatusRes = 1; res = true; } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест пройден") } DeviceTesting_ChekExit(env); LoggerInfoStatic(LOGGER, LOG_SIGN, "Горит красный") LoggerInfoStatic(LOGGER, LOG_SIGN, "Ожидание подтверждения кнопкой доп. функций...") if(env->audioHintsMode != HINTS_MINIMAL){ DEVTST_PLAY_SAMPLE("test_red_led.mp3") } DeviceTesting_ChekExit(env); char audioFileName_[] = "red_led_ok.mp3"; if (!DeviceTesting_WaitAddButtonClick(env, audioFileName_,sizeof(audioFileName_)-1, timeoutPresButton, UIU_RED)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("red_led_error.mp3") res = true; if (env->indicationStatusRes == 0) { env->indicationStatusRes = 2; } else { env->indicationStatusRes = 3; } } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if (env->indicationStatusRes == 0 && res == false) { env->indicationStatusRes = 0; } } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } return false; } bool DeviceTesting_Buttons(tDeviceTesting *env) { bool res = false; env->buttonAddStatusRes = 0; LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест кнопок") DeviceTesting_ChekExit(env); LoggerInfoStatic(LOGGER, LOG_SIGN, "Ожидание нажатия кнопки экстренного вызова...") char audioFileName_[] = "test_button_emer.mp3"; if (!DeviceTesting_WaitSosButtonClick(env, audioFileName_, sizeof(audioFileName_)-1,timeoutPresButton)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("error_this_test.mp3") env->buttonAddStatusRes = 1; res = true; } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест пройден") } DeviceTesting_ChekExit(env); LoggerInfoStatic(LOGGER, LOG_SIGN, "Ожидание нажатия кнопки дополнительных функций...") SystemDelayMs(100); char audioFileName[] = "test_button_add.mp3"; if (!DeviceTesting_WaitAddButtonClick(env, audioFileName, sizeof(audioFileName)-1,timeoutPresButton, UIU_OFF)) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста...") DEVTST_PLAY_SAMPLE("error_this_test.mp3") res = true; if (env->buttonAddStatusRes == 0) { env->buttonAddStatusRes = 2; } else { env->buttonAddStatusRes = 3; } } else { DEVTST_PLAY_SAMPLE("sucsess.mp3") LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") if (env->buttonAddStatusRes == 0 && res == false) { env->buttonAddStatusRes = 0; } } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } return false; } bool DeviceTesting_Ecall(tDeviceTesting *env) { SystemDelayMs(800); env->ecallAddStatusRes = 0; bool res = false; LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест экстренного вызова") if (env->ErGlUv->settings->ECALL_TEST_NUMBER.length < 2) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста 1") DEVTST_PLAY_SAMPLE("error_this_test") env->ecallAddStatusRes = 1; res = false; } else { eEraGlonassUveos_EcallProcessingResult resCall; LoggerInfoStatic(LOGGER, LOG_SIGN, "Ожидание выполнения теста экстренного вызова...") resCall = EraGlonassUveos_TestEmergencyCall(env->ErGlUv, &env->tmsdDiagRes); if (resCall == ERA_GLONASS_UVEOS_TEST_CALL_NOT_ALLOWED) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка текущего теста 2") DEVTST_PLAY_SAMPLE("error_this_test") env->ecallAddStatusRes = 2; res = false; } else { LoggerInfoStatic(LOGGER, LOG_SIGN, "Текущий тест пройден") res = true; } } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } return res; } bool DeviceTesting_TestIgnitionRes(tDeviceTesting *env) { SystemDelayMs(100); bool res = false; if (env->tmsdDiagRes.ignitionLineFailure != 1) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест зажигания успешно выполнен") // DeviceTesting_IgnitionSucsessPlay(env); res = true; } else { // if (env->ignitionAddStatusRes == 1) { // SystemDelayMs(100); // LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка при тестировании отключения заигания") // DeviceTesting_IgnitionOffErrorPlay(env); // } // if (env->ignitionAddStatusRes == 2) { // SystemDelayMs(100); // LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка при тестировании включения заигания") // DeviceTesting_IgnitionOnErrorPlay(env); // } res = false; } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } return false; } bool DeviceTesting_TestButtonRes(tDeviceTesting *env) { bool res = false; if (env->tmsdDiagRes.uimFailure != 1) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест кнопок успешно выполнен") // DeviceTesting_ButtonSuccessPlay(env); // SystemDelayMs(500); res = true; } else { // if (env->buttonAddStatusRes == 1) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка тестировании кнопки экстренного вызова") // SystemDelayMs(500); // DeviceTesting_ErorSosButtonPlay(env); // } // if (env->buttonAddStatusRes == 2) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка тестировании кнопки дополнительный функций") // SystemDelayMs(500); // DeviceTesting_ErorAddButtonPlay(env); // } // if (env->buttonAddStatusRes == 3) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка тестировании кнопки дополнительный функций") // SystemDelayMs(500); // DeviceTesting_ErorSosButtonPlay(env); // SystemDelayMs(500); // DeviceTesting_ErorAddButtonPlay(env); // } res = false; } if(!AudioPlayer_IsBusy(env->audioPlayer,0)) { return res; } return false; } bool DeviceTesting_TestAudioSpeakerRes(tDeviceTesting *env) { if (env->tmsdDiagRes.speakersFailure == 1) { // DeviceTesting_ErorSpeakerPlay(env); LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка тестирования динамика") return 0; } else { LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест динамика успешно выполнен") // DeviceTesting_SucsessSpeakerPlay(env); return 1; } } bool DeviceTesting_TestMicRes(tDeviceTesting *env) { if (env->tmsdDiagRes.micFailure != 1) { LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест микрофона успешно выполнен") // DeviceTesting_SucsessMicPlay(env); return 1; } else { LoggerInfoStatic(LOGGER, LOG_SIGN, "Ошибка тестирования микрофона") // DeviceTesting_ErorMicPlay(env); return 0; } } bool DeviceTesting_TestIndicationRes(tDeviceTesting *env) { bool res = false; if (env->tmsdDiagRes.statusIndicatorFailure != 1) { //// LoggerInfoStatic(LOGGER, LOG_SIGN, "Тест индикаторов успешно выполнен") // SystemDelayMs(500); // DeviceTesting_SucsessIndicationPlay(env); res = true; } else { res = false; } return res; } void DeviceTesting_GetEcalRes(tDeviceTesting *env) { if (env->ecallAddStatusRes == 0) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Тестирование вызова выполнено успешно") SystemDelayMs(500); DeviceTesting_EmergencySucsessPlay(env); } if (env->ecallAddStatusRes == 1) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Номер тестового вызова не установлен, вызов не возможен") // DeviceTesting_ErorEmergencyPlay(env); SystemDelayMs(500); DeviceTesting_ErorEmergencyNumberNotSetPlay(env); } if (env->ecallAddStatusRes == 2) { // LoggerInfoStatic(LOGGER, LOG_SIGN, "Превышен допустимый интервал, вызов не возможен, попробуйте позже") SystemDelayMs(500); DeviceTesting_ErorEmergencyTempLocPlay(env); } } bool DeviceTesting_UserGetResult(tDeviceTesting *env) { bool fullRes = true; SystemDelayMs(1000); if (DeviceTesting_TestAudioSpeakerRes(env) && fullRes) { fullRes = true; } else { fullRes = false; } if (DeviceTesting_TestMicRes(env) && fullRes) { fullRes = true; } else { fullRes = false; } if (DeviceTesting_TestIgnitionRes(env) && fullRes) { fullRes = true; } else { fullRes = false; } if (DeviceTesting_TestButtonRes(env) && fullRes) { fullRes = true; } else { fullRes = false; } if (DeviceTesting_TestIndicationRes(env) && fullRes) { fullRes = true; } else { fullRes = false; } return fullRes; }