From 1fdf269489b0c2724a1599caa689c57c3f0dbfc2 Mon Sep 17 00:00:00 2001 From: alexwahl Date: Sat, 17 Mar 2018 21:22:50 +0100 Subject: [PATCH] process frequencies with more or less 9 digits --- .../GlobalSuppressions.cs | Bin 0 -> 2870 bytes SDRSharp.GpredictConnector/Rigctrld.cs | 58 +++++------------- .../SDRSharp.GpredictConnector.csproj | 1 + .../Test_rigctrld_set_frequency.cs | 51 ++++++++++++--- 4 files changed, 59 insertions(+), 51 deletions(-) create mode 100644 SDRSharp.GpredictConnector/GlobalSuppressions.cs diff --git a/SDRSharp.GpredictConnector/GlobalSuppressions.cs b/SDRSharp.GpredictConnector/GlobalSuppressions.cs new file mode 100644 index 0000000000000000000000000000000000000000..22456ebb3f54d473f1d63c2c459a350659c82774 GIT binary patch literal 2870 zcmeH}OKTHh6o$`Q@IMT3qhM3JRB#ckw}o0vq@cK%CX+fQnS_~1i~ZrQM17xgGMz+| zx)D(*fy{R~m-pPi@88~AYL$MO&FsXc_Sqg-VtsuptNpZVhn9=#)C!yXX>LP(yY^W7 zk!X6lNu9S6B{zLr+Csllw@81v`XVK>+t$$uQc9ONx3P4g2kP84b?mNibflwa2X;@t z`$7iAP?}Pg{KU?*FU0#?Cxx&~wJ#+DWTn##b&FLYuP^SoaAlJH(B;px#&YuH&k=#RiD{YospX(oss8r zRWQ3pI^9OUtDfqW&OcpCzpu9=;a#eC0Ek6K 0) + { + if (matches[0].Groups.Count == 2) + { + var f_string = matches[0].Groups[1].Value; + frequency_set_thread_ = new Thread(() => FrequencyInHzString = f_string); + frequency_set_thread_.Start(); + } + } } - return answer; - } - - private string SetFrequency(string command) - { - var f_string = command.Substring(3, 9); - frequency_set_thread_ = new Thread(() => FrequencyInHzString = f_string); - frequency_set_thread_.Start(); - return GenAnswer(Errcode.RIG_OK); + return "RPRT 0\n"; } public long FrequencyInHz @@ -72,6 +41,7 @@ private set } } + public string FrequencyInHzString { get diff --git a/SDRSharp.GpredictConnector/SDRSharp.GpredictConnector.csproj b/SDRSharp.GpredictConnector/SDRSharp.GpredictConnector.csproj index 6a21c69..c06368b 100644 --- a/SDRSharp.GpredictConnector/SDRSharp.GpredictConnector.csproj +++ b/SDRSharp.GpredictConnector/SDRSharp.GpredictConnector.csproj @@ -64,6 +64,7 @@ Controlpanel.cs + diff --git a/UnitTestGpredictConnector/Test_rigctrld_set_frequency.cs b/UnitTestGpredictConnector/Test_rigctrld_set_frequency.cs index 6e8ac96..66a9df4 100644 --- a/UnitTestGpredictConnector/Test_rigctrld_set_frequency.cs +++ b/UnitTestGpredictConnector/Test_rigctrld_set_frequency.cs @@ -1,9 +1,5 @@ -using System; -using System.Text; -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using SDRSharp.GpredictConnector; -using System.Threading; namespace UnitTestGpredictConnector { @@ -62,15 +58,56 @@ public void Initialize() [TestMethod] public void SetFrequency_F__144800123() { - Rigctrld cut = new Rigctrld(); TestHelper_SetFrequency(expected_freq: 144800123, command: "F 144800123"); } + [TestMethod] + public void SetFrequency_F__1GHZ() + { + TestHelper_SetFrequency(expected_freq: 1234567890, command: "F 1234567890"); + } + [TestMethod] + public void SetFrequency_F__10m() + { + TestHelper_SetFrequency(expected_freq: 29420877, command: "F 29420877"); + } + + [TestMethod] + public void SetFrequency_F_144800123() + { + TestHelper_SetFrequency(expected_freq: 144800123, command: "F 144800123"); + } + + [TestMethod] + public void SetFrequency_F_00144800123() + { + TestHelper_SetFrequency(expected_freq: 144800123, command: "F 00144800123"); + } + + [TestMethod] + public void SetFrequency_F_1GHZ() + { + TestHelper_SetFrequency(expected_freq: 1234567890, command: "F 1234567890"); + } + [TestMethod] + public void SetFrequency_F_10m() + { + TestHelper_SetFrequency(expected_freq: 29420877, command: "F 29420877"); + } + + [TestMethod] + public void SetFrequency_unparseableFreq() + { + Assert.AreEqual("RPRT 0\n", class_under_test_.ExecCommand("F 1234d567890")); + Assert.IsNull(class_under_test_.FrequencySetThread); + Assert.AreEqual(0, class_under_test_.FrequencyInHz); + } private void TestHelper_SetFrequency(long expected_freq, string command) { long result_freq = 0; + class_under_test_.FrequencyInHzChanged += x => result_freq = x; - class_under_test_.ExecCommand(command); + Assert.AreEqual("RPRT 0\n", class_under_test_.ExecCommand(command)); Assert.IsNotNull(class_under_test_.FrequencySetThread); // should be running class_under_test_.FrequencySetThread.Join(); // wait for the freqeuncy set thread to finish his work Assert.AreEqual(expected_freq, class_under_test_.FrequencyInHz);