Ver código fonte

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

Hcsy 7 anos atrás
pai
commit
e01120d616

+ 1 - 1
UAS-出货标签管理(泽天)/PublicMethod/DataHelper.cs

@@ -49,7 +49,7 @@ namespace UAS_LabelMachine
         //泽天ERP地址
         public static readonly string ERPAddesss = "http://183.47.41.2:8099/ERP/";
         //泽天FTP
-        public static readonly string FTPAdress = "ftp://183.47.41.3:21|uas|Zt2018";
+        public static readonly string FTPAdress = "ftp://10.2.10.241|uas|Lz201478c";
         //Oracle端口
         public static readonly string OraclePort = "1521";
         //需要显示的账套

BIN
UAS-出货标签管理(泽天)/tool/FastReport.Bars.dll


BIN
UAS-出货标签管理(泽天)/tool/FastReport.Editor.dll


BIN
UAS-出货标签管理(泽天)/tool/FastReport.dll


+ 41 - 0
UAS_DeviceMonitor/Entity/SocketObject.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Sockets;
+using System.Text;
+
+namespace UAS_DeviceMonitor.Entity
+{
+    class SocketObject
+    {
+        private Socket socket;
+
+        private string receiveCoding;
+
+        public Socket Socket
+        {
+            get
+            {
+                return socket;
+            }
+
+            set
+            {
+                socket = value;
+            }
+        }
+
+        public string ReceiveCoding
+        {
+            get
+            {
+                return receiveCoding;
+            }
+
+            set
+            {
+                receiveCoding = value;
+            }
+        }
+    }
+}

+ 18 - 0
UAS_DeviceMonitor/Main.Designer.cs

@@ -134,10 +134,12 @@ namespace UAS_DeviceMonitor
             this.pl_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
             this.PanelDeviceStatus = new DevExpress.XtraEditors.XtraScrollableControl();
+            this.pictureEdit1 = new DevExpress.XtraEditors.PictureEdit();
             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);
+            this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -164,6 +166,8 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).BeginInit();
             this.PageDeviceStatus.SuspendLayout();
+            this.PanelDeviceStatus.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.pictureEdit1.Properties)).BeginInit();
             this.PageWorkCenterStatus.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).BeginInit();
@@ -1198,12 +1202,22 @@ namespace UAS_DeviceMonitor
             // 
             // PanelDeviceStatus
             // 
+            this.PanelDeviceStatus.Controls.Add(this.pictureEdit1);
             this.PanelDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
             this.PanelDeviceStatus.Location = new System.Drawing.Point(0, 0);
             this.PanelDeviceStatus.Name = "PanelDeviceStatus";
             this.PanelDeviceStatus.Size = new System.Drawing.Size(1027, 577);
             this.PanelDeviceStatus.TabIndex = 0;
             // 
+            // pictureEdit1
+            // 
+            this.pictureEdit1.Location = new System.Drawing.Point(502, 126);
+            this.pictureEdit1.MenuManager = this.RibbonNav;
+            this.pictureEdit1.Name = "pictureEdit1";
+            this.pictureEdit1.Properties.ShowCameraMenuItem = DevExpress.XtraEditors.Controls.CameraMenuItemVisibility.Auto;
+            this.pictureEdit1.Size = new System.Drawing.Size(100, 96);
+            this.pictureEdit1.TabIndex = 0;
+            // 
             // PageWorkCenterStatus
             // 
             this.PageWorkCenterStatus.Controls.Add(this.GridWorkCenterStatus);
@@ -1287,6 +1301,8 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).EndInit();
             this.PageDeviceStatus.ResumeLayout(false);
+            this.PanelDeviceStatus.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)(this.pictureEdit1.Properties)).EndInit();
             this.PageWorkCenterStatus.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).EndInit();
@@ -1400,5 +1416,7 @@ namespace UAS_DeviceMonitor
         private AutoDataGridControl GridWorkCenterStatus;
         private GridViewWithSerialNum GridViewWorkCenterStatus;
         private XtraScrollableControl PanelDeviceStatus;
+        private PictureEdit pictureEdit1;
+        private DevExpress.Utils.ToolTipController CommonTipController;
     }
 }

+ 20 - 8
UAS_DeviceMonitor/Main.cs

@@ -207,7 +207,7 @@ namespace UAS_DeviceMonitor
 
         private void Brand_SelectedIndexChanged(object sender, EventArgs e)
         {
-            GridCommandSetting.Condition = " where dc_debrand='" + BaseUtil.GetComboxEditValue(Brand) + "'";
+            GridCommandSetting.Condition = " where dc_debrand='" + BaseUtil.GetComboxEditValue(Brand) + "' order by dc_id";
             GridCommandSetting.RefreshData();
         }
 
