Browse Source

界面定时器改成线程

339075217 3 years ago
parent
commit
aa34aaea24

+ 46 - 57
unnormalized_node/unnormalized_node/Form1.cs

@@ -25,7 +25,7 @@ namespace UnNomalized_node
         private FormArrow m_form_arrow = new FormArrow();
         Thread m_freash_arrow_thread = null;
         bool m_bexit = false;
-        System.Windows.Forms.Timer m_timer = new System.Windows.Forms.Timer();
+        //System.Windows.Forms.Timer m_timer = new System.Windows.Forms.Timer();
 
         public Form1()
         {
@@ -77,12 +77,12 @@ namespace UnNomalized_node
             m_freash_arrow_thread = new Thread(fresh_image);
             m_freash_arrow_thread.Start();
 
-            m_timer.Tick += new EventHandler(HandleTime);
+            /*m_timer.Tick += new EventHandler(HandleTime);
             //使timer可用
             m_timer.Enabled = true;
             //设置时间间隔,以毫秒为单位
             m_timer.Interval = 100;//1s
-            m_timer.Start();
+            m_timer.Start();*/
 
 
             //this.Size = new System.Drawing.Size(1920, 1080);
@@ -98,70 +98,59 @@ namespace UnNomalized_node
         }
         public void fresh_image()
         {
-            return;
-            /*while (m_bexit == false)
+            while (m_bexit == false)
             {
-                Bitmap image= m_hk_camera.Camera.get_bitmap();
-                if (image != null)
-                {
-                    this.Invoke(new Action(() =>
-                   {
-
-                       if (pictureBox_camera.Image != null)
-                           pictureBox_camera.Image.Dispose();
-                       pictureBox_camera.Image = image;
+                //m_hk_camera.Camera.draw_image_to_wnd(pictureBox_camera.Handle);
+                //跟新led
+                update_led_screen();
 
-                   }));
-                   // image.Dispose();
+                //跟新投影仪界面车辆信息
+                string car_number_str = "";
+                if (communication_data.Instance.car_license.IsTimeout() == false)
+                {
+                    car_number_str = communication_data.Instance.car_license.Value;
                 }
-                Thread.Sleep(100);
-            }*/
-        }
-        public void HandleTime(object sender, EventArgs e)
-        {
-
-            //m_hk_camera.Camera.draw_image_to_wnd(pictureBox_camera.Handle);
-            //跟新led
-           update_led_screen();
-
-            //更新投影仪提示箭头
-            TimedData<Message.Ground_status_msg> lidar_statu = communication_data.Instance.lidar_statu;
-            m_form_arrow.Update_arrow();
-
-            //跟新投影仪界面车辆信息
-            string car_number_str = "";
-            if (communication_data.Instance.car_license.IsTimeout() == false)
-            {
-                car_number_str = communication_data.Instance.car_license.Value;
-            }
-            car_number.Text = car_number_str+"\n"+"欢迎光临";
-
-            //显示车辆信息
-            string car_info_str = "  ";
-
-            Message.Locate_information locate_info = lidar_statu.Value.LocateInformationRealtime;
-            //
-            if (lidar_statu.IsTimeout() == false)
-            {
-
-                if (lidar_statu.Value.GroundStatus == Ground_statu.CarCorrect
-                   || lidar_statu.Value.GroundStatus == Ground_statu.CarBorderReached)
+                
+
+                //显示车辆信息
+                string car_info_str = "  ";
+                TimedData<Message.Ground_status_msg> lidar_statu = communication_data.Instance.lidar_statu;
+                Message.Locate_information locate_info = lidar_statu.Value.LocateInformationRealtime;
+                //
+                if (lidar_statu.IsTimeout() == false)
                 {
 
-                    if (locate_info != null)
+                    if (lidar_statu.Value.GroundStatus == Ground_statu.CarCorrect
+                       || lidar_statu.Value.GroundStatus == Ground_statu.CarBorderReached)
                     {
 
-                        car_info_str += string.Format("X:{0:.000}m Y:{1:.000}m 角度:{2:.00}°" +
-                            "轴距:{3:.000}m 车宽:{4:.000}m 前轮角:{5:.00}°", locate_info.LocateX,
-                            locate_info.LocateY,locate_info.LocateAngle,
-                            locate_info.LocateWheelBase,locate_info.LocateWheelWidth,
-                            locate_info.LocateFrontTheta);
-                       
+                        if (locate_info != null)
+                        {
+
+                            car_info_str += string.Format("X:{0:0.000}m Y:{1:0.000}m 角度:{2:0.00}°" +
+                                "轴距:{3:0.000}m 车宽:{4:0.000}m 前轮角:{5:0.00}°", locate_info.LocateX,
+                                locate_info.LocateY, locate_info.LocateAngle,
+                                locate_info.LocateWheelBase, locate_info.LocateWheelWidth,
+                                locate_info.LocateFrontTheta);
+
+                        }
                     }
+
                 }
 
+                //更新投影仪提示箭头
+                this.Invoke((Action)(() =>
+                {
+                    label_car_info.Text = car_info_str;
+                    car_number.Text = car_number_str + "\n" + "欢迎光临";
+                    m_form_arrow.Update_arrow();
+                }));
+                Thread.Sleep(100);
             }
-            label_car_info.Text = car_info_str;
+            
+        }
+        public void HandleTime(object sender, EventArgs e)
+        {
         }
         private void update_led_screen()
         {
@@ -238,7 +227,7 @@ namespace UnNomalized_node
             BroadcastBoardManager.Instance.squareBoardList[0].UpdateStatus(
                                 BroadcastSquareBoard.Entrance_statu.ENTRANCE_NOSIGNAL, false);
             m_bexit = true;
-            m_timer.Stop();
+            //m_timer.Stop();
             BroadcastBoardManager.Instance.Close();
             if (m_freash_arrow_thread.IsAlive)
             {

+ 37 - 24
unnormalized_node/unnormalized_node/FormArrow.cs

@@ -67,8 +67,9 @@ namespace UnNomalized_node
             eDisconnect=0x0d,
             eWidthError=0x0e,
             eWheelBaseError=0x0f,
+            eWheelAngleError=0x16,
             //数量
-            eNum=0x16,
+            eNum=0x17,
         };
         Timer m_timer;
         PictureBox[] m_arrows_images = new PictureBox[(int)Car_statu.eNum];
@@ -123,6 +124,7 @@ namespace UnNomalized_node
             m_arrows_images[(int)Car_statu.eOutRightDown].BackColor = Color.DarkOrange;
             m_arrows_images[(int)Car_statu.eOutRotateLeft].BackColor = Color.DarkOrange;
             m_arrows_images[(int)Car_statu.eOutRotateRight].BackColor = Color.DarkOrange;
+            //m_arrows_images[(int)Car_statu.eWheelAngleError].BackColor = Color.DarkOrange;
 
             tableLayoutPanel2.Controls.Add(m_text_image_warning, 0, 0);
             tableLayoutPanel2.Controls.Add(m_text_image_ok, 0, 0);
@@ -187,6 +189,8 @@ namespace UnNomalized_node
                 "/Resource/arrows/" + "leftRotate.png");
             m_arrows_images[(int)Car_statu.eOutRotateRight].Image = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory +
                 "/Resource/arrows/" + "rightRotate.png");
