Browse Source

添加缓存数据

章政 6 years ago
parent
commit
b45f8eb9d8

+ 5 - 3
PLCDataReader/CustomerControl/Button/ButtonSaveGrid.cs

@@ -68,17 +68,19 @@ namespace UAS_PLCDataReader.CustomerControl.Button
         /// <summary>
         /// 外部调用,不重新刷新数据
         /// </summary>
-        public void DoSaveAfterHandler()
+        public void DoSaveAfterHandler(bool MessageBoxAlert)
         {
             DataTable dt = ((DataTable)grid.DataSource).GetChanges();
             if (dt != null && dt.Rows.Count > 0)
             {
                 SystemInf.dh.SaveDataTable(dt, grid.TableName, grid.ID, out LastSaveID, grid.InsertSQL);
-                XtraMessageBox.Show("保存成功", "提示");
+                if (MessageBoxAlert)
+                    XtraMessageBox.Show("保存成功", "提示");
             }
             else
             {
-                XtraMessageBox.Show("没有修改过的数据", "提示");
+                if (MessageBoxAlert)
+                    XtraMessageBox.Show("没有修改过的数据", "提示");
             }
         }
 

+ 113 - 50
PLCDataReader/Device/Information/DeviceStatusInfo.Designer.cs

@@ -31,6 +31,9 @@ namespace UAS_PLCDataReader.Device.Infomation
         private void InitializeComponent()
         {
             this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
+            this.sc_name = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.de_sourcecode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
+            this.labelControl15 = new DevExpress.XtraEditors.LabelControl();
             this.de_linecode = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.de_address = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
@@ -49,19 +52,21 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl7 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl11 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl12 = new DevExpress.XtraEditors.LabelControl();
-            this.labelControl10 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl9 = new DevExpress.XtraEditors.LabelControl();
             this.labelControl14 = new DevExpress.XtraEditors.LabelControl();
             this.groupControl3 = new DevExpress.XtraEditors.GroupControl();
             this.dpg_runtime = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_count = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_receivedatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
-            this.dpg_senddatasize = new UAS_PLCDataReader.CustomerControl.ValueLabel.ValueLabel();
             this.dpg_starttime = 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.data = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.GridDeviceRunLog = new DevExpress.XtraGrid.GridControl();
+            this.GridViewDeviceRunLog = new DevExpress.XtraGrid.Views.Grid.GridView();
+            this.drr_commandfrom = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.drr_command = new DevExpress.XtraGrid.Columns.GridColumn();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
             this.groupControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.groupControl2)).BeginInit();
@@ -70,10 +75,15 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl3.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridDeivceStatusInfo)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceStatusInfo)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceRunLog)).BeginInit();
             this.SuspendLayout();
             // 
             // groupControl1
             // 
+            this.groupControl1.Controls.Add(this.sc_name);
+            this.groupControl1.Controls.Add(this.de_sourcecode);
+            this.groupControl1.Controls.Add(this.labelControl15);
             this.groupControl1.Controls.Add(this.de_linecode);
             this.groupControl1.Controls.Add(this.de_address);
             this.groupControl1.Controls.Add(this.labelControl4);
@@ -82,16 +92,45 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl1.Controls.Add(this.de_name);
             this.groupControl1.Controls.Add(this.labelControl2);
             this.groupControl1.Controls.Add(this.labelControl1);
-            this.groupControl1.Location = new System.Drawing.Point(12, 12);
+            this.groupControl1.Location = new System.Drawing.Point(12, 7);
             this.groupControl1.Name = "groupControl1";
-            this.groupControl1.Size = new System.Drawing.Size(187, 175);
+            this.groupControl1.Size = new System.Drawing.Size(248, 213);
             this.groupControl1.TabIndex = 0;
             this.groupControl1.Text = "设备信息";
             // 
