Browse Source

修改定时上传数据

章政 6 years ago
parent
commit
e2b6881fba

+ 55 - 39
PLCDataReader/Device/Information/DeviceStatusInfo.Designer.cs

@@ -58,12 +58,13 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.dpg_receivedatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dnc_port = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_runtime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.dpg_interval = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.dnc_ip = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_senddatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_onlinetime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.GridDeivceStatusInfo = new DevExpress.XtraGrid.GridControl();
             this.GridViewDeviceStatusInfo = new DevExpress.XtraGrid.Views.Grid.GridView();
             this.dc_name = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.dr_updatedate = new DevExpress.XtraGrid.Columns.GridColumn();
             this.data = new DevExpress.XtraGrid.Columns.GridColumn();
             this.GridDeviceRunLog = new DevExpress.XtraGrid.GridControl();
             this.GridViewDeviceRunLog = new DevExpress.XtraGrid.Views.Grid.GridView();
@@ -96,7 +97,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl1.Controls.Add(this.labelControl1);
             this.groupControl1.Location = new System.Drawing.Point(12, 7);
             this.groupControl1.Name = "groupControl1";
-            this.groupControl1.Size = new System.Drawing.Size(248, 213);
+            this.groupControl1.Size = new System.Drawing.Size(235, 213);
             this.groupControl1.TabIndex = 0;
             this.groupControl1.Text = "设备信息";
             // 
@@ -104,7 +105,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // 
             this.sc_name.Appearance.Font = new System.Drawing.Font("黑体", 12F);
             this.sc_name.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Horizontal;
-            this.sc_name.Location = new System.Drawing.Point(92, 192);
+            this.sc_name.Location = new System.Drawing.Point(92, 189);
             this.sc_name.MaximumSize = new System.Drawing.Size(140, 0);
             this.sc_name.Name = "sc_name";
             this.sc_name.Size = new System.Drawing.Size(0, 16);
@@ -114,7 +115,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // 
             this.de_sourcecode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
             this.de_sourcecode.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Horizontal;
-            this.de_sourcecode.Location = new System.Drawing.Point(92, 165);
+            this.de_sourcecode.Location = new System.Drawing.Point(92, 162);
             this.de_sourcecode.MaximumSize = new System.Drawing.Size(140, 0);
             this.de_sourcecode.Name = "de_sourcecode";
             this.de_sourcecode.Size = new System.Drawing.Size(0, 16);
@@ -123,7 +124,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl15
             // 
             this.labelControl15.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl15.Location = new System.Drawing.Point(13, 165);
+            this.labelControl15.Location = new System.Drawing.Point(13, 162);
             this.labelControl15.Name = "labelControl15";
             this.labelControl15.Size = new System.Drawing.Size(64, 16);
             this.labelControl15.TabIndex = 20;
@@ -132,7 +133,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // de_linecode
             // 
             this.de_linecode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_linecode.Location = new System.Drawing.Point(70, 131);
+            this.de_linecode.Location = new System.Drawing.Point(70, 128);
             this.de_linecode.Name = "de_linecode";
             this.de_linecode.Size = new System.Drawing.Size(0, 16);
             this.de_linecode.TabIndex = 19;
@@ -140,7 +141,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // de_address
             // 
             this.de_address.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_address.Location = new System.Drawing.Point(70, 100);
+            this.de_address.Location = new System.Drawing.Point(70, 97);
             this.de_address.Name = "de_address";
             this.de_address.Size = new System.Drawing.Size(0, 16);
             this.de_address.TabIndex = 18;
@@ -148,7 +149,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl4
             // 
             this.labelControl4.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl4.Location = new System.Drawing.Point(13, 131);
+            this.labelControl4.Location = new System.Drawing.Point(13, 128);
             this.labelControl4.Name = "labelControl4";
             this.labelControl4.Size = new System.Drawing.Size(32, 16);
             this.labelControl4.TabIndex = 6;
@@ -157,7 +158,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // de_wccode
             // 
             this.de_wccode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_wccode.Location = new System.Drawing.Point(70, 68);
+            this.de_wccode.Location = new System.Drawing.Point(70, 65);
             this.de_wccode.Name = "de_wccode";
             this.de_wccode.Size = new System.Drawing.Size(0, 16);
             this.de_wccode.TabIndex = 17;
@@ -165,7 +166,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl3
             // 
             this.labelControl3.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl3.Location = new System.Drawing.Point(13, 100);
+            this.labelControl3.Location = new System.Drawing.Point(13, 97);
             this.labelControl3.Name = "labelControl3";
             this.labelControl3.Size = new System.Drawing.Size(32, 16);
             this.labelControl3.TabIndex = 5;
@@ -174,7 +175,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // de_name
             // 
             this.de_name.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_name.Location = new System.Drawing.Point(70, 35);
+            this.de_name.Location = new System.Drawing.Point(70, 32);
             this.de_name.Name = "de_name";
             this.de_name.Size = new System.Drawing.Size(0, 16);
             this.de_name.TabIndex = 16;
@@ -182,7 +183,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl2
             // 
             this.labelControl2.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl2.Location = new System.Drawing.Point(13, 68);
+            this.labelControl2.Location = new System.Drawing.Point(13, 65);
             this.labelControl2.Name = "labelControl2";
             this.labelControl2.Size = new System.Drawing.Size(32, 16);
             this.labelControl2.TabIndex = 4;
@@ -191,7 +192,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl1
             // 
             this.labelControl1.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl1.Location = new System.Drawing.Point(13, 35);
+            this.labelControl1.Location = new System.Drawing.Point(13, 32);
             this.labelControl1.Name = "labelControl1";
             this.labelControl1.Size = new System.Drawing.Size(32, 16);
             this.labelControl1.TabIndex = 0;
@@ -208,7 +209,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl2.Controls.Add(this.labelControl7);
             this.groupControl2.Location = new System.Drawing.Point(12, 226);
             this.groupControl2.Name = "groupControl2";
