| | |
| | | |
| | | void SetDummyLightExam(int n, struct dummy_light_exam *cfg) |
| | | { |
| | | DEBUG("获取模拟路考灯光测试项目"); |
| | | DEBUG("获取模拟路考灯光测试项目 N = %d %d", n, TestStart); |
| | | |
| | | if (TestStart) return; |
| | | // if (TestStart) return; |
| | | |
| | | if (DummyLightContent != NULL) { |
| | | free(DummyLightContent); |
| | |
| | | for (int i = 0; i < n; i++) { |
| | | DummyLightContent[i] = cfg[i]; |
| | | } |
| | | |
| | | StartDummyLightExam(DummyLightContent, DummyLightContentSize); |
| | | } |
| | | |
| | | void StartDriverExam(int start, int type) |
| | |
| | | DEBUG("++++++++++++考试启动 start %d type %d+++++++++++++", start, type); |
| | | |
| | | if (start == 0) { |
| | | DEBUG("结束考试"); |
| | | // CurrExamMapIndex = -1; |
| | | // TestStart = false; |
| | | // CommTestStart(false); |
| | |
| | | |
| | | if (!err) { |
| | | if (!TestStart) { |
| | | DEBUG("启动考试"); |
| | | ExamFaultList.clear(); |
| | | examFaultIndex = 0; |
| | | |
| | |
| | | return ciphertext_length; |
| | | } |
| | | |
| | | void TextSpeak(const char *text) |
| | | { |
| | | JNIEnv *env; |
| | | bool ready_in_java_env = false; |
| | | |
| | | if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { |
| | | // Attach主线程 |
| | | if (sg_jvm->AttachCurrentThread(&env, NULL) != JNI_OK) { |
| | | LOGE("%s: AttachCurrentThread() failed", __FUNCTION__); |
| | | return; |
| | | } |
| | | } else { |
| | | ready_in_java_env = true; |
| | | } |
| | | |
| | | jclass cls = env->GetObjectClass(sg_obj); |
| | | jmethodID fun = env->GetMethodID(cls, "TextSpeak", "(Ljava/lang/String;)V"); |
| | | |
| | | std::string cstext = text; |
| | | env->CallVoidMethod(sg_obj, fun, env->NewStringUTF(cstext.c_str())); |
| | | env->DeleteLocalRef(cls); |
| | | |
| | | if (!ready_in_java_env) { |
| | | //Detach主线程 |
| | | if (sg_jvm->DetachCurrentThread() != JNI_OK) { |
| | | LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void TextOsd(int type, const char *text) |
| | | { |
| | | /* JNIEnv *env; |
| | |
| | | } |
| | | } |
| | | |
| | | void PlayTTS(const char *string) |
| | | void PlayTTS(const char *string, int id) |
| | | { |
| | | DEBUG("PlayTTS: %s", string); |
| | | |
| | |
| | | } |
| | | |
| | | jclass cls = env->GetObjectClass(sg_obj); |
| | | jmethodID fun = env->GetMethodID(cls, "TextSpeak", "(Ljava/lang/String;)V"); |
| | | jmethodID fun = env->GetMethodID(cls, "TextSpeak", "(Ljava/lang/String;I)V"); |
| | | |
| | | env->CallVoidMethod(sg_obj, fun, env->NewStringUTF(string)); |
| | | env->CallVoidMethod(sg_obj, fun, env->NewStringUTF(string), id); |
| | | |
| | | env->DeleteLocalRef(cls); |
| | | |
| | |
| | | env->GetJavaVM(&sg_jvm); |
| | | // 不能直接赋值(g_obj = ojb) |
| | | sg_obj = env->NewGlobalRef(thiz); |
| | | |
| | | srand(time(NULL)); |
| | | |
| | | AppTimer_Init(); |
| | | ConfigMCU(); |
| | |
| | | |
| | | env->ReleaseByteArrayElements(data, c_dat, NULL); |
| | | } |
| | | |
| | | extern "C" |
| | | JNIEXPORT void JNICALL |
| | | Java_com_anyun_exam_lib_RemoteService_TextSpeakEnd(JNIEnv *env, jobject thiz, jint id) { |
| | | // TODO: implement TextSpeakEnd() |
| | | PlatformStatusChanged(PLAY_TTS_DONE_EVT, (uint8_t *)&id, sizeof(id)); |
| | | } |
| | |
| | | const uint8_t *plaintext, int plaintext_length, |
| | | uint8_t **ciphertext); |
| | | |
| | | void TextSpeak(const char *text); |
| | | |
| | | void TextOsd(int type, const char *text); |
| | | void DrawScreen(const Polygon *map, const Polygon *car); |
| | | void SendMsgToMainProc(int cmd, const char *value); |
| | | void PlayTTS(const char *string); |
| | | void PlayTTS(const char *string, int id); |
| | | |
| | | #endif //RTKBASESTATION_NATIVE_LIB_H |
| | |
| | | |
| | | MA_SendCardBrief(&brief); |
| | | } |
| | | if (events & PLAY_TTS_DONE_EVT) { |
| | | DummyLightTTSDone(*((int *)data)); |
| | | } |
| | | } |
| | | |
| | | static void *PlatformDataListenThread(void *p) { |
| | |
| | | #define GPS_UPDATE_EVT 0x0020 |
| | | #define MCU_UPDATE_EVT 0x0040 |
| | | #define CARD_UPDATE_EVT 0x0080 |
| | | #define PLAY_TTS_DONE_EVT 0x0100 |
| | | |
| | | typedef struct { |
| | | char domain_name[32]; |
| | |
| | | static int contentNum; |
| | | static int currContent; |
| | | |
| | | static void DummyLightCheckLight(union sigval sig); |
| | | static void ExamDummyLight(union sigval sig); |
| | | |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num) |
| | | { |
| | | DEBUG("StartDummyLightExam"); |
| | | content = ptr; |
| | | contentNum = num; |
| | | currContent = 0; |
| | | |
| | | AppTimer_delete(DummyLightCheckLight); |
| | | AppTimer_delete(ExamDummyLight); |
| | | AppTimer_add(ExamDummyLight, D_SEC(2)); |
| | | } |
| | | |
| | | void DummyLightTTSDone(int id) |
| | | { |
| | | DEBUG("DummyLightTTSDone %d", id); |
| | | |
| | | if (id == 100) { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(3), id); |
| | | } else if (id == 101) { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(1), id); |
| | | } else { |
| | | AppTimer_add(DummyLightCheckLight, D_SEC(5), id); |
| | | } |
| | | } |
| | | |
| | | static void DummyLightCheckLight(union sigval sig) |
| | | { |
| | | AppTimer_delete(DummyLightCheckLight); |
| | | |
| | | DEBUG("DummyLightCheckLight %d", sig.sival_int); |
| | | } |
| | | |
| | | static void ExamDummyLight(union sigval sig) |
| | |
| | | if (currContent < contentNum) { |
| | | DEBUG("模拟灯光测试 %s", content[currContent].tts); |
| | | |
| | | PlayTTS(content[currContent].tts); |
| | | PlayTTS(content[currContent].tts, content[currContent].item); |
| | | currContent++; |
| | | AppTimer_add(ExamDummyLight, D_SEC(5)); |
| | | } |
| | |
| | | }; |
| | | |
| | | void StartDummyLightExam(struct dummy_light_exam *ptr, int num); |
| | | void DummyLightTTSDone(int id); |
| | | |
| | | #endif //MYAPPLICATION2_DUMMY_LIGHT_H |
| | |
| | | return null; |
| | | } |
| | | |
| | | public void TextSpeak(String text) { |
| | | public void TextSpeak(String text, int id) { |
| | | if (speaker != null && ttsInitSucc) { |
| | | speaker.speak(text); |
| | | speaker.speak(text, Integer.toString(id)); |
| | | } else { |
| | | TextSpeakEnd(id); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void PlayStart() { |
| | | public void PlayStart(String s) { |
| | | Log.d(TAG, "TTS引擎播放开始"); |
| | | } |
| | | |
| | | @Override |
| | | public void PlayDone() { |
| | | public void PlayDone(String s) { |
| | | Log.d(TAG, "TTS引擎播放结束"); |
| | | TextSpeakEnd(Integer.valueOf(s)); |
| | | } |
| | | |
| | | @Override |
| | | public void PlayError() { |
| | | public void PlayError(String s) { |
| | | Log.d(TAG, "TTS引擎播放出错"); |
| | | TextSpeakEnd(Integer.valueOf(s)); |
| | | } |
| | | } |
| | | |
| | |
| | | public native void startNative(); |
| | | public native void MainProcMsgEntry(int cmd, String value); |
| | | public native void MainProcBinMsgEntry(int cmd, byte []data, int length); |
| | | public native void TextSpeakEnd(int id); |
| | | } |
| | |
| | | @Override |
| | | public void onStart(String s) { |
| | | if (callback != null) { |
| | | callback.PlayStart(); |
| | | callback.PlayStart(s); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDone(String s) { |
| | | if (callback != null) { |
| | | callback.PlayDone(); |
| | | callback.PlayDone(s); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onError(String s) { |
| | | if (callback != null) { |
| | | callback.PlayError(); |
| | | callback.PlayError(s); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public void speak(String text, String id) { |
| | | // tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); |
| | | tts.speak(text, TextToSpeech.QUEUE_ADD, null, id); |
| | | } |
| | | |
| | | public void speak(String text) { |
| | | // tts.speak(text, TextToSpeech.QUEUE_FLUSH, null); |
| | | tts.speak(text, TextToSpeech.QUEUE_ADD, null, "speech"); |
| | | tts.speak(text, TextToSpeech.QUEUE_ADD, null, "talk"); |
| | | } |
| | | } |
| | |
| | | |
| | | public interface SpeakerCallback { |
| | | void PlayInit(boolean ret); |
| | | void PlayStart(); |
| | | void PlayDone(); |
| | | void PlayError(); |
| | | void PlayStart(String s); |
| | | void PlayDone(String s); |
| | | void PlayError(String s); |
| | | } |