| | |
| | | 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) |
| | |
| | | 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) |
| | |
| | | // 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, |
| | |
| | | return; |
| | | } |
| | | |
| | | type = TEST_TYPE_ROAD_CALIBRATE; |
| | | |
| | | if (AreaMapList.size() == 0 && type == TEST_TYPE_AREA) { |
| | | DEBUG("没有场考地图"); |
| | | err = true; |
| | |
| | | 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) { |
| | |
| | | ExecuteExam(speed, move, azimuth, &rtkTime); |
| | | } |
| | | |
| | | PrintObdInfo(&rtkTime, speed); |
| | | // PrintObdInfo(&rtkTime, speed); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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 { |
| | |
| | | brief.status = status; |
| | | |
| | | MA_SendRoadStatus(&brief); |
| | | |
| | | DEBUG("报告长官 进出路段 road %d status %d", road, status); |
| | | } |
| | | |
| | | void CrossingChange(int road, int crossing, int status) |
| | |
| | | brief.status = status; |
| | | |
| | | MA_SendCrossingStatus(&brief); |
| | | |
| | | DEBUG("报告长官 进出路口 road %d crossing %d status %d", road, crossing, status); |
| | | } |
| | | |
| | | void AddExamFault(int wrong, const struct RtkTime *rtkTime) |
| | |
| | | |
| | | 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, |
| | |
| | | #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 |
| | |
| | | |
| | | 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); |
| | |
| | | break; |
| | | } |
| | | case ID_MS_SENSOR_CFG: { |
| | | Document doc; |
| | | /*Document doc; |
| | | doc.Parse(value); |
| | | if (!doc.HasParseError()) { |
| | | const Value &a = doc.GetArray(); |
| | |
| | | SetSensorCfg(sensor, n); |
| | | delete []sensor; |
| | | } |
| | | } |
| | | }*/ |
| | | break; |
| | | } |
| | | case ID_MS_START_EXAM: { |
| | |
| | | #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) |
| | | |
| | |
| | | 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)); |
| | | } |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | #define CARD_UPDATE_EVT 0x0080 |
| | | #define PLAY_TTS_DONE_EVT 0x0100 |
| | | #define CAR_SENSOR_UPDATE_EVT 0x0200 |
| | | #define MASTER_COMM_EVT 0x0400 |
| | | |
| | | typedef struct { |
| | | char domain_name[32]; |
| | |
| | | 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; |
| | | |
| | |
| | | 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; |
| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | |
| | | } 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; |
| | | } |
| | | } |
| | | } |
| | | |