2010-12-18 18:23:09 -04:00
|
|
|
using System;
|
|
|
|
using System.IO.Ports;
|
|
|
|
|
|
|
|
namespace ArducopterConfigurator.PresentationModels
|
|
|
|
{
|
2011-02-13 14:14:28 -04:00
|
|
|
public class SerialMonitorVm : NotifyProperyChangedBase, IPresentationModel
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
|
|
|
private string _text;
|
|
|
|
|
|
|
|
public string ReceviedText { get { return _text; } }
|
|
|
|
|
|
|
|
public string SendText { get; set; }
|
2011-02-13 14:14:28 -04:00
|
|
|
|
|
|
|
public string Name
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
2011-02-13 14:14:28 -04:00
|
|
|
get { return "Serial Monitor"; }
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
|
2011-02-13 14:14:28 -04:00
|
|
|
public void Activate()
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
2011-02-13 14:14:28 -04:00
|
|
|
_text = string.Empty;
|
2010-12-18 18:23:09 -04:00
|
|
|
FirePropertyChanged("ReceviedText");
|
|
|
|
}
|
|
|
|
|
2011-02-13 14:14:28 -04:00
|
|
|
public void DeActivate()
|
2010-12-18 18:23:09 -04:00
|
|
|
{
|
2011-02-13 14:14:28 -04:00
|
|
|
if (sendTextToApm!=null)
|
|
|
|
sendTextToApm(this, new sendTextToApmEventArgs("X"));
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
|
2011-02-13 14:14:28 -04:00
|
|
|
public event EventHandler updatedByApm;
|
|
|
|
|
2010-12-18 18:23:09 -04:00
|
|
|
public void SendTextCommand()
|
|
|
|
{
|
2011-02-13 14:14:28 -04:00
|
|
|
if (sendTextToApm != null)
|
|
|
|
sendTextToApm(this, new sendTextToApmEventArgs(SendText));
|
2010-12-18 18:23:09 -04:00
|
|
|
SendText = "";
|
|
|
|
FirePropertyChanged("SendText");
|
|
|
|
}
|
2011-02-13 14:14:28 -04:00
|
|
|
|
|
|
|
public void handleLineOfText(string strRx)
|
|
|
|
{
|
|
|
|
_text += strRx + Environment.NewLine;
|
|
|
|
FirePropertyChanged("ReceviedText");
|
|
|
|
}
|
|
|
|
|
|
|
|
public event EventHandler<sendTextToApmEventArgs> sendTextToApm;
|
2010-12-18 18:23:09 -04:00
|
|
|
}
|
|
|
|
}
|