+            // sc_name
+            // 
+            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.MaximumSize = new System.Drawing.Size(140, 0);
+            this.sc_name.Name = "sc_name";
+            this.sc_name.Size = new System.Drawing.Size(0, 16);
+            this.sc_name.TabIndex = 22;
+            // 
+            // de_sourcecode
+            // 
+            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.MaximumSize = new System.Drawing.Size(140, 0);
+            this.de_sourcecode.Name = "de_sourcecode";
+            this.de_sourcecode.Size = new System.Drawing.Size(0, 16);
+            this.de_sourcecode.TabIndex = 21;
+            // 
+            // labelControl15
+            // 
+            this.labelControl15.Appearance.Font = new System.Drawing.Font("黑体", 12F);
+            this.labelControl15.Location = new System.Drawing.Point(13, 165);
+            this.labelControl15.Name = "labelControl15";
+            this.labelControl15.Size = new System.Drawing.Size(64, 16);
+            this.labelControl15.TabIndex = 20;
+            this.labelControl15.Text = "岗位资源";
+            // 
             // de_linecode
             // 
             this.de_linecode.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.de_linecode.Location = new System.Drawing.Point(70, 137);
+            this.de_linecode.Location = new System.Drawing.Point(70, 131);
             this.de_linecode.Name = "de_linecode";
             this.de_linecode.Size = new System.Drawing.Size(0, 16);
             this.de_linecode.TabIndex = 19;
@@ -99,7 +138,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, 106);
+            this.de_address.Location = new System.Drawing.Point(70, 100);
             this.de_address.Name = "de_address";
             this.de_address.Size = new System.Drawing.Size(0, 16);
             this.de_address.TabIndex = 18;
@@ -107,7 +146,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl4
             // 
             this.labelControl4.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl4.Location = new System.Drawing.Point(13, 137);
+            this.labelControl4.Location = new System.Drawing.Point(13, 131);
             this.labelControl4.Name = "labelControl4";
             this.labelControl4.Size = new System.Drawing.Size(32, 16);
             this.labelControl4.TabIndex = 6;
@@ -116,7 +155,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, 74);
+            this.de_wccode.Location = new System.Drawing.Point(70, 68);
             this.de_wccode.Name = "de_wccode";
             this.de_wccode.Size = new System.Drawing.Size(0, 16);
             this.de_wccode.TabIndex = 17;
@@ -124,7 +163,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl3
             // 
             this.labelControl3.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl3.Location = new System.Drawing.Point(13, 106);
+            this.labelControl3.Location = new System.Drawing.Point(13, 100);
             this.labelControl3.Name = "labelControl3";
             this.labelControl3.Size = new System.Drawing.Size(32, 16);
             this.labelControl3.TabIndex = 5;
@@ -133,7 +172,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, 41);
+            this.de_name.Location = new System.Drawing.Point(70, 35);
             this.de_name.Name = "de_name";
             this.de_name.Size = new System.Drawing.Size(0, 16);
             this.de_name.TabIndex = 16;
@@ -141,7 +180,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl2
             // 
             this.labelControl2.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl2.Location = new System.Drawing.Point(13, 74);
+            this.labelControl2.Location = new System.Drawing.Point(13, 68);
             this.labelControl2.Name = "labelControl2";
             this.labelControl2.Size = new System.Drawing.Size(32, 16);
             this.labelControl2.TabIndex = 4;
@@ -150,7 +189,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // labelControl1
             // 
             this.labelControl1.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl1.Location = new System.Drawing.Point(13, 41);
+            this.labelControl1.Location = new System.Drawing.Point(13, 35);
             this.labelControl1.Name = "labelControl1";
             this.labelControl1.Size = new System.Drawing.Size(32, 16);
             this.labelControl1.TabIndex = 0;
@@ -165,9 +204,9 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl2.Controls.Add(this.labelControl6);
             this.groupControl2.Controls.Add(this.labelControl8);
             this.groupControl2.Controls.Add(this.labelControl7);
-            this.groupControl2.Location = new System.Drawing.Point(12, 202);
+            this.groupControl2.Location = new System.Drawing.Point(12, 226);
             this.groupControl2.Name = "groupControl2";
-            this.groupControl2.Size = new System.Drawing.Size(187, 182);
+            this.groupControl2.Size = new System.Drawing.Size(248, 182);
             this.groupControl2.TabIndex = 1;
             this.groupControl2.Text = "生产信息";
             // 