@@ -293,18 +293,20 @@ namespace UAS_DeviceMonitor
             string Decode = pl.DeviceCode;
             string Dccode = pl.CommandCode;
             DataTable dt = (DataTable)dh.ExecuteSql("select dnc_ip,dnc_port from DEVICENETCONFIG where dnc_decode='" + Decode + "'", "select");
-            DataTable dt1 = (DataTable)dh.ExecuteSql("select dc_sendcoding,dc_value from devicecommand where dc_code='" + Dccode + "'", "select");
+            DataTable dt1 = (DataTable)dh.ExecuteSql("select dc_sendcoding,dc_value,dc_receivecoding from devicecommand where dc_code='" + Dccode + "'", "select");
             if (dt.Rows.Count > 0)
             {
                 string IP = dt.Rows[0]["dnc_ip"].ToString() + ":" + dt.Rows[0]["dnc_port"].ToString();
-                string Coding = "";
+                string SendCoding = "";
+                string ReceiveCoding = "";
                 string Command = "";
                 if (dt1.Rows.Count > 0)
                 {
-                    Coding = dt1.Rows[0]["dc_sendcoding"].ToString();
+                    SendCoding = dt1.Rows[0]["dc_sendcoding"].ToString();
+                    ReceiveCoding = dt1.Rows[0]["dc_receivecoding"].ToString();
                     Command = dt1.Rows[0]["dc_value"].ToString();
                 }
-                mbt.Send(IP, Coding, Command);
+                mbt.Send(IP, SendCoding, ReceiveCoding, Command);
                 //处理2秒之内返回的指令
                 Thread.Sleep(2000);
                 if (mbt.Returnvalue.ContainsKey(IP))
@@ -395,7 +397,7 @@ namespace UAS_DeviceMonitor
         //重新展示设备图像界面
         private void ShowDeviceStatus()
         {
-            DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code where rownum<4 order by de_code", "select");
             int CountPerRow = PanelDeviceStatus.Width / 110;
             int RightPadding = PanelDeviceStatus.Width % 110;
             int Count = dt.Rows.Count;
@@ -409,15 +411,25 @@ namespace UAS_DeviceMonitor
                 {
                     LastRowCount = Count % CountPerRow;
                 }
+                CommonTipController.ShowBeak = true;
                 for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                 {
                     PictureEditWithText pic = new PictureEditWithText();
+                    pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
                     pic.Anchor = AnchorStyles.Left;
                     pic.Anchor = AnchorStyles.Top;
+                    pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
+
                     if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
-                        pic.Picedit.Image = Properties.Resources.close_24px_1069872_easyicon_net;
+                    {
+                        CommonTipController.SetToolTip(pic, "离线");
+                        pic.Picedit.Image = Properties.Resources.network_offline;
+                    }
                     else
-                        pic.Picedit.Image = Properties.Resources.devicecontrol;
+                    {
+                        CommonTipController.SetToolTip(pic, "在线");
+                        pic.Picedit.Image = Properties.Resources.net_connected;
+                    }
                     pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
                     pic.Picedit.BorderStyle = BorderStyles.HotFlat;
                     pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);

+ 3 - 0
UAS_DeviceMonitor/Main.resx

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

+ 20 - 0
UAS_DeviceMonitor/Properties/Resources.Designer.cs

@@ -90,6 +90,16 @@ namespace UAS_DeviceMonitor.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap net_connected {
+            get {
+                object obj = ResourceManager.GetObject("net_connected", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>
@@ -100,6 +110,16 @@ namespace UAS_DeviceMonitor.Properties {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Drawing.Bitmap 类型的本地化资源。
+        /// </summary>
+        internal static System.Drawing.Bitmap network_offline {
+            get {
+                object obj = ResourceManager.GetObject("network_offline", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Drawing.Bitmap 类型的本地化资源。
         /// </summary>

+ 6 - 0
UAS_DeviceMonitor/Properties/Resources.resx

@@ -145,4 +145,10 @@
   <data name="devicecontrol" type="System.Resources.ResXFileRef, System.Windows.Forms">
     <value>..\Resources\devicecontrol.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
   </data>
+  <data name="network_offline" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\network-offline.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+  <data name="net_connected" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>..\Resources\net_connected.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
 </root>

+ 15 - 0
UAS_DeviceMonitor/PublicMethod/BaseUtil.cs

@@ -1,6 +1,8 @@
 using DevExpress.XtraEditors;
 using DevExpress.XtraEditors.Repository;
+using System;
 using System.Data;
+using System.Text;
 using UAS_DeviceMonitor.DataOperate;
 
 namespace UAS_DeviceMonitor.PublicMethod
@@ -80,5 +82,18 @@ namespace UAS_DeviceMonitor.PublicMethod
 
             return LRCre;
         }
+
+        public static string ByteToHexadecimalString(byte[] b, int length)
+        {
+            string returnStr = "";
+            if (b != null)
+            {
+                for (int i = 0; i < length; i++)
+                {
+                    returnStr += Convert.ToString(b[i], 16);//ToString("X2") 为C#中的字符串格式控制符
+                }
+            }
+            return returnStr;
+        }
     }
 }

+ 25 - 13
UAS_DeviceMonitor/PublicMethod/ModeBusTCPServer.cs

@@ -84,6 +84,8 @@ namespace UAS_DeviceMonitor.PublicMethod
             }
         }
 
+        public Dictionary<string, string> ReceiveCoding = new Dictionary<string, string>();
+
         private string iP;
 
         private string port;
@@ -106,7 +108,6 @@ namespace UAS_DeviceMonitor.PublicMethod
                     if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                         iP = IpEntry.AddressList[i].ToString();
                 }
-                Console.WriteLine(iP);
                 //定义一个套接字用于监听客户端发来的信息  包含3个参数(IP4寻址协议,流式连接,TCP协议)
                 socketWatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                 //服务端发送信息 需要1个IP地址和端口号
@@ -133,8 +134,10 @@ namespace UAS_DeviceMonitor.PublicMethod
             }
         }
 
-        public void Send(string IPAddress, string EnCoding, string Command)
+        public void Send(string IPAddress, string EnCoding, string receiveCoding, string Command)
         {
+            if (!ReceiveCoding.ContainsKey(IPAddress))
+                ReceiveCoding.Add(IPAddress, receiveCoding);
             foreach (Socket item in list)
             {
                 if (item != null)
@@ -226,13 +229,6 @@ namespace UAS_DeviceMonitor.PublicMethod
                 thread.IsBackground = true;
                 //启动线程     
                 thread.Start(connection);
-                //创建一个通信线程
-                //ParameterizedThreadStart sed = new ParameterizedThreadStart(sends);
-                //Thread threadsed = new Thread(sed);
-                //设置为后台线程,随着主线程退出而退出
-                //threadsed.IsBackground = true;
-                //启动线程
-                //threadsed.Start(connection);
                 list.Add(connection);
             }
         }
@@ -253,10 +249,26 @@ namespace UAS_DeviceMonitor.PublicMethod
                     {
                         break;
                     }
-                    if (!returnvalue.ContainsKey(socketServer.RemoteEndPoint.ToString()))
-                        returnvalue.Add(socketServer.RemoteEndPoint.ToString(), Encoding.UTF8.GetString(arrServerRecMsg, 0, length));
-                    //将机器接受到的字节数组转换为人可以读懂的字符串     
-                    //将发送的字符串信息附加到文本框txtMsg上     
+                    if (ReceiveCoding.ContainsKey(socketServer.RemoteEndPoint.ToString()))
+                    {
+                        if (!returnvalue.ContainsKey(socketServer.RemoteEndPoint.ToString()))
+                        {
+                            switch (ReceiveCoding[socketServer.RemoteEndPoint.ToString()])
+                            {
+                                case "UTF-8":
+                                    returnvalue.Add(socketServer.RemoteEndPoint.ToString(), Encoding.UTF8.GetString(arrServerRecMsg, 0, length));
+                                    break;
+                                case "ASCII":
+                                    returnvalue.Add(socketServer.RemoteEndPoint.ToString(), Encoding.ASCII.GetString(arrServerRecMsg, 0, length));
+                                    break;
+                                case "Hexadecimal":
+                                    returnvalue.Add(socketServer.RemoteEndPoint.ToString(), BaseUtil.ByteToHexadecimalString(arrServerRecMsg, length));
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
                 }
                 catch (Exception)
                 {

BIN
UAS_DeviceMonitor/Resources/net_connected.png


BIN
UAS_DeviceMonitor/Resources/network-offline.png


+ 3 - 0
UAS_DeviceMonitor/UAS_DeviceMonitor.csproj

@@ -118,6 +118,7 @@
       <DependentUpon>FormNewCommand.cs</DependentUpon>
     </Compile>
     <Compile Include="Entity\Polling.cs" />
+    <Compile Include="Entity\SocketObject.cs" />
     <Compile Include="Entity\SystemInf.cs" />
     <Compile Include="Main.cs">
       <SubType>Form</SubType>
@@ -194,6 +195,8 @@
     <None Include="Resources\close_24px_1069872_easyicon.net.png" />
     <None Include="Resources\check_16px_1137507_easyicon.net.png" />
     <None Include="Resources\devicecontrol.png" />
+    <None Include="Resources\network-offline.png" />
+    <None Include="Resources\net_connected.png" />
     <Content Include="Tool\Oracle.ManagedDataAccess.dll" />
   </ItemGroup>
   <ItemGroup>