Files
LPCClocklessAnalyzer/src/LPCClocklessAnalyzerSettings.cpp

114 lines
3.6 KiB
C++
Raw Normal View History

2023-10-12 00:21:47 +02:00
#include "LPCClocklessAnalyzerSettings.h"
#include <AnalyzerHelpers.h>
2023-10-12 00:21:47 +02:00
LPCClocklessAnalyzerSettings::LPCClocklessAnalyzerSettings() :
// : mInputChannel( UNDEFINED_CHANNEL ),
mFrameChannel( UNDEFINED_CHANNEL ),
2023-10-12 01:32:58 +02:00
mBitRate( 25000000 )
{
2023-10-12 00:21:47 +02:00
ClearChannels();
for(int i=0; i < 4; i++) {
mLaddChannel[i] = Channel(UNDEFINED_CHANNEL);
// }
mLaddChannelInterface[i].reset( new AnalyzerSettingInterfaceChannel() );
// const char *name = std::string("Ladd" + std::to_string(i)).c_str();
mLaddChannelInterface[i]->SetTitleAndTooltip(std::string("Ladd" + std::to_string(i)).c_str(), "Signal.");
mLaddChannelInterface[i]->SetChannel( mLaddChannel[i] );
AddInterface( mLaddChannelInterface[i].get() );
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), false );
}
mFrameChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
mFrameChannelInterface->SetTitleAndTooltip( "Frame", "Frame signal" );
mFrameChannelInterface->SetChannel( mFrameChannel );
AddInterface(mFrameChannelInterface.get());
// mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
// mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard LPC Clockless" );
// mInputChannelInterface->SetChannel( mInputChannel );
mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
2023-10-12 01:32:58 +02:00
mBitRateInterface->SetMax( 50000000 );
mBitRateInterface->SetMin( 1 );
mBitRateInterface->SetInteger( mBitRate );
2023-10-12 00:21:47 +02:00
// AddInterface( mInputChannelInterface.get() );
AddInterface( mBitRateInterface.get() );
AddExportOption( 0, "Export as text/csv file" );
AddExportExtension( 0, "text", "txt" );
AddExportExtension( 0, "csv", "csv" );
2023-10-12 00:21:47 +02:00
// ClearChannels();
AddChannel( mFrameChannel, "Frame", false );
}
2023-10-12 00:21:47 +02:00
LPCClocklessAnalyzerSettings::~LPCClocklessAnalyzerSettings()
{
}
2023-10-12 00:21:47 +02:00
bool LPCClocklessAnalyzerSettings::SetSettingsFromInterfaces()
{
2023-10-12 00:21:47 +02:00
// mInputChannel = mInputChannelInterface->GetChannel();
mFrameChannel = mFrameChannelInterface->GetChannel();
for(int i=0; i < 4; i++) {
mLaddChannel[i] = mLaddChannelInterface[i]->GetChannel();
}
mBitRate = mBitRateInterface->GetInteger();
ClearChannels();
2023-10-12 00:21:47 +02:00
for(int i=0; i < 4; i++) {
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), true);
}
// AddChannel( mInputChannel, "LPC Clockless", true );
AddChannel( mFrameChannel, "Frame", true );
return true;
}
2023-10-12 00:21:47 +02:00
void LPCClocklessAnalyzerSettings::UpdateInterfacesFromSettings()
{
2023-10-12 00:21:47 +02:00
for(int i=0; i < 4; i++) {
mLaddChannelInterface[i]->SetChannel( mLaddChannel[i] );
}
mFrameChannelInterface->SetChannel( mFrameChannel );
// mInputChannelInterface->SetChannel( mInputChannel );
mBitRateInterface->SetInteger( mBitRate );
}
2023-10-12 00:21:47 +02:00
void LPCClocklessAnalyzerSettings::LoadSettings( const char* settings )
{
SimpleArchive text_archive;
text_archive.SetString( settings );
2023-10-12 00:21:47 +02:00
for(int i=0; i < 4; i++) {
text_archive >> mLaddChannel[i];
}
text_archive >> mFrameChannel;
text_archive >> mBitRate;
ClearChannels();
2023-10-12 00:21:47 +02:00
for(int i=0; i < 4; i++) {
AddChannel( mLaddChannel[i], std::string("Ladd" + std::to_string(i)).c_str(), true);
}
// AddChannel( mInputChannel, "LPC Clockless", true );
AddChannel( mFrameChannel, "Frame", true );
// AddChannel( mInputChannel, "LPC Clockless", true );
UpdateInterfacesFromSettings();
}
2023-10-12 00:21:47 +02:00
const char* LPCClocklessAnalyzerSettings::SaveSettings()
{
SimpleArchive text_archive;
2023-10-12 00:21:47 +02:00
for(int i=0; i < 4; i++) {
text_archive << mLaddChannel[i];
}
text_archive << mFrameChannel;
// text_archive << mInputChannel;
text_archive << mBitRate;
return SetReturnString( text_archive.GetString() );
}