@@ -239,66 +278,55 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.labelControl11.Name = "labelControl11";
             this.labelControl11.Size = new System.Drawing.Size(64, 16);
             this.labelControl11.TabIndex = 11;
-            this.labelControl11.Text = "开时间";
+            this.labelControl11.Text = "开时间";
             // 
             // labelControl12
             // 
             this.labelControl12.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl12.Location = new System.Drawing.Point(21, 74);
+            this.labelControl12.Location = new System.Drawing.Point(21, 72);
             this.labelControl12.Name = "labelControl12";
             this.labelControl12.Size = new System.Drawing.Size(64, 16);
             this.labelControl12.TabIndex = 12;
-            this.labelControl12.Text = "持续时长";
-            // 
-            // labelControl10
-            // 
-            this.labelControl10.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl10.Location = new System.Drawing.Point(21, 106);
-            this.labelControl10.Name = "labelControl10";
-            this.labelControl10.Size = new System.Drawing.Size(64, 16);
-            this.labelControl10.TabIndex = 13;
-            this.labelControl10.Text = "发送字节";
+            this.labelControl12.Text = "当前运行";
             // 
             // labelControl9
             // 
             this.labelControl9.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl9.Location = new System.Drawing.Point(21, 139);
+            this.labelControl9.Location = new System.Drawing.Point(21, 132);
             this.labelControl9.Name = "labelControl9";
             this.labelControl9.Size = new System.Drawing.Size(64, 16);
             this.labelControl9.TabIndex = 14;
-            this.labelControl9.Text = "接收字节";
+            this.labelControl9.Text = "最近轮询";
             // 
             // labelControl14
             // 
             this.labelControl14.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.labelControl14.Location = new System.Drawing.Point(21, 172);
+            this.labelControl14.Location = new System.Drawing.Point(21, 102);
             this.labelControl14.Name = "labelControl14";
             this.labelControl14.Size = new System.Drawing.Size(64, 16);
             this.labelControl14.TabIndex = 15;
-            this.labelControl14.Text = "轮询次数";
+            this.labelControl14.Text = "轮询信息";
             // 
             // groupControl3
             // 
             this.groupControl3.Controls.Add(this.dpg_runtime);
             this.groupControl3.Controls.Add(this.dpg_count);
             this.groupControl3.Controls.Add(this.dpg_receivedatasize);
-            this.groupControl3.Controls.Add(this.dpg_senddatasize);
             this.groupControl3.Controls.Add(this.labelControl14);
             this.groupControl3.Controls.Add(this.dpg_starttime);
             this.groupControl3.Controls.Add(this.labelControl9);
-            this.groupControl3.Controls.Add(this.labelControl10);
             this.groupControl3.Controls.Add(this.labelControl12);
             this.groupControl3.Controls.Add(this.labelControl11);
-            this.groupControl3.Location = new System.Drawing.Point(216, 12);
+            this.groupControl3.Location = new System.Drawing.Point(266, 7);
             this.groupControl3.Name = "groupControl3";
-            this.groupControl3.Size = new System.Drawing.Size(328, 372);
+            this.groupControl3.Size = new System.Drawing.Size(328, 213);
             this.groupControl3.TabIndex = 2;
             this.groupControl3.Text = "运行信息";
             // 
             // dpg_runtime
             // 
             this.dpg_runtime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_runtime.Location = new System.Drawing.Point(101, 74);
+            this.dpg_runtime.Location = new System.Drawing.Point(101, 72);
             this.dpg_runtime.Name = "dpg_runtime";
             this.dpg_runtime.Size = new System.Drawing.Size(0, 16);
             this.dpg_runtime.TabIndex = 16;
@@ -306,7 +334,7 @@ namespace UAS_PLCDataReader.Device.Infomation
             // dpg_count
             // 
             this.dpg_count.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_count.Location = new System.Drawing.Point(101, 172);
+            this.dpg_count.Location = new System.Drawing.Point(101, 102);
             this.dpg_count.Name = "dpg_count";
             this.dpg_count.Size = new System.Drawing.Size(0, 16);
             this.dpg_count.TabIndex = 3;
