From 5dada9781ad4be7de9fa39b022a768cb9fde0b6a Mon Sep 17 00:00:00 2001 From: Erick Kinnee Date: Thu, 7 Mar 2019 06:16:19 -0600 Subject: [PATCH] Some re-org. Working on the Forms app so we can test the dll. --- SharpCAT.sln | 2 +- SharpCAT/Models/CATCommand.cs | 2 +- SharpCAT/Models/Radio.cs | 2 +- SharpCAT/Models/Radios/Icom/ID4100a.cs | 2 +- SharpCAT/Models/Radios/Icom/ID880H.cs | 2 +- SharpCAT/Models/Radios/Kenwood/THD74A.cs | 2 +- SharpCAT/Models/Radios/Yaesu/FT818.cs | 2 +- SharpCAT/Serial.cs | 46 +------ SharpCAT/SharpCAT.cs | 13 +- .../{SharpCAT.csproj => SharpCATLib.csproj} | 0 SharpCATForms/Form1.Designer.cs | 32 ++++- SharpCATForms/Form1.cs | 5 + SharpCATForms/Form1.resx | 120 ++++++++++++++++++ SharpCATForms/Program.cs | 6 +- SharpCATForms/SharpCATForms.csproj | 15 ++- SharpCATForms/packages.config | 4 + 16 files changed, 199 insertions(+), 56 deletions(-) rename SharpCAT/{SharpCAT.csproj => SharpCATLib.csproj} (100%) create mode 100644 SharpCATForms/Form1.resx create mode 100644 SharpCATForms/packages.config diff --git a/SharpCAT.sln b/SharpCAT.sln index 1a8fca1..7f838cf 100644 --- a/SharpCAT.sln +++ b/SharpCAT.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.28307.421 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCATForms", "SharpCATForms\SharpCATForms.csproj", "{3483B368-338A-4BE3-AEB9-460E374B2C99}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpCAT", "SharpCAT\SharpCAT.csproj", "{DAD3E7BE-905A-4768-A695-0BCF96171E35}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpCATLib", "SharpCAT\SharpCATLib.csproj", "{DAD3E7BE-905A-4768-A695-0BCF96171E35}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/SharpCAT/Models/CATCommand.cs b/SharpCAT/Models/CATCommand.cs index fb61b65..a9ba3f2 100644 --- a/SharpCAT/Models/CATCommand.cs +++ b/SharpCAT/Models/CATCommand.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharpCAT +namespace SharpCATLib { class CATCommand { diff --git a/SharpCAT/Models/Radio.cs b/SharpCAT/Models/Radio.cs index b78f4ad..b5d656f 100644 --- a/SharpCAT/Models/Radio.cs +++ b/SharpCAT/Models/Radio.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharpCAT.Models +namespace SharpCATLib.Models { //Base Radio Model class Radio diff --git a/SharpCAT/Models/Radios/Icom/ID4100a.cs b/SharpCAT/Models/Radios/Icom/ID4100a.cs index 85d94dc..4dafcd6 100644 --- a/SharpCAT/Models/Radios/Icom/ID4100a.cs +++ b/SharpCAT/Models/Radios/Icom/ID4100a.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharpCAT.Models.Radios.Icom +namespace SharpCATLib.Models.Radios.Icom { class ID4100a : Radio { diff --git a/SharpCAT/Models/Radios/Icom/ID880H.cs b/SharpCAT/Models/Radios/Icom/ID880H.cs index a8dee6d..d3d2c71 100644 --- a/SharpCAT/Models/Radios/Icom/ID880H.cs +++ b/SharpCAT/Models/Radios/Icom/ID880H.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharpCAT.Models.Radios.Icom +namespace SharpCATLib.Models.Radios.Icom { class ID880H : Radio { diff --git a/SharpCAT/Models/Radios/Kenwood/THD74A.cs b/SharpCAT/Models/Radios/Kenwood/THD74A.cs index 0c56edb..ead498c 100644 --- a/SharpCAT/Models/Radios/Kenwood/THD74A.cs +++ b/SharpCAT/Models/Radios/Kenwood/THD74A.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace SharpCAT.Models.Radios.Kenwood +namespace SharpCATLib.Models.Radios.Kenwood { class THD74A : Radio { diff --git a/SharpCAT/Models/Radios/Yaesu/FT818.cs b/SharpCAT/Models/Radios/Yaesu/FT818.cs index 16ff554..588410a 100644 --- a/SharpCAT/Models/Radios/Yaesu/FT818.cs +++ b/SharpCAT/Models/Radios/Yaesu/FT818.cs @@ -1,4 +1,4 @@ -namespace SharpCAT.Models.Radios.Yaesu +namespace SharpCATLib.Models.Radios.Yaesu { internal class FT818 : Radio { diff --git a/SharpCAT/Serial.cs b/SharpCAT/Serial.cs index d616ec8..7e2d604 100644 --- a/SharpCAT/Serial.cs +++ b/SharpCAT/Serial.cs @@ -1,45 +1,12 @@ using System; using System.IO.Ports; -using System.Threading; -namespace SharpCAT +namespace SharpCATLib { public class Serial { private SerialPort _serialPort; - public string[] PortNames { get => SerialPort.GetPortNames(); } - public static int[] BaudRates { get; } = new int[] { 1200, 2400, 4800, 9600, 19200, 38400 }; - - public static int[] DataBits { get; } = new int[] { 7, 8 }; - - public enum Parity - { - Even = System.IO.Ports.Parity.Even, - Mark = System.IO.Ports.Parity.Mark, - None = System.IO.Ports.Parity.None, - Odd = System.IO.Ports.Parity.Odd, - Space = System.IO.Ports.Parity.Space - } - - public enum StopBits - { - None = System.IO.Ports.StopBits.None, - One = System.IO.Ports.StopBits.One, - OnePointFive = System.IO.Ports.StopBits.OnePointFive, - Two = System.IO.Ports.StopBits.Two - } - - public enum Handshake - { - None = System.IO.Ports.Handshake.None, - RequestToSend = System.IO.Ports.Handshake.RequestToSend, - RequestToSendXOnXOff = System.IO.Ports.Handshake.RequestToSendXOnXOff, - XOnXOff = System.IO.Ports.Handshake.XOnXOff - } - - private readonly string CmdPad = "00000000"; - public Serial(string portname, int baudrate, Parity parity, StopBits bits, Handshake handshake) { _serialPort = new SerialPort @@ -48,9 +15,9 @@ namespace SharpCAT WriteTimeout = 500, PortName = portname, BaudRate = baudrate, - Parity = (System.IO.Ports.Parity)parity, - StopBits = (System.IO.Ports.StopBits)bits, - Handshake = (System.IO.Ports.Handshake)handshake + Parity = parity, + StopBits = bits, + Handshake = handshake }; _serialPort.DataReceived += new SerialDataReceivedEventHandler(SerialDataReceived); @@ -59,22 +26,18 @@ namespace SharpCAT private void SerialErrorReceived(object sender, SerialErrorReceivedEventArgs e) { - } private void SerialDataReceived(object sender, SerialDataReceivedEventArgs e) { - } public void ProbeSerialPort(SerialPort port) { - } public void Read() { - try { string message = _serialPort.ReadLine(); @@ -82,6 +45,5 @@ namespace SharpCAT } catch (TimeoutException) { } } - } } \ No newline at end of file diff --git a/SharpCAT/SharpCAT.cs b/SharpCAT/SharpCAT.cs index e472579..dd8dc20 100644 --- a/SharpCAT/SharpCAT.cs +++ b/SharpCAT/SharpCAT.cs @@ -1,4 +1,6 @@ -namespace SharpCAT +using System.IO.Ports; + +namespace SharpCATLib { public class SharpCAT { @@ -14,5 +16,14 @@ 365, 371, 411, 412, 413, 423, 431, 432, 445, 446, 452, 454, 455, 462, 464, 465, 466, 503, 506, 516, 523, 526, 532, 546, 565, 606, 612, 624, 627, 631, 632, 654, 662, 664, 703, 712, 723, 731, 732, 734, 743, 754 }; + + public string[] PortNames { get => SerialPort.GetPortNames(); } + + public static int[] BaudRates { get; } = new int[] { 1200, 2400, 4800, 9600, 19200, 38400 }; + + public static int[] DataBits { get; } = new int[] { 7, 8 }; + + private readonly string CmdPad = "00000000"; + } } \ No newline at end of file diff --git a/SharpCAT/SharpCAT.csproj b/SharpCAT/SharpCATLib.csproj similarity index 100% rename from SharpCAT/SharpCAT.csproj rename to SharpCAT/SharpCATLib.csproj diff --git a/SharpCATForms/Form1.Designer.cs b/SharpCATForms/Form1.Designer.cs index af3e729..70be0c9 100644 --- a/SharpCATForms/Form1.Designer.cs +++ b/SharpCATForms/Form1.Designer.cs @@ -28,13 +28,43 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.ComPorts = new System.Windows.Forms.ListBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // ComPorts + // + this.ComPorts.FormattingEnabled = true; + this.ComPorts.Location = new System.Drawing.Point(229, 25); + this.ComPorts.Name = "ComPorts"; + this.ComPorts.Size = new System.Drawing.Size(120, 95); + this.ComPorts.TabIndex = 0; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(98, 335); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(100, 20); + this.textBox1.TabIndex = 1; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.textBox1); + this.Controls.Add(this.ComPorts); + this.Name = "Form1"; this.Text = "Form1"; + this.ResumeLayout(false); + this.PerformLayout(); + } #endregion + + private System.Windows.Forms.ListBox ComPorts; + private System.Windows.Forms.TextBox textBox1; } } diff --git a/SharpCATForms/Form1.cs b/SharpCATForms/Form1.cs index 10a3fc8..18992de 100644 --- a/SharpCATForms/Form1.cs +++ b/SharpCATForms/Form1.cs @@ -1,4 +1,5 @@ using System.Windows.Forms; +using SharpCATLib; namespace SharpCATForms { @@ -6,7 +7,11 @@ namespace SharpCATForms { public Form1() { + SharpCAT sharpCAT = new SharpCAT(); + InitializeComponent(); + + ComPorts.DataSource = sharpCAT.PortNames; } } } \ No newline at end of file diff --git a/SharpCATForms/Form1.resx b/SharpCATForms/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SharpCATForms/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SharpCATForms/Program.cs b/SharpCATForms/Program.cs index bf0b362..7f8c0a1 100644 --- a/SharpCATForms/Program.cs +++ b/SharpCATForms/Program.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using SharpCATLib; namespace SharpCATForms { @@ -10,11 +11,12 @@ namespace SharpCATForms /// [STAThread] private static void Main() - { - //SharpCAT sharpCAT = new SharpCAT(); + { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); + + } } } \ No newline at end of file diff --git a/SharpCATForms/SharpCATForms.csproj b/SharpCATForms/SharpCATForms.csproj index 988b796..0f8cc36 100644 --- a/SharpCATForms/SharpCATForms.csproj +++ b/SharpCATForms/SharpCATForms.csproj @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -33,11 +34,15 @@ 4 - SharpCATForms.Program + + + + ..\packages\System.IO.Ports.4.5.0\lib\net461\System.IO.Ports.dll + @@ -57,6 +62,9 @@ + + Form1.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -66,6 +74,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs @@ -80,9 +89,9 @@ - + {dad3e7be-905a-4768-a695-0bcf96171e35} - SharpCAT + SharpCATLib diff --git a/SharpCATForms/packages.config b/SharpCATForms/packages.config new file mode 100644 index 0000000..932ac8c --- /dev/null +++ b/SharpCATForms/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file