Browse Source

修改产量数据对应

章政 7 years ago
parent
commit
e256927278
3 changed files with 157 additions and 38 deletions
  1. 68 22
      PLCDataReader/Main.Designer.cs
  2. 62 16
      PLCDataReader/Main.cs
  3. 27 0
      PLCDataReader/PublicMethod/LogicHandler.cs

+ 68 - 22
PLCDataReader/Main.Designer.cs

@@ -79,6 +79,10 @@ namespace UAS_PLCDataReader
             this.de_address = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_linecode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.de_wccode = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.de_item1 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.DataItemRepositoryItemComboBox1 = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
+            this.de_item2 = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.de_item3 = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageCommandSet = new DevExpress.XtraTab.XtraTabPage();
             this.ButtonDeleteCommand = new UAS_PLCDataReader.CustomerControl.Button.ButtonDeleteRow();
             this.Brand_label = new DevExpress.XtraEditors.LabelControl();
@@ -93,6 +97,7 @@ namespace UAS_PLCDataReader
             this.dc_code = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_name = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_type = new DevExpress.XtraGrid.Columns.GridColumn();
+            this.dc_dataindex = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_value = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dc_sendcoding = new DevExpress.XtraGrid.Columns.GridColumn();
             this.CommandSetRepositoryItemComboBox1 = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
@@ -169,7 +174,6 @@ namespace UAS_PLCDataReader
             this.TimerDeviceStatus = new System.Windows.Forms.Timer();
             this.CommonTipController = new DevExpress.Utils.ToolTipController();
             this.TimerUpdateDevice = new System.Windows.Forms.Timer();
-            this.dc_dataindex = new DevExpress.XtraGrid.Columns.GridColumn();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -181,6 +185,7 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceList)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceList)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.DataItemRepositoryItemComboBox1)).BeginInit();
             this.PageCommandSet.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.Brand.Properties)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridCommandSetting)).BeginInit();
@@ -231,6 +236,7 @@ namespace UAS_PLCDataReader
             this.DeviceInf,
             this.DeviceCommandSetting});
             this.RibbonNav.Size = new System.Drawing.Size(1033, 128);
+            this.RibbonNav.Click += new System.EventHandler(this.RibbonNav_Click);
             // 
             // ButtonDeviceList
             // 
@@ -513,6 +519,8 @@ namespace UAS_PLCDataReader
             this.GridDeviceList.MainView = this.GridViewDeviceList;
             this.GridDeviceList.MenuManager = this.RibbonNav;
             this.GridDeviceList.Name = "GridDeviceList";
+            this.GridDeviceList.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
+            this.DataItemRepositoryItemComboBox1});
             this.GridDeviceList.RowCount = 0;
             this.GridDeviceList.Size = new System.Drawing.Size(1027, 546);
             this.GridDeviceList.TabIndex = 0;
@@ -538,7 +546,10 @@ namespace UAS_PLCDataReader
             this.de_vendname,
             this.de_address,
             this.de_linecode,
-            this.de_wccode});
+            this.de_wccode,
+            this.de_item1,
+            this.de_item2,
+            this.de_item3});
             this.GridViewDeviceList.GridControl = this.GridDeviceList;
             this.GridViewDeviceList.IndicatorWidth = 30;
             this.GridViewDeviceList.Name = "GridViewDeviceList";
@@ -599,7 +610,7 @@ namespace UAS_PLCDataReader
             this.de_stepcode.FieldName = "DE_STEPCODE";
             this.de_stepcode.Name = "de_stepcode";
             this.de_stepcode.Visible = true;
-            this.de_stepcode.VisibleIndex = 5;
+            this.de_stepcode.VisibleIndex = 4;
             // 
             // de_stepname
             // 
@@ -607,7 +618,7 @@ namespace UAS_PLCDataReader
             this.de_stepname.FieldName = "DE_STEPNAME";
             this.de_stepname.Name = "de_stepname";
             this.de_stepname.Visible = true;
-            this.de_stepname.VisibleIndex = 7;
+            this.de_stepname.VisibleIndex = 6;
             // 
             // de_sourcecode
             // 
@@ -615,7 +626,7 @@ namespace UAS_PLCDataReader
             this.de_sourcecode.FieldName = "DE_SOURCECODE";
             this.de_sourcecode.Name = "de_sourcecode";
             this.de_sourcecode.Visible = true;