@@ -314,19 +342,11 @@ namespace UAS_PLCDataReader.Device.Infomation
             // dpg_receivedatasize
             // 
             this.dpg_receivedatasize.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_receivedatasize.Location = new System.Drawing.Point(101, 139);
+            this.dpg_receivedatasize.Location = new System.Drawing.Point(101, 132);
             this.dpg_receivedatasize.Name = "dpg_receivedatasize";
             this.dpg_receivedatasize.Size = new System.Drawing.Size(0, 16);
             this.dpg_receivedatasize.TabIndex = 2;
             // 
-            // dpg_senddatasize
-            // 
-            this.dpg_senddatasize.Appearance.Font = new System.Drawing.Font("黑体", 12F);
-            this.dpg_senddatasize.Location = new System.Drawing.Point(101, 106);
-            this.dpg_senddatasize.Name = "dpg_senddatasize";
-            this.dpg_senddatasize.Size = new System.Drawing.Size(0, 16);
-            this.dpg_senddatasize.TabIndex = 1;
-            // 
             // dpg_starttime
             // 
             this.dpg_starttime.Appearance.Font = new System.Drawing.Font("黑体", 12F);
@@ -337,10 +357,10 @@ namespace UAS_PLCDataReader.Device.Infomation
             // 
             // GridDeivceStatusInfo
             // 
-            this.GridDeivceStatusInfo.Location = new System.Drawing.Point(550, 12);
+            this.GridDeivceStatusInfo.Location = new System.Drawing.Point(600, 7);
             this.GridDeivceStatusInfo.MainView = this.GridViewDeviceStatusInfo;
             this.GridDeivceStatusInfo.Name = "GridDeivceStatusInfo";
-            this.GridDeivceStatusInfo.Size = new System.Drawing.Size(207, 372);
+            this.GridDeivceStatusInfo.Size = new System.Drawing.Size(207, 213);
             this.GridDeivceStatusInfo.TabIndex = 3;
             this.GridDeivceStatusInfo.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
             this.GridViewDeviceStatusInfo});
@@ -370,11 +390,47 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.data.Visible = true;
             this.data.VisibleIndex = 1;
             // 
+            // GridDeviceRunLog
+            // 
+            this.GridDeviceRunLog.Location = new System.Drawing.Point(266, 226);
+            this.GridDeviceRunLog.MainView = this.GridViewDeviceRunLog;
+            this.GridDeviceRunLog.Name = "GridDeviceRunLog";
+            this.GridDeviceRunLog.Size = new System.Drawing.Size(541, 182);
+            this.GridDeviceRunLog.TabIndex = 4;
+            this.GridDeviceRunLog.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] {
+            this.GridViewDeviceRunLog});
+            // 
+            // GridViewDeviceRunLog
+            // 
+            this.GridViewDeviceRunLog.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
+            this.drr_commandfrom,
+            this.drr_command});
+            this.GridViewDeviceRunLog.GridControl = this.GridDeviceRunLog;
+            this.GridViewDeviceRunLog.Name = "GridViewDeviceRunLog";
+            this.GridViewDeviceRunLog.OptionsView.ShowGroupPanel = false;
+            // 
+            // drr_commandfrom
+            // 
+            this.drr_commandfrom.Caption = "指令编号";
+            this.drr_commandfrom.FieldName = "DRR_COMMANDFROM";
+            this.drr_commandfrom.Name = "drr_commandfrom";
+            this.drr_commandfrom.Visible = true;
+            this.drr_commandfrom.VisibleIndex = 1;
+            // 
+            // drr_command
+            // 
+            this.drr_command.Caption = "指令内容";
+            this.drr_command.FieldName = "DRR_COMMAND";
+            this.drr_command.Name = "drr_command";
+            this.drr_command.Visible = true;
+            this.drr_command.VisibleIndex = 0;
+            // 
             // DeviceStatusInfo
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(769, 396);
+            this.ClientSize = new System.Drawing.Size(811, 413);
+            this.Controls.Add(this.GridDeviceRunLog);
             this.Controls.Add(this.GridDeivceStatusInfo);
             this.Controls.Add(this.groupControl3);
             this.Controls.Add(this.groupControl2);
