瀏覽代碼

调整显示值

章政 7 年之前
父節點
當前提交
86609cfdb4
共有 3 個文件被更改,包括 17 次插入58 次删除
  1. 3 7
      PLCDataReader/Main.Designer.cs
  2. 4 42
      PLCDataReader/Main.cs
  3. 10 9
      PLCDataReader/PublicMethod/ModBusTCPClient.cs

+ 3 - 7
PLCDataReader/Main.Designer.cs

@@ -1244,8 +1244,6 @@ namespace UAS_PLCDataReader
             this.GridViewPollSetting.Name = "GridViewPollSetting";
             this.GridViewPollSetting.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
             this.GridViewPollSetting.OptionsView.ShowGroupPanel = false;
-            this.GridViewPollSetting.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.GridViewPollSetting_CellValueChanged);
-            this.GridViewPollSetting.CellValueChanging += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(this.GridViewPollSetting_CellValueChanging);
             // 
             // PollSettingCheckedColumn
             // 
@@ -1371,7 +1369,7 @@ namespace UAS_PLCDataReader
             this.em_name1.Name = "em_name1";
             this.em_name1.OptionsColumn.AllowEdit = false;
             this.em_name1.Visible = true;
-            this.em_name1.VisibleIndex = 10;
+            this.em_name1.VisibleIndex = 9;
             // 
             // dpc_status
             // 
@@ -1379,8 +1377,6 @@ namespace UAS_PLCDataReader
             this.dpc_status.FieldName = "DPC_STATUS";
             this.dpc_status.Name = "dpc_status";
             this.dpc_status.OptionsColumn.AllowEdit = false;
-            this.dpc_status.Visible = true;
-            this.dpc_status.VisibleIndex = 7;
             this.dpc_status.Width = 90;
             // 
             // dpc_man
@@ -1396,7 +1392,7 @@ namespace UAS_PLCDataReader
             this.dpc_remark.FieldName = "DPC_REMARK";
             this.dpc_remark.Name = "dpc_remark";
             this.dpc_remark.Visible = true;
-            this.dpc_remark.VisibleIndex = 8;
+            this.dpc_remark.VisibleIndex = 7;
             this.dpc_remark.Width = 87;
             // 
             // POLLSETTINGSTATUSCOLUMN
@@ -1406,7 +1402,7 @@ namespace UAS_PLCDataReader
             this.POLLSETTINGSTATUSCOLUMN.Name = "POLLSETTINGSTATUSCOLUMN";
             this.POLLSETTINGSTATUSCOLUMN.OptionsColumn.ReadOnly = true;
             this.POLLSETTINGSTATUSCOLUMN.Visible = true;
-            this.POLLSETTINGSTATUSCOLUMN.VisibleIndex = 9;
+            this.POLLSETTINGSTATUSCOLUMN.VisibleIndex = 8;
             this.POLLSETTINGSTATUSCOLUMN.Width = 98;
             // 
             // PollingSetItemLookUpEdit

+ 4 - 42
PLCDataReader/Main.cs

@@ -485,7 +485,7 @@ namespace UAS_PLCDataReader
                 }
                 else
                 {
-                    ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), int.Parse(DNC.Rows[0]["dnc_port"].ToString()), pl.DeviceCode, pl.DeviceName);
+                    ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), DNC.Rows[0]["dnc_port"].ToString(), pl.DeviceCode, pl.DeviceName);
                     client.Add(DpcID, modclient);
                 }
                 //如果不包含该项数据则在键值对中添加
@@ -576,44 +576,6 @@ namespace UAS_PLCDataReader
             Ptime.Clear();
         }
 
