From dfb2859b21d154eea9d7487d5099da64d743ef62 Mon Sep 17 00:00:00 2001 From: CNXY Date: Mon, 17 May 2021 18:34:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E6=8C=87=E5=AE=9A=E4=B8=AA=E6=95=B0=E4=B8=8E?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E4=B8=AA=E6=95=B0=E5=AF=B9=E5=BA=94=E4=B8=8D?= =?UTF-8?q?=E4=B8=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VISAInstrument/FrmMain.Designer.cs | 22 +++++++++++----------- VISAInstrument/FrmMain.cs | 21 +++++++++++++++++++-- VISAInstrument/Port/PortOperator.cs | 5 +++++ VISAInstrument/Properties/AssemblyInfo.cs | 4 ++-- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/VISAInstrument/FrmMain.Designer.cs b/VISAInstrument/FrmMain.Designer.cs index bde4f9d..ceb864f 100644 --- a/VISAInstrument/FrmMain.Designer.cs +++ b/VISAInstrument/FrmMain.Designer.cs @@ -341,7 +341,7 @@ private void InitializeComponent() this.groupBox2.Controls.Add(this.flowLayoutPanel8); this.groupBox2.Location = new System.Drawing.Point(244, 3); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(458, 50); + this.groupBox2.Size = new System.Drawing.Size(502, 50); this.groupBox2.TabIndex = 9; this.groupBox2.TabStop = false; this.groupBox2.Text = "接收"; @@ -355,7 +355,7 @@ private void InitializeComponent() this.flowLayoutPanel8.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel8.Location = new System.Drawing.Point(3, 17); this.flowLayoutPanel8.Name = "flowLayoutPanel8"; - this.flowLayoutPanel8.Size = new System.Drawing.Size(452, 30); + this.flowLayoutPanel8.Size = new System.Drawing.Size(496, 30); this.flowLayoutPanel8.TabIndex = 0; // // rdoUntilNewLine @@ -412,7 +412,7 @@ private void InitializeComponent() this.chkRealTimeReceive.Anchor = System.Windows.Forms.AnchorStyles.None; this.chkRealTimeReceive.AutoSize = true; this.chkRealTimeReceive.Location = new System.Drawing.Point(339, 5); - this.chkRealTimeReceive.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.chkRealTimeReceive.Margin = new System.Windows.Forms.Padding(2); this.chkRealTimeReceive.Name = "chkRealTimeReceive"; this.chkRealTimeReceive.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0); this.chkRealTimeReceive.Size = new System.Drawing.Size(92, 16); @@ -426,7 +426,7 @@ private void InitializeComponent() this.groupBox3.Controls.Add(this.flowLayoutPanel9); this.groupBox3.Location = new System.Drawing.Point(3, 59); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(699, 50); + this.groupBox3.Size = new System.Drawing.Size(743, 50); this.groupBox3.TabIndex = 9; this.groupBox3.TabStop = false; this.groupBox3.Text = "循环"; @@ -438,7 +438,7 @@ private void InitializeComponent() this.flowLayoutPanel9.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel9.Location = new System.Drawing.Point(3, 17); this.flowLayoutPanel9.Name = "flowLayoutPanel9"; - this.flowLayoutPanel9.Size = new System.Drawing.Size(693, 30); + this.flowLayoutPanel9.Size = new System.Drawing.Size(737, 30); this.flowLayoutPanel9.TabIndex = 0; // // chkStartCycle @@ -464,7 +464,7 @@ private void InitializeComponent() this.flowLayoutPanel10.Controls.Add(this.label4); this.flowLayoutPanel10.Enabled = false; this.flowLayoutPanel10.Location = new System.Drawing.Point(104, 2); - this.flowLayoutPanel10.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.flowLayoutPanel10.Margin = new System.Windows.Forms.Padding(2); this.flowLayoutPanel10.Name = "flowLayoutPanel10"; this.flowLayoutPanel10.Size = new System.Drawing.Size(471, 27); this.flowLayoutPanel10.TabIndex = 5; @@ -509,7 +509,7 @@ private void InitializeComponent() // this.nudCycleCount.Anchor = System.Windows.Forms.AnchorStyles.None; this.nudCycleCount.Location = new System.Drawing.Point(227, 2); - this.nudCycleCount.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.nudCycleCount.Margin = new System.Windows.Forms.Padding(2); this.nudCycleCount.Maximum = new decimal(new int[] { 10000000, 0, @@ -534,7 +534,7 @@ private void InitializeComponent() // this.nudInterval.Anchor = System.Windows.Forms.AnchorStyles.None; this.nudInterval.Location = new System.Drawing.Point(361, 2); - this.nudInterval.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.nudInterval.Margin = new System.Windows.Forms.Padding(2); this.nudInterval.Maximum = new decimal(new int[] { 10000, 0, @@ -800,7 +800,7 @@ private void InitializeComponent() // btnRefresh // this.btnRefresh.Location = new System.Drawing.Point(2, 2); - this.btnRefresh.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnRefresh.Margin = new System.Windows.Forms.Padding(2); this.btnRefresh.Name = "btnRefresh"; this.btnRefresh.Size = new System.Drawing.Size(88, 23); this.btnRefresh.TabIndex = 5; @@ -1013,7 +1013,7 @@ private void InitializeComponent() this.lblOverTime.Anchor = System.Windows.Forms.AnchorStyles.None; this.lblOverTime.AutoSize = true; this.lblOverTime.Location = new System.Drawing.Point(3, 7); - this.lblOverTime.Margin = new System.Windows.Forms.Padding(3, 3, 3, 3); + this.lblOverTime.Margin = new System.Windows.Forms.Padding(3); this.lblOverTime.Name = "lblOverTime"; this.lblOverTime.Size = new System.Drawing.Size(29, 12); this.lblOverTime.TabIndex = 5; @@ -1029,7 +1029,7 @@ private void InitializeComponent() 0}); this.nudTimeout.Location = new System.Drawing.Point(38, 3); this.nudTimeout.Maximum = new decimal(new int[] { - 10000, + 20000, 0, 0, 0}); diff --git a/VISAInstrument/FrmMain.cs b/VISAInstrument/FrmMain.cs index 46214b0..41908c5 100644 --- a/VISAInstrument/FrmMain.cs +++ b/VISAInstrument/FrmMain.cs @@ -27,10 +27,13 @@ private void radioButton_CheckedChanged(object sender, EventArgs e) { if(rbtRS232 == sender as RadioButton) { + rdoSpecifiedCount.Text = "读取指定字节数量"; this.tableLayoutPanel.RowStyles[2].Height = 35F; - this.tableLayoutPanel.RowStyles[3].Height = 0F; + this.tableLayoutPanel.RowStyles[3].Height = 0F; + return; } + rdoSpecifiedCount.Text = "读取指定字节数量或收到结束符"; if (rbtLAN == sender as RadioButton) { this.tableLayoutPanel.RowStyles[2].Height = 0F; @@ -375,7 +378,10 @@ private void btnOpen_Click(object sender, EventArgs e) chkRealTimeReceive.Enabled = true; BindOrRemoveDataReceivedEvent(); } - else chkRealTimeReceive.Enabled = false; + else + { + chkRealTimeReceive.Enabled = false; + } EnableControl(false); chkStartCycle_CheckedChanged(null, null); @@ -583,6 +589,17 @@ private void rdoAsciiByte_CheckedChanged(object sender, EventArgs e) private void rdoUntilNewLineSpecifiedCount_CheckedChanged(object sender, EventArgs e) { + if (_portOperatorBase is RS232PortOperator portOperator) + { + if (rdoUntilNewLine.Checked) + { + portOperator.SetReadTerminationCharacterEnabled(true); + } + else + { + portOperator.SetReadTerminationCharacterEnabled(false); + } + } nudSpecifiedCount.Enabled = !rdoUntilNewLine.Checked; } diff --git a/VISAInstrument/Port/PortOperator.cs b/VISAInstrument/Port/PortOperator.cs index 6a2d022..d371156 100644 --- a/VISAInstrument/Port/PortOperator.cs +++ b/VISAInstrument/Port/PortOperator.cs @@ -63,6 +63,11 @@ public RS232PortOperator(string address,int baudRate,SerialParity parity, Serial serialSession = (SerialSession)Session; } + public void SetReadTerminationCharacterEnabled(bool enabled) + { + serialSession.ReadTermination = enabled?SerialTerminationMethod.TerminationCharacter: SerialTerminationMethod.None; + } + public override void Open() { base.Open(); diff --git a/VISAInstrument/Properties/AssemblyInfo.cs b/VISAInstrument/Properties/AssemblyInfo.cs index da924e1..cc42b35 100644 --- a/VISAInstrument/Properties/AssemblyInfo.cs +++ b/VISAInstrument/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0.4")] -[assembly: AssemblyFileVersion("1.3.0.4")] +[assembly: AssemblyVersion("1.3.0.5")] +[assembly: AssemblyFileVersion("1.3.0.5")]