339075217 3 年 前
コミット
46b795ed84

+ 6 - 6
unnormalized_node/unnormalized_node/bin/x86/Debug/unnoralized_node_settings.json

@@ -1,17 +1,17 @@
 {
 
   "communication_connect": [
-    "tcp://192.168.1.184:30009", //终端
+    "tcp://192.168.1.180:30009", //终端
     "tcp://192.168.1.233:30010", //地面雷达
     "tcp://192.168.1.233:30008" //车位管理
   ],
 
-  "ternimalNumber": "4", //终端号
-  "unit_id": "2", //单元号
-  "led_screen_ip": "192.168.1.164",
-  "numberMachine_ip": "192.168.1.154",
+  "ternimalNumber": "0", //终端号
+  "unit_id": "0", //单元号
+  "led_screen_ip": "192.168.1.160",
+  "numberMachine_ip": "192.168.1.150",
   "city": "武汉",
-  "camera_ip": "192.168.1.144",
+  "camera_ip": "192.168.1.140",
   "camera_user": "admin",
   "camera_password": "zx123456",
   "camera_port": "8000"

+ 20 - 9
unnormalized_node/unnormalized_node/communication/Communicator.cs

@@ -122,6 +122,18 @@ namespace Communication
         /// nanomsg 通信句柄
         /// </summary>
         protected BusSocket m_socket;
+        protected object m_sock_lock = new object();
+        BusSocket Net
+        {
+            get
+            {
+                lock(m_sock_lock)
+                {
+                    return m_socket;
+                }
+            }
+        }
+
         /// <summary>
         /// nnxx生成id队列
         /// </summary>
@@ -331,9 +343,9 @@ namespace Communication
             {
                 try
                 {
-                    if (!comm.mb_initialized || comm.m_socket == null)
+                    if (!comm.mb_initialized || comm.Net == null)
                         continue;
-                    byte[] data = comm.m_socket.ReceiveImmediate();
+                    byte[] data = comm.Net.ReceiveImmediate();
                     if (data != null && data.Length > 0 && comm.m_receive_queue != null)
                     {
                         // 解析头
@@ -366,16 +378,15 @@ namespace Communication
             {
                 try
                 {
-                    if (!comm.mb_initialized || comm.m_socket == null)
+                    if (!comm.mb_initialized || comm.Net == null)
                         continue;
-                    lock (comm.m_send_lock)
+
+                    if (comm.m_send_queue.Count > 0)
                     {
-                        if(comm.m_send_queue.Count > 0)
-                        {
-                            MsgStamped msg_stamped = comm.m_send_queue.Dequeue();
-                            comm.m_socket.Send(msg_stamped.msg.ToByteArray());
-                        }
+                        MsgStamped msg_stamped = comm.m_send_queue.Dequeue();
+                        comm.Net.Send(msg_stamped.msg.ToByteArray());
                     }
+
                     //Console.WriteLine("msg sent");
                 }
                 catch (Exception ex) { Console.WriteLine(ex.StackTrace); }