-            this.de_sourcecode.VisibleIndex = 6;
+            this.de_sourcecode.VisibleIndex = 5;
             // 
             // de_indate
             // 
@@ -626,8 +637,6 @@ namespace UAS_PLCDataReader
             this.de_indate.FilterMode = DevExpress.XtraGrid.ColumnFilterMode.DisplayText;
             this.de_indate.Name = "de_indate";
             this.de_indate.OptionsColumn.AllowEdit = false;
-            this.de_indate.Visible = true;
-            this.de_indate.VisibleIndex = 4;
             // 
             // de_spec
             // 
@@ -635,7 +644,7 @@ namespace UAS_PLCDataReader
             this.de_spec.FieldName = "DE_SPEC";
             this.de_spec.Name = "de_spec";
             this.de_spec.Visible = true;
-            this.de_spec.VisibleIndex = 8;
+            this.de_spec.VisibleIndex = 7;
             // 
             // de_inman
             // 
@@ -643,7 +652,7 @@ namespace UAS_PLCDataReader
             this.de_inman.FieldName = "DE_INMAN";
             this.de_inman.Name = "de_inman";
             this.de_inman.Visible = true;
-            this.de_inman.VisibleIndex = 9;
+            this.de_inman.VisibleIndex = 8;
             // 
             // de_vendcode
             // 
@@ -656,8 +665,6 @@ namespace UAS_PLCDataReader
             this.de_vendname.Caption = "供应商名称";
             this.de_vendname.FieldName = "DE_VENDNAME";
             this.de_vendname.Name = "de_vendname";
-            this.de_vendname.Visible = true;
-            this.de_vendname.VisibleIndex = 10;
             // 
             // de_address
             // 
@@ -665,7 +672,7 @@ namespace UAS_PLCDataReader
             this.de_address.FieldName = "DE_ADDRESS";
             this.de_address.Name = "de_address";
             this.de_address.Visible = true;
-            this.de_address.VisibleIndex = 11;
+            this.de_address.VisibleIndex = 9;
             // 
             // de_linecode
             // 
@@ -673,7 +680,7 @@ namespace UAS_PLCDataReader
             this.de_linecode.FieldName = "DE_LINECODE";
             this.de_linecode.Name = "de_linecode";
             this.de_linecode.Visible = true;
-            this.de_linecode.VisibleIndex = 12;
+            this.de_linecode.VisibleIndex = 10;
             // 
             // de_wccode
             // 
@@ -681,7 +688,41 @@ namespace UAS_PLCDataReader
             this.de_wccode.FieldName = "DE_WCCODE";
             this.de_wccode.Name = "de_wccode";
             this.de_wccode.Visible = true;
-            this.de_wccode.VisibleIndex = 13;
+            this.de_wccode.VisibleIndex = 11;
+            // 
+            // de_item1
+            // 
+            this.de_item1.Caption = "参数1";
+            this.de_item1.ColumnEdit = this.DataItemRepositoryItemComboBox1;
+            this.de_item1.FieldName = "DE_ITEM1";
+            this.de_item1.Name = "de_item1";
+            this.de_item1.Visible = true;
+            this.de_item1.VisibleIndex = 12;
+            // 
+            // DataItemRepositoryItemComboBox1
+            // 
+            this.DataItemRepositoryItemComboBox1.AutoHeight = false;
+            this.DataItemRepositoryItemComboBox1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
+            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
+            this.DataItemRepositoryItemComboBox1.Name = "DataItemRepositoryItemComboBox1";
+            // 
+            // de_item2
+            // 
+            this.de_item2.Caption = "参数2";
+            this.de_item2.ColumnEdit = this.DataItemRepositoryItemComboBox1;
+            this.de_item2.FieldName = "DE_ITEM2";
+            this.de_item2.Name = "de_item2";
+            this.de_item2.Visible = true;
+            this.de_item2.VisibleIndex = 13;
+            // 
+            // de_item3
+            // 
+            this.de_item3.Caption = "参数3";
+            this.de_item3.ColumnEdit = this.DataItemRepositoryItemComboBox1;
+            this.de_item3.FieldName = "DE_ITEM3";
+            this.de_item3.Name = "de_item3";
+            this.de_item3.Visible = true;
+            this.de_item3.VisibleIndex = 14;
             // 
             // PageCommandSet
             // 
@@ -846,6 +887,14 @@ namespace UAS_PLCDataReader
             this.dc_type.VisibleIndex = 3;
             this.dc_type.Width = 57;
             // 
