diff --git a/Configurator/Configurator.Net/CommsSession.cs b/Configurator/Configurator.Net/CommsSession.cs index 269545a76b..dc9889ca03 100644 --- a/Configurator/Configurator.Net/CommsSession.cs +++ b/Configurator/Configurator.Net/CommsSession.cs @@ -76,8 +76,20 @@ namespace ArducopterConfigurator void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { // Thanks to BG worker, this should be raised on the UI thread + var lineReceived = e.UserState as string; - if (LineOfDataReceived != null) + + +// for (int i = 0; i < lineReceived.Length; i++) +// { +// var c = lineReceived[i]; +// Console.WriteLine("{0}] U+{1:x4} {2}", i, (int)c, (int)c); +// } +// +// +// + + if (LineOfDataReceived != null) LineOfDataReceived(lineReceived); } diff --git a/Configurator/Configurator.Net/PresentationModels/ConfigWithPidsBase.cs b/Configurator/Configurator.Net/PresentationModels/ConfigWithPidsBase.cs index 34191ea2f2..6f936b1585 100644 --- a/Configurator/Configurator.Net/PresentationModels/ConfigWithPidsBase.cs +++ b/Configurator/Configurator.Net/PresentationModels/ConfigWithPidsBase.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics; @@ -25,6 +26,7 @@ namespace ArducopterConfigurator.PresentationModels protected override void OnStringReceived(string strRx) { + Console.WriteLine("Badoosh strnig rxd"); PopulatePropsFromUpdate(strRx,true); } } diff --git a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs index ed237a505e..52357affa3 100644 --- a/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/MonitorVm.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics; using System.Text; @@ -86,11 +87,15 @@ namespace ArducopterConfigurator // property update order, and reflection to get the property type protected void PopulatePropsFromUpdate(string strRx, bool fireInpc) { + + var strs = strRx.Split(','); + + if (PropsInUpdateOrder.Length!=strs.Length) { - Debug.WriteLine("Processing update with only " + strs.Length + Console.WriteLine("Processing update with only " + strs.Length + " values, but have " + PropsInUpdateOrder.Length + " properties to populate. Ignoring this update"); return; @@ -107,7 +112,7 @@ namespace ArducopterConfigurator float val; if (!float.TryParse(s, out val)) { - Debug.WriteLine("Error parsing float: " + s); + Console.WriteLine("Error parsing float: " + s); break; } value = val; @@ -117,7 +122,7 @@ namespace ArducopterConfigurator float val; if (!float.TryParse(s, out val)) { - Debug.WriteLine("Error parsing float (bool): " + s); + Console.WriteLine("Error parsing float (bool): " + s); break; } value = val != 0.0; @@ -128,7 +133,7 @@ namespace ArducopterConfigurator int val; if (!int.TryParse(s, out val)) { - Debug.WriteLine("Error parsing int: " + s); + Console.WriteLine("Error parsing int: " + s); break; } value = val; @@ -136,6 +141,9 @@ namespace ArducopterConfigurator prop.SetValue(this, value, null); + Console.WriteLine("Badoosh firing inpc"); + + if (fireInpc) FirePropertyChanged(PropsInUpdateOrder[i]); } diff --git a/Configurator/Configurator.Net/PresentationModels/StableModeConfigVm.cs b/Configurator/Configurator.Net/PresentationModels/StableModeConfigVm.cs index a9f41db113..3b61a4af45 100644 --- a/Configurator/Configurator.Net/PresentationModels/StableModeConfigVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/StableModeConfigVm.cs @@ -30,7 +30,12 @@ namespace ArducopterConfigurator.PresentationModels public float KPrate { get; set; } - public bool MagnetometerEnable { get; set; } + private bool magnetometerEnable; + public bool MagnetometerEnable + { + get { return magnetometerEnable; } + set { magnetometerEnable = value; } + } private void RefreshValues() { diff --git a/Configurator/Configurator.Net/PresentationModels/TransmitterChannelsVm.cs b/Configurator/Configurator.Net/PresentationModels/TransmitterChannelsVm.cs index 46b81db01a..2749e475fe 100644 --- a/Configurator/Configurator.Net/PresentationModels/TransmitterChannelsVm.cs +++ b/Configurator/Configurator.Net/PresentationModels/TransmitterChannelsVm.cs @@ -71,10 +71,6 @@ namespace ArducopterConfigurator.PresentationModels } - - - - private int _mode; public int Mode { @@ -154,42 +150,6 @@ namespace ArducopterConfigurator.PresentationModels PopulatePropsFromUpdate(strReceived,false); } - - private void manualPropset(string strReceived) - { - // PopulatePropsFromUpdate(strReceived,false); - var strs = strReceived.Split(','); - var ints = new List(); - foreach (var s in strs) - { - int val; - if (!int.TryParse(s, out val)) - { - Debug.WriteLine("Could not parse expected integer: " + s); - return; - } - ints.Add(val); - } - - if (ints.Count != 9) - { - Debug.WriteLine("Tx Data sentence expected, but only got one of size: " + ints.Count); - return; - } - - Roll = ints[0]; - // Pitch = ints[1]; - // Yaw = ints[2]; - Throttle = ints[3]; - // Mode = ints[4]; - // Aux = ints[5]; - // RollMidValue = ints[6]; - // PitchMidValue = ints[7]; - // YawMidValue = ints[8]; - - - } - public override string Name { get { return "Transmitter Channels"; } diff --git a/Configurator/Configurator.Net/Program.cs b/Configurator/Configurator.Net/Program.cs index 1e5fc8e2ae..a5452efc7e 100644 --- a/Configurator/Configurator.Net/Program.cs +++ b/Configurator/Configurator.Net/Program.cs @@ -24,9 +24,13 @@ namespace ArducopterConfigurator var session = new CommsSession(); //var session = new FakeCommsSession(); + var mainVm = new MainVm(session); + Application.Run(new mainForm(mainVm)); } + + } } diff --git a/Configurator/Configurator.Net/Views/AcroConfigView.cs b/Configurator/Configurator.Net/Views/AcroConfigView.cs index 72b309142f..5d18a000d6 100644 --- a/Configurator/Configurator.Net/Views/AcroConfigView.cs +++ b/Configurator/Configurator.Net/Views/AcroConfigView.cs @@ -20,6 +20,9 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(AcroModeConfigVm model) { AcroModeConfigVmBindingSource.DataSource = model; + + if (Program.IsMonoRuntime) + model.PropertyChanged += ((sender, e) => AcroModeConfigVmBindingSource.ResetBindings(false)); } } diff --git a/Configurator/Configurator.Net/Views/AltitudeHoldConfigView.cs b/Configurator/Configurator.Net/Views/AltitudeHoldConfigView.cs index afcfd7ae81..c474e39565 100644 --- a/Configurator/Configurator.Net/Views/AltitudeHoldConfigView.cs +++ b/Configurator/Configurator.Net/Views/AltitudeHoldConfigView.cs @@ -20,6 +20,9 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(AltitudeHoldConfigVm model) { AltitudeHoldConfigBindingSource.DataSource = model; + + if (Program.IsMonoRuntime) + model.PropertyChanged += ((sender, e) => AltitudeHoldConfigBindingSource.ResetBindings(false)); } } diff --git a/Configurator/Configurator.Net/Views/CalibrationView.cs b/Configurator/Configurator.Net/Views/CalibrationView.cs index bba8c674b4..1e91c1b5e1 100644 --- a/Configurator/Configurator.Net/Views/CalibrationView.cs +++ b/Configurator/Configurator.Net/Views/CalibrationView.cs @@ -20,6 +20,10 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(CalibrationOffsetsDataVm model) { calibrationOffsetsDataVmBindingSource.DataSource = model; + + + if (Program.IsMonoRuntime) + model.PropertyChanged += ((sender, e) => calibrationOffsetsDataVmBindingSource.ResetBindings(false)); } } diff --git a/Configurator/Configurator.Net/Views/PositionHoldConfigView.cs b/Configurator/Configurator.Net/Views/PositionHoldConfigView.cs index fca47a7df8..d5b56f4dfd 100644 --- a/Configurator/Configurator.Net/Views/PositionHoldConfigView.cs +++ b/Configurator/Configurator.Net/Views/PositionHoldConfigView.cs @@ -18,7 +18,9 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(PositionHoldConfigVm model) { PositionHoldConfigBindingSource.DataSource = model; - _vm = model; + + if (Program.IsMonoRuntime) + model.PropertyChanged += ((sender, e) => PositionHoldConfigBindingSource.ResetBindings(false)); } } // Required for VS2008 designer. No functional value diff --git a/Configurator/Configurator.Net/Views/StableConfigView.cs b/Configurator/Configurator.Net/Views/StableConfigView.cs index b5986d51b3..f7b644a802 100644 --- a/Configurator/Configurator.Net/Views/StableConfigView.cs +++ b/Configurator/Configurator.Net/Views/StableConfigView.cs @@ -20,6 +20,13 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(StableModeConfigVm model) { StableModeConfigVmBindingSource.DataSource = model; + + if (Program.IsMonoRuntime) + model.PropertyChanged += (delegate + { + Console.WriteLine("Badoosh1"); + StableModeConfigVmBindingSource.ResetBindings(false); + }); } } diff --git a/Configurator/Configurator.Net/Views/TransmitterChannelsView.cs b/Configurator/Configurator.Net/Views/TransmitterChannelsView.cs index f139b50d89..36d3761ab1 100644 --- a/Configurator/Configurator.Net/Views/TransmitterChannelsView.cs +++ b/Configurator/Configurator.Net/Views/TransmitterChannelsView.cs @@ -19,6 +19,9 @@ namespace ArducopterConfigurator.Views public override void SetDataContext(TransmitterChannelsVm model) { TransmitterChannelsBindingSource.DataSource = model; + + if (Program.IsMonoRuntime) + model.PropertyChanged += ((sender, e) => TransmitterChannelsBindingSource.ResetBindings(false)); } } diff --git a/Configurator/Configurator.Net/Views/ViewCommon.cs b/Configurator/Configurator.Net/Views/ViewCommon.cs index 4f4288547f..c330b0adb4 100644 --- a/Configurator/Configurator.Net/Views/ViewCommon.cs +++ b/Configurator/Configurator.Net/Views/ViewCommon.cs @@ -7,8 +7,6 @@ namespace ArducopterConfigurator.Views // cannot be abstract due to vs2008 designer public class ViewCommon : UserControl, IView where T : IPresentationModel { - protected T _vm; - public virtual void SetDataContext(T model) { } diff --git a/Configurator/Configurator.Net/Views/controls/LinearIndicatorControl.cs b/Configurator/Configurator.Net/Views/controls/LinearIndicatorControl.cs index 39674a6f3c..04d1c8ef91 100644 --- a/Configurator/Configurator.Net/Views/controls/LinearIndicatorControl.cs +++ b/Configurator/Configurator.Net/Views/controls/LinearIndicatorControl.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Drawing; using System.Data; using System.Drawing.Drawing2D; @@ -330,7 +331,15 @@ namespace ArducopterConfigurator.Views.controls public int Value { get { return _val; } - set { _val = value; Refresh(); } + set + { + if (_val != value) + { + _val = value; + Refresh(); + } + + } } [System.ComponentModel.Description("Gets or sets whether the indicator is vertical")] diff --git a/Configurator/Configurator.Net/Views/mainForm.cs b/Configurator/Configurator.Net/Views/mainForm.cs index 99d2474a22..2d2ea5ef7c 100644 --- a/Configurator/Configurator.Net/Views/mainForm.cs +++ b/Configurator/Configurator.Net/Views/mainForm.cs @@ -128,7 +128,6 @@ namespace ArducopterConfigurator private void tabCtrlConfigs_Selected(object sender, TabControlEventArgs e) { - Console.WriteLine("Tab click"); var control = e.TabPage.Controls[0]; control.Size = e.TabPage.ClientRectangle.Size; var tabVm = e.TabPage.Tag as MonitorVm;