+            m_arrows_images[(int)Car_statu.eWheelAngleError].Image = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory +
+                "/Resource/arrows/" + "reset_wheel.png");
 
             m_text_image_warning.Image = Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory +
                 "/Resource/arrows/" + "warning.png");
@@ -219,6 +223,7 @@ namespace UnNomalized_node
                 case Car_statu.eOutRightDown:
                 case Car_statu.eOutRotateLeft:
                 case Car_statu.eOutRotateRight:
+                case Car_statu.eWheelAngleError:
                     m_arrows_images[(int)m_last_lidar_statu].Visible = (m_arrows_images[(int)m_last_lidar_statu].Visible == false);
                     break;
             }
@@ -274,29 +279,6 @@ namespace UnNomalized_node
             {
 
                 int border_statu = lidar_statu.Value.BorderStatus;
-                //先判断车辆是否超宽
-                if (((border_statu >> 6) & 0x01) > 0)
-                {
-                    Set_arrow(Car_statu.eWidthError);
-                    return;
-                }
-                //轴距超差
-                if (((border_statu >> 7) & 0x01) > 0)
-                {
-                    Set_arrow(Car_statu.eWheelBaseError);
-                    return;
-                }
-                //左右旋转
-                if (((border_statu >> 9) & 0x01) > 0)
-                {
-                    Set_arrow(Car_statu.eOutRotateLeft);
-                    return;
-                }
-                if (((border_statu >> 8) & 0x01) > 0)
-                {
-                    Set_arrow(Car_statu.eOutRotateRight);
-                    return;
-                }
 
                 switch (lidar_statu.Value.GroundStatus)
                 {
@@ -311,6 +293,36 @@ namespace UnNomalized_node
                         Set_arrow(Car_statu.eOK);
                         break;
                     case Ground_statu.CarBorderReached:
+                        //先判断车辆是否超宽
+                        if (((border_statu >> 6) & 0x01) > 0)
+                        {
+                            Set_arrow(Car_statu.eWidthError);
+                            break;
+                        }
+                        //轴距超差
+                        if (((border_statu >> 7) & 0x01) > 0)
+                        {
+                            Set_arrow(Car_statu.eWheelBaseError);
+                            break;
+                        }
+                        //左右旋转
+                        if (((border_statu >> 9) & 0x01) > 0)
+                        {
+                            Set_arrow(Car_statu.eOutRotateLeft);
+                            break;
+                        }
+                        if (((border_statu >> 8) & 0x01) > 0)
+                        {
+                            Set_arrow(Car_statu.eOutRotateRight);
+                            break;
+                        }
+                        //方向盘
+                        if(((border_statu >> 10) & 0x01) > 0)
+                        {
+                            Set_arrow(Car_statu.eWheelAngleError);
+                            break;
+                        }
+                        //显示超界
                         switch ((Car_statu)border_statu)
                         {
                             case Car_statu.eOK:
@@ -404,6 +416,7 @@ namespace UnNomalized_node
                 case Car_statu.eOutRightDown:
                 case Car_statu.eOutRotateLeft:
                 case Car_statu.eOutRotateRight:
+                case Car_statu.eWheelAngleError:
                     m_text_image_warning.Visible = true;
                     m_text_image_ok.Visible = false;
                     m_text_image_disconnect.Visible = false;