From 57744dfb6a7c25d9cb55525349f65da94b5eb634 Mon Sep 17 00:00:00 2001 From: Erick Kinnee Date: Fri, 8 Mar 2019 13:04:43 -0600 Subject: [PATCH] Formatting and cleanup. --- SharpCAT/Models/CATCommand.cs | 10 ++-- SharpCAT/Models/CATRadio.cs | 23 ++++----- SharpCAT/Models/CIVCommand.cs | 18 +++---- SharpCAT/Models/CIVRadio.cs | 10 ++-- SharpCAT/Radios/Icom/ID4100a.cs | 14 +++--- SharpCAT/Radios/Icom/ID4100a.json | 3 +- SharpCAT/Radios/Icom/ID880H.cs | 11 ++-- SharpCAT/Radios/Icom/ID880H.json | 3 +- SharpCAT/Radios/Kenwood/THD74A.cs | 11 ++-- SharpCAT/Radios/Kenwood/THD74A.json | 3 +- SharpCAT/Radios/Yaesu/FT818.cs | 50 +++++++++---------- SharpCAT/Radios/Yaesu/FT818.json | 3 +- SharpCAT/Serial.cs | 5 +- SharpCAT/SerialClient.cs | 10 ++-- SharpCAT/SerialServer.cs | 10 ++-- SharpCAT/SharpCAT.cs | 34 +++++-------- SharpCAT/Socket.cs | 10 ++-- SharpCATConsole/App.config | 6 +-- SharpCATConsole/Program.cs | 18 +++---- SharpCATConsole/Properties/AssemblyInfo.cs | 3 +- SharpCATService/App.config | 6 +-- SharpCATService/Client.cs | 12 ++--- SharpCATService/Program.cs | 15 ++---- SharpCATService/Properties/AssemblyInfo.cs | 3 +- SharpCATService/Server.cs | 12 ++--- ...rvice1.Designer.cs => Service.Designer.cs} | 2 +- SharpCATService/Service.cs | 20 ++++++++ SharpCATService/Service1.cs | 28 ----------- SharpCATService/SharpCATService.csproj | 6 +-- 29 files changed, 139 insertions(+), 220 deletions(-) rename SharpCATService/{Service1.Designer.cs => Service.Designer.cs} (97%) create mode 100644 SharpCATService/Service.cs delete mode 100644 SharpCATService/Service1.cs diff --git a/SharpCAT/Models/CATCommand.cs b/SharpCAT/Models/CATCommand.cs index a9ba3f2..a618e6c 100644 --- a/SharpCAT/Models/CATCommand.cs +++ b/SharpCAT/Models/CATCommand.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib +namespace SharpCATLib.Models { - class CATCommand + internal class CATCommand { public string P1 { get; set; } public string P2 { get; set; } @@ -12,4 +8,4 @@ namespace SharpCATLib public string P4 { get; set; } public string OpCode { get; set; } } -} +} \ No newline at end of file diff --git a/SharpCAT/Models/CATRadio.cs b/SharpCAT/Models/CATRadio.cs index 8209480..b347cae 100644 --- a/SharpCAT/Models/CATRadio.cs +++ b/SharpCAT/Models/CATRadio.cs @@ -3,19 +3,19 @@ //Base Radio Model public partial class CATRadio { - string RadioMfg { get; } - string RadioModel { get; } + private string RadioMfg { get; } + private string RadioModel { get; } - string CmdPad { get; } + private string CmdPad { get; } = "00000000"; - string VFOToggle { get; } - Lock Lock { get; } - Ptt Ptt { get; } - Clar Clar { get; } - Split Split { get; } - Power Power { get; } - ToneMode ToneMode { get; } - OpModes OpModes { get; } + private string VFOToggle { get; } + private Lock Lock { get; } + private Ptt Ptt { get; } + private Clar Clar { get; } + private Split Split { get; } + private Power Power { get; } + private ToneMode ToneMode { get; } + private OpModes OpModes { get; } partial void LockOn(); @@ -101,5 +101,4 @@ public static readonly string DIG; public static readonly string PKT; } - } \ No newline at end of file diff --git a/SharpCAT/Models/CIVCommand.cs b/SharpCAT/Models/CIVCommand.cs index d796004..5c02fd5 100644 --- a/SharpCAT/Models/CIVCommand.cs +++ b/SharpCAT/Models/CIVCommand.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib.Models +namespace SharpCATLib.Models { - class CIVCommand + internal class CIVCommand { - string CmdToRadio = "FE FE 9A E0 Cn Sc Data area FD"; - string DataFromRadio = "FE FE E0 9A Cn Sc Data area FD"; - string OKFromRadio { get; set; } - string NGFromRadio { get; set; } + private string CmdToRadio = "FE FE 9A E0 Cn Sc Data area FD"; + private string DataFromRadio = "FE FE E0 9A Cn Sc Data area FD"; + private string OKFromRadio { get; set; } + private string NGFromRadio { get; set; } } -} +} \ No newline at end of file diff --git a/SharpCAT/Models/CIVRadio.cs b/SharpCAT/Models/CIVRadio.cs index 4d64503..c0252ef 100644 --- a/SharpCAT/Models/CIVRadio.cs +++ b/SharpCAT/Models/CIVRadio.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib.Models +namespace SharpCATLib.Models { - class CIVRadio + internal class CIVRadio { } -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Icom/ID4100a.cs b/SharpCAT/Radios/Icom/ID4100a.cs index b1ef79f..95d21c3 100644 --- a/SharpCAT/Radios/Icom/ID4100a.cs +++ b/SharpCAT/Radios/Icom/ID4100a.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; +using SharpCATLib.Models; -namespace SharpCATLib.Models.Radios.Icom +namespace SharpCATLib.Radios.Icom { - class ID4100a : CIVRadio + internal class ID4100a : CIVRadio { - string OKFromRadio = "FEFEE09AFBFD"; - string NGFromRadio = "FEFEE09AFAFD"; + private string OKFromRadio = "FEFEE09AFBFD"; + private string NGFromRadio = "FEFEE09AFAFD"; } -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Icom/ID4100a.json b/SharpCAT/Radios/Icom/ID4100a.json index 0db3279..7a73a41 100644 --- a/SharpCAT/Radios/Icom/ID4100a.json +++ b/SharpCAT/Radios/Icom/ID4100a.json @@ -1,3 +1,2 @@ { - -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Icom/ID880H.cs b/SharpCAT/Radios/Icom/ID880H.cs index b5e1b92..4bcbb03 100644 --- a/SharpCAT/Radios/Icom/ID880H.cs +++ b/SharpCAT/Radios/Icom/ID880H.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib.Models.Radios.Icom +namespace SharpCATLib.Radios.Icom { - class ID880H + internal class ID880H { - } -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Icom/ID880H.json b/SharpCAT/Radios/Icom/ID880H.json index 0db3279..7a73a41 100644 --- a/SharpCAT/Radios/Icom/ID880H.json +++ b/SharpCAT/Radios/Icom/ID880H.json @@ -1,3 +1,2 @@ { - -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Kenwood/THD74A.cs b/SharpCAT/Radios/Kenwood/THD74A.cs index 278f223..5711d9d 100644 --- a/SharpCAT/Radios/Kenwood/THD74A.cs +++ b/SharpCAT/Radios/Kenwood/THD74A.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib.Models.Radios.Kenwood +namespace SharpCATLib.Radios.Kenwood { - class THD74A + internal class THD74A { - } -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Kenwood/THD74A.json b/SharpCAT/Radios/Kenwood/THD74A.json index 0db3279..7a73a41 100644 --- a/SharpCAT/Radios/Kenwood/THD74A.json +++ b/SharpCAT/Radios/Kenwood/THD74A.json @@ -1,3 +1,2 @@ { - -} +} \ No newline at end of file diff --git a/SharpCAT/Radios/Yaesu/FT818.cs b/SharpCAT/Radios/Yaesu/FT818.cs index 10e7c37..9f7cd3f 100644 --- a/SharpCAT/Radios/Yaesu/FT818.cs +++ b/SharpCAT/Radios/Yaesu/FT818.cs @@ -1,14 +1,14 @@ -using SharpCATLib; +using SharpCATLib.Models; -namespace SharpCATLib.Models.Radios.Yaesu +namespace SharpCATLib.Radios.Yaesu { public class FT818 : CATRadio { public string RadioMfg => "Yaesu"; public string RadioModel => "FT-818"; - public string CmdPad => "00000000"; - + public string CmdPad => "00000000"; + public class Lock { public static readonly string ON = "00"; @@ -61,87 +61,87 @@ namespace SharpCATLib.Models.Radios.Yaesu public static readonly string PKT = "0C"; } - string LockOn() - { - return ""; - } - - string LockOff() + private string LockOn() { return ""; } - string PttOn() + private string LockOff() { return ""; } - string PttOff() + private string PttOn() { return ""; } - string ClarOn() + private string PttOff() { return ""; } - string ClarOff() + private string ClarOn() { return ""; } - string SplitOn() + private string ClarOff() { return ""; } - string SplitOff() + private string SplitOn() { return ""; } - string PowerOn() + private string SplitOff() { return ""; } - string PowerOff() + private string PowerOn() { return ""; } - string SetFreq(double freq) + private string PowerOff() { return ""; } - string SetOpMode(OpModes opmode) + private string SetFreq(double freq) { return ""; } - string SwitchVFO() + private string SetOpMode(OpModes opmode) { return ""; } - string SetToneMode(ToneMode mode) + private string SwitchVFO() { return ""; } - string GetRXStatus() + private string SetToneMode(ToneMode mode) { return ""; } - string GetTXStatus() + private string GetRXStatus() { return ""; } - string GetFreqAndModeStatus() + private string GetTXStatus() + { + return ""; + } + + private string GetFreqAndModeStatus() { return ""; } diff --git a/SharpCAT/Radios/Yaesu/FT818.json b/SharpCAT/Radios/Yaesu/FT818.json index 0db3279..7a73a41 100644 --- a/SharpCAT/Radios/Yaesu/FT818.json +++ b/SharpCAT/Radios/Yaesu/FT818.json @@ -1,3 +1,2 @@ { - -} +} \ No newline at end of file diff --git a/SharpCAT/Serial.cs b/SharpCAT/Serial.cs index 7e2d604..8b39baa 100644 --- a/SharpCAT/Serial.cs +++ b/SharpCAT/Serial.cs @@ -7,14 +7,15 @@ namespace SharpCATLib { private SerialPort _serialPort; - public Serial(string portname, int baudrate, Parity parity, StopBits bits, Handshake handshake) + //Init + public Serial(string portname, SharpCAT.BaudRates baudrate, Parity parity, StopBits bits, Handshake handshake) { _serialPort = new SerialPort { ReadTimeout = 500, WriteTimeout = 500, PortName = portname, - BaudRate = baudrate, + BaudRate = (int)baudrate, Parity = parity, StopBits = bits, Handshake = handshake diff --git a/SharpCAT/SerialClient.cs b/SharpCAT/SerialClient.cs index a8a16a7..6990f42 100644 --- a/SharpCAT/SerialClient.cs +++ b/SharpCAT/SerialClient.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib +namespace SharpCATLib { - class SerialClient + internal class SerialClient { } -} +} \ No newline at end of file diff --git a/SharpCAT/SerialServer.cs b/SharpCAT/SerialServer.cs index 18ad1cd..8e8fc9e 100644 --- a/SharpCAT/SerialServer.cs +++ b/SharpCAT/SerialServer.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib +namespace SharpCATLib { - class SerialServer + internal class SerialServer { } -} +} \ No newline at end of file diff --git a/SharpCAT/SharpCAT.cs b/SharpCAT/SharpCAT.cs index f3b1c05..92361f5 100644 --- a/SharpCAT/SharpCAT.cs +++ b/SharpCAT/SharpCAT.cs @@ -1,30 +1,17 @@ -using SharpCATLib; -using System; +using System.Collections.Generic; using System.IO.Ports; namespace SharpCATLib { public class SharpCAT { - delegate string OnPortsSelected(string[] portnames); + private delegate string OnPortsSelected(string[] portnames); - event OnPortsSelected PortsSelected; + private static event OnPortsSelected PortsSelected; - public SharpCAT() - { - PortsSelected += new OnPortsSelected(ConnectPorts); - } + public SharpCAT() => SharpCAT.PortsSelected += new OnPortsSelected(ConnectPorts); - private string[] _portstouse; - public string[] PortsToUse - { - get => _portstouse; - set - { - _portstouse = value; - PortsSelected.Invoke(_portstouse); - } - } + public string[] PortsToUse { get; set; } public double[] CTCSSTones = { 67.0, 69.3, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123, 127.3, 131.8, @@ -41,18 +28,21 @@ namespace SharpCATLib public string[] PortNames { get => SerialPort.GetPortNames(); } - public static int[] BaudRates { get; } = new int[] { 1200, 2400, 4800, 9600, 19200, 38400 }; + public enum BaudRates : int { TwelveHundred = 1200, TwentyFourHundred = 2400, FourtyEightHUndred = 4800, NinteySixHundred = 9600, NineteenTwo = 19200, ThirtyEightFour = 38400 }; public static int[] DataBits { get; } = new int[] { 7, 8 }; public static string[] RadioTypes { get; } = new string[] { "CAT", "CIV" }; - private readonly string CATCmdPad = "00000000"; - private string ConnectPorts(string[] portnames) { + List ports = new List(); + + foreach (string port in portnames) + { + ports.Add(new Serial("COM11", BaudRates.ThirtyEightFour, Parity.None, StopBits.Two, Handshake.None)); + } return ""; } - } } \ No newline at end of file diff --git a/SharpCAT/Socket.cs b/SharpCAT/Socket.cs index 89ea75b..d51f562 100644 --- a/SharpCAT/Socket.cs +++ b/SharpCAT/Socket.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SharpCATLib +namespace SharpCATLib { - class Socket + internal class Socket { } -} +} \ No newline at end of file diff --git a/SharpCATConsole/App.config b/SharpCATConsole/App.config index 56efbc7..0f3b743 100644 --- a/SharpCATConsole/App.config +++ b/SharpCATConsole/App.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/SharpCATConsole/Program.cs b/SharpCATConsole/Program.cs index 2fdc4ba..7d755ae 100644 --- a/SharpCATConsole/Program.cs +++ b/SharpCATConsole/Program.cs @@ -1,24 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using SharpCATLib; +using SharpCATLib; +using System; namespace SharpCATConsole { - class Program + internal class Program { - static void Main(string[] args) + private static void Main(string[] args) { SharpCAT sharpCAT = new SharpCAT(); - + Console.WriteLine("Ports found: "); foreach (var port in sharpCAT.PortNames) { Console.WriteLine(port); } - + Console.ReadKey(); } @@ -27,4 +23,4 @@ namespace SharpCATConsole throw new NotImplementedException(); } } -} +} \ No newline at end of file diff --git a/SharpCATConsole/Properties/AssemblyInfo.cs b/SharpCATConsole/Properties/AssemblyInfo.cs index 8adc79b..70dd7a1 100644 --- a/SharpCATConsole/Properties/AssemblyInfo.cs +++ b/SharpCATConsole/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -33,4 +32,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SharpCATService/App.config b/SharpCATService/App.config index 56efbc7..0f3b743 100644 --- a/SharpCATService/App.config +++ b/SharpCATService/App.config @@ -1,6 +1,6 @@  - - - + + + \ No newline at end of file diff --git a/SharpCATService/Client.cs b/SharpCATService/Client.cs index becf21d..6f1dd42 100644 --- a/SharpCATService/Client.cs +++ b/SharpCATService/Client.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SharpCATService +namespace SharpCATService { - class Client + internal class Client { } -} +} \ No newline at end of file diff --git a/SharpCATService/Program.cs b/SharpCATService/Program.cs index bcfd883..b62f4c2 100644 --- a/SharpCATService/Program.cs +++ b/SharpCATService/Program.cs @@ -1,25 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceProcess; -using System.Text; -using System.Threading.Tasks; +using System.ServiceProcess; namespace SharpCATService { - static class Program + internal static class Program { /// /// The main entry point for the application. /// - static void Main() + private static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { - new Service1() + new Service() }; ServiceBase.Run(ServicesToRun); } } -} +} \ No newline at end of file diff --git a/SharpCATService/Properties/AssemblyInfo.cs b/SharpCATService/Properties/AssemblyInfo.cs index 17d08cf..30390dd 100644 --- a/SharpCATService/Properties/AssemblyInfo.cs +++ b/SharpCATService/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -33,4 +32,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/SharpCATService/Server.cs b/SharpCATService/Server.cs index 8749a5f..15c0c27 100644 --- a/SharpCATService/Server.cs +++ b/SharpCATService/Server.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SharpCATService +namespace SharpCATService { - class Server + internal class Server { } -} +} \ No newline at end of file diff --git a/SharpCATService/Service1.Designer.cs b/SharpCATService/Service.Designer.cs similarity index 97% rename from SharpCATService/Service1.Designer.cs rename to SharpCATService/Service.Designer.cs index b8e1e2d..69e1b56 100644 --- a/SharpCATService/Service1.Designer.cs +++ b/SharpCATService/Service.Designer.cs @@ -1,6 +1,6 @@ namespace SharpCATService { - partial class Service1 + partial class Service { /// /// Required designer variable. diff --git a/SharpCATService/Service.cs b/SharpCATService/Service.cs new file mode 100644 index 0000000..0d2dc22 --- /dev/null +++ b/SharpCATService/Service.cs @@ -0,0 +1,20 @@ +using System.ServiceProcess; + +namespace SharpCATService +{ + public partial class Service : ServiceBase + { + public Service() + { + InitializeComponent(); + } + + protected override void OnStart(string[] args) + { + } + + protected override void OnStop() + { + } + } +} \ No newline at end of file diff --git a/SharpCATService/Service1.cs b/SharpCATService/Service1.cs deleted file mode 100644 index 3a0093c..0000000 --- a/SharpCATService/Service1.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.ServiceProcess; -using System.Text; -using System.Threading.Tasks; - -namespace SharpCATService -{ - public partial class Service1 : ServiceBase - { - public Service1() - { - InitializeComponent(); - } - - protected override void OnStart(string[] args) - { - } - - protected override void OnStop() - { - } - } -} diff --git a/SharpCATService/SharpCATService.csproj b/SharpCATService/SharpCATService.csproj index 870fe66..bb51569 100644 --- a/SharpCATService/SharpCATService.csproj +++ b/SharpCATService/SharpCATService.csproj @@ -46,11 +46,11 @@ - + Component - - Service1.cs + + Service.cs