+            // dc_dataindex
+            // 
+            this.dc_dataindex.Caption = "数据索引";
+            this.dc_dataindex.FieldName = "DC_DATAINDEX";
+            this.dc_dataindex.Name = "dc_dataindex";
+            this.dc_dataindex.Visible = true;
+            this.dc_dataindex.VisibleIndex = 4;
+            // 
             // dc_value
             // 
             this.dc_value.Caption = "发送指令";
@@ -1630,14 +1679,6 @@ namespace UAS_PLCDataReader
             this.TimerUpdateDevice.Interval = 20000;
             this.TimerUpdateDevice.Tick += new System.EventHandler(this.TimerUpdateDevice_Tick);
             // 
-            // dc_dataindex
-            // 
-            this.dc_dataindex.Caption = "数据索引";
-            this.dc_dataindex.FieldName = "DC_DATAINDEX";
-            this.dc_dataindex.Name = "dc_dataindex";
-            this.dc_dataindex.Visible = true;
-            this.dc_dataindex.VisibleIndex = 4;
-            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
@@ -1667,6 +1708,7 @@ namespace UAS_PLCDataReader
             ((System.ComponentModel.ISupportInitialize)(this.GridDeviceList)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewDeviceList)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.DataItemRepositoryItemComboBox1)).EndInit();
             this.PageCommandSet.ResumeLayout(false);
             this.PageCommandSet.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.Brand.Properties)).EndInit();
@@ -1839,5 +1881,9 @@ namespace UAS_PLCDataReader
         private DevExpress.XtraGrid.Columns.GridColumn dpc_dename;
         private System.Windows.Forms.Timer TimerUpdateDevice;
         private DevExpress.XtraGrid.Columns.GridColumn dc_dataindex;
+        private DevExpress.XtraGrid.Columns.GridColumn de_item1;
+        private DevExpress.XtraGrid.Columns.GridColumn de_item2;
+        private DevExpress.XtraGrid.Columns.GridColumn de_item3;
+        private DevExpress.XtraEditors.Repository.RepositoryItemComboBox DataItemRepositoryItemComboBox1;
     }
 }

+ 62 - 16
PLCDataReader/Main.cs

@@ -43,6 +43,8 @@ namespace UAS_PLCDataReader
             CheckForIllegalCrossThreadCalls = false;
             dpc_enableCheckEdit.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             CommandSetRepositoryItemComboBox1.ParseEditValue += CommandSetRepositoryItemComboBox1_ParseEditValue;
+            DataItemRepositoryItemComboBox1.ParseEditValue += CommandSetRepositoryItemComboBox1_ParseEditValue;
+            DataItemRepositoryItemComboBox1.SelectedValueChanged += DataItemRepositoryItemComboBox1_SelectedValueChanged;
             CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             PollSettingItemSearchLookUpEdit.ParseEditValue += PollSettingItemSearchLookUpEdit_ParseEditValue;
             GridViewPollSetting.RowCellStyle += GridViewPollSetting_RowCellStyle;
@@ -59,9 +61,43 @@ namespace UAS_PLCDataReader
             CommandSetRepositoryItemComboBox1.Items.Add(cbd);
             CommandSetRepositoryItemComboBox1.Items.Add(cbd1);
             CommandSetRepositoryItemComboBox1.Items.Add(cbd2);
+
+            ComboBoxData cbd3 = new ComboBoxData();
+            cbd3.Text = "INQTY";
+            cbd3.Value = "INQTY";
+            ComboBoxData cbd4 = new ComboBoxData();
+            cbd4.Text = "OUTQTY";
+            cbd4.Value = "OUTQTY";
+            ComboBoxData cbd5 = new ComboBoxData();
+            cbd5.Text = "TEMPERATURE";
+            cbd5.Value = "TEMPERATURE";
+            DataItemRepositoryItemComboBox1.Items.Add(cbd3);
+            DataItemRepositoryItemComboBox1.Items.Add(cbd4);
+            DataItemRepositoryItemComboBox1.Items.Add(cbd5);
+
             #endregion
         }
 
