yy1717
2020-11-24 6e0f29b08a040d14576d7053c1206a8439936570
lib/src/main/cpp/master/comm_if.cpp
@@ -41,6 +41,7 @@
#define ID_MS_ROAD_MAP2         0x8013
#define ID_MS_SCHEME            0x8017
#define ID_MS_EXAM_PARAM        0x8019
#define ID_MS_BLUETOOTH_NAME    0x8020
#define ID_SM_READ_CAR          0x0007
#define ID_MS_CAR               0x8007
@@ -71,6 +72,7 @@
#define ID_MS_INQ_ROAD_CROSSING 0x8018              // Master查询当前路段和路口
#define ID_SM_CAN_BRIEF         0x0021
#define ID_SM_BLUETOOTH_BRIEF   0x0022
#define MA_OUT_GPS_BRIEF        0x0001
#define MA_OUT_RTK_BRIEF        0x0002
@@ -1290,6 +1292,9 @@
        case ID_MS_SCHEME: {
            Document doc;
            doc.Parse(value);
            DEBUG("方案 %s", value);
            if (!doc.HasParseError()) {
                DEBUG("开始解析路考方案");
                vector<scheme_t> schemes;
@@ -1379,87 +1384,104 @@
                if (doc.HasMember("hold_start_key_limit_time")) {
                    const Value &a = doc["hold_start_key_limit_time"];
                    examParam.hold_start_key_limit_time = a.GetInt();
                    DEBUG("hold_start_key_limit_time = %d", examParam.hold_start_key_limit_time);
                }
                if (doc.HasMember("curve_pause_criteria")) {
                    const Value &a = doc["curve_pause_criteria"];
                    examParam.curve_pause_criteria = a.GetInt();
                    DEBUG("curve_pause_criteria = %d", examParam.curve_pause_criteria);
                }
                if (doc.HasMember("park_bottom_pause_criteria")) {
                    const Value &a = doc["park_bottom_pause_criteria"];
                    examParam.park_bottom_pause_criteria = a.GetInt();
                    DEBUG("park_bottom_pause_criteria = %d", examParam.park_bottom_pause_criteria);
                }
                if (doc.HasMember("park_bottom_limit_time")) {
                    const Value &a = doc["park_bottom_limit_time"];
                    examParam.park_bottom_limit_time = D_SEC(a.GetInt());
                    DEBUG("park_bottom_limit_time = %d", examParam.park_bottom_limit_time);
                }
                if (doc.HasMember("park_edge_pause_criteria")) {
                    const Value &a = doc["park_edge_pause_criteria"];
                    examParam.park_edge_pause_criteria = a.GetInt();
                    DEBUG("park_edge_pause_criteria = %d", examParam.park_edge_pause_criteria);
                }
                if (doc.HasMember("park_edge_limit_time")) {
                    const Value &a = doc["park_edge_limit_time"];
                    examParam.park_edge_limit_time = D_SEC(a.GetInt());
                    DEBUG("park_edge_limit_time = %d", examParam.park_edge_limit_time);
                }
                if (doc.HasMember("turn_a90_pause_criteria")) {
                    const Value &a = doc["turn_a90_pause_criteria"];
                    examParam.turn_a90_pause_criteria = a.GetInt();
                    DEBUG("turn_a90_pause_criteria = %d", examParam.turn_a90_pause_criteria);
                }
                if (doc.HasMember("ramp_stoppoint_red_distance")) {
                    const Value &a = doc["ramp_stoppoint_red_distance"];
                    examParam.ramp_stoppoint_red_distance = a.GetDouble();
                    DEBUG("ramp_stoppoint_red_distance = %f", examParam.ramp_stoppoint_red_distance);
                }
                if (doc.HasMember("ramp_edge_yellow_distance")) {
                    const Value &a = doc["ramp_edge_yellow_distance"];
                    examParam.ramp_edge_yellow_distance = a.GetDouble();
                    DEBUG("ramp_edge_yellow_distance = %f", examParam.ramp_edge_yellow_distance);
                }
                if (doc.HasMember("ramp_edge_red_distance")) {
                    const Value &a = doc["ramp_edge_red_distance"];
                    examParam.ramp_edge_red_distance = a.GetDouble();
                    DEBUG("ramp_edge_red_distance = %f", examParam.ramp_edge_red_distance);
                }
                if (doc.HasMember("ramp_slide_yellow_distance")) {
                    const Value &a = doc["ramp_slide_yellow_distance"];
                    examParam.ramp_slide_yellow_distance = a.GetDouble();
                    DEBUG("ramp_slide_yellow_distance = %f", examParam.ramp_slide_yellow_distance);
                }
                if (doc.HasMember("ramp_slide_red_distance")) {
                    const Value &a = doc["ramp_slide_red_distance"];
                    examParam.ramp_slide_red_distance = a.GetDouble();
                    DEBUG("ramp_slide_red_distance = %f", examParam.ramp_slide_red_distance);
                }
                if (doc.HasMember("ramp_start_car_limit_time")) {
                    const Value &a = doc["ramp_start_car_limit_time"];
                    examParam.ramp_start_car_limit_time = D_SEC(a.GetInt());
                    DEBUG("ramp_start_car_limit_time = %d", examParam.ramp_start_car_limit_time);
                }
                if (doc.HasMember("road_slide_yellow_distance")) {
                    const Value &a = doc["road_slide_yellow_distance"];
                    examParam.road_slide_yellow_distance = a.GetDouble();
                    DEBUG("road_slide_yellow_distance = %f", examParam.road_slide_yellow_distance);
                }
                double road_slide_red_distance;
                if (doc.HasMember("road_slide_red_distance")) {
                    const Value &a = doc["road_slide_red_distance"];
                    examParam.road_slide_red_distance = a.GetDouble();
                    DEBUG("road_slide_red_distance = %f", examParam.road_slide_red_distance);
                }
                if (doc.HasMember("road_total_distance")) {
                    const Value &a = doc["road_total_distance"];
                    examParam.road_total_distance = a.GetDouble();
                    examParam.road_total_distance = a.GetInt();
                    DEBUG("road_total_distance = %d", examParam.road_total_distance);
                }
                if (doc.HasMember("road_max_speed")) {
                    const Value &a = doc["road_max_speed"];
                    examParam.road_max_speed = a.GetInt();
                    DEBUG("road_max_speed = %d", examParam.road_max_speed);
                }
                if (doc.HasMember("gear_speed_table")) {
@@ -1467,12 +1489,17 @@
                    int m = 0, n = 0;
                    for (Value::ConstValueIterator itr = a.Begin();
                         itr != a.End() && m < 6; ++itr, ++m) {
                        n = 0;
                        for (Value::ConstValueIterator itr2 = (*itr).Begin();
                             itr2 != (*itr).End() && n < 2; ++itr2, ++n) {
                            examParam.gear_speed_table[m][n] = (*itr2).GetInt();
                    if (a.IsArray()) {
                        for (Value::ConstValueIterator itr = a.Begin();
                             itr != a.End() && m < 6; ++itr, ++m) {
                            n = 0;
                            if ((*itr).IsArray()) {
                                for (Value::ConstValueIterator itr2 = (*itr).Begin();
                                     itr2 != (*itr).End() && n < 2; ++itr2, ++n) {
                                    examParam.gear_speed_table[m][n] = (*itr2).GetInt();
                                    DEBUG("gear_speed_table[%d][%d] = %d", m, n, examParam.gear_speed_table[m][n]);
                                }
                            }
                        }
                    }
                }
@@ -1480,118 +1507,141 @@
                if (doc.HasMember("gear_n_allow_time")) {
                    const Value &a = doc["gear_n_allow_time"];
                    examParam.gear_n_allow_time = D_SEC(a.GetInt());
                    DEBUG("gear_n_allow_time = %d", examParam.gear_n_allow_time);
                }
                if (doc.HasMember("same_gear_min_time")) {
                    const Value &a = doc["same_gear_min_time"];
                    examParam.same_gear_min_time = D_SEC(a.GetInt());
                    DEBUG("same_gear_min_time = %d", examParam.same_gear_min_time);
                }
                if (doc.HasMember("gear_speed_error_cumulative_time")) {
                    const Value &a = doc["gear_speed_error_cumulative_time"];
                    examParam.gear_speed_error_cumulative_time = D_SEC(a.GetInt());
                    DEBUG("gear_speed_error_cumulative_time = %d", examParam.gear_speed_error_cumulative_time);
                }
                if (doc.HasMember("road_pause_criteria")) {
                    const Value &a = doc["road_pause_criteria"];
                    examParam.road_pause_criteria = a.GetInt();
                    DEBUG("road_pause_criteria = %d", examParam.road_pause_criteria);
                }
                if (doc.HasMember("continuous_change_lane_min_time")) {
                    const Value &a = doc["continuous_change_lane_min_time"];
                    examParam.continuous_change_lane_min_time = D_SEC(a.GetInt());
                    DEBUG("continuous_change_lane_min_time = %d", examParam.continuous_change_lane_min_time);
                }
                if (doc.HasMember("crash_dotted_line_cumulative_time")) {
                    const Value &a = doc["crash_dotted_line_cumulative_time"];
                    examParam.crash_dotted_line_cumulative_time = D_SEC(a.GetInt());
                    DEBUG("crash_dotted_line_cumulative_time = %d", examParam.crash_dotted_line_cumulative_time);
                }
                if (doc.HasMember("turn_signal_min_advance")) {
                    const Value &a = doc["turn_signal_min_advance"];
                    examParam.turn_signal_min_advance = D_SEC(a.GetInt());
                    DEBUG("turn_signal_min_advance = %d", examParam.turn_signal_min_advance);
                }
                if (doc.HasMember("start_car_max_rpm")) {
                    const Value &a = doc["start_car_max_rpm"];
                    examParam.start_car_max_rpm = a.GetInt();
                    DEBUG("start_car_max_rpm = %d", examParam.start_car_max_rpm);
                }
                if (doc.HasMember("start_car_limit_distance")) {
                    const Value &a = doc["start_car_limit_distance"];
                    examParam.start_car_limit_distance = a.GetInt();
                    DEBUG("start_car_limit_distance = %d", examParam.start_car_limit_distance);
                }
                if (doc.HasMember("open_door_drive_allow_distance")) {
                    const Value &a = doc["open_door_drive_allow_distance"];
                    examParam.open_door_drive_allow_distance = a.GetDouble();
                    DEBUG("open_door_drive_allow_distance = %f", examParam.open_door_drive_allow_distance);
                }
                if (doc.HasMember("change_lane_limit_distance")) {
                    const Value &a = doc["change_lane_limit_distance"];
                    examParam.change_lane_limit_distance = a.GetInt();
                    DEBUG("change_lane_limit_distance = %d", examParam.change_lane_limit_distance);
                }
                if (doc.HasMember("shift_limit_distance")) {
                    const Value &a = doc["shift_limit_distance"];
                    examParam.shift_limit_distance = a.GetInt();
                    DEBUG("shift_limit_distance = %d", examParam.shift_limit_distance);
                }
                if (doc.HasMember("shift_hold_time")) {
                    const Value &a = doc["shift_hold_time"];
                    examParam.shift_hold_time = D_SEC(a.GetInt());
                    DEBUG("shift_hold_time = %d", examParam.shift_hold_time);
                }
                int straight_limit_distance;
                if (doc.HasMember("straight_limit_distance")) {
                    const Value &a = doc["straight_limit_distance"];
                    examParam.straight_limit_distance = a.GetInt();
                    DEBUG("straight_limit_distance = %d", examParam.straight_limit_distance);
                }
                if (doc.HasMember("straight_max_offset")) {
                    const Value &a = doc["straight_max_offset"];
                    examParam.straight_max_offset = a.GetDouble();
                    DEBUG("straight_max_offset = %f", examParam.straight_max_offset);
                }
                if (doc.HasMember("overtake_limit_distance")) {
                    const Value &a = doc["overtake_limit_distance"];
                    examParam.overtake_limit_distance = a.GetInt();
                    DEBUG("overtake_limit_distance = %d", examParam.overtake_limit_distance);
                }
                if (doc.HasMember("stop_car_limit_distance")) {
                    const Value &a = doc["stop_car_limit_distance"];
                    examParam.stop_car_limit_distance = a.GetInt();
                    DEBUG("stop_car_limit_distance = %d", examParam.stop_car_limit_distance);
                }
                if (doc.HasMember("stop_car_open_door_allow_time")) {
                    const Value &a = doc["stop_car_open_door_allow_time"];
                    examParam.stop_car_open_door_allow_time = D_SEC(a.GetInt());
                    DEBUG("stop_car_open_door_allow_time = %d", examParam.stop_car_open_door_allow_time);
                }
                if (doc.HasMember("stop_car_edge_red_distance")) {
                    const Value &a = doc["stop_car_edge_red_distance"];
                    examParam.stop_car_edge_red_distance = a.GetDouble();
                    DEBUG("stop_car_edge_red_distance = %f", examParam.stop_car_edge_red_distance);
                }
                if (doc.HasMember("stop_car_edge_yellow_distance")) {
                    const Value &a = doc["stop_car_edge_yellow_distance"];
                    examParam.stop_car_edge_yellow_distance = a.GetDouble();
                    DEBUG("stop_car_edge_yellow_distance = %f", examParam.stop_car_edge_yellow_distance);
                }
                if (doc.HasMember("crossing_stop_valid_distance")) {
                    const Value &a = doc["crossing_stop_valid_distance"];
                    examParam.crossing_stop_valid_distance = a.GetDouble();
                    DEBUG("crossing_stop_valid_distance = %f", examParam.crossing_stop_valid_distance);
                }
                if (doc.HasMember("cross_school_max_speed")) {
                    const Value &a = doc["cross_school_max_speed"];
                    examParam.cross_school_max_speed = a.GetInt();
                    DEBUG("cross_school_max_speed = %d", examParam.cross_school_max_speed);
                }
                if (doc.HasMember("crossing_break_valid_distance")) {
                    const Value &a = doc["crossing_break_valid_distance"];
                    examParam.crossing_break_valid_distance = a.GetInt();
                    DEBUG("crossing_break_valid_distance = %d", examParam.crossing_break_valid_distance);
                }
            }
            break;
@@ -1975,3 +2025,16 @@
{
    SendMsgToMainProcIndep(ID_SM_LIGHT_EXAM_REQ, NULL);
}
void MA_SendBlueStatus(int status)
{
    StringBuffer sb;
    Writer<StringBuffer> writer(sb);
    writer.StartObject();
    writer.Key("bluetooth_status");
    writer.Int(status);
    writer.EndObject();
    SendMsgToMainProcIndep(ID_SM_BLUETOOTH_BRIEF, sb.GetString());
}