diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 4405d66..8cda24b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 4405d66..8cda24b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = 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(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - 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.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 4405d66..8cda24b 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = 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(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - 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.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file