-        private void GridViewPollSetting_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
-        {
-            if (e.Column.Name.ToUpper() == "DPC_ENABLE")
-            {
-                GridViewPollSetting.SetRowCellValue(e.RowHandle, e.Column, e.Value);
-                if (GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ENABLE").ToString() == "0")
-                {
-                    int id = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ID").ToString());
-                    if (Ptime.ContainsKey(id))
-                    {
-                        Ptime[id].Stop();
-                        Ptime.Remove(id);
-                        client.Remove(id.ToString());
-                        PollSettingPaintRowIndex.Remove(e.RowHandle);
-                    }
-                }
-                else
-                {
-                    Polling pl = new Polling();
-                    pl.Id = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ID").ToString());
-                    pl.DeviceCode = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DECODE").ToString();
-                    pl.DeviceName = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DENAME").ToString();
-                    pl.Interval = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_INTERVAL").ToString());
-                    pl.CommandCode = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DCCODE").ToString();
-                    pl.Enable = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ENABLE").ToString() != "0";
-                    pl.Dh = new DataHelper();
-                    if (pl.Enable)
-                        pt.AddTask(RunTask, pl);
-                    PollSettingPaintRowIndex.Add(e.RowHandle);
-                }
-            }
-        }
-
-        private void GridViewPollSetting_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
-        {
-
-        }
-
         private void ButtonSaveCommandSet_Click(object sender, EventArgs e)
         {
             ButtonSaveCommandSet.DoSaveAfterHandler();
@@ -665,7 +627,7 @@ namespace UAS_PLCDataReader
             if (CheckEditDeviceStatusEnable.Checked)
             {
                 DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
-                DeviceStatusQuerySQL.Append("on dr_decode=de_code where nvl(dpc_enable,0)<>0 order by de_code");
+                DeviceStatusQuerySQL.Append("on dr_decode=de_code left join DEVICEPOLLINGCONFIG on de_code=dpc_decode where nvl(dpc_enable,0)<>0 order by de_code");
             }
             else
             {
@@ -681,8 +643,8 @@ namespace UAS_PLCDataReader
             string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
             if (CheckEditDeviceStatusEnable.Checked)
             {
-                DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
-                DeviceStatusQuerySQL.Append("on dr_decode=de_code where nvl(dpc_enable,0)<>0 and de_wccode='" + WC + "' order by de_code");
+                DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus left join  ");
+                DeviceStatusQuerySQL.Append("on dr_decode=de_code left join DEVICEPOLLINGCONFIG on de_code=dpc_decode where nvl(dpc_enable,0)<>0 and de_wccode='" + WC + "' order by de_code");
             }
             else
             {

+ 10 - 9
PLCDataReader/PublicMethod/ModBusTCPClient.cs

@@ -91,19 +91,20 @@ namespace UAS_PLCDataReader.PublicMethod
         string decode = "";
         string dename = "";
 
-        public ModBusTCPClient(string IP, int Port,string Decode,string Dename)
+        public ModBusTCPClient(string IP, string Port, string Decode, string Dename)
         {
-            decode = Decode;
-            dename = Dename;
-            socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-            serverFullAddr = new IPEndPoint(IPAddress.Parse(IP), Port);//设置IP,端口
             try
             {
+                decode = Decode;
+                dename = Dename;
+                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+                serverFullAddr = new IPEndPoint(IPAddress.Parse(IP), int.Parse(Port));//设置IP,端口
                 socket.Connect(serverFullAddr);
             }
-            catch (Exception)
+            catch (Exception e)
             {
-                LogicHandler.UpdateDeviceStatus(decode, dename,"disconnect");
+                Console.WriteLine(e.Message);
+                LogicHandler.UpdateDeviceStatus(decode, dename, "disconnect");
             }
         }
 
@@ -133,9 +134,9 @@ namespace UAS_PLCDataReader.PublicMethod
                 {
                     returnvalue.Add(socket.RemoteEndPoint.ToString(), BaseUtil.ByteToHexadecimalString(receive, length));
                 }
-              
+
             }
-            catch (Exception e)
+            catch (Exception)
             {
                 LogicHandler.UpdateDeviceStatus(decode, dename, "disconnect");
             }