-            this.groupControl2.Size = new System.Drawing.Size(248, 182);
+            this.groupControl2.Size = new System.Drawing.Size(235, 182);
             this.groupControl2.TabIndex = 1;
             this.groupControl2.Text = "生产信息";
             // 
@@ -276,7 +277,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl11
             // 
             this.labelControl11.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl11.Location = new System.Drawing.Point(16, 35);
+            this.labelControl11.Location = new System.Drawing.Point(16, 32);
             this.labelControl11.Name = "labelControl11";
             this.labelControl11.Size = new System.Drawing.Size(64, 16);
             this.labelControl11.TabIndex = 11;
@@ -285,7 +286,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl12
             // 
             this.labelControl12.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl12.Location = new System.Drawing.Point(16, 68);
+            this.labelControl12.Location = new System.Drawing.Point(16, 65);
             this.labelControl12.Name = "labelControl12";
             this.labelControl12.Size = new System.Drawing.Size(64, 16);
             this.labelControl12.TabIndex = 12;
@@ -294,7 +295,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl9
             // 
             this.labelControl9.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl9.Location = new System.Drawing.Point(16, 159);
+            this.labelControl9.Location = new System.Drawing.Point(16, 156);
             this.labelControl9.Name = "labelControl9";
             this.labelControl9.Size = new System.Drawing.Size(64, 16);
             this.labelControl9.TabIndex = 14;
@@ -303,7 +304,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl14
             // 
             this.labelControl14.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl14.Location = new System.Drawing.Point(16, 100);
+            this.labelControl14.Location = new System.Drawing.Point(16, 97);
             this.labelControl14.Name = "labelControl14";
             this.labelControl14.Size = new System.Drawing.Size(64, 16);
             this.labelControl14.TabIndex = 15;
@@ -314,23 +315,23 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl3.Controls.Add(this.dpg_receivedatasize);
             this.groupControl3.Controls.Add(this.dnc_port);
             this.groupControl3.Controls.Add(this.dpg_runtime);
-            this.groupControl3.Controls.Add(this.dpg_interval);
+            this.groupControl3.Controls.Add(this.dnc_ip);
             this.groupControl3.Controls.Add(this.dpg_senddatasize);
             this.groupControl3.Controls.Add(this.labelControl14);
             this.groupControl3.Controls.Add(this.dpg_onlinetime);
             this.groupControl3.Controls.Add(this.labelControl9);
             this.groupControl3.Controls.Add(this.labelControl12);
             this.groupControl3.Controls.Add(this.labelControl11);
-            this.groupControl3.Location = new System.Drawing.Point(266, 7);
+            this.groupControl3.Location = new System.Drawing.Point(253, 7);
             this.groupControl3.Name = "groupControl3";
-            this.groupControl3.Size = new System.Drawing.Size(328, 213);
+            this.groupControl3.Size = new System.Drawing.Size(288, 213);
             this.groupControl3.TabIndex = 2;
             this.groupControl3.Text = "运行信息";
             // 
             // dpg_receivedatasize
             // 
             this.dpg_receivedatasize.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_receivedatasize.Location = new System.Drawing.Point(97, 190);
+            this.dpg_receivedatasize.Location = new System.Drawing.Point(97, 187);
             this.dpg_receivedatasize.Name = "dpg_receivedatasize";
             this.dpg_receivedatasize.Size = new System.Drawing.Size(0, 16);
             this.dpg_receivedatasize.TabIndex = 18;
@@ -338,7 +339,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // dnc_port
             // 
             this.dnc_port.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dnc_port.Location = new System.Drawing.Point(96, 130);
+            this.dnc_port.Location = new System.Drawing.Point(96, 127);
             this.dnc_port.Name = "dnc_port";
             this.dnc_port.Size = new System.Drawing.Size(0, 16);
             this.dnc_port.TabIndex = 17;
@@ -346,23 +347,23 @@ namespace UAS_PLCDataReader.Device.Infomation
             // dpg_runtime
             // 
             this.dpg_runtime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_runtime.Location = new System.Drawing.Point(96, 68);
+            this.dpg_runtime.Location = new System.Drawing.Point(96, 65);
             this.dpg_runtime.Name = "dpg_runtime";
             this.dpg_runtime.Size = new System.Drawing.Size(0, 16);
             this.dpg_runtime.TabIndex = 16;
             // 
-            // dpg_interval
+            // dnc_ip
             // 
-            this.dpg_interval.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_interval.Location = new System.Drawing.Point(96, 100);
-            this.dpg_interval.Name = "dpg_interval";
-            this.dpg_interval.Size = new System.Drawing.Size(0, 16);
-            this.dpg_interval.TabIndex = 3;
+            this.dnc_ip.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.dnc_ip.Location = new System.Drawing.Point(96, 97);
+            this.dnc_ip.Name = "dnc_ip";
+            this.dnc_ip.Size = new System.Drawing.Size(0, 16);
+            this.dnc_ip.TabIndex = 3;
             // 
             // dpg_senddatasize
             // 
             this.dpg_senddatasize.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_senddatasize.Location = new System.Drawing.Point(96, 159);
+            this.dpg_senddatasize.Location = new System.Drawing.Point(96, 156);
             this.dpg_senddatasize.Name = "dpg_senddatasize";
             this.dpg_senddatasize.Size = new System.Drawing.Size(0, 16);
             this.dpg_senddatasize.TabIndex = 2;
@@ -370,17 +371,17 @@ namespace UAS_PLCDataReader.Device.Infomation
             // dpg_onlinetime
             // 
             this.dpg_onlinetime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_onlinetime.Location = new System.Drawing.Point(96, 35);
+            this.dpg_onlinetime.Location = new System.Drawing.Point(96, 32);
             this.dpg_onlinetime.Name = "dpg_onlinetime";
             this.dpg_onlinetime.Size = new System.Drawing.Size(0, 16);
             this.dpg_onlinetime.TabIndex = 0;
             // 
             // GridDeivceStatusInfo
             // 
