From 03a05501800d2c02bca1c05ca6f7080d715aba23 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期五, 18 九月 2020 15:41:50 +0800
Subject: [PATCH] 坐标
---
lib/src/main/cpp/driver_test.cpp | 33 +++++++-
lib/src/main/cpp/rtk_platform/platform.h | 3
lib/src/main/cpp/master/comm_if.cpp | 89 +++++++++++++++++++++
lib/src/main/cpp/native-lib.cpp | 25 +++++
lib/src/main/cpp/test_items2/road_exam.cpp | 34 +++++++
lib/src/main/cpp/driver_test.h | 1
lib/src/main/cpp/rtk_platform/platform.cpp | 16 ++++
7 files changed, 188 insertions(+), 13 deletions(-)
diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp
index e596990..600be36 100644
--- a/lib/src/main/cpp/driver_test.cpp
+++ b/lib/src/main/cpp/driver_test.cpp
@@ -148,7 +148,7 @@
free(AreaMapList[i].map2.point);
}
- AreaMapList.clear();
+ LIST_AREA_MAP().swap(AreaMapList);
}
void AddAreaMap(int id, int type, const double (*map)[2], int pointNum, const double (*map2)[2], int pointNum2)
@@ -195,7 +195,7 @@
vector<road_t>().swap(RoadMap.roads);
vector<special_area_t>().swap(RoadMap.specialAreas);
vector<forbid_line_t>().swap(RoadMap.forbidLines);
- vector<scheme_t>().swap(RoadMap.examScheme);
+// vector<scheme_t>().swap(RoadMap.examScheme);
}
void SetRoadMap(road_exam_map &map, vector<scheme_t> &scheme)
@@ -207,9 +207,20 @@
// RoadMap.triggerLines.assign(map.triggerLines.begin(), map.triggerLines.end());
RoadMap.forbidLines.assign(map.forbidLines.begin(), map.forbidLines.end());
- RoadMap.examScheme.assign(scheme.begin(), scheme.end());
+// RoadMap.examScheme.assign(scheme.begin(), scheme.end());
DEBUG("寰楀埌鏂扮殑璺�冨湴鍥� 璺暟閲� %d 鐗规畩鍖哄煙鏁伴噺 %d 鍏朵粬绂佹绾挎暟閲� %d 椤圭洰鏁伴噺 %d", RoadMap.roads.size(), RoadMap.specialAreas.size(), RoadMap.forbidLines.size(), RoadMap.examScheme.size());
+}
+
+void SetRoadExamScheme(vector<scheme_t> &scheme)
+{
+ if (ExamStart) return;
+
+ vector<scheme_t>().swap(RoadMap.examScheme);
+
+ RoadMap.examScheme.assign(scheme.begin(), scheme.end());
+
+ DEBUG("寰楀埌鏂扮殑璺�冨湴鍥� 椤圭洰鏁伴噺 %d", RoadMap.examScheme.size());
}
void SetCarMeasurePoint(double *basePoint, int *axial, int *left_front_tire,
@@ -375,6 +386,8 @@
return;
}
+ type = TEST_TYPE_ROAD_CALIBRATE;
+
if (AreaMapList.size() == 0 && type == TEST_TYPE_AREA) {
DEBUG("娌℃湁鍦鸿�冨湴鍥�");
err = true;
@@ -394,6 +407,12 @@
DEBUG("娌℃湁璺�冨湴鍥�");
err = true;
MA_SendExamStatus(0, -1);
+ }
+
+ if ((type == TEST_TYPE_ROAD_DUMMY_LIGHT || type == TEST_TYPE_ROAD_TRUE_LIGHT) && RoadMap.examScheme.size() == 0) {
+ DEBUG("娌℃湁璺�冪嚎璺柟妗�");
+ err = true;
+ MA_SendExamStatus(0, -3);
}
if (!err) {
@@ -514,7 +533,7 @@
ExecuteExam(speed, move, azimuth, &rtkTime);
}
- PrintObdInfo(&rtkTime, speed);
+// PrintObdInfo(&rtkTime, speed);
}
}
@@ -684,7 +703,7 @@
}
if (ExamType != TEST_TYPE_AREA) {
- if (exam_dummy_light == 2 || ExamType == TEST_TYPE_ROAD_TRUE_LIGHT) {
+ if (exam_dummy_light == 2 || ExamType == TEST_TYPE_ROAD_TRUE_LIGHT || ExamType == TEST_TYPE_ROAD_CALIBRATE) {
TestRoadGeneral(RoadMap, CarModel, CarModelList, speed, move, rtkTime);
}
} else {
@@ -885,6 +904,8 @@
brief.status = status;
MA_SendRoadStatus(&brief);
+
+ DEBUG("鎶ュ憡闀垮畼 杩涘嚭璺 road %d status %d", road, status);
}
void CrossingChange(int road, int crossing, int status)
@@ -896,6 +917,8 @@
brief.status = status;
MA_SendCrossingStatus(&brief);
+
+ DEBUG("鎶ュ憡闀垮畼 杩涘嚭璺彛 road %d crossing %d status %d", road, crossing, status);
}
void AddExamFault(int wrong, const struct RtkTime *rtkTime)
diff --git a/lib/src/main/cpp/driver_test.h b/lib/src/main/cpp/driver_test.h
index d19c35b..6c24bc3 100644
--- a/lib/src/main/cpp/driver_test.h
+++ b/lib/src/main/cpp/driver_test.h
@@ -225,6 +225,7 @@
void CleanRoadMap(void);
void SetRoadMap(road_exam_map &map, vector<scheme_t> &scheme);
+void SetRoadExamScheme(vector<scheme_t> &scheme);
void SetCarMeasurePoint(double *basePoint, int *axial, int *left_front_tire,
int *right_front_tire, int *left_rear_tire, int *right_rear_tire,
diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp
index 0468b02..7ffd67d 100644
--- a/lib/src/main/cpp/master/comm_if.cpp
+++ b/lib/src/main/cpp/master/comm_if.cpp
@@ -39,6 +39,7 @@
#define ID_MS_MAP 0x8006
#define ID_MS_ROAD_MAP 0x8014
#define ID_MS_ROAD_MAP2 0x8013
+#define ID_MS_SCHEME 0x8017
#define ID_SM_READ_CAR 0x0007
#define ID_MS_CAR 0x8007
@@ -1263,6 +1264,90 @@
break;
}
+ case ID_MS_SCHEME: {
+ Document doc;
+ doc.Parse(value);
+ if (!doc.HasParseError()) {
+ DEBUG("寮�濮嬭В鏋愯矾鑰冩柟妗�");
+ vector<scheme_t> schemes;
+
+ if (doc.HasMember("scheme")) {
+ const Value &a = doc["scheme"];
+
+ for (Value::ConstValueIterator itr = a.Begin();
+ itr != a.End(); ++itr) {
+ scheme_t scheme;
+ if (itr->HasMember("name")) {
+ const Value &s = (*itr)["name"];
+ scheme.name = s.GetString();
+ }
+ if (itr->HasMember("crossing_active")) {
+ const Value &a2 = (*itr)["crossing_active"];
+
+ for (Value::ConstValueIterator itr2 = a2.Begin();
+ itr2 != a2.End(); ++itr2) {
+ crossing_active_t act;
+
+ if (itr2->HasMember("road")) {
+ const Value &s = (*itr2)["road"];
+ act.road_id = s.GetInt();
+ }
+ if (itr2->HasMember("idx")) {
+ const Value &s = (*itr2)["idx"];
+ act.index = s.GetInt();
+ }
+ if (itr2->HasMember("active")) {
+ const Value &s = (*itr2)["active"];
+ act.active = s.GetInt();
+ }
+
+ scheme.crossingActive.push_back(act);
+ }
+ }
+ if (itr->HasMember("trigger_line")) {
+ const Value &a2 = (*itr)["trigger_line"];
+
+ for (Value::ConstValueIterator itr2 = a2.Begin();
+ itr2 != a2.End(); ++itr2) {
+ trigger_line_t ins;
+
+ if (itr2->HasMember("x_y")) {
+ const Value &a3 = (*itr2)["x_y"];
+ if (a3.IsArray()) {
+ PointF point;
+ int n = 0;
+ for (Value::ConstValueIterator itr3 = a3.Begin();
+ itr3 != a3.End(); ++itr3) {
+ if (n == 0) {
+ point.X = (*itr3).GetDouble();
+ n = 1;
+ } else if (n == 1) {
+ point.Y = (*itr3).GetDouble();
+ ins.points.push_back(point);
+ n = 0;
+ }
+ }
+ }
+ }
+ if (itr2->HasMember("road")) {
+ const Value &s = (*itr2)["road"];
+ ins.road = s.GetInt();
+ }
+ if (itr2->HasMember("type")) {
+ const Value &s = (*itr2)["type"];
+ ins.active = s.GetInt();
+ }
+
+ scheme.triggerLines.push_back(ins);
+ }
+ }
+ schemes.push_back(scheme);
+ }
+ }
+ SetRoadExamScheme(schemes);
+ }
+ break;
+ }
case ID_MS_MAP: {
Document doc;
doc.Parse(value);
@@ -1471,7 +1556,7 @@
break;
}
case ID_MS_SENSOR_CFG: {
- Document doc;
+ /*Document doc;
doc.Parse(value);
if (!doc.HasParseError()) {
const Value &a = doc.GetArray();
@@ -1500,7 +1585,7 @@
SetSensorCfg(sensor, n);
delete []sensor;
}
- }
+ }*/
break;
}
case ID_MS_START_EXAM: {
diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp
index b8e44e1..6eedb68 100644
--- a/lib/src/main/cpp/native-lib.cpp
+++ b/lib/src/main/cpp/native-lib.cpp
@@ -17,6 +17,7 @@
#include "driver_test.h"
#include "master/comm_if.h"
#include "rtk_module/virtual_rtk.h"
+#include "defs.h"
#define DEBUG(fmt, args...) LOGD("<native-lib> <%s>: " fmt, __func__, ##args)
@@ -322,12 +323,32 @@
Java_com_anyun_exam_lib_RemoteService_MainProcMsgEntry(JNIEnv *env, jobject thiz, jint cmd,
jstring value) {
// TODO: implement MainProcMsgEntry()
+ union {
+ int a;
+ uint8_t b[sizeof(int)];
+ } c;
+
+ c.a = cmd;
+
if (value != NULL) {
const char *str = env->GetStringUTFChars(value, 0);
- MA_MainProcMsgEntry(cmd, str);
+
+ uint8_t *data = new uint8_t[4 + strlen(str) + 1];
+
+ data[0] = c.b[0];
+ data[1] = c.b[1];
+ data[2] = c.b[2];
+ data[3] = c.b[3];
+
+ strcpy((char *)data + 4, str);
+// MA_MainProcMsgEntry(cmd, str);
+ PlatformStatusChanged(MASTER_COMM_EVT, data, 4 + strlen(str) + 1);
env->ReleaseStringUTFChars(value, str);
+
+ delete []data;
} else {
- MA_MainProcMsgEntry(cmd, NULL);
+ //MA_MainProcMsgEntry(cmd, NULL);
+ PlatformStatusChanged(MASTER_COMM_EVT, c.b, sizeof(int));
}
}
diff --git a/lib/src/main/cpp/rtk_platform/platform.cpp b/lib/src/main/cpp/rtk_platform/platform.cpp
index a343c04..6060868 100644
--- a/lib/src/main/cpp/rtk_platform/platform.cpp
+++ b/lib/src/main/cpp/rtk_platform/platform.cpp
@@ -520,6 +520,22 @@
cb->callback(cb->seq);
}
}
+ if (events & MASTER_COMM_EVT) {
+ union {
+ int a;
+ uint8_t b[sizeof(int)];
+ } c;
+
+ c.b[0] = data[0];
+ c.b[1] = data[1];
+ c.b[2] = data[2];
+ c.b[3] = data[3];
+
+ if (length == 4)
+ MA_MainProcMsgEntry(c.a, NULL);
+ else
+ MA_MainProcMsgEntry(c.a, (char *)data + 4);
+ }
}
static void *PlatformDataListenThread(void *p) {
diff --git a/lib/src/main/cpp/rtk_platform/platform.h b/lib/src/main/cpp/rtk_platform/platform.h
index 62c0c60..f48eb4e 100644
--- a/lib/src/main/cpp/rtk_platform/platform.h
+++ b/lib/src/main/cpp/rtk_platform/platform.h
@@ -16,7 +16,8 @@
#define MCU_UPDATE_EVT 0x0040
#define CARD_UPDATE_EVT 0x0080
#define PLAY_TTS_DONE_EVT 0x0100
-#define CAR_SENSOR_UPDATE_EVT 0x0200
+#define CAR_SENSOR_UPDATE_EVT 0x0200
+#define MASTER_COMM_EVT 0x0400
typedef struct {
char domain_name[32];
diff --git a/lib/src/main/cpp/test_items2/road_exam.cpp b/lib/src/main/cpp/test_items2/road_exam.cpp
index 0ade5a9..8a1c97f 100644
--- a/lib/src/main/cpp/test_items2/road_exam.cpp
+++ b/lib/src/main/cpp/test_items2/road_exam.cpp
@@ -90,9 +90,11 @@
static bool occurSlide;
static struct RtkTime crashGreenRunTime, crashGreenStartTime, stopTimepoint;
-
+static struct RtkTime gearChangeTimePoint;
static struct RtkTime gearErrorTimePoint;
static struct RtkTime gearNSlideTimePoint;
+
+static int gearChange;
static car_sensor_value_t turnSignalStatus;
@@ -1324,6 +1326,21 @@
occurSecondBreak = false;
}
+ // 涓ゆ鎹㈡尅涓嶈繘
+ static int prevGear = -1;
+
+ int currGear = ReadCarStatus(GEAR);
+ if (currGear != GEAR_N && prevGear == GEAR_N) {
+ // 涓�娆℃崲鎸�
+ if (gearChange == currGear && TimeGetDiff(rtkTime, &gearChangeTimePoint) < D_SEC(5)) {
+ AddExamFault(7, rtkTime);
+ }
+
+ gearChange = currGear;
+ gearChangeTimePoint = *rtkTime;
+ }
+ prevGear = currGear;
+
// 鎸′綅鍖归厤妫�娴�
bool currGearError = false;
bool currGearNSlide = false;
@@ -1475,9 +1492,9 @@
if (RoadMap.calibrate) {
if (currExamMapIndex < 0 && oldid >= 0) {
- RoadChange(oldid, 0);
+ RoadChange(RoadMap.roads[oldid].id, 0);
} else if (currExamMapIndex >= 0) {
- RoadChange(currExamMapIndex, 1);
+ RoadChange(RoadMap.roads[currExamMapIndex].id, 1);
}
}
Lane.guide = 0;
@@ -1648,6 +1665,9 @@
RoadExamItem[RoadExamStatus] = ROAD_EXAM_ITEM_EXECED;
if (RoadExamStatus == ROAD_EXAM_ITEM_CAR_START) {
freeRunExceptDistance = 60.0;
+ } else if (RoadExamStatus == ROAD_EXAM_ITEM_CAR_STOP) {
+ // 鑰冭瘯缁撴潫
+ MA_SendExamStatus(1, 1);
} else {
freeRunExceptDistance = 2;//250.0;
}
@@ -1674,6 +1694,14 @@
} else if (RoadExamStatus == ROAD_EXAM_READY_NEXT && item == 2) {
StartOvertakeExam(Lane.no);
RoadExamStatus = ROAD_EXAM_ITEM_OVER_TAKE;
+ } else if (RoadExamStatus == ROAD_EXAM_READY_NEXT && item == 5) {
+ if (RoadExamItem[ROAD_EXAM_ITEM_STRAIGHT] == ROAD_EXAM_ITEM_EXECED &&
+ RoadExamItem[ROAD_EXAM_ITEM_OP_GEAR] == ROAD_EXAM_ITEM_EXECED &&
+ RoadExamItem[ROAD_EXAM_ITEM_CHANGE_LANE] == ROAD_EXAM_ITEM_EXECED &&
+ RoadExamItem[ROAD_EXAM_ITEM_OVER_TAKE] == ROAD_EXAM_ITEM_EXECED) {
+ StartStopCarExam();
+ RoadExamStatus = ROAD_EXAM_ITEM_CAR_STOP;
+ }
}
}
--
Gitblit v1.8.0