Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

Hcsy 7 years ago
parent
commit
7f99ac0094

+ 17 - 9
UAS_DeviceMonitor/Main.Designer.cs

@@ -33,6 +33,7 @@ namespace UAS_DeviceMonitor
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup1 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
@@ -138,6 +139,7 @@ namespace UAS_DeviceMonitor
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -1198,33 +1200,33 @@ namespace UAS_DeviceMonitor
             // 
             // GalleryDeviceStatus
             // 
-            this.GalleryDeviceStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
-            | System.Windows.Forms.AnchorStyles.Left) 
-            | System.Windows.Forms.AnchorStyles.Right)));
+            this.GalleryDeviceStatus.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Style3D;
             this.GalleryDeviceStatus.Controls.Add(this.galleryControlClient1);
             this.GalleryDeviceStatus.DesignGalleryGroupIndex = 0;
             this.GalleryDeviceStatus.DesignGalleryItemIndex = 0;
+            this.GalleryDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
             // 
             // 
             // 
             galleryItemGroup1.Caption = "Group9";
             galleryItemGroup1.CaptionAlignment = DevExpress.XtraBars.Ribbon.GalleryItemGroupCaptionAlignment.Center;
             galleryItemGroup1.CaptionControlSize = new System.Drawing.Size(200, 200);
+            galleryItemGroup1.Visible = true;
             this.GalleryDeviceStatus.Gallery.Groups.AddRange(new DevExpress.XtraBars.Ribbon.GalleryItemGroup[] {
             galleryItemGroup1});
             this.GalleryDeviceStatus.Gallery.ImageSize = new System.Drawing.Size(100, 100);
             this.GalleryDeviceStatus.Gallery.ShowItemText = true;
-            this.GalleryDeviceStatus.Location = new System.Drawing.Point(0, 31);
+            this.GalleryDeviceStatus.Location = new System.Drawing.Point(0, 0);
             this.GalleryDeviceStatus.Name = "GalleryDeviceStatus";
-            this.GalleryDeviceStatus.Size = new System.Drawing.Size(1027, 546);
+            this.GalleryDeviceStatus.Size = new System.Drawing.Size(1027, 577);
             this.GalleryDeviceStatus.TabIndex = 0;
             this.GalleryDeviceStatus.Text = "GalleryDeviceStatus";
             // 
             // galleryControlClient1
             // 
             this.galleryControlClient1.GalleryControl = this.GalleryDeviceStatus;
-            this.galleryControlClient1.Location = new System.Drawing.Point(2, 2);
-            this.galleryControlClient1.Size = new System.Drawing.Size(1006, 542);
+            this.galleryControlClient1.Location = new System.Drawing.Point(3, 3);
+            this.galleryControlClient1.Size = new System.Drawing.Size(1004, 571);
             // 
             // PageWorkCenterStatus
             // 
@@ -1261,6 +1263,11 @@ namespace UAS_DeviceMonitor
             this.GridViewWorkCenterStatus.Name = "GridViewWorkCenterStatus";
             this.GridViewWorkCenterStatus.OptionsView.ShowGroupPanel = false;
             // 
+            // TimerDeviceStatus
+            // 
+            this.TimerDeviceStatus.Interval = 10000;
+            this.TimerDeviceStatus.Tick += new System.EventHandler(this.TimerDeviceStatus_Tick);
+            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
@@ -1398,8 +1405,6 @@ namespace UAS_DeviceMonitor
         private GridViewWithSerialNum GridViewDeviceNetSetting;
         private DevExpress.XtraTab.XtraTabPage PageDeviceStatus;
         private DevExpress.XtraTab.XtraTabPage PageWorkCenterStatus;
-        private AutoDataGridControl GridWorkCenterStatus;
-        private GridViewWithSerialNum GridViewWorkCenterStatus;
         private DevExpress.XtraGrid.Columns.GridColumn dnc_id;
         private DevExpress.XtraGrid.Columns.GridColumn dnc_decode;
         private DevExpress.XtraGrid.Columns.GridColumn dnc_getway;
@@ -1418,5 +1423,8 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraEditors.Repository.RepositoryItemComboBox CommandSetRepositoryItemComboBox1;
         private DevExpress.XtraBars.Ribbon.GalleryControl GalleryDeviceStatus;
         private DevExpress.XtraBars.Ribbon.GalleryControlClient galleryControlClient1;
+        private System.Windows.Forms.Timer TimerDeviceStatus;
+        private AutoDataGridControl GridWorkCenterStatus;
+        private GridViewWithSerialNum GridViewWorkCenterStatus;
     }
 }

+ 41 - 18
UAS_DeviceMonitor/Main.cs

@@ -301,9 +301,18 @@ namespace UAS_DeviceMonitor
                     Command = dt1.Rows[0]["dc_value"].ToString();
                 }
                 mbt.Send(IP, Coding, Command);