-            this.GridDeivceStatusInfo.Location = new System.Drawing.Point(600, 7);
+            this.GridDeivceStatusInfo.Location = new System.Drawing.Point(547, 7);
             this.GridDeivceStatusInfo.MainView = this.GridViewDeviceStatusInfo;
             this.GridDeivceStatusInfo.Name = "GridDeivceStatusInfo";
-            this.GridDeivceStatusInfo.Size = new System.Drawing.Size(207, 213);
+            this.GridDeivceStatusInfo.Size = new System.Drawing.Size(261, 213);
             this.GridDeivceStatusInfo.TabIndex = 3;
             this.GridDeivceStatusInfo.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
             this.GridViewDeviceStatusInfo});
@@ -389,6 +390,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // 
             this.GridViewDeviceStatusInfo.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
             this.dc_name,
+            this.dr_updatedate,
             this.data});
             this.GridViewDeviceStatusInfo.GridControl = this.GridDeivceStatusInfo;
             this.GridViewDeviceStatusInfo.Name = "GridViewDeviceStatusInfo";
@@ -399,23 +401,34 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.dc_name.Caption = "参数";
             this.dc_name.FieldName = "DC_NAME";
             this.dc_name.Name = "dc_name";
+            this.dc_name.OptionsColumn.AllowEdit = false;
             this.dc_name.Visible = true;
             this.dc_name.VisibleIndex = 0;
             // 
+            // dr_updatedate
+            // 
+            this.dr_updatedate.Caption = "最近更新日期";
+            this.dr_updatedate.FieldName = "DR_UPDATEDATE";
+            this.dr_updatedate.Name = "dr_updatedate";
+            this.dr_updatedate.OptionsColumn.AllowEdit = false;
+            this.dr_updatedate.Visible = true;
+            this.dr_updatedate.VisibleIndex = 1;
+            // 
             // data
             // 
-            this.data.Caption = "上一次更新值";
+            this.data.Caption = "最近更新值";
             this.data.FieldName = "DATA";
             this.data.Name = "data";
+            this.data.OptionsColumn.AllowEdit = false;
             this.data.Visible = true;
-            this.data.VisibleIndex = 1;
+            this.data.VisibleIndex = 2;
             // 
             // GridDeviceRunLog
             // 
-            this.GridDeviceRunLog.Location = new System.Drawing.Point(266, 226);
+            this.GridDeviceRunLog.Location = new System.Drawing.Point(253, 226);
             this.GridDeviceRunLog.MainView = this.GridViewDeviceRunLog;
             this.GridDeviceRunLog.Name = "GridDeviceRunLog";
-            this.GridDeviceRunLog.Size = new System.Drawing.Size(541, 182);
+            this.GridDeviceRunLog.Size = new System.Drawing.Size(555, 182);
             this.GridDeviceRunLog.TabIndex = 4;
             this.GridDeviceRunLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
             this.GridViewDeviceRunLog});
@@ -434,6 +447,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.drr_commandfrom.Caption = "指令编号";
             this.drr_commandfrom.FieldName = "DRR_COMMANDFROM";
             this.drr_commandfrom.Name = "drr_commandfrom";
+            this.drr_commandfrom.OptionsColumn.AllowEdit = false;
             this.drr_commandfrom.Visible = true;
             this.drr_commandfrom.VisibleIndex = 1;
             // 
@@ -442,6 +456,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.drr_command.Caption = "指令内容";
             this.drr_command.FieldName = "DRR_COMMAND";
             this.drr_command.Name = "drr_command";
+            this.drr_command.OptionsColumn.AllowEdit = false;
             this.drr_command.Visible = true;
             this.drr_command.VisibleIndex = 0;
             // 
@@ -498,7 +513,7 @@ namespace UAS_PLCDataReader.Device.Infomation
         private ValueLabel dpg_onlinetime;
         private DevExpress.XtraEditors.LabelControl labelControl14;
         private ValueLabel dpg_senddatasize;
-        private ValueLabel dpg_interval;
+        private ValueLabel dnc_ip;
         private DevExpress.XtraEditors.GroupControl groupControl3;
         private ValueLabel de_linecode;
         private ValueLabel de_address;
@@ -521,5 +536,6 @@ namespace UAS_PLCDataReader.Device.Infomation
         private DevExpress.XtraGrid.Columns.GridColumn drr_commandfrom;
         private ValueLabel dnc_port;
         private ValueLabel dpg_receivedatasize;
+        private DevExpress.XtraGrid.Columns.GridColumn dr_updatedate;
     }
 }

+ 35 - 32
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -43,51 +43,54 @@ namespace UAS_PLCDataReader.Device.Infomation
             }
             //查询设备参数信息
             sql.Clear();
-            sql.Append("select dc_name,case when dc_type='INQTY' then dr_qty when dc_type='OUTQTY' then dr_okqty end data ");
+            sql.Append("select dr_updatedate,dc_name,case when dc_type='INQTY' then dr_qty when dc_type='OUTQTY' then dr_okqty end data ");
             sql.Append("from DEVICEPOLLINGCONFIG left join devicecommand on dpc_dccode = dc_code left join DEVICERUNSTATUS ");
             sql.Append("on dpc_decode = dr_decode where dpc_decode = '" + de_code + "'");
             GridDeivceStatusInfo.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
+            GridViewDeviceStatusInfo.BestFitColumns();
             sql.Clear();
             //查询设备运行日志
-            sql.Append("select * from DEVICERUNRECORD");
+            sql.Append("select * from DEVICERUNRECORD where drr_decode='"+ de_code + "'");
             GridDeviceRunLog.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             sql.Clear();
             sql.Append("select '接收'||nvl(dpg_senddatasize,0)||'字节' dpg_receivedatasize,'发送'||nvl(dpg_receivedatasize,0)||'字节' dpg_senddatasize");
