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/master/comm_if.cpp |   89 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 87 insertions(+), 2 deletions(-)

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: {

--
Gitblit v1.8.0