@@ -398,6 +454,8 @@ namespace UAS_PLCDataReader.Device.Infomation
             this.groupControl3.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridDeivceStatusInfo)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceStatusInfo)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridDeviceRunLog)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceRunLog)).EndInit();
             this.ResumeLayout(false);
 
         }
@@ -416,11 +474,9 @@ namespace UAS_PLCDataReader.Device.Infomation
         private DevExpress.XtraEditors.LabelControl labelControl7;
         private DevExpress.XtraEditors.LabelControl labelControl11;
         private DevExpress.XtraEditors.LabelControl labelControl12;
-        private DevExpress.XtraEditors.LabelControl labelControl10;
         private DevExpress.XtraEditors.LabelControl labelControl9;
         private ValueLabel dpg_starttime;
         private DevExpress.XtraEditors.LabelControl labelControl14;
-        private ValueLabel dpg_senddatasize;
         private ValueLabel dpg_receivedatasize;
         private ValueLabel dpg_count;
         private DevExpress.XtraEditors.GroupControl groupControl3;
@@ -436,5 +492,12 @@ namespace UAS_PLCDataReader.Device.Infomation
         private DevExpress.XtraGrid.Views.Grid.GridView GridViewDeviceStatusInfo;
         private DevExpress.XtraGrid.Columns.GridColumn dc_name;
         private DevExpress.XtraGrid.Columns.GridColumn data;
+        private ValueLabel de_sourcecode;
+        private DevExpress.XtraEditors.LabelControl labelControl15;
+        private ValueLabel sc_name;
+        private DevExpress.XtraGrid.GridControl GridDeviceRunLog;
+        private DevExpress.XtraGrid.Views.Grid.GridView GridViewDeviceRunLog;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_command;
+        private DevExpress.XtraGrid.Columns.GridColumn drr_commandfrom;
     }
 }

+ 5 - 3
PLCDataReader/Device/Information/DeviceStatusInfo.cs

