2011-02-13 05:25:54 -04:00
|
|
|
using System;
|
|
|
|
|
2010-12-18 18:23:09 -04:00
|
|
|
namespace ArducopterConfigurator.PresentationModels
|
|
|
|
{
|
2010-12-22 06:04:16 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Vm for Altitude hold settings
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// 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.
|
|
|
|
/// </remarks>
|
2011-02-13 05:25:54 -04:00
|
|
|
public class AltitudeHoldConfigVm : VmBase, IPresentationModel, ItalksToApm
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
2011-02-13 05:25:54 -04:00
|
|
|
public AltitudeHoldConfigVm()
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
|
|
|
PropsInUpdateOrder = new[] { "P", "I", "D", };
|
|
|
|
|
|
|
|
RefreshCommand = new DelegateCommand(_ => RefreshValues());
|
|
|
|
UpdateCommand = new DelegateCommand(_ => UpdateValues());
|
|
|
|
}
|
|
|
|
|
|
|
|
public ICommand RefreshCommand { get; private set; }
|
|
|
|
public ICommand UpdateCommand { get; private set; }
|
|
|
|
|
2010-12-20 18:14:39 -04:00
|
|
|
public float P { get; set; }
|
|
|
|
public float I { get; set; }
|
|
|
|
public float D { get; set; }
|
2010-12-18 18:23:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
private void RefreshValues()
|
|
|
|
{
|
2011-02-13 05:25:54 -04:00
|
|
|
if (sendTextToApm != null)
|
|
|
|
sendTextToApm(this, new sendTextToApmEventArgs("F"));
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateValues()
|
|
|
|
{
|
2011-02-13 05:25:54 -04:00
|
|
|
if (sendTextToApm != null)
|
|
|
|
sendTextToApm(this, new sendTextToApmEventArgs(ComposePropsWithCommand("E")));
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
{
|
|
|
|
get { return "Altitude Hold"; }
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
|
2011-02-13 05:25:54 -04:00
|
|
|
public void Activate()
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
|
|
|
RefreshValues();
|
|
|
|
}
|
|
|
|
|
2011-02-13 05:25:54 -04:00
|
|
|
public void DeActivate()
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-02-13 05:25:54 -04:00
|
|
|
public event EventHandler updatedByApm;
|
|
|
|
|
|
|
|
public void handleLineOfText(string strRx)
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
2011-02-13 05:25:54 -04:00
|
|
|
PopulatePropsFromUpdate(strRx, true);
|
|
|
|
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
2011-02-13 05:25:54 -04:00
|
|
|
|
|
|
|
public event EventHandler<sendTextToApmEventArgs> sendTextToApm;
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
}
|