-                Thread.Sleep(5000);
-                Console.WriteLine(IP);
-                Console.WriteLine(mbt.Returnvalue);
+                //处理2秒之内返回的指令
+                Thread.Sleep(2000);
+                if (mbt.Returnvalue.ContainsKey(IP))
+                {
+                    mbt.Returnvalue.Remove(IP);
+                    dh.UpdateByCondition("DEVICEPOLLINGCONFIG", "dpc_status='Running'", "dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                }
+                else
+                {
+                    dh.UpdateByCondition("DEVICEPOLLINGCONFIG", "dpc_status='Stop'", "dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
+                }
+                //mbt.Returnvalue = "";
             }
         }
 
@@ -387,27 +396,41 @@ namespace UAS_DeviceMonitor
         {
             if (PageDeviceStatus.PageVisible)
             {
-                //清除之前添加的图像
-                for (int i = 0; i < GalleryDeviceStatus.Gallery.Groups.Count; i++)
+                ShowDeviceStatus();
+                TimerDeviceStatus.Start();
+            }
+        }
+
+        //重新展示设备图像界面
+        private void ShowDeviceStatus()
+        {
+            //清除之前添加的图像
+            for (int i = 0; i < GalleryDeviceStatus.Gallery.Groups.Count; i++)
+            {
+                GalleryDeviceStatus.Gallery.Groups[i].Items.Clear();
+            }
+            DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code ", "select");
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                GalleryItem gallery;
+                //判断运行状态,是否
+                if (dt.Rows[i]["dpc_status"].ToString() == "Running")
                 {
-                    GalleryDeviceStatus.Gallery.Groups[i].Items.Clear();
+                    gallery = new GalleryItem(Properties.Resources.devicecontrol, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
                 }
-                DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code ", "select");
-                for (int i = 0; i < dt.Rows.Count; i++)
+                else
                 {
-                    GalleryItem gallery;
-                    if (dt.Rows[i]["dpc_status"].ToString() == "")
-                    {
-                        gallery = new GalleryItem(Properties.Resources.devicecontrol, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
-                    }
-                    else
-                    {
-                        gallery = new GalleryItem(Properties.Resources.close_24px_1069872_easyicon_net, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
-                    }
-                    GalleryDeviceStatus.Gallery.Groups[0].Items.Add(gallery);
+                    gallery = new GalleryItem(Properties.Resources.close_24px_1069872_easyicon_net, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
                 }
+                GalleryDeviceStatus.Gallery.Groups[0].Items.Add(gallery);
             }
         }
+
+        //刷新界面
+        private void TimerDeviceStatus_Tick(object sender, EventArgs e)
+        {
+            ShowDeviceStatus();
+        }
         #endregion
     }
 }

+ 3 - 0
UAS_DeviceMonitor/Main.resx

@@ -470,6 +470,9 @@
         Q/7XnP804u8k70qGzd6FP70Dfyb4dyh83/5/A3K8qVtfPX9uAAAAAElFTkSuQmCC
 </value>
   </data>
+  <metadata name="TimerDeviceStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         AAABAAEAQEAAAAEAIAAoQgAAFgAAACgAAABAAAAAgAAAAAEAIAAAAAAAAEAAABMLAAATCwAAAAAAAAAA

+ 5 - 7
UAS_DeviceMonitor/PublicMethod/ModeBusTCPServer.cs

@@ -14,11 +14,11 @@ namespace UAS_DeviceMonitor.PublicMethod
 
         private bool receiveData;
 
+        private Dictionary<string, string> returnvalue = new Dictionary<string, string>();
+
         Thread threadWatch = null; //负责监听客户端的线程
         Socket socketWatch = null; //负责监听客户端的套接字
 
-        string returnvalue;
-
         public bool IsOpen
         {
             get
@@ -71,7 +71,7 @@ namespace UAS_DeviceMonitor.PublicMethod
             }
         }
 
-        public string Returnvalue
+        public Dictionary<string, string> Returnvalue
         {
             get
             {
@@ -253,11 +253,9 @@ namespace UAS_DeviceMonitor.PublicMethod
                     {
                         break;
                     }
+                    if (!returnvalue.ContainsKey(socketServer.RemoteEndPoint.ToString()))
+                        returnvalue.Add(socketServer.RemoteEndPoint.ToString(), Encoding.UTF8.GetString(arrServerRecMsg, 0, length));
                     //将机器接受到的字节数组转换为人可以读懂的字符串     
-                    lock (returnvalue)
-                    {
-                        returnvalue = Encoding.UTF8.GetString(arrServerRecMsg, 0, length);
-                    }
                     //将发送的字符串信息附加到文本框txtMsg上     
                 }
                 catch (Exception)