diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.cs b/RbFreqStandMeasure/info/accuracy.cs index 4fdbccc..376ea37 100644 --- a/RbFreqStandMeasure/info/accuracy.cs +++ b/RbFreqStandMeasure/info/accuracy.cs @@ -11,9 +11,11 @@ { public partial class accuracy : UserControl { + public static Label label_result; public accuracy() { InitializeComponent(); + label_result = label_accuracy; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.cs b/RbFreqStandMeasure/info/accuracy.cs index 4fdbccc..376ea37 100644 --- a/RbFreqStandMeasure/info/accuracy.cs +++ b/RbFreqStandMeasure/info/accuracy.cs @@ -11,9 +11,11 @@ { public partial class accuracy : UserControl { + public static Label label_result; public accuracy() { InitializeComponent(); + label_result = label_accuracy; } } } diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 5735c1e..15067c5 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -39,7 +39,7 @@ this.label_accuracy.BackColor = System.Drawing.Color.Transparent; this.label_accuracy.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_accuracy.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_accuracy.Location = new System.Drawing.Point(206, 111); + this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; this.label_accuracy.Size = new System.Drawing.Size(162, 27); @@ -50,7 +50,7 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(102, 110); + this.label4.Location = new System.Drawing.Point(79, 110); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(104, 27); @@ -63,7 +63,7 @@ this.label_devModel.BackColor = System.Drawing.Color.Transparent; this.label_devModel.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_devModel.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_devModel.Location = new System.Drawing.Point(206, 62); + this.label_devModel.Location = new System.Drawing.Point(183, 62); this.label_devModel.Margin = new System.Windows.Forms.Padding(0); this.label_devModel.Name = "label_devModel"; this.label_devModel.Size = new System.Drawing.Size(83, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(70, 61); + this.label9.Location = new System.Drawing.Point(47, 61); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(136, 27); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.cs b/RbFreqStandMeasure/info/accuracy.cs index 4fdbccc..376ea37 100644 --- a/RbFreqStandMeasure/info/accuracy.cs +++ b/RbFreqStandMeasure/info/accuracy.cs @@ -11,9 +11,11 @@ { public partial class accuracy : UserControl { + public static Label label_result; public accuracy() { InitializeComponent(); + label_result = label_accuracy; } } } diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 5735c1e..15067c5 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -39,7 +39,7 @@ this.label_accuracy.BackColor = System.Drawing.Color.Transparent; this.label_accuracy.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_accuracy.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_accuracy.Location = new System.Drawing.Point(206, 111); + this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; this.label_accuracy.Size = new System.Drawing.Size(162, 27); @@ -50,7 +50,7 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(102, 110); + this.label4.Location = new System.Drawing.Point(79, 110); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(104, 27); @@ -63,7 +63,7 @@ this.label_devModel.BackColor = System.Drawing.Color.Transparent; this.label_devModel.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_devModel.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_devModel.Location = new System.Drawing.Point(206, 62); + this.label_devModel.Location = new System.Drawing.Point(183, 62); this.label_devModel.Margin = new System.Windows.Forms.Padding(0); this.label_devModel.Name = "label_devModel"; this.label_devModel.Size = new System.Drawing.Size(83, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(70, 61); + this.label9.Location = new System.Drawing.Point(47, 61); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(136, 27); diff --git a/RbFreqStandMeasure/info/stability.cs b/RbFreqStandMeasure/info/stability.cs index 22e26df..413acf8 100644 --- a/RbFreqStandMeasure/info/stability.cs +++ b/RbFreqStandMeasure/info/stability.cs @@ -11,7 +11,7 @@ { private int x = 0; private int y = 0; - + public static Label label_result; public stability() { @@ -19,6 +19,7 @@ //设置背景颜色为透明 this.BackColor = Color.Transparent; + label_result = label_stability; } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.cs b/RbFreqStandMeasure/info/accuracy.cs index 4fdbccc..376ea37 100644 --- a/RbFreqStandMeasure/info/accuracy.cs +++ b/RbFreqStandMeasure/info/accuracy.cs @@ -11,9 +11,11 @@ { public partial class accuracy : UserControl { + public static Label label_result; public accuracy() { InitializeComponent(); + label_result = label_accuracy; } } } diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 5735c1e..15067c5 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -39,7 +39,7 @@ this.label_accuracy.BackColor = System.Drawing.Color.Transparent; this.label_accuracy.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_accuracy.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_accuracy.Location = new System.Drawing.Point(206, 111); + this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; this.label_accuracy.Size = new System.Drawing.Size(162, 27); @@ -50,7 +50,7 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(102, 110); + this.label4.Location = new System.Drawing.Point(79, 110); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(104, 27); @@ -63,7 +63,7 @@ this.label_devModel.BackColor = System.Drawing.Color.Transparent; this.label_devModel.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_devModel.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_devModel.Location = new System.Drawing.Point(206, 62); + this.label_devModel.Location = new System.Drawing.Point(183, 62); this.label_devModel.Margin = new System.Windows.Forms.Padding(0); this.label_devModel.Name = "label_devModel"; this.label_devModel.Size = new System.Drawing.Size(83, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(70, 61); + this.label9.Location = new System.Drawing.Point(47, 61); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(136, 27); diff --git a/RbFreqStandMeasure/info/stability.cs b/RbFreqStandMeasure/info/stability.cs index 22e26df..413acf8 100644 --- a/RbFreqStandMeasure/info/stability.cs +++ b/RbFreqStandMeasure/info/stability.cs @@ -11,7 +11,7 @@ { private int x = 0; private int y = 0; - + public static Label label_result; public stability() { @@ -19,6 +19,7 @@ //设置背景颜色为透明 this.BackColor = Color.Transparent; + label_result = label_stability; } diff --git a/RbFreqStandMeasure/tools/ConfigHelper.cs b/RbFreqStandMeasure/tools/ConfigHelper.cs index 0609290..3f425c2 100644 --- a/RbFreqStandMeasure/tools/ConfigHelper.cs +++ b/RbFreqStandMeasure/tools/ConfigHelper.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Configuration; +using System.Reflection; namespace Casic.Birmm.RbFreqStandMeasure.Tools { @@ -24,16 +25,26 @@ public static string getKeyByValue(string value) { - string file = System.Windows.Forms.Application.ExecutablePath; - Configuration config = ConfigurationManager.OpenExeConfiguration(file); - foreach (string key in config.AppSettings.Settings.AllKeys) - { - string val = config.AppSettings.Settings[key].Value.ToString(); - if (val.Equals(value)) + try + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777:" + value); + + string file = System.Windows.Forms.Application.ExecutablePath; + Configuration config = ConfigurationManager.OpenExeConfiguration(file); + foreach (string key in config.AppSettings.Settings.AllKeys) { - return key; + string val = config.AppSettings.Settings[key].Value.ToString(); + if (val.Equals(value)) + { + return key; + } } } + catch (Exception e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getKeyByValue:" + e.Message); + + } return null; } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 03f4faa..0179b93 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -77,6 +77,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -90,6 +91,8 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); + iRetval = 0; } diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index c03e715..6c4071b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 1b0a534..74bfd5a 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -250,7 +250,6 @@ detectionHelper.detecAgeRate(deviceId, startTime, port, false); } } - long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, textBox_channelNo.Text,stability1,stability10,stability20,stability100); detectionHelper.detectionId = detectionId0; this.HideMaskAction(); diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 6282fbc..8ed1f64 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; @@ -144,8 +145,8 @@ string devTypeCode = cbBox_devType.SelectedValue.ToString(); string channelNo = text_channelNo.Text.Trim(); string statusId = ""; - + // 初始化数据访问接口 DeviceService devService = new DeviceServiceImpl(); bool needDetec = false; @@ -163,9 +164,13 @@ string stability20 = "-3"; string stability100 = "-3"; string portName = ""; - SerialPort port = new SerialPort() ; + SerialPort port = new SerialPort(); + + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { + + port.Dispose(); port = RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1]; picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); @@ -174,7 +179,8 @@ needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); - + + // 打开串口 if (port.IsOpen) port.Close(); port.PortName = portName; @@ -185,9 +191,12 @@ port.Handshake = Handshake.None; port.ReadTimeout = -1; port.WriteTimeout = 3000; + + try { port.Open(); + if (!port.IsOpen) { MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); @@ -200,27 +209,32 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + try { - MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); - return; + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + { + MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); + return; + } + } + catch (Exception exc) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "。。。..."+exc.Message); } } - LogHelper.WriteErrorLog(this.GetType(), "串口检测完成。。。"); - + if (labelTitle.Text.Equals("添加")) - { - + { statusId = "1"; if(needDetec) statusId = "2"; deviceId = devService.add(devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo, statusId); - LogHelper.WriteErrorLog(this.GetType(), "添加"+ deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加"+ deviceId); if (deviceId == -1) { - LogHelper.WriteErrorLog(this.GetType(), "添加仪器[" + devName + "]失败"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "添加仪器[" + devName + "]失败"); MessageBox.Show("添加仪器[" + devName + "]失败", "错误"); this.HideMaskAction(); return; @@ -228,19 +242,21 @@ } else if (labelTitle.Text.Equals("修改")) { - LogHelper.WriteErrorLog(this.GetType(), "修改" + deviceId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); + } - + //添加检测 if (deviceId != -1 && needDetec) { - LogHelper.WriteErrorLog(this.GetType(), "各项检测开始。。。。"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "各项检测开始。。。。"); - DetectionHelper detectionHelper = new DetectionHelper(); + //开始检测 if (checkBox_stability.Checked) { @@ -312,10 +328,11 @@ } } - LogHelper.WriteErrorLog(this.GetType(), "detectionItemService更新检测记录表"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "更新检测记录表" + deviceId); //开始检测 - detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + long detectionId0 = detectionItemService.add(deviceId, startTime, endTime, stability, accuracy, bootFeature, ageRate, interval, text_channelNo.Text, stability1, stability10, stability20, stability100); + detectionHelper.detectionId = detectionId0; } if (labelTitle.Text.Equals("添加")) MessageBox.Show("添加成功!"); diff --git a/RbFreqStandMeasure/info/DetailDlg.Designer.cs b/RbFreqStandMeasure/info/DetailDlg.Designer.cs index 3cdc1ad..778dbfa 100644 --- a/RbFreqStandMeasure/info/DetailDlg.Designer.cs +++ b/RbFreqStandMeasure/info/DetailDlg.Designer.cs @@ -29,14 +29,15 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.btnClose = new System.Windows.Forms.Button(); this.labelTitle = new System.Windows.Forms.Label(); + this.label_reDetecting = new System.Windows.Forms.Label(); this.channel1 = new DevComponents.Editors.ComboItem(); this.channel2 = new DevComponents.Editors.ComboItem(); this.channel3 = new DevComponents.Editors.ComboItem(); @@ -71,7 +72,6 @@ this.radio_1s = new System.Windows.Forms.RadioButton(); this.btn_reDetec = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.dataGridView_Data = new System.Windows.Forms.DataGridView(); - this.label_reDetecting = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -122,6 +122,20 @@ this.labelTitle.TabIndex = 0; this.labelTitle.Text = "仪器检测详情"; // + // label_reDetecting + // + this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; + this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); + this.label_reDetecting.Location = new System.Drawing.Point(331, 2); + this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); + this.label_reDetecting.Name = "label_reDetecting"; + this.label_reDetecting.Size = new System.Drawing.Size(168, 27); + this.label_reDetecting.TabIndex = 81; + this.label_reDetecting.Text = "正在重新检测......"; + this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.label_reDetecting.Visible = false; + // // channel1 // this.channel1.Text = "通道1"; @@ -325,14 +339,14 @@ this.dataGridView_times.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_times.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_times.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_times.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_times.ColumnHeadersHeight = 28; this.dataGridView_times.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_times.GridColor = System.Drawing.Color.White; @@ -340,13 +354,13 @@ this.dataGridView_times.Name = "dataGridView_times"; this.dataGridView_times.RowHeadersVisible = false; this.dataGridView_times.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle12.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.dataGridView_times.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_times.RowTemplate.Height = 23; this.dataGridView_times.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView_times.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -546,27 +560,27 @@ this.dataGridView_Data.AllowUserToDeleteRows = false; this.dataGridView_Data.AllowUserToResizeColumns = false; this.dataGridView_Data.AllowUserToResizeRows = false; - dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle13.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle13.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle3.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_Data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_Data.BackgroundColor = System.Drawing.Color.White; this.dataGridView_Data.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_Data.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView_Data.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Data.ColumnHeadersHeight = 28; this.dataGridView_Data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_Data.GridColor = System.Drawing.Color.White; @@ -576,34 +590,20 @@ this.dataGridView_Data.ReadOnly = true; this.dataGridView_Data.RowHeadersVisible = false; this.dataGridView_Data.RowHeadersWidth = 30; - dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle15.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.NullValue = "-"; - dataGridViewCellStyle15.SelectionBackColor = System.Drawing.Color.LightGray; - dataGridViewCellStyle15.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle15; + dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle5.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.NullValue = "-"; + dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.LightGray; + dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_Data.RowsDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView_Data.RowTemplate.Height = 26; this.dataGridView_Data.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_Data.Size = new System.Drawing.Size(433, 426); this.dataGridView_Data.TabIndex = 3; // - // label_reDetecting - // - this.label_reDetecting.BackColor = System.Drawing.Color.Transparent; - this.label_reDetecting.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label_reDetecting.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128))))); - this.label_reDetecting.Location = new System.Drawing.Point(331, 2); - this.label_reDetecting.Margin = new System.Windows.Forms.Padding(0); - this.label_reDetecting.Name = "label_reDetecting"; - this.label_reDetecting.Size = new System.Drawing.Size(168, 27); - this.label_reDetecting.TabIndex = 81; - this.label_reDetecting.Text = "正在重新检测......"; - this.label_reDetecting.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.label_reDetecting.Visible = false; - // // DetailDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -672,6 +672,6 @@ private System.Windows.Forms.RadioButton radio_10s; private System.Windows.Forms.RadioButton radio_1s; public System.Windows.Forms.DataGridView dataGridView_Data; - private System.Windows.Forms.Label label_reDetecting; + public System.Windows.Forms.Label label_reDetecting; } } \ No newline at end of file diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index 2ece77a..7636e03 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -391,6 +391,11 @@ private void btn_reDetec_Click(object sender, EventArgs e) { + if (label_reDetecting.Visible == true) + { + MessageBox.Show("正在重新检测!"); + return; + } dataGridView = this.dataGridView_Data; label_redetecting = this.label_reDetecting; diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.cs b/RbFreqStandMeasure/info/InfoCtrlForm.cs index 0436571..55ae028 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.cs @@ -183,7 +183,7 @@ TextAlign = ContentAlignment.MiddleCenter, BackColor = titleBackColor, AutoSize = false, - Text = "设备状态", + Text = "仪器状态", Location = new Point(764, 0), Size = new Size(100, 40) }; diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 043c900..b426aee 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -123,6 +123,7 @@ MessageBox.Show("无法打开通道" + channelNo + ",检测失败!"); return; } + DetectionHelper detectionHelper = new DetectionHelper(); if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { @@ -134,8 +135,7 @@ DeviceService devService = new DeviceServiceImpl(); - DetectionHelper detectionHelper = new DetectionHelper(); - + //开始检测 if (label1.Text.Contains("稳定")) { diff --git a/RbFreqStandMeasure/info/accuracy.cs b/RbFreqStandMeasure/info/accuracy.cs index 4fdbccc..376ea37 100644 --- a/RbFreqStandMeasure/info/accuracy.cs +++ b/RbFreqStandMeasure/info/accuracy.cs @@ -11,9 +11,11 @@ { public partial class accuracy : UserControl { + public static Label label_result; public accuracy() { InitializeComponent(); + label_result = label_accuracy; } } } diff --git a/RbFreqStandMeasure/info/accuracy.designer.cs b/RbFreqStandMeasure/info/accuracy.designer.cs index 5735c1e..15067c5 100644 --- a/RbFreqStandMeasure/info/accuracy.designer.cs +++ b/RbFreqStandMeasure/info/accuracy.designer.cs @@ -39,7 +39,7 @@ this.label_accuracy.BackColor = System.Drawing.Color.Transparent; this.label_accuracy.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_accuracy.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_accuracy.Location = new System.Drawing.Point(206, 111); + this.label_accuracy.Location = new System.Drawing.Point(183, 111); this.label_accuracy.Margin = new System.Windows.Forms.Padding(0); this.label_accuracy.Name = "label_accuracy"; this.label_accuracy.Size = new System.Drawing.Size(162, 27); @@ -50,7 +50,7 @@ // this.label4.BackColor = System.Drawing.Color.Transparent; this.label4.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(102, 110); + this.label4.Location = new System.Drawing.Point(79, 110); this.label4.Margin = new System.Windows.Forms.Padding(0); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(104, 27); @@ -63,7 +63,7 @@ this.label_devModel.BackColor = System.Drawing.Color.Transparent; this.label_devModel.Font = new System.Drawing.Font("微软雅黑", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); this.label_devModel.ForeColor = System.Drawing.SystemColors.GrayText; - this.label_devModel.Location = new System.Drawing.Point(206, 62); + this.label_devModel.Location = new System.Drawing.Point(183, 62); this.label_devModel.Margin = new System.Windows.Forms.Padding(0); this.label_devModel.Name = "label_devModel"; this.label_devModel.Size = new System.Drawing.Size(83, 27); @@ -75,7 +75,7 @@ // this.label9.BackColor = System.Drawing.Color.Transparent; this.label9.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(70, 61); + this.label9.Location = new System.Drawing.Point(47, 61); this.label9.Margin = new System.Windows.Forms.Padding(0); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(136, 27); diff --git a/RbFreqStandMeasure/info/stability.cs b/RbFreqStandMeasure/info/stability.cs index 22e26df..413acf8 100644 --- a/RbFreqStandMeasure/info/stability.cs +++ b/RbFreqStandMeasure/info/stability.cs @@ -11,7 +11,7 @@ { private int x = 0; private int y = 0; - + public static Label label_result; public stability() { @@ -19,6 +19,7 @@ //设置背景颜色为透明 this.BackColor = Color.Transparent; + label_result = label_stability; } diff --git a/RbFreqStandMeasure/tools/ConfigHelper.cs b/RbFreqStandMeasure/tools/ConfigHelper.cs index 0609290..3f425c2 100644 --- a/RbFreqStandMeasure/tools/ConfigHelper.cs +++ b/RbFreqStandMeasure/tools/ConfigHelper.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Configuration; +using System.Reflection; namespace Casic.Birmm.RbFreqStandMeasure.Tools { @@ -24,16 +25,26 @@ public static string getKeyByValue(string value) { - string file = System.Windows.Forms.Application.ExecutablePath; - Configuration config = ConfigurationManager.OpenExeConfiguration(file); - foreach (string key in config.AppSettings.Settings.AllKeys) - { - string val = config.AppSettings.Settings[key].Value.ToString(); - if (val.Equals(value)) + try + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777:" + value); + + string file = System.Windows.Forms.Application.ExecutablePath; + Configuration config = ConfigurationManager.OpenExeConfiguration(file); + foreach (string key in config.AppSettings.Settings.AllKeys) { - return key; + string val = config.AppSettings.Settings[key].Value.ToString(); + if (val.Equals(value)) + { + return key; + } } } + catch (Exception e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getKeyByValue:" + e.Message); + + } return null; } diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index c2c84a7..45e6e14 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -168,6 +168,7 @@ detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", result1, "", "", ""); updateView(resultStability1); + stability.label_result.Text = result1; resultStability1.Clear(); } @@ -215,7 +216,6 @@ if (resultStability10.Count == 101) { - timerStability10.Dispose(); result = FreMath.Stable(resultStability10) + ""; LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "10s稳定度检测结果:" + result); @@ -255,6 +255,7 @@ detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", result1, "", ""); updateView(resultStability10); + stability.label_result.Text = result1; } } break; @@ -335,7 +336,7 @@ detectionItemService.updateDetecStatus(devIdStability, "", "", "", "", "", "", "", result1, ""); updateView(resultStability20); - + stability.label_result.Text = result1; resultStability20.Clear(); } @@ -357,7 +358,6 @@ { if (!isUsing) { - isUsing = true; LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测稳定度"); string result = ""; @@ -415,11 +415,10 @@ detectionItemService.updateDetecStatus(detectionId, "", "", "", "", "", "", "", "", result1); updateView(resultStability100); - + stability.label_result.Text = result1; resultStability100.Clear(); } } - isUsing = false; break; } } @@ -458,15 +457,15 @@ { if (!isUsing) { - isUsing = true; string result = ""; double sum = 0.0; List resultList = new List(); + for (int i = 0; i < 50; i++) { string fre = getFrequencyData(portAccuracy); resultList.Add(fre); - + if (fre.Equals("")) continue; if (!isUpdate) { detectionService.add(devIdAccuracy, fre, "2"); @@ -479,18 +478,30 @@ Thread.Sleep(500); } - - - - result = sum / 3 + ""; + + result = sum / 3 + ""; timerAccuracy.Dispose(); - detectionItemService.updateDetecStatus(detectionId, "", result, "", "", "", "", "", "", ""); - deviceService.updateStatus(devIdAccuracy, "3", ""); - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - portAccuracy.Close(); - if (isUpdate) updateView(resultList); - isUsing = false; + + while (true) + { + if (detectionId != -1) + { + detectionItemService.updateDetecStatus(detectionId, "", result, "", "", "", "", "", "", ""); + break; + } + } + if (!isUpdate) + { + deviceService.updateStatus(devIdAccuracy, "3", ""); + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + else + { + accuracy.label_result.Text = result; + updateView(resultList); + } + portAccuracy.Close(); break; } } @@ -669,6 +680,7 @@ { try { + isUsing = true; if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); string received = ""; @@ -765,11 +777,14 @@ new Thread(() => { int index = 0; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "DetailDlg.dataGridView.Rows:" + DetailDlg.dataGridView.Rows); + + foreach (DataGridViewRow row in DetailDlg.dataGridView.Rows) { if (index < result.Count) { - row.Cells[1].Value = result[index].ToString(); + row.Cells[2].Value = result[index].ToString(); detectionService.updateFrequency(Convert.ToInt64(row.Cells[3].Value), result[index].ToString()); } index++;