From 2dd405a64e0a6e468a205e7348520e87576e5358 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期一, 09 三月 2020 17:13:12 +0800
Subject: [PATCH] 更新地图
---
lib/src/main/cpp/master/comm_if.h | 3
lib/src/main/java/com/anyun/exam/lib/util/Speaker.java | 3 +
lib/src/main/cpp/driver_test.cpp | 34 ++++++++++-
lib/src/main/cpp/master/comm_if.cpp | 52 ++++++++++++++++
lib/src/main/cpp/native-lib.cpp | 2
lib/src/main/cpp/test_items2/dummy_light.cpp | 16 +++++
lib/src/main/cpp/test_items2/dummy_light.h | 13 ++++
lib/src/main/cpp/CMakeLists.txt | 1
lib/src/main/cpp/driver_test.h | 5 +
lib/src/main/java/com/anyun/exam/lib/RemoteService.java | 21 ++++++
10 files changed, 141 insertions(+), 9 deletions(-)
diff --git a/lib/src/main/cpp/CMakeLists.txt b/lib/src/main/cpp/CMakeLists.txt
index 31b9e27..a194d80 100644
--- a/lib/src/main/cpp/CMakeLists.txt
+++ b/lib/src/main/cpp/CMakeLists.txt
@@ -36,6 +36,7 @@
test_items/comm_test.cpp
test_items2/common_check.cpp
+ test_items2/dummy_light.cpp
rtk_module/rtk.cpp
rtk_module/virtual_rtk.cpp
diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp
index c961a25..699c23c 100644
--- a/lib/src/main/cpp/driver_test.cpp
+++ b/lib/src/main/cpp/driver_test.cpp
@@ -93,6 +93,9 @@
static int SensorValidLevel;
+static struct dummy_light_exam *DummyLightContent;
+static int DummyLightContentSize;
+
#define MOV_AVG_SIZE 1
#define RTK_BUFFER_SIZE 100
#define CAR_MODEL_CACHE_SIZE 10
@@ -129,6 +132,9 @@
memset(SensorConfig, 0, sizeof(SensorConfig));
SensorValidLevel = 0;
+
+ DummyLightContentSize = 0;
+ DummyLightContent = NULL;
RtkBuffer = (rtk_info *) malloc(RTK_BUFFER_SIZE * sizeof(rtk_info));
RtkBufferNum = RtkBufferIn = 0;
@@ -359,7 +365,24 @@
}
}
-void StartDriverExam(int start)
+void SetDummyLightExam(int n, struct dummy_light_exam *cfg)
+{
+ if (TestStart) return;
+
+ if (DummyLightContent != NULL) {
+ free(DummyLightContent);
+ DummyLightContent = NULL;
+ }
+
+ DummyLightContent = (struct dummy_light_exam *)malloc(n * sizeof(struct dummy_light_exam));
+ DummyLightContentSize = n;
+
+ for (int i = 0; i < n; i++) {
+ DummyLightContent[i] = cfg[i];
+ }
+}
+
+void StartDriverExam(int start, int type)
{
bool err = false;
@@ -383,6 +406,11 @@
err = true;
MA_SendExamStatus(0, -2);
}
+ if (DummyLightContent == NULL && type == 3) {
+ err = true;
+ MA_SendExamStatus(0, -3);
+ }
+
if (!err) {
if (!TestStart) {
ExamFaultList.clear();
@@ -498,7 +526,7 @@
CurrEnterMapIndex = EnterMap(CarModel, MapList, MapNum);
if (CurrEnterMapIndex >= 0) {
DEBUG("鍙戦�佽繘鍏ュ満鍦版姤鍛� %d", GetMapId(CurrEnterMapIndex, MapList, MapNum));
- MA_EnterMap(GetMapId(CurrEnterMapIndex, MapList, MapNum), 1);
+ MA_EnterMap(GetMapId(CurrEnterMapIndex, MapList, MapNum), GetMapType(CurrEnterMapIndex, MapList, MapNum), 1);
CurrExamMapIndex = CurrEnterMapIndex;
CurrExamStatus = EXAM_AREA_START;
@@ -506,7 +534,7 @@
} else {
if (ExitMap(CarModel, CurrEnterMapIndex, MapList, MapNum)) {
DEBUG("鍙戦�佺寮�鍦哄湴鎶ュ憡 %d", GetMapId(CurrEnterMapIndex, MapList, MapNum));
- MA_EnterMap(GetMapId(CurrEnterMapIndex, MapList, MapNum), 0);
+ MA_EnterMap(GetMapId(CurrEnterMapIndex, MapList, MapNum), GetMapType(CurrEnterMapIndex, MapList, MapNum), 0);
CurrEnterMapIndex = -1;
}
}
diff --git a/lib/src/main/cpp/driver_test.h b/lib/src/main/cpp/driver_test.h
index c411cf2..6f6288d 100644
--- a/lib/src/main/cpp/driver_test.h
+++ b/lib/src/main/cpp/driver_test.h
@@ -7,6 +7,7 @@
#include "Geometry.h"
#include "rtk_module/rtk.h"
+#include "test_items2/dummy_light.h"
#include <vector>
@@ -92,7 +93,7 @@
void GetSensorCfg(int gpio, int &func, bool &lvl);
void FindSensorCfg(int func, int &gpio, bool &lvl);
-void StartDriverExam(int start);
+void StartDriverExam(int start, int type);
void StartMapExam(int map_id, int exam);
void GetRtkClock(struct RtkTime *s);
void UpdateRTKInfo(const rtk_info *s);
@@ -100,4 +101,6 @@
car_model_cache_t *GetCarModelCache(int node);
void SystemShutdown(int event, int timeout);
+void SetDummyLightExam(int n, struct dummy_light_exam *cfg);;
+
#endif //RTKDRIVERTEST_DRIVER_TEST_H
diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp
index 3ee83da..5b64329 100644
--- a/lib/src/main/cpp/master/comm_if.cpp
+++ b/lib/src/main/cpp/master/comm_if.cpp
@@ -53,6 +53,8 @@
#define ID_MS_READ_CARD 0x8011
#define ID_SM_PUT_CARD 0x0011
#define ID_MS_SYS_SHUTDOWN 0x8010
+#define ID_SM_LIGHT_EXAM_REQ 0x0012
+#define ID_MS_LIGHT_EXAM_RES 0x8012
#define MA_OUT_GPS_BRIEF 0x0001
#define MA_OUT_RTK_BRIEF 0x0002
@@ -708,10 +710,16 @@
Document doc;
doc.Parse(value);
if (!doc.HasParseError()) {
+ int start = 0, type = 0;
if (doc.HasMember("exam")) {
Value& s = doc["exam"];
- StartDriverExam(s.GetInt());
+ start = s.GetInt();
}
+ if (doc.HasMember("type")) {
+ Value& s = doc["type"];
+ type = s.GetInt();
+ }
+ StartDriverExam(start, type);
}
break;
}
@@ -763,6 +771,39 @@
}
break;
}
+ case ID_MS_LIGHT_EXAM_RES: {
+ Document doc;
+ doc.Parse(value);
+ if (!doc.HasParseError()) {
+ if (doc.HasMember("exam")) {
+ const Value& s = doc["exam"];
+ s.GetInt();
+ }
+ if (doc.HasMember("question")) {
+ const Value& s = doc["question"];
+ if (s.IsArray() && s.Size() > 0) {
+ int n = 0;
+ struct dummy_light_exam *content = new struct dummy_light_exam[s.Size()];
+
+ for(Value::ConstValueIterator itr = s.Begin(); itr != s.End(); ++itr) {
+ if (itr->HasMember("item") && itr->HasMember("tts")) {
+ const Value &s1 = (*itr)["item"];
+ const Value &s2 = (*itr)["tts"];
+
+ content[n].item = s1.GetInt();
+ strcpy(content[n].tts, s1.GetString());
+ n++;
+ }
+ }
+
+ SetDummyLightExam(n, content);
+
+ delete []content;
+ }
+ }
+ }
+ break;
+ }
default:break;
}
}
@@ -779,7 +820,7 @@
}
}
-void MA_EnterMap(int map_id, int enter)
+void MA_EnterMap(int map_id, int type, int enter)
{
StringBuffer sb;
Writer<StringBuffer> writer(sb);
@@ -787,9 +828,16 @@
writer.StartObject();
writer.Key("map_id");
writer.Int(map_id);
+ writer.Key("type");
+ writer.Int(type);
writer.Key("enter");
writer.Int(enter);
writer.EndObject();
SendMsgToMainProc(ID_SM_ENTER_MAP, sb.GetString());
}
+
+void MA_ExamLight(void)
+{
+ SendMsgToMainProc(ID_SM_LIGHT_EXAM_REQ, NULL);
+}
diff --git a/lib/src/main/cpp/master/comm_if.h b/lib/src/main/cpp/master/comm_if.h
index 0c5da32..2f02af1 100644
--- a/lib/src/main/cpp/master/comm_if.h
+++ b/lib/src/main/cpp/master/comm_if.h
@@ -93,6 +93,7 @@
void MA_SendExamWrong(vector<ExamFault> &ExamFaultList);
void MA_SendRtcmInd(int length);
void MA_SendDebugInfo(const char *str, ...);
-void MA_EnterMap(int map_id, int enter);
+void MA_EnterMap(int map_id, int type, int enter);
+void MA_ExamLight(void);
#endif //MYAPPLICATION2_COMM_IF_H
diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp
index bd79e17..8f18adf 100644
--- a/lib/src/main/cpp/native-lib.cpp
+++ b/lib/src/main/cpp/native-lib.cpp
@@ -26,7 +26,7 @@
const int RTK_PLATFORM_PORT = 12125;
const uint8_t phone[] = {0x20,0x19,0x10,0x15,0x00,0x00,0x00,0x01};
-const char *VIRTUAL_RTK_IP = "192.168.3.52";
+const char *VIRTUAL_RTK_IP = "192.168.16.100";
const int VIRTUAL_RTK_PORT = 9001;
static void SendBootIndicate(union sigval sig);
diff --git a/lib/src/main/cpp/test_items2/dummy_light.cpp b/lib/src/main/cpp/test_items2/dummy_light.cpp
new file mode 100644
index 0000000..4cd2771
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/dummy_light.cpp
@@ -0,0 +1,16 @@
+//
+// Created by YY on 2020/3/9.
+//
+
+#include <cstdlib>
+#include "dummy_light.h"
+
+static struct dummy_light_exam *content;
+static int cn;
+
+void StartDummyLightExam(struct dummy_light_exam *ptr, int num)
+{
+ content = ptr;
+ cn = num;
+}
+
diff --git a/lib/src/main/cpp/test_items2/dummy_light.h b/lib/src/main/cpp/test_items2/dummy_light.h
new file mode 100644
index 0000000..68d4a06
--- /dev/null
+++ b/lib/src/main/cpp/test_items2/dummy_light.h
@@ -0,0 +1,13 @@
+//
+// Created by YY on 2020/3/9.
+//
+
+#ifndef MYAPPLICATION2_DUMMY_LIGHT_H
+#define MYAPPLICATION2_DUMMY_LIGHT_H
+
+struct dummy_light_exam {
+ int item;
+ char tts[512];
+};
+
+#endif //MYAPPLICATION2_DUMMY_LIGHT_H
diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
index d6ba6fd..bc33c8a 100644
--- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
+++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java
@@ -33,6 +33,7 @@
private IListenerInterface mListener;
private int msgId = 0;
private Speaker speaker = null;
+ private boolean ttsInitSucc = false;
private IRemoteInterface.Stub iRemoteInterface = new IRemoteInterface.Stub(){
@Override
@@ -80,6 +81,20 @@
speaker = new Speaker(getApplicationContext());
new Thread(new StartNative()).start();
+
+ new Thread(new TestThread()).start();
+ }
+
+ class TestThread implements Runnable {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+
+ }
+ ttsInitSucc = true;
+ }
}
class StartNative implements Runnable {
@@ -145,11 +160,15 @@
}
public void TextSpeak(String text) {
- if (speaker != null) {
+ if (speaker != null && ttsInitSucc) {
speaker.speak(text);
}
}
+ public void TextSpeakInitCallback(boolean ret) {
+ ttsInitSucc = ret;
+ }
+
private String byte2hex(byte [] buffer){
StringBuilder h = new StringBuilder();
diff --git a/lib/src/main/java/com/anyun/exam/lib/util/Speaker.java b/lib/src/main/java/com/anyun/exam/lib/util/Speaker.java
index 4cfb739..8a7c738 100644
--- a/lib/src/main/java/com/anyun/exam/lib/util/Speaker.java
+++ b/lib/src/main/java/com/anyun/exam/lib/util/Speaker.java
@@ -4,6 +4,8 @@
import android.speech.tts.TextToSpeech;
import android.util.Log;
+import com.anyun.exam.lib.RemoteService;
+
import java.util.Locale;
public class Speaker {
@@ -14,6 +16,7 @@
public Speaker(final Context context) {
// TODO Auto-generated constructor stub
+ Log.d(TAG, "Speaker Init...");
this.context = context;
tts = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
--
Gitblit v1.8.0