2011-02-13 05:25:54 -04:00
using System ;
2010-12-18 18:23:09 -04:00
namespace ArducopterConfigurator.PresentationModels
{
2011-02-13 05:25:54 -04:00
public class PositionHoldConfigVm : ConfigWithPidsBase , IPresentationModel , ItalksToApm
2010-12-18 18:23:09 -04:00
{
2011-02-13 05:25:54 -04:00
public PositionHoldConfigVm ( )
2010-12-18 18:23:09 -04:00
{
PropsInUpdateOrder = new [ ]
{
"RollP" ,
"RollI" ,
"RollD" ,
"PitchP" ,
"PitchI" ,
"PitchD" ,
"MaximumAngle" ,
"GeoCorrectionFactor" ,
} ;
RefreshCommand = new DelegateCommand ( _ = > RefreshValues ( ) ) ;
UpdateCommand = new DelegateCommand ( _ = > UpdateValues ( ) ) ;
}
public float MaximumAngle { get ; set ; }
public float GeoCorrectionFactor { get ; set ; }
public ICommand RefreshCommand { get ; private set ; }
public ICommand UpdateCommand { get ; private set ; }
//Send an 'C' followed by numeric values to transmit user defined roll and pitch PID values for gyro stabilized flight control. Each value is separated by a semi-colon in the form:
//C[P GPS ROLL];[I GPS ROLL];[D GPS ROLL];[P GPS PITCH];[I GPS PITCH];[D GPS PITCH];[GPS MAX ANGLE];[GEOG Correction factor]
public void UpdateValues ( )
{
2011-02-13 05:25:54 -04:00
if ( sendTextToApm ! = null )
sendTextToApm ( this , new sendTextToApmEventArgs ( ComposePropsWithCommand ( "C" ) ) ) ;
2010-12-18 18:23:09 -04:00
}
public void RefreshValues ( )
{
2011-02-13 05:25:54 -04:00
if ( sendTextToApm ! = null )
sendTextToApm ( this , new sendTextToApmEventArgs ( "D" ) ) ;
}
public string Name
{
get { return "Position 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
2010-12-18 18:23:09 -04:00
}
2011-02-13 05:25:54 -04:00
public void handleLineOfText ( string strRx )
{
PopulatePropsFromUpdate ( strRx , true ) ;
if ( updatedByApm ! = null )
updatedByApm ( this , EventArgs . Empty ) ;
}
public event EventHandler < sendTextToApmEventArgs > sendTextToApm ;
public event EventHandler updatedByApm ;
2010-12-18 18:23:09 -04:00
}
}