-            sql.Append(",dpg_onlinetime,dpg_offlinetime,'IP:'||dnc_ip dpg_interval,'端口:'|| dnc_port||',间隔'||dpg_interval||'S' dnc_port ");
-            sql.Append("from devicepollinglog left join DEVICENETCONFIG on dnc_decode=dpg_decode ");
-            sql.Append("where dpg_id=(select max(dpg_id) from devicepollinglog where dpg_decode='"+de_code+"')");
+            sql.Append(",dpg_onlinetime,dpg_offlinetime,'IP:'||dnc_ip dnc_ip,'端口:'|| dnc_port||',间隔'||dpg_interval||'S' dnc_port,");
+            sql.Append("round(to_number(sysdate-DPG_ONLINETIME )*1440) dpg_runtime from devicepollinglog left join DEVICENETCONFIG on dnc_decode=dpg_decode ");
+            sql.Append("where dpg_id=(select max(dpg_id) from devicepollinglog where dpg_decode='" + de_code + "')");
             dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             if (dt.Rows.Count > 0)
             {
                 BaseUtil.SetFormValue(this.Controls, dt);
+                string TimeSpan = dt.Rows[0]["dpg_runtime"].ToString();
+                dpg_runtime.Text = BaseUtil.MinutesToDayTime(int.Parse(TimeSpan == "" ? "0" : TimeSpan));
             }
-            if (Main.ReturnData.ContainsKey(de_code))
-            {
-                dpg_interval.Text = Main.ReturnData[de_code].SendCount.ToString();
-                dpg_runtime.Text = (DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes.ToString("f1") + "分钟";
-                dpg_onlinetime.Text = Main.ReturnData[de_code].StartTime.ToString("yyyy-MM-dd HH:mm:ss");
-                dpg_senddatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
-                Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
-                if (ItemData != null && ItemData.Count > 0)
-                {
-                    foreach (var item in ItemData)
-                    {
-                        switch (item.Key)
-                        {
-                            case "INQTY":
-                                INQTY.Text = item.Value;
-                                break;
-                            case "OUTQTY":
-                                OUTQTY.Text = item.Value;
-                                break;
-                            case "TEMPERATURE":
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                }
-            }
+            //if (Main.ReturnData.ContainsKey(de_code))
+            //{
+            //    //dnc_ip.Text = Main.ReturnData[de_code].SendCount.ToString();
+            //    //dpg_runtime.Text = BaseUtil.MinutesToDayTime((DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes);
+            //    //dpg_onlinetime.Text = Main.ReturnData[de_code].StartTime.ToString("yyyy-MM-dd HH:mm:ss");
+            //    //dpg_senddatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
+            //    Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
+            //    if (ItemData != null && ItemData.Count > 0)
+            //    {
+            //        foreach (var item in ItemData)
+            //        {
+            //            switch (item.Key)
+            //            {
+            //                case "INQTY":
+            //                    INQTY.Text = item.Value;
+            //                    break;
+            //                case "OUTQTY":
+            //                    OUTQTY.Text = item.Value;
+            //                    break;
+            //                case "TEMPERATURE":
+            //                    break;
+            //                default:
+            //                    break;
+            //            }
+            //        }
+            //    }
+            //}
         }
 
         private void DeviceStatusInfo_KeyDown(object sender, KeyEventArgs e)

+ 50 - 0
PLCDataReader/Entity/DeviceStatus.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace UAS_PLCDataReader.Entity
+{
+    class DeviceStatus
+    {
+        private static string running;
+
+        private static string stopped;
+
+        private static string noanswer;
+
+        private static string disconnect;
+
+        public static string Running
+        {
+            get
+            {
+                return "running";
+            }
+        }
+
+        public static string Stopped
+        {
+            get
+            {
+                return "stopped";
+            }
+        }
+
+        public static string Noanswer
+        {
+            get
+            {
+                return "noanswer";
+            }
+        }
+
+        public static string Disconnect
+        {
+            get
+            {
+                return "disconnect";
+            }
+        }
+    }
+}

+ 71 - 6
PLCDataReader/Main.Designer.cs

@@ -33,6 +33,7 @@ namespace UAS_PLCDataReader
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
             this.ButtonDeviceList = new DevExpress.XtraBars.BarButtonItem();
@@ -43,6 +44,7 @@ namespace UAS_PLCDataReader
             this.ButtonDeviceStatus = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonWorkCenterStatus = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonDeviceRunLog = new DevExpress.XtraBars.BarButtonItem();
+            this.ButtonClientParam = new DevExpress.XtraBars.BarButtonItem();
             this.DeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPage();
             this.RibDeviceInf = new DevExpress.XtraBars.Ribbon.RibbonPageGroup();
             this.DeviceCommandSetting = new DevExpress.XtraBars.Ribbon.RibbonPage();
@@ -187,9 +189,13 @@ namespace UAS_PLCDataReader
             this.drr_commandfrom = new DevExpress.XtraGrid.Columns.GridColumn();
             this.drr_doman = new DevExpress.XtraGrid.Columns.GridColumn();
             this.drr_remark = new DevExpress.XtraGrid.Columns.GridColumn();
-            this.TimerDeviceStatus = new System.Windows.Forms.Timer();
-            this.CommonTipController = new DevExpress.Utils.ToolTipController();
-            this.TimerUpdateDevice = new System.Windows.Forms.Timer();
+            this.PageClientParam = new DevExpress.XtraTab.XtraTabPage();
+            this.UpdateTimeSpan = new System.Windows.Forms.NumericUpDown();
+            this.label1 = new System.Windows.Forms.Label();
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
+            this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
+            this.TimerUpdateDevice = new System.Windows.Forms.Timer(this.components);
+            this.ButtonSaveClientParam = new DevExpress.XtraEditors.SimpleButton();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -233,6 +239,8 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).BeginInit();
+            this.PageClientParam.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.UpdateTimeSpan)).BeginInit();
             this.SuspendLayout();
             // 
             // RibbonNav
@@ -249,9 +257,10 @@ namespace UAS_PLCDataReader
             this.ButtionPolling,
             this.ButtonDeviceStatus,
             this.ButtonWorkCenterStatus,
