diff --git a/Configurator/Configurator.Net/PresentationModels/AltitudeHoldConfigVm.cs b/Configurator/Configurator.Net/PresentationModels/AltitudeHoldConfigVm.cs
index b0a85b6ac4..5b72be3e31 100644
--- a/Configurator/Configurator.Net/PresentationModels/AltitudeHoldConfigVm.cs
+++ b/Configurator/Configurator.Net/PresentationModels/AltitudeHoldConfigVm.cs
@@ -1,5 +1,13 @@
namespace ArducopterConfigurator.PresentationModels
{
+ ///
+ /// Vm for Altitude hold settings
+ ///
+ ///
+ /// Todo: this one is weird because the APM sends and receives the values
+ /// in a different order
+ /// There is a unit test to cover it but it will need fixing.
+ ///
public class AltitudeHoldConfigVm : MonitorVm
{
public AltitudeHoldConfigVm(IComms sp)
diff --git a/Configurator/Configurator.Net/PresentationModels/CalibrationOffsetsDataVm.cs b/Configurator/Configurator.Net/PresentationModels/CalibrationOffsetsDataVm.cs
index 7b999ab144..741d24b9b4 100644
--- a/Configurator/Configurator.Net/PresentationModels/CalibrationOffsetsDataVm.cs
+++ b/Configurator/Configurator.Net/PresentationModels/CalibrationOffsetsDataVm.cs
@@ -28,13 +28,13 @@ namespace ArducopterConfigurator.PresentationModels
- public int GyroRollOffset { get; set; }
- public int GyroPitchOffset { get; set; }
- public int GyroYawOffset { get; set; }
+ public float GyroRollOffset { get; set; }
+ public float GyroPitchOffset { get; set; }
+ public float GyroYawOffset { get; set; }
- public int AccelRollOffset { get; set; }
- public int AccelPitchOffset { get; set; }
- public int AccelZOffset { get; set; }
+ public float AccelRollOffset { get; set; }
+ public float AccelPitchOffset { get; set; }
+ public float AccelZOffset { get; set; }
protected override void OnActivated()
{
diff --git a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs
index f665a741a1..709b00a715 100644
--- a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs
+++ b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs
@@ -127,7 +127,7 @@ namespace ArducopterConfigurator
int val;
if (!int.TryParse(s, out val))
{
- Debug.WriteLine("Error parsing float: " + s);
+ Debug.WriteLine("Error parsing int: " + s);
break;
}
value = val;
diff --git a/Configurator/Configurator.Net/Test/AcroModeConfigVmTest.cs b/Configurator/Configurator.Net/Test/AcroModeConfigVmTest.cs
index 6a8b3e67a5..a0e02acb6c 100644
--- a/Configurator/Configurator.Net/Test/AcroModeConfigVmTest.cs
+++ b/Configurator/Configurator.Net/Test/AcroModeConfigVmTest.cs
@@ -39,48 +39,4 @@ namespace ArducopterConfiguratorTest
}
- [TestFixture]
- public class AltitudeHoldVmTest : VmTestBase
- {
-
- [SetUp]
- public void Setup()
- {
- sampleLineOfData = "0.800,0.200,0.300";
- getCommand = "F";
- setCommand = "E";
-
- _fakeComms = new FakeComms();
- _vm = new AltitudeHoldConfigVm(_fakeComms);
- }
-
-
- [Test]
- public void UpdateStringSentIsCorrect()
- {
- _vm.P = 1.0F;
- _vm.I = 2.0F;
- _vm.D = 3.0F;
-
- _vm.UpdateCommand.Execute(null);
-
- Assert.AreEqual(1, _fakeComms.SentItems.Count);
- Assert.AreEqual("E1;3;2", _fakeComms.SentItems[0]);
- }
-
- [Test]
- // For whatever reason, for Altitude the properties are sent in P, D ,I
- // order, but received in P,I,D order
- public void UpdateStringReceivedPopulatesValuesCorrectly()
- {
- _vm.Activate();
- _fakeComms.FireLineRecieve(sampleLineOfData);
-
- Assert.AreEqual(0.8f, _vm.P);
- Assert.AreEqual(0.2f, _vm.I);
- Assert.AreEqual(0.3f, _vm.D);
- }
-
-
- }
}
diff --git a/Configurator/Configurator.Net/Test/AltitudeHoldVmTest.cs b/Configurator/Configurator.Net/Test/AltitudeHoldVmTest.cs
index 1660eead60..9006984975 100644
--- a/Configurator/Configurator.Net/Test/AltitudeHoldVmTest.cs
+++ b/Configurator/Configurator.Net/Test/AltitudeHoldVmTest.cs
@@ -1,44 +1,52 @@
-using ArducopterConfigurator;
+using ArducopterConfigurator.PresentationModels;
using NUnit.Framework;
namespace ArducopterConfiguratorTest
{
- public abstract class VmTestBase where T : MonitorVm
+ [TestFixture]
+ public class AltitudeHoldVmTest : VmTestBase
{
- protected T _vm;
- protected FakeComms _fakeComms;
- protected string sampleLineOfData;
- protected string getCommand;
- protected string setCommand;
- [Test]
- public void ActivateSendsCorrectCommand()
+ [SetUp]
+ public void Setup()
{
- _vm.Activate();
- Assert.AreEqual(1, _fakeComms.SentItems.Count);
- Assert.AreEqual(getCommand, _fakeComms.SentItems[0]);
+ sampleLineOfData = "0.800,0.200,0.300";
+ getCommand = "F";
+ setCommand = "E";
+
+ _fakeComms = new FakeComms();
+ _vm = new AltitudeHoldConfigVm(_fakeComms);
}
+
[Test]
- public void ReceivedDataIgnoredWhenNotActive()
+ // For whatever reason, for Altitude the properties are sent in P, D ,I
+ // order, but received in P,I,D order
+ public void UpdateStringSentIsCorrect()
{
- bool inpcFired = false;
- _vm.PropertyChanged += delegate { inpcFired = true; };
+ _vm.P = 1.0F;
+ _vm.I = 2.0F;
+ _vm.D = 3.0F;
- _fakeComms.FireLineRecieve(sampleLineOfData);
- Assert.False(inpcFired);
+ _vm.UpdateCommand.Execute(null);
+
+ Assert.AreEqual(1, _fakeComms.SentItems.Count);
+ Assert.AreEqual("E1;3;2", _fakeComms.SentItems[0]);
}
[Test]
- public void UpdateStringReceivedPopulatesValues()
+ // For whatever reason, for Altitude the properties are sent in P, D ,I
+ // order, but received in P,I,D order
+ public void UpdateStringReceivedPopulatesValuesCorrectly()
{
- bool inpcFired = false;
- _vm.PropertyChanged += delegate { inpcFired = true; };
-
_vm.Activate();
_fakeComms.FireLineRecieve(sampleLineOfData);
- Assert.True(inpcFired);
+ Assert.AreEqual(0.8f, _vm.P);
+ Assert.AreEqual(0.2f, _vm.I);
+ Assert.AreEqual(0.3f, _vm.D);
}
+
+
}
}
diff --git a/Configurator/Configurator.Net/Test/ArducopterConfiguratorTest.csproj b/Configurator/Configurator.Net/Test/ArducopterConfiguratorTest.csproj
index a1ea511a6c..d17c25de26 100644
--- a/Configurator/Configurator.Net/Test/ArducopterConfiguratorTest.csproj
+++ b/Configurator/Configurator.Net/Test/ArducopterConfiguratorTest.csproj
@@ -42,10 +42,13 @@
+
+
+
diff --git a/Configurator/Configurator.Net/Test/CalibrationOffsetsDataVmTest.cs b/Configurator/Configurator.Net/Test/CalibrationOffsetsDataVmTest.cs
new file mode 100644
index 0000000000..7317fcc2c0
--- /dev/null
+++ b/Configurator/Configurator.Net/Test/CalibrationOffsetsDataVmTest.cs
@@ -0,0 +1,22 @@
+using ArducopterConfigurator.PresentationModels;
+using NUnit.Framework;
+
+namespace ArducopterConfiguratorTest
+{
+ [TestFixture]
+ public class CalibrationOffsetsDataVmTest : VmTestBase
+ {
+
+ [SetUp]
+ public void Setup()
+ {
+ sampleLineOfData = "0.100,0.200,0.300,0.400,0.500,0.600";
+ getCommand = "J";
+ setCommand = "I";
+
+ _fakeComms = new FakeComms();
+ _vm = new CalibrationOffsetsDataVm(_fakeComms);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Configurator/Configurator.Net/Test/PositionHoldConfigVmTest.cs b/Configurator/Configurator.Net/Test/PositionHoldConfigVmTest.cs
new file mode 100644
index 0000000000..dba712e9fe
--- /dev/null
+++ b/Configurator/Configurator.Net/Test/PositionHoldConfigVmTest.cs
@@ -0,0 +1,22 @@
+using ArducopterConfigurator.PresentationModels;
+using NUnit.Framework;
+
+namespace ArducopterConfiguratorTest
+{
+ [TestFixture]
+ public class PositionHoldConfigVmTest : VmTestBase
+ {
+
+ [SetUp]
+ public void Setup()
+ {
+ sampleLineOfData = "0.015,0.005,0.010,0.015,0.005,0.010,22.000,0.870";
+ getCommand = "D";
+ setCommand = "C";
+
+ _fakeComms = new FakeComms();
+ _vm = new PositionHoldConfigVm(_fakeComms);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Configurator/Configurator.Net/Test/VmTestBase.cs b/Configurator/Configurator.Net/Test/VmTestBase.cs
new file mode 100644
index 0000000000..f77b664182
--- /dev/null
+++ b/Configurator/Configurator.Net/Test/VmTestBase.cs
@@ -0,0 +1,57 @@
+using ArducopterConfigurator;
+using NUnit.Framework;
+
+namespace ArducopterConfiguratorTest
+{
+ public abstract class VmTestBase where T : MonitorVm
+ {
+ protected T _vm;
+ protected FakeComms _fakeComms;
+ protected string sampleLineOfData; // should be taken from a real APM if possible
+ protected string getCommand;
+ protected string setCommand;
+
+ [Test]
+ public void ActivateSendsCorrectCommand()
+ {
+ _vm.Activate();
+ Assert.AreEqual(1, _fakeComms.SentItems.Count);
+ Assert.AreEqual(getCommand, _fakeComms.SentItems[0]);
+ }
+
+ [Test]
+ public void ReceivedDataIgnoredWhenNotActive()
+ {
+ bool inpcFired = false;
+ _vm.PropertyChanged += delegate { inpcFired = true; };
+
+ _fakeComms.FireLineRecieve(sampleLineOfData);
+ Assert.False(inpcFired);
+ }
+
+ [Test]
+ public void ReceivedDataIgnoredAfterDeActive()
+ {
+ _vm.Activate();
+ _fakeComms.FireLineRecieve(sampleLineOfData);
+ _vm.DeActivate();
+ _fakeComms.FireLineRecieve(sampleLineOfData);
+ bool inpcFired = false;
+ _vm.PropertyChanged += delegate { inpcFired = true; };
+
+ Assert.False(inpcFired);
+ }
+
+ [Test]
+ public void UpdateStringReceivedPopulatesValues()
+ {
+ bool inpcFired = false;
+ _vm.PropertyChanged += delegate { inpcFired = true; };
+
+ _vm.Activate();
+ _fakeComms.FireLineRecieve(sampleLineOfData);
+
+ Assert.True(inpcFired);
+ }
+ }
+}
\ No newline at end of file