text: #include "dshotAnalyzerSettings.h"
  #include <AnalyzerHelpers.h>
  
  
  dshotAnalyzerSettings::dshotAnalyzerSettings()
  :	mInputChannel( UNDEFINED_CHANNEL ),
  	mBitRate( 100000 )
  {
  	mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
  	mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard dshot" );
  	mInputChannelInterface->SetChannel( mInputChannel );
  
  	mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
  	mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)",  "Specify the bit rate in bits per second." );
  	mBitRateInterface->SetMax( 6000000 );
  	mBitRateInterface->SetMin( 1 );
  	mBitRateInterface->SetInteger( mBitRate );
  
  	AddInterface( mInputChannelInterface.get() );
  	AddInterface( mBitRateInterface.get() );
  
  	AddExportOption( 0, "Export as text/csv file" );
  	AddExportExtension( 0, "text", "txt" );
  	AddExportExtension( 0, "csv", "csv" );
  
  	ClearChannels();
  	AddChannel( mInputChannel, "Serial", false );
  }
  
  dshotAnalyzerSettings::~dshotAnalyzerSettings()
  {
  }
  
  bool dshotAnalyzerSettings::SetSettingsFromInterfaces()
  {
  	mInputChannel = mInputChannelInterface->GetChannel();
  	mBitRate = mBitRateInterface->GetInteger();
  
  	ClearChannels();
  	AddChannel( mInputChannel, "dshot", true );
  
  	return true;
  }
  
  void dshotAnalyzerSettings::UpdateInterfacesFromSettings()
  {
  	mInputChannelInterface->SetChannel( mInputChannel );
  	mBitRateInterface->SetInteger( mBitRate );
  }
  
  void dshotAnalyzerSettings::LoadSettings( const char* settings )
  {
  	SimpleArchive text_archive;
  	text_archive.SetString( settings );
  
  	text_archive >> mInputChannel;
  	text_archive >> mBitRate;
  
  	ClearChannels();
  	AddChannel( mInputChannel, "dshot", true );
  
  	UpdateInterfacesFromSettings();
  }
  
  const char* dshotAnalyzerSettings::SaveSettings()
  {
  	SimpleArchive text_archive;
  
  	text_archive << mInputChannel;
  	text_archive << mBitRate;
  
  	return SetReturnString( text_archive.GetString() );
  }
  