+        private void DataItemRepositoryItemComboBox1_SelectedValueChanged(object sender, EventArgs e)
+        {
+            ComboBoxData item = new ComboBoxData();
+            try
+            {
+                item = (ComboBoxData)(sender as ComboBoxEdit).SelectedItem;
+                string text = item.Text.ToString();
+                string value = item.Value;
+                GridView myView = (GridDeviceList.MainView as GridView);
+                int dataIndex = myView.GetDataSourceRowIndex(myView.FocusedRowHandle);
+                DataTable dt = (DataTable)GridDeviceList.DataSource;
+                dt.Rows[dataIndex]["de_item1"] = value;
+                GridDeviceList.DataSource = dt;
+            }
+            catch (Exception ex)
+            {
+                XtraMessageBox.Show(ex.Message, "提示");
+            }
+        }
+
         private void CommandSetRepositoryItemComboBox1_ParseEditValue(object sender, ConvertEditValueEventArgs e)
         {
             string val = "";
@@ -85,10 +121,10 @@ namespace UAS_PLCDataReader
         private void Main_Load(object sender, EventArgs e)
         {
             //设备列表
-            GridDeviceList.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE FROM DEVICE ORDER BY DE_CODE".ToUpper();
+            GridDeviceList.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE,DE_ITEM1,DE_ITEM2,DE_ITEM3 FROM DEVICE ORDER BY DE_CODE".ToUpper();
             GridDeviceList.TableName = "device";
             GridDeviceList.ID = "de_id";
-            GridDeviceList.InsertSQL = "INSERT INTO DEVICE(DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE) VALUES(DEVICE_SEQ.NEXTVAL,:DE_CODE,:DE_NAME,:DE_SPEC,sysdate,:DE_RUNSTATUS,:DE_ADDRESS,:DE_INMAN,:DE_LINECODE,:DE_WCCODE,:DE_VENDCODE,:DE_VENDNAME,:DE_STEPCODE,:DE_STEPNAME,:DE_SOURCECODE)";
+            GridDeviceList.InsertSQL = "INSERT INTO DEVICE(DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE,DE_ITEM1,DE_ITEM2,DE_ITEM3) VALUES(DEVICE_SEQ.NEXTVAL,:DE_CODE,:DE_NAME,:DE_SPEC,sysdate,:DE_RUNSTATUS,:DE_ADDRESS,:DE_INMAN,:DE_LINECODE,:DE_WCCODE,:DE_VENDCODE,:DE_VENDNAME,:DE_STEPCODE,:DE_STEPNAME,:DE_SOURCECODE,:DE_ITEM1,:DE_ITEM2,:DE_ITEM3)";
             ButtonAddDevice.Grid = GridDeviceList;
             ButtonSaveDevice.Grid = GridDeviceList;
             ButtonDeleteDevice.Grid = GridDeviceList;
@@ -199,7 +235,7 @@ namespace UAS_PLCDataReader
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
             string LC = BaseUtil.GetComboxEditValue(ComboxDeviceListLC);
             DeviceListQuerySQL.Append("select 0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode, ");
-            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE from device ");
+            DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE,de_item1,de_item2,de_item3 from device ");
             if (WC != "全部" && LC != "全部")
                 DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
             if (WC == "全部" && LC != "全部")
@@ -442,20 +478,20 @@ namespace UAS_PLCDataReader
             string Decode = pl.DeviceCode;
             string Dccode = pl.CommandCode;
             string DpcID = pl.Id.ToString();
-            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,dc_receivecoding from devicecommand where dc_code='" + Dccode + "'", "select");
-            if (dt.Rows.Count > 0)
+            DataTable DNC = (DataTable)dh.ExecuteSql("select dnc_ip,dnc_port from DEVICENETCONFIG where dnc_decode='" + Decode + "'", "select");
+            DataTable DC = (DataTable)dh.ExecuteSql("select dc_sendcoding,dc_value,dc_receivecoding,dc_type from devicecommand where dc_code='" + Dccode + "' order by dc_dataindex", "select");
+            if (DNC.Rows.Count > 0)
             {
-                string IP = dt.Rows[0]["dnc_ip"].ToString() + ":" + dt.Rows[0]["dnc_port"].ToString();
+                string IP = DNC.Rows[0]["dnc_ip"].ToString() + ":" + DNC.Rows[0]["dnc_port"].ToString();
                 string SendCoding = "";
                 string ReceiveCoding = "";
                 string Command = "";
                 int SendCommandByteSize = 0;
-                if (dt1.Rows.Count > 0)
+                if (DC.Rows.Count > 0)
                 {
-                    SendCoding = dt1.Rows[0]["dc_sendcoding"].ToString();
-                    ReceiveCoding = dt1.Rows[0]["dc_receivecoding"].ToString();
-                    Command = dt1.Rows[0]["dc_value"].ToString();
+                    SendCoding = DC.Rows[0]["dc_sendcoding"].ToString();
+                    ReceiveCoding = DC.Rows[0]["dc_receivecoding"].ToString();
+                    Command = DC.Rows[0]["dc_value"].ToString();
                     SendCommandByteSize = Encoding.Default.GetBytes(Command.ToCharArray()).Length;
                 }
                 if (client.ContainsKey(DpcID))
@@ -464,7 +500,7 @@ namespace UAS_PLCDataReader
                 }
                 else
                 {
-                    ModBusTCPClient modclient = new ModBusTCPClient(dt.Rows[0]["dnc_ip"].ToString(), int.Parse(dt.Rows[0]["dnc_port"].ToString()));
+                    ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), int.Parse(DNC.Rows[0]["dnc_port"].ToString()));
                     client.Add(DpcID, modclient);
                 }
                 //发送指令