-            this.ButtonDeviceRunLog});
+            this.ButtonDeviceRunLog,
+            this.ButtonClientParam});
             this.RibbonNav.Location = new System.Drawing.Point(0, 0);
-            this.RibbonNav.MaxItemId = 16;
+            this.RibbonNav.MaxItemId = 17;
             this.RibbonNav.Name = "RibbonNav";
             this.RibbonNav.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
             this.DeviceInf,
@@ -337,6 +346,16 @@ namespace UAS_PLCDataReader
             this.ButtonDeviceRunLog.Tag = "PageDeviceRunLog";
             this.ButtonDeviceRunLog.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
             // 
+            // ButtonClientParam
+            // 
+            this.ButtonClientParam.Caption = "客户端参数设置";
+            this.ButtonClientParam.Glyph = ((System.Drawing.Image)(resources.GetObject("ButtonClientParam.Glyph")));
+            this.ButtonClientParam.Id = 16;
+            this.ButtonClientParam.LargeGlyph = ((System.Drawing.Image)(resources.GetObject("ButtonClientParam.LargeGlyph")));
+            this.ButtonClientParam.Name = "ButtonClientParam";
+            this.ButtonClientParam.Tag = "PageClientParam";
+            this.ButtonClientParam.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.ButtonItem_ItemClick);
+            // 
             // DeviceInf
             // 
             this.DeviceInf.Groups.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPageGroup[] {
@@ -351,6 +370,7 @@ namespace UAS_PLCDataReader
             this.RibDeviceInf.ItemLinks.Add(this.ButtonDeviceList);
             this.RibDeviceInf.ItemLinks.Add(this.ButtonDeviceNetSetting);
             this.RibDeviceInf.ItemLinks.Add(this.ButtonPollingSetting);
+            this.RibDeviceInf.ItemLinks.Add(this.ButtonClientParam);
             this.RibDeviceInf.Name = "RibDeviceInf";
             this.RibDeviceInf.ShowCaptionButton = false;
             // 
@@ -385,7 +405,8 @@ namespace UAS_PLCDataReader
             this.PagePolling,
             this.PageDeviceStatus,
             this.PageWorkCenterStatus,
-            this.PageDeviceRunLog});
+            this.PageDeviceRunLog,
+            this.PageClientParam});
             // 
             // PageDeviceList
             // 
@@ -1838,6 +1859,33 @@ namespace UAS_PLCDataReader
             this.drr_remark.VisibleIndex = 6;
             this.drr_remark.Width = 144;
             // 
+            // PageClientParam
+            // 
+            this.PageClientParam.Controls.Add(this.ButtonSaveClientParam);
+            this.PageClientParam.Controls.Add(this.UpdateTimeSpan);
+            this.PageClientParam.Controls.Add(this.label1);
+            this.PageClientParam.Name = "PageClientParam";
+            this.PageClientParam.PageVisible = false;
+            this.PageClientParam.Size = new System.Drawing.Size(1027, 577);
+            this.PageClientParam.VisibleChanged += new System.EventHandler(this.PageClientParam_VisibleChanged);
+            // 
+            // UpdateTimeSpan
+            // 
+            this.UpdateTimeSpan.Location = new System.Drawing.Point(140, 30);
+            this.UpdateTimeSpan.Name = "UpdateTimeSpan";
+            this.UpdateTimeSpan.Size = new System.Drawing.Size(53, 22);
+            this.UpdateTimeSpan.TabIndex = 1;
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.label1.Location = new System.Drawing.Point(28, 30);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(106, 21);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "数据上传时间";
+            // 
             // TimerDeviceStatus
             // 
             this.TimerDeviceStatus.Interval = 10000;
@@ -1852,6 +1900,15 @@ namespace UAS_PLCDataReader
             this.TimerUpdateDevice.Interval = 20000;
             this.TimerUpdateDevice.Tick += new System.EventHandler(this.TimerUpdateDevice_Tick);
             // 
+            // ButtonSaveClientParam
+            // 
+            this.ButtonSaveClientParam.Location = new System.Drawing.Point(140, 122);
+            this.ButtonSaveClientParam.Name = "ButtonSaveClientParam";
+            this.ButtonSaveClientParam.Size = new System.Drawing.Size(64, 23);
+            this.ButtonSaveClientParam.TabIndex = 2;
+            this.ButtonSaveClientParam.Text = "保存";
+            this.ButtonSaveClientParam.Click += new System.EventHandler(this.ButtonSaveClientParam_Click);
+            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
@@ -1915,6 +1972,9 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.TextDrrDeCode.Properties)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GirdViewDeviceRunLog)).EndInit();
+            this.PageClientParam.ResumeLayout(false);
+            this.PageClientParam.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.UpdateTimeSpan)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -2078,5 +2138,10 @@ namespace UAS_PLCDataReader
         private LabelControl LabelDrrDeCode;
         private SimpleButton ButtonSearchDeviceRunLog;
         private TextEdit TextDrrDeCode;
+        private DevExpress.XtraBars.BarButtonItem ButtonClientParam;
+        private DevExpress.XtraTab.XtraTabPage PageClientParam;
+        private System.Windows.Forms.NumericUpDown UpdateTimeSpan;
+        private System.Windows.Forms.Label label1;
+        private SimpleButton ButtonSaveClientParam;
     }
 }

+ 59 - 11
PLCDataReader/Main.cs

@@ -35,6 +35,10 @@ namespace UAS_PLCDataReader
         /// 需要更新的设备列表
         /// </summary>
         public static Queue<Entity.Device> QueueUpdateDevice = new Queue<Entity.Device>();
+        /// <summary>
+        /// 本地设定的上传时间
+        /// </summary>
+        int TimeSpan = 1;
 
         #region 初始化代码
         public Main()
@@ -177,9 +181,21 @@ namespace UAS_PLCDataReader
             GridDeviceRunLog.GetDataSQL = "SELECT * FROM DEVICERUNRECORD";
             GridDeviceRunLog.ID = "drr_id";
             GridDeviceRunLog.TableName = "DEVICERUNRECORD";
+
+            if (int.TryParse(BaseUtil.GetCacheData("UpdateTime").ToString(), out TimeSpan))
+            {
+                TimerUpdateDevice.Interval = TimeSpan * 60 * 1000;
+            }
+            else
+            {
+                TimerUpdateDevice.Interval = 60 * 1000;
+            }
             TimerUpdateDevice.Start();
 
             Ptime = new Dictionary<int, PollingTimer>();
+
+            ButtonPollingSetting.PerformClick();
+            ButtonStartPolling.PerformClick();
         }
         #endregion
 
@@ -324,13 +340,19 @@ namespace UAS_PLCDataReader
         /// <param name="e"></param>
         private void TimerUpdateDevice_Tick(object sender, EventArgs e)
         {
-            while (QueueUpdateDevice.Count > 0)
+            foreach (var device in ReturnData)
             {
-                Entity.Device item = QueueUpdateDevice.Dequeue();
-                SQL.Clear();
-                //更新轮询日志状态
+                Entity.Device item = device.Value;
                 LogicHandler.DoDevicePollingLog(item.Decode, item.SendDataSize.ToString(), item.ReceiveDataSize.ToString());
+                LogicHandler.UpdateDeviceData(item.Decode, item.ItemData);
             }
+            //while (QueueUpdateDevice.Count > 0)
+            //{
+            //    Entity.Device item = QueueUpdateDevice.Dequeue();
+            //    SQL.Clear();
+            //    //更新轮询日志状态
+            //    LogicHandler.DoDevicePollingLog(item.Decode, item.SendDataSize.ToString(), item.ReceiveDataSize.ToString());
+            //}
         }
         #endregion
 
@@ -405,13 +427,13 @@ namespace UAS_PLCDataReader
                     sql.Append("insert into DEVICEPOLLINGLOG(dpg_id,dpg_decode,dpg_starttime,dpg_interval)values");
                     sql.Append("(DEVICEPOLLINGLOG_seq.nextval,'" + pl.DeviceCode + "',sysdate,'" + pl.Interval + "')");
                     dh.ExecuteSql(sql.ToString(), "insert");
-                    LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, "noanswer");
+                    LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, DeviceStatus.Noanswer);
                     pt.AddTask(RunTask, pl);
                     //添加到状态为运行的行
                     PollSettingPaintRowIndex.Add(i);
                     GridPollingSetting.Focus();
                 }
-                else LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, "stopped");
+                else LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, DeviceStatus.Stopped);
             }
             ButtonSaveCommandSet.DoSaveAfterHandler(false);
         }
@@ -487,9 +509,16 @@ namespace UAS_PLCDataReader
                 }
                 else
                 {
-                    ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), DNC.Rows[0]["dnc_port"].ToString(), pl.DeviceCode, pl.DeviceName);
-                    modclient.Dh = dh;
-                    client.Add(DpcID, modclient);
+                    try
+                    {
+                        ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), DNC.Rows[0]["dnc_port"].ToString(), pl.DeviceCode, pl.DeviceName);
+                        modclient.Dh = dh;
+                        client.Add(DpcID, modclient);
+                    }
+                    catch (Exception)
+                    {
+                        LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, DeviceStatus.Disconnect);
+                    }
                 }
                 //如果不包含该项数据则在键值对中添加
                 if (!ReturnData.ContainsKey(Decode))
@@ -557,12 +586,11 @@ namespace UAS_PLCDataReader
                         }
                         //每次更新轮询的数据
                         ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
-                        //检测键值对是否发生变化,发生变化时赋予新值
+                        //检测键值对是否发生变化,发生变化时赋予新值并上传信息
                         if (BaseUtil.CheckDicDiff(ReturnData[Decode].ItemData, ItemData))
                         {
                             ReturnData[Decode].ItemData = ItemData;
                             LogicHandler.UpdateDeviceData(dh, Decode, ItemData);
-                            QueueUpdateDevice.Enqueue(ReturnData[Decode]);
                             LogicHandler.DoDeviceDataDiffLog(dh, pl.DeviceCode, pl.DeviceName, Command, pl.CommandCode, User.UserName);
                         }
                     }
@@ -874,5 +902,25 @@ namespace UAS_PLCDataReader
             GridDeviceRunLog.RefreshData();
         }
         #endregion
+
+        #region 客户端参数设置
+        private void ButtonSaveClientParam_Click(object sender, EventArgs e)
+        {
+            BaseUtil.SetCacheData("UpdateTime", UpdateTimeSpan.Value);
+            XtraMessageBox.Show("保存成功!");
+        }
+
+        private void PageClientParam_VisibleChanged(object sender, EventArgs e)
+        {
+            if (PageClientParam.PageVisible)
+            {
+                decimal time = 0;
+                if (decimal.TryParse(BaseUtil.GetCacheData("UpdateTime").ToString(), out time))
+                {
+                    UpdateTimeSpan.Value = time;
+                }
+            }
+        }
+        #endregion
     }
 }

+ 64 - 0
PLCDataReader/Main.resx

@@ -468,6 +468,70 @@
         MbrStgIBcdV77/Y96DMvlT3LotILiOAXkfQykuCmS2tytYePCSyCRRovUr0QZRM44BNa8kgRXQUFWUlU
         0IQK+NMk/6hy+EcSEeXwi1DBlwknwsrgE16G81QZ79C7EiGl8ApmlPCi8TmqgiAlPJnAEoGb3812yhZv
         Q/7XnP804u8k70qGzd6FP70Dfyb4dyh83/5/A3K8qVtfPX9uAAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="ButtonClientParam.Glyph" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAPdEVYdFRpdGxlAERvdWdobnV0Oxm8p88AAAMuSURB