@@ -33,8 +33,8 @@ namespace UAS_PLCDataReader.Device.Infomation
         private void DeviceStatusInfo_Load(object sender, EventArgs e)
         {
             sql.Clear();
-            sql.Append("select de_linecode,de_wccode,de_name,de_address from device ");
-            sql.Append("where de_code='" + de_code + "'");
+            sql.Append("select de_linecode,de_wccode,de_name,de_address,de_sourcecode,sc_name from device ");
+            sql.Append("left join source on sc_code=de_sourcecode where de_code='" + de_code + "'");
             DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             if (dt.Rows.Count > 0)
             {
@@ -45,13 +45,15 @@ namespace UAS_PLCDataReader.Device.Infomation
             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");
+            sql.Clear();
+            sql.Append("select * from DEVICERUNRECORD");
+            GridDeviceRunLog.DataSource = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             if (Main.ReturnData.ContainsKey(de_code))
             {
                 dpg_count.Text = Main.ReturnData[de_code].SendCount.ToString();
                 string totalMinutes = (DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes.ToString();
                 dpg_runtime.Text = (DateTime.Now - Main.ReturnData[de_code].StartTime).TotalMinutes.ToString("f1") + "分钟";
                 dpg_starttime.Text = Main.ReturnData[de_code].StartTime.ToString("yyyy-MM-dd HH:mm:ss");
-                dpg_senddatasize.Text = Main.ReturnData[de_code].SendDataSize.ToString();
                 dpg_receivedatasize.Text = Main.ReturnData[de_code].ReceiveDataSize.ToString();
                 Dictionary<string, string> ItemData = Main.ReturnData[de_code].ItemData;
                 if (ItemData != null && ItemData.Count > 0)

+ 9 - 20
PLCDataReader/Main.Designer.cs

@@ -33,7 +33,6 @@ 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();
@@ -188,9 +187,9 @@ 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.components);
-            this.CommonTipController = new DevExpress.Utils.ToolTipController(this.components);
-            this.TimerUpdateDevice = new System.Windows.Forms.Timer(this.components);
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer();
+            this.CommonTipController = new DevExpress.Utils.ToolTipController();
+            this.TimerUpdateDevice = new System.Windows.Forms.Timer();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -950,8 +949,6 @@ namespace UAS_PLCDataReader
             this.dc_sendcoding.ColumnEdit = this.CommandSetRepositoryItemComboBox1;
             this.dc_sendcoding.FieldName = "DC_SENDCODING";
             this.dc_sendcoding.Name = "dc_sendcoding";
-            this.dc_sendcoding.Visible = true;
-            this.dc_sendcoding.VisibleIndex = 6;
             this.dc_sendcoding.Width = 114;
             // 
             // CommandSetRepositoryItemComboBox1
@@ -967,8 +964,6 @@ namespace UAS_PLCDataReader
             this.dc_receivecoding.ColumnEdit = this.CommandSetRepositoryItemComboBox1;
             this.dc_receivecoding.FieldName = "DC_RECEIVECODING";
             this.dc_receivecoding.Name = "dc_receivecoding";
-            this.dc_receivecoding.Visible = true;
-            this.dc_receivecoding.VisibleIndex = 7;
             this.dc_receivecoding.Width = 115;
             // 
             // dc_man
@@ -978,7 +973,7 @@ namespace UAS_PLCDataReader
             this.dc_man.Name = "dc_man";
             this.dc_man.OptionsColumn.AllowEdit = false;
             this.dc_man.Visible = true;
-            this.dc_man.VisibleIndex = 9;
+            this.dc_man.VisibleIndex = 7;
             this.dc_man.Width = 126;
             // 
             // dc_date
@@ -990,7 +985,7 @@ namespace UAS_PLCDataReader
             this.dc_date.Name = "dc_date";
             this.dc_date.OptionsColumn.AllowEdit = false;
             this.dc_date.Visible = true;
-            this.dc_date.VisibleIndex = 10;
+            this.dc_date.VisibleIndex = 8;
             this.dc_date.Width = 107;
             // 
             // repositoryItemDateEdit1
@@ -1008,7 +1003,7 @@ namespace UAS_PLCDataReader
             this.db_name.FieldName = "DB_NAME";
             this.db_name.Name = "db_name";
             this.db_name.Visible = true;
-            this.db_name.VisibleIndex = 8;
+            this.db_name.VisibleIndex = 6;
             this.db_name.Width = 47;
             // 
             // PageDeviceNetSetting
@@ -1122,16 +1117,12 @@ namespace UAS_PLCDataReader
             this.dnc_getway.Caption = "网关";
             this.dnc_getway.FieldName = "DNC_GATEWAY";
             this.dnc_getway.Name = "dnc_getway";
-            this.dnc_getway.Visible = true;
-            this.dnc_getway.VisibleIndex = 2;
             // 
             // dnc_upperip
             // 
             this.dnc_upperip.Caption = "上级IP";
             this.dnc_upperip.FieldName = "DNC_UPPERIP";
             this.dnc_upperip.Name = "dnc_upperip";
-            this.dnc_upperip.Visible = true;
-            this.dnc_upperip.VisibleIndex = 3;
             // 
             // dnc_port
             // 
@@ -1139,7 +1130,7 @@ namespace UAS_PLCDataReader
             this.dnc_port.FieldName = "DNC_PORT";
             this.dnc_port.Name = "dnc_port";
             this.dnc_port.Visible = true;
-            this.dnc_port.VisibleIndex = 4;
+            this.dnc_port.VisibleIndex = 2;
             // 
             // dnc_mac
             // 
@@ -1147,7 +1138,7 @@ namespace UAS_PLCDataReader
             this.dnc_mac.FieldName = "DNC_MAC";
             this.dnc_mac.Name = "dnc_mac";
             this.dnc_mac.Visible = true;
-            this.dnc_mac.VisibleIndex = 5;
+            this.dnc_mac.VisibleIndex = 3;
             // 
             // dnc_ip
             // 
@@ -1155,15 +1146,13 @@ namespace UAS_PLCDataReader
             this.dnc_ip.FieldName = "DNC_IP";
             this.dnc_ip.Name = "dnc_ip";
             this.dnc_ip.Visible = true;
-            this.dnc_ip.VisibleIndex = 6;
+            this.dnc_ip.VisibleIndex = 4;
             // 
             // dnc_type
             // 
             this.dnc_type.Caption = "类型";
             this.dnc_type.FieldName = "DNC_TYPE";
             this.dnc_type.Name = "dnc_type";
-            this.dnc_type.Visible = true;
-            this.dnc_type.VisibleIndex = 7;
             // 
             // PagePollingSetting
             // 

+ 5 - 3
PLCDataReader/Main.cs

@@ -206,7 +206,7 @@ namespace UAS_PLCDataReader
 
         private void ButtonSaveDevice_Click(object sender, EventArgs e)
         {
-            ButtonSaveDevice.DoSaveAfterHandler();
+            ButtonSaveDevice.DoSaveAfterHandler(true);
             sql.Clear();
             sql.Append("update device set de_inman='" + User.UserName + "' where de_id=:de_id");
             if (ButtonSaveDevice.LastSaveID != null && ButtonSaveDevice.LastSaveID.Length > 0)
@@ -351,7 +351,7 @@ namespace UAS_PLCDataReader
         private void ButtonSaveCommand_Click(object sender, EventArgs e)
         {
             GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date,dc_dataindex) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate,:dc_dataindex)";
-            ButtonSaveCommand.DoSaveAfterHandler();
+            ButtonSaveCommand.DoSaveAfterHandler(true);
             sql.Clear();
             sql.Append("update devicecommand set dc_man='" + User.UserName + "',dc_date=sysdate where dc_id=:dc_id");
             if (ButtonSaveCommand.LastSaveID != null && ButtonSaveCommand.LastSaveID.Length > 0)
@@ -421,6 +421,7 @@ namespace UAS_PLCDataReader
                 }
                 else LogicHandler.UpdateDeviceStatus(pl.Dh, pl.DeviceCode, pl.DeviceName, "stopped");
             }
+            ButtonSaveCommandSet.DoSaveAfterHandler(false);
         }
 
         /// <summary>