@@ -497,9 +533,12 @@ namespace UAS_PLCDataReader
                     //存放返回的所有数据
                     Dictionary<string, string> ItemData = new Dictionary<string, string>();
                     int[] Arr = BaseUtil.GetDecimalData(BaseUtil.ASCIIToString(client[DpcID].Returnvalue[IP]), 8);
-                    for (int i = 0; i < Arr.Length; i++)
+                    if (Arr.Length == DC.Rows.Count)
                     {
-                        ItemData.Add("Item" + i, Arr[i].ToString());
+                        for (int i = 0; i < Arr.Length; i++)
+                        {
+                            ItemData.Add(DC.Rows[i]["dc_type"].ToString(), Arr[i].ToString());
+                        }
                     }
                     if (!ReturnData.ContainsKey(Decode))
                     {
@@ -519,13 +558,15 @@ namespace UAS_PLCDataReader
                         if (ReturnData[Decode].ItemData == null)
                         {
                             ReturnData[Decode].ItemData = ItemData;
+                            LogicHandler.UpdateDeviceData(Decode, ItemData);
                         }
                         //每次更新轮询的数据
                         ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
                         //检测键值对是否发生变化,发生变化时赋予新值
-                        if ((BaseUtil.CheckDicDiff(ReturnData[Decode].ItemData, ItemData)))
+                        if (BaseUtil.CheckDicDiff(ReturnData[Decode].ItemData, ItemData))
                         {
                             ReturnData[Decode].ItemData = ItemData;
+                            LogicHandler.UpdateDeviceData(Decode, ItemData);
                             QueueUpdateDevice.Enqueue(ReturnData[Decode]);
                             LogicHandler.DoDeviceDataDiffLog(pl.DeviceCode, pl.DeviceName, pl.CommandCode, User.UserName);
                         }
@@ -836,7 +877,7 @@ namespace UAS_PLCDataReader
                 ShowDeviceStatus();
             }
         }
-
+        
         private void PanelDeviceStatus_SizeChanged(object sender, EventArgs e)
         {
             if (PageDeviceStatus.PageVisible)
@@ -846,5 +887,10 @@ namespace UAS_PLCDataReader
             }
         }
         #endregion
+
+        private void RibbonNav_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }

+ 27 - 0
PLCDataReader/PublicMethod/LogicHandler.cs

@@ -48,5 +48,32 @@ namespace UAS_PLCDataReader.PublicMethod
             sql.Append("values(DeviceRunRecord_seq.nextval,'" + iDeCode + "','" + iDeName + "','" + iCommand + "',sysdate,'" + iMan + "','')");
             dh.ExecuteSql(sql.ToString(), "insert");
         }
+
+        public static void UpdateDeviceData(string Decode,Dictionary<string,string> ItemData)
+        {
+            string INQTY = "";
+            string OUTQTY = "";
+            string TEMPERATURE = "";
+            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;
+                    default:
+                        break;
+                }
+            }
+            sql.Clear();
+            sql.Append("update DeviceRunstatus set dr_qty=:dr_inqty,dr_okqty=:dr_okqty,dr_TEMPERATURE=:dr_TEMPERATURE where dr_decode='" + Decode + "'");
+            dh.ExecuteSql(sql.ToString(), "select", INQTY, OUTQTY, TEMPERATURE);
+        }
     }
 }