+        VDhPZZPdT1NnHMfPn7G7Xex+8WaZLmO72STLNiNmDreRVRCnKXOl0GYTlFJomkmGdQWCMAFpHRnhrYlC
+        qaBCpaCCL0NnfJlUZNI3QPr+QstnzzlMbnbxOU/OL+f55Pt7nt+Rmi/cvSKgyS5zR8Fqe81tfu3e4sx5
+        mTksXXOc7pxVaOy4dUUyt06zCVuIx/b6Pzb/A3IKmxit15FMLR6lmExlSaQ2iMdTBK+O4j1dxyP1V/z1
+        3X6emn9iecRBNJokltxQyAmL4Ywbqb55ShHExeZIMIT3VBWLxnLW/mgnfnmA+Gg/K/YWHmlVPKgsJeBf
+        JZrIkBWCGssEkhxDjhONJVkw6fFZ60lODpNw9hKzNxNtbxCcItpt5aJtAM25G7yKpshmc1Q3XkOqsbiV
+        OD7XJZ5VHSUxNkSkp1VE/xL37p1M5r/Lg8NfMDNzn7OeFQ41T9M/tUBGCI43XEU62TihxHlcq2Olu4no
+        QBfzJfuYLVMR+vMeK4Iuk5VK+z2sk35ODj5B3TTBhhD8+PM4UtUv18TLJnOFHxPu62S1qY7xD3cQ9vmV
+        cwnHMiwGYhSYx+iYCWIaXuR9Ta8i0IuaJFvkOJ7P81i90ILfrGcs723WXy6LXtOsiX7/Xg6z13SZ7ptB
+        Tjie8Z76d0WgrXMh6YQlvZHjxpEiXjRUs1yrEWnyuVt5hOCLlwT9AdxnLZR33aJtysfh325TaBgiI/Zo
+        ap1bglQmx8PzHbg/+4Alg4bn+lLmD+5l+pOdzJpVeHuNzHg81A972VXWQ5vjDulMdktQYXKRTGcJhaKM
+        79vNzQOfsqAtZqGimCVjBTy1weNOuG+hr17HnmPtorWkMnTHDCNIWuOoclih9ST/PHmOa89HuPJ2KG08
+        LN1PwqXGe66QQdU72Iry8S0tEYmniYjDLTtxCUljcCqjGXiVJLCWwB8MM9/eiutAAT1vvUHjrjexHypg
+        ytbGejgubiWNX3y3LlZ1tRB8XzMiRlOMcTyzTVgQE7WE+D/k9mTklPIIy1Oo3E4kxdHjF5FK9A5nic5B
+        sW6IgwJV5SCqikG+1Q4oFJX3b/ON5jV9fP2DTJ/zX8w8J3DZ3B3NAAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="ButtonClientParam.LargeGlyph" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        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
 </value>
   </data>
   <metadata name="TimerDeviceStatus.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

+ 17 - 1
PLCDataReader/PublicMethod/BaseUtil.cs

@@ -175,7 +175,8 @@ namespace UAS_PLCDataReader.PublicMethod
         {
             foreach (var item in B)
             {
-                if (A.ContainsKey(item.Key))
+                //不对比产量和产出
+                if (A.ContainsKey(item.Key) && item.Key != "INQTY" && item.Key != "OUTQTY")
                 {
                     if (A[item.Key] != item.Value)
                     {
@@ -467,6 +468,9 @@ namespace UAS_PLCDataReader.PublicMethod
                             case "System.Boolean":
                                 o = node.InnerText == "True" ? true : false;
                                 break;
+                            case "System.Decimal":
+                                o = decimal.Parse(node.InnerText);
+                                break;
                             default:
                                 break;
                         }
@@ -486,5 +490,17 @@ namespace UAS_PLCDataReader.PublicMethod
                 return "";
             }
         }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="Minutes"></param>
+        /// <returns></returns>
+        public static string MinutesToDayTime(int Minutes)
+        {
+            int Day = Minutes / 1440;
+            int Hour = Minutes % 1440 / 60;
+            int Mins = Minutes % 60;
+            return Day + "天" + Hour + "小时" + Mins + "分钟";
+        }
     }
 }

+ 84 - 3
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -49,6 +49,42 @@ namespace UAS_PLCDataReader.PublicMethod
             dh.ExecuteSql(sql.ToString(), "insert");
         }
 
+        /// <summary>
+        /// 进行差异日志记录
+        /// </summary>
+        public static void DoDeviceDataDiffLog(string iDeCode, string iDeName, string iCommand, string iCommandFrom, string iMan)
+        {
+            sql.Clear();
+            sql.Append("insert into DeviceRunRecord(drr_id,drr_decode,drr_dename,drr_command,drr_commandfrom,drr_date,drr_doman,drr_remark)");
+            sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "','" + iCommandFrom + "',sysdate,'" + iMan + "','')");
+            dh.ExecuteSql(sql.ToString(), "insert");
+        }
+
+        /// <summary>
+        /// 记录轮询日志,记录时间
+        /// </summary>
+        /// <param name="iDeCode">设备编号</param>
+        /// <param name="iSendDataSize">发送数据大小</param>
+        /// <param name="iReceiveDataSize">接收数据大小</param>
+        /// <param name="iOnLine">上线或者离线</param>
+        public static void DoDevicePollingLog(string iDeCode, bool iOnLine)
+        {
+            sql.Clear();
+            sql.Append("update DEVICEPOLLINGLOG set ");
+            if (iOnLine)
+            {
+                sql.Append("dpg_onlinetime = sysdate,dpg_status='running' where dpg_id=(select max(dpg_id)");
+                sql.Append(" from DEVICEPOLLINGLOG where dpg_decode='" + iDeCode + "') and nvl(dpg_status,'disconnected')='disconnected'");
+            }
+            else
+            {
+                sql.Append("dpg_offlinetime = sysdate,dpg_status='disconnected' where dpg_id=(select max(dpg_id)");
+                sql.Append(" from DEVICEPOLLINGLOG where dpg_decode='" + iDeCode + "') and dpg_status='running'");
+            }
+
+            dh.ExecuteSql(sql.ToString(), "insert");
+        }
+
         /// <summary>
         /// 记录轮询日志,记录时间
         /// </summary>
@@ -59,15 +95,15 @@ namespace UAS_PLCDataReader.PublicMethod
         public static void DoDevicePollingLog(string iDeCode, string iSendDataSize, string iReceiveDataSize, bool iOnLine)
         {
             sql.Clear();
-            sql.Append("update DEVICEPOLLINGLOG set dpg_status='running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
+            sql.Append("update DEVICEPOLLINGLOG set dpg_senddatasize=nvl(dpg_senddatasize,0)+" + iSendDataSize);
             sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + iReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
             if (iOnLine)
             {
-                sql.Append(",dpg_onlinetime = sysdate");
+                sql.Append(",dpg_onlinetime = sysdate,dpg_status='running'");
             }
             else
             {
-                sql.Append(",dpg_offlinetime = sysdate");
+                sql.Append(",dpg_offlinetime = sysdate,dpg_status='disconnected'");
             }
             sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + iDeCode + "')");
             dh.ExecuteSql(sql.ToString(), "insert");
@@ -133,6 +169,51 @@ namespace UAS_PLCDataReader.PublicMethod
             dh.ExecuteSql(sql.ToString(), "update", INQTY, OUTQTY, TEMPERATURE, PARAM1, PARAM2, PARAM3);
         }
 
+        /// <summary>
+        /// 更新设备数据投入,产出等数据
+        /// </summary>
+        /// <param name="Decode"></param>
+        /// <param name="ItemData"></param>
+        public static void UpdateDeviceData(string Decode, Dictionary<string, string> ItemData)
+        {
+            string INQTY = "";
+            string OUTQTY = "";
+            string TEMPERATURE = "";
+            string PARAM1 = "";
+            string PARAM2 = "";
+            string PARAM3 = "";
+            foreach (var item in ItemData)
+            {
+                switch (item.Key)
+                {
+                    case "INQTY":
+                        INQTY = item.Value;
+                        break;
+                    case "OUTQTY":
+                        OUTQTY = item.Value;
+                        break;
+                    case "TEMPERATURE":
+                        TEMPERATURE = item.Value;
+                        break;
+                    case "PARAM1":
+                        PARAM1 = item.Value;
+                        break;
+                    case "PARAM2":
+                        PARAM2 = item.Value;
+                        break;
+                    case "PARAM3":
+                        PARAM3 = item.Value;
+                        break;
+                    default:
+                        break;
+                }
+            }
+            sql.Clear();
+            sql.Append("update DeviceRunstatus set dr_qty=:dr_inqty,dr_okqty=:dr_okqty,dr_TEMPERATURE=:dr_TEMPERATURE,");
+            sql.Append("dr_value1=:dr_value1,dr_value2=:dr_value2,dr_value3=:dr_value3,dr_updatedate=sysdate where dr_decode='" + Decode + "'");
+            dh.ExecuteSql(sql.ToString(), "update", INQTY, OUTQTY, TEMPERATURE, PARAM1, PARAM2, PARAM3);
+        }
+
         /// <summary>
         /// 更新设备运行状态
         /// </summary>

+ 9 - 6
PLCDataReader/PublicMethod/ModBusTCPClient.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Net;
 using System.Net.Sockets;
 using UAS_PLCDataReader.DataOperate;
+using UAS_PLCDataReader.Entity;
 
 namespace UAS_PLCDataReader.PublicMethod
 {
@@ -115,9 +116,10 @@ namespace UAS_PLCDataReader.PublicMethod
                 serverFullAddr = new IPEndPoint(IPAddress.Parse(IP), int.Parse(Port));//设置IP,端口
                 socket.Connect(serverFullAddr);
             }
-            catch (Exception e)
+            catch (Exception)
             {
-                LogicHandler.UpdateDeviceStatus(Dh,decode, dename, "disconnect");
+                LogicHandler.UpdateDeviceStatus(Dh, decode, dename, DeviceStatus.Disconnect);
+                LogicHandler.DoDevicePollingLog(decode, false);
             }
         }
 
@@ -140,18 +142,19 @@ namespace UAS_PLCDataReader.PublicMethod
                 socket.Send(arr);
 
                 byte[] receive = new byte[1024 * 1024];
-                LogicHandler.UpdateDeviceStatus(Dh,decode, dename, "noanswer");
+                LogicHandler.UpdateDeviceStatus(Dh, decode, dename, DeviceStatus.Noanswer);
+                LogicHandler.DoDevicePollingLog(decode, true);
                 int length = socket.Receive(receive);
-                LogicHandler.UpdateDeviceStatus(Dh,decode, dename, "running");
+                LogicHandler.UpdateDeviceStatus(Dh, decode, dename, DeviceStatus.Running);
                 if (!returnvalue.ContainsKey(socket.RemoteEndPoint.ToString()))
                 {
                     returnvalue.Add(socket.RemoteEndPoint.ToString(), BaseUtil.ByteToHexadecimalString(receive, length));
                 }
-
             }
             catch (Exception)
             {
-                LogicHandler.UpdateDeviceStatus(Dh,decode, dename, "disconnect");
+                LogicHandler.UpdateDeviceStatus(Dh, decode, dename, DeviceStatus.Disconnect);
+                LogicHandler.DoDevicePollingLog(decode, false);
             }
         }
     }

+ 1 - 0
PLCDataReader/UAS_PLCDataReader.csproj

@@ -248,6 +248,7 @@
       <DependentUpon>DeviceStatusInfo.cs</DependentUpon>
     </Compile>
     <Compile Include="Entity\Device.cs" />
+    <Compile Include="Entity\DeviceStatus.cs" />
     <Compile Include="Entity\Polling.cs" />
     <Compile Include="Entity\SocketObject.cs" />
     <Compile Include="Entity\SystemInf.cs" />