@@ -593,11 +594,12 @@ namespace UAS_PLCDataReader
             GridPollingSetting.Focus();
             client.Clear();
             Ptime.Clear();
+            ButtonSaveCommandSet.DoSaveAfterHandler(false);
         }
 
         private void ButtonSaveCommandSet_Click(object sender, EventArgs e)
         {
-            ButtonSaveCommandSet.DoSaveAfterHandler();
+            ButtonSaveCommandSet.DoSaveAfterHandler(true);
             sql.Clear();
             sql.Append("update DEVICEPOLLINGCONFIG set dpc_man='" + User.UserCode + "' where dpc_id=:dpc_id");
             if (ButtonSaveCommandSet.LastSaveID != null && ButtonSaveCommandSet.LastSaveID.Length > 0)

+ 1 - 1
PLCDataReader/Main.resx

@@ -477,7 +477,7 @@
     <value>164, 18</value>
   </metadata>
   <metadata name="TimerUpdateDevice.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>360, 12</value>
+    <value>350, 20</value>
   </metadata>
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 16 - 0
PLCDataReader/Program.cs

@@ -4,6 +4,7 @@ using System.Security.Principal;
 using System.Text;
 using System.Windows.Forms;
 using System.Xml;
+using UAS_PLCDataReader.Entity;
 using UAS_PLCDataReader.PublicMethod;
 
 namespace UAS_PLCDataReader
@@ -37,6 +38,21 @@ namespace UAS_PLCDataReader
                 FileStream fs = new FileStream(LogManager.LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                 fs.Close();
                 DevExpress.Skins.SkinManager.EnableFormSkins();
+                FileStream fcaches = new FileStream(SystemInf.CacheFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
+                fcaches.Close();
+                //判断是否xml文件大小为0
+                FileInfo info = new FileInfo(SystemInf.CacheFilePath);
+                if (info.Length == 0)
+                {
+                    XmlDocument doc = new XmlDocument();
+                    //创建类型声明节点  
+                    XmlNode node = doc.CreateXmlDeclaration("1.0", "utf-8", "");
+                    doc.AppendChild(node);
+                    //创建根节点  
+                    XmlElement xeRoot = doc.CreateElement("cacheInfo");
+                    doc.AppendChild(xeRoot);
+                    doc.Save(SystemInf.CacheFilePath);
+                }
                 if (principal.IsInRole(WindowsBuiltInRole.Administrator))
                     Application.Run(new Login());
                 else

+ 103 - 0
PLCDataReader/PublicMethod/BaseUtil.cs

@@ -9,6 +9,8 @@ using UAS_PLCDataReader.DataOperate;
 using DevExpress.Utils;
 using UAS_PLCDataReader.CustomerControl.ValueLabel;
 using System.Collections.Generic;
+using System.Xml;
+using UAS_PLCDataReader.Entity;
 
 namespace UAS_PLCDataReader.PublicMethod
 {
@@ -383,5 +385,106 @@ namespace UAS_PLCDataReader.PublicMethod
             }
             return ReturnData.ToArray();
         }
+
+        public static void SetCacheData(string ParamName, object Value)
+        {
+            try
+            {
+                //根据地址读取xml文件
+                XmlDocument doc = new XmlDocument();
+                XmlReaderSettings settings = new XmlReaderSettings { CheckCharacters = false };
+                //忽略文档里面的注释
+                settings.IgnoreComments = true;
+                XmlReader reader = XmlReader.Create(SystemInf.CacheFilePath, settings);
+                doc.Load(reader);
+                //先得到根节点
+                XmlNode rootNode = doc.SelectSingleNode("cacheInfo");
+                //再由根节点去找制定的节点
+                XmlNodeList nodeList = rootNode.ChildNodes;
+                bool flag = false;
+                foreach (XmlNode node in nodeList)
+                {
+                    //找到了这个节点名字
+                    if (node.Name == ParamName)
+                    {
+                        //就直接赋值
+                        node.InnerText = Value.ToString();
+                        flag = true;
+                    }
+                }
+                //如果没有该节点,就创建节点保存结果
+                if (!flag)
+                {
+                    //创建节点
+                    XmlElement newNode = doc.CreateElement(ParamName);
+                    XmlAttribute attr = doc.CreateAttribute("Type");
+                    attr.InnerText = Value.GetType().ToString();
+                    newNode.InnerText = Value.ToString();
+                    newNode.SetAttributeNode(attr);
+                    //讲新建的节点挂到根节点上
+                    rootNode.AppendChild(newNode);
+                }
+                //关闭Reader
+                reader.Close();
+                doc.Save(SystemInf.CacheFilePath);
+            }
+            catch (Exception e)
+            {
+                LogManager.DoLog(e.Message);
+            }
+        }
+
+        public static Object GetCacheData(string ParamName)
+        {
+            try
+            {
+                Object o = null;
+                //根据地址读取xml文件
+                XmlDocument doc = new XmlDocument();
+                XmlReaderSettings settings = new XmlReaderSettings { CheckCharacters = false };
+                //忽略文档里面的注释
+                settings.IgnoreComments = true;
+                XmlReader reader = XmlReader.Create(SystemInf.CacheFilePath, settings);
+                doc.Load(reader);
+                //先得到根节点
+                XmlNode rootNode = doc.SelectSingleNode("cacheInfo");
+                //再由根节点去找制定的节点
+                XmlNodeList nodeList = rootNode.ChildNodes;
+                foreach (XmlNode node in nodeList)
+                {
+                    //找到了这个节点名字
+                    if (node.Name == ParamName)
+                    {
+                        //返回节点的内容
+                        switch (((XmlElement)node).GetAttribute("Type"))
+                        {
+                            case "System.String":
+                                o = node.InnerText;
+                                break;
+                            case "System.Int32":
+                                o = int.Parse(node.InnerText);
+                                break;
+                            case "System.Boolean":
+                                o = node.InnerText == "True" ? true : false;
+                                break;
+                            default:
+                                break;
+                        }
+                        break;
+                    }
+                }
+                //关闭reader
+                reader.Close();
+                if (o == null)
+                    return "";
+                else
+                    return o;
+            }
+            catch (Exception e)
+            {
+                LogManager.DoLog(e.Message);
+                return "";
+            }
+        }
     }
 }

+ 1 - 1
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -90,7 +90,7 @@ namespace UAS_PLCDataReader.PublicMethod
             }
             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 where dr_decode='" + Decode + "'");
+            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);
         }