Merge pull request #33 from saleae/remove-auto-ptr
Remove std::auto_ptr
This commit is contained in:
@@ -172,8 +172,6 @@ One of the services the Analyzer SDK provides is a means for users to edit your
|
|||||||
- ```AnalyzerSettingInterfaceText``` - Allows a user to enter some text into a textbox.
|
- ```AnalyzerSettingInterfaceText``` - Allows a user to enter some text into a textbox.
|
||||||
- ```AnalyzerSettingInterfaceBool``` - Provides the user with a checkbox.
|
- ```AnalyzerSettingInterfaceBool``` - Provides the user with a checkbox.
|
||||||
|
|
||||||
```AnalyzerSettingsInterface``` types should be declared as pointers. We’re using the ```std::auto_ptr``` type, which largely acts like a standard (raw) pointer. It’s a simple form of what’s called a “smart pointer” and it automatically calls ```delete``` on its contents when it goes out of scope.
|
|
||||||
|
|
||||||
## {YourName}AnalyzerSettings.cpp
|
## {YourName}AnalyzerSettings.cpp
|
||||||
|
|
||||||
### The Constructor
|
### The Constructor
|
||||||
@@ -182,15 +180,10 @@ First, initialize all your settings variables to their default values. Second,
|
|||||||
|
|
||||||
### Setting up each AnalyzerSettingInterface object
|
### Setting up each AnalyzerSettingInterface object
|
||||||
|
|
||||||
First, we create the object (call new) and assign the value to the interface’s pointer. Note that we’re using ```std::auto_ptr```, so this means calling the member function ```reset()```. For standard (raw pointers), you would do something like:
|
First, call the member function ```SetTitleAndTooltip()```. The title will appear to the left of the input element. Note that often times you won’t need a title, but you should use one for ```Channels```. The tooltip shows up when hovering over the input element.
|
||||||
```c++
|
|
||||||
mInputChannelInterface = new AnalyzerSettingInterfaceChannel();
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, we call the member function ```SetTitleAndTooltip()```. The title will appear to the left of the input element. Note that often times you won’t need a title, but you should use one for ```Channels```. The tooltip shows up when hovering over the input element.
|
|
||||||
```c++
|
```c++
|
||||||
void SetTitleAndTooltip( const char* title, const char* tooltip );
|
void SetTitleAndTooltip( const char* title, const char* tooltip );
|
||||||
mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard Async Serial" );
|
mInputChannelInterface.SetTitleAndTooltip( "Serial", "Standard Async Serial" );
|
||||||
```
|
```
|
||||||
Finally, We’ll want to set the value. The interface object is, well, an interface to our settings variables. When setting up the interface, we copy the value from our settings variable to the interface. When the user makes a change, we copy the value in the interface to our settings variable. The function names for this differ depending on the type of interface.
|
Finally, We’ll want to set the value. The interface object is, well, an interface to our settings variables. When setting up the interface, we copy the value from our settings variable to the interface. When the user makes a change, we copy the value in the interface to our settings variable. The function names for this differ depending on the type of interface.
|
||||||
```c++
|
```c++
|
||||||
@@ -292,7 +285,7 @@ After assigning the interface values to your settings variables, you also need t
|
|||||||
```c++
|
```c++
|
||||||
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
||||||
{
|
{
|
||||||
mInputChannel = mInputChannelInterface->GetChannel();
|
mInputChannel = mInputChannelInterface.GetChannel();
|
||||||
mBitRate = mBitRateInterface->GetInteger();
|
mBitRate = mBitRateInterface->GetInteger();
|
||||||
ClearChannels();
|
ClearChannels();
|
||||||
AddChannel( mInputChannel, "Simple Serial", true );
|
AddChannel( mInputChannel, "Simple Serial", true );
|
||||||
@@ -307,7 +300,7 @@ bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
|||||||
```c++
|
```c++
|
||||||
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
||||||
{
|
{
|
||||||
mInputChannelInterface->SetChannel( mInputChannel );
|
mInputChannelInterface.SetChannel( mInputChannel );
|
||||||
mBitRateInterface->SetInteger( mBitRate );
|
mBitRateInterface->SetInteger( mBitRate );
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -673,8 +666,8 @@ extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );
|
|||||||
|
|
||||||
You’ll also need these member variables:
|
You’ll also need these member variables:
|
||||||
```c++
|
```c++
|
||||||
std::auto_ptr< {YourName}AnalyzerSettings > mSettings;
|
{YourName}AnalyzerSettings mSettings;
|
||||||
std::auto_ptr< {YourName}AnalyzerResults > mResults;
|
std::unique_ptr<{YourName}AnalyzerResults> mResults;
|
||||||
{YourName}SimulationDataGenerator mSimulationDataGenerator;
|
{YourName}SimulationDataGenerator mSimulationDataGenerator;
|
||||||
bool mSimulationInitialized;
|
bool mSimulationInitialized;
|
||||||
```
|
```
|
||||||
@@ -692,13 +685,13 @@ Your constructor will look something like this
|
|||||||
```c++
|
```c++
|
||||||
{YourName}Analyzer::{YourName}Analyzer()
|
{YourName}Analyzer::{YourName}Analyzer()
|
||||||
: Analyzer(),
|
: Analyzer(),
|
||||||
mSettings( new {YourName}AnalyzerSettings() ),
|
mSettings(),
|
||||||
mSimulationInitialized( false )
|
mSimulationInitialized( false )
|
||||||
{
|
{
|
||||||
SetAnalyzerSettings( mSettings.get() );
|
SetAnalyzerSettings( &mSettings );
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Note that here you’re calling the base class constructor, ```new()```'ing your ```AnalyzerSettings``` derived class, and providing the base class with a pointer to your ```AnalyzerSettings``` - derived object.
|
Note that here you’re calling the base class constructor and providing the base class with a pointer to your ```AnalyzerSettings``` - derived object.
|
||||||
|
|
||||||
## Destructor
|
## Destructor
|
||||||
This only thing your destructor must do is call ```KillThread```. This is a base class member function and will make sure your class destructs in the right order.
|
This only thing your destructor must do is call ```KillThread```. This is a base class member function and will make sure your class destructs in the right order.
|
||||||
@@ -727,7 +720,7 @@ U32 {YourName}Analyzer::GenerateSimulationData( U64 minimum_sample_index, U32 de
|
|||||||
{
|
{
|
||||||
if( mSimulationInitialized == false )
|
if( mSimulationInitialized == false )
|
||||||
{
|
{
|
||||||
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() );
|
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), &mSettings );
|
||||||
mSimulationInitialized = true;
|
mSimulationInitialized = true;
|
||||||
}
|
}
|
||||||
return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
|
return mSimulationDataGenerator.GenerateSimulationData( minimum_sample_index, device_sample_rate, simulation_channels );
|
||||||
@@ -740,7 +733,7 @@ This function is called to see if the user’s selected sample rate is sufficien
|
|||||||
```c++
|
```c++
|
||||||
U32 SerialAnalyzer::GetMinimumSampleRateHz()
|
U32 SerialAnalyzer::GetMinimumSampleRateHz()
|
||||||
{
|
{
|
||||||
return mSettings->mBitRate * 4;
|
return mSettings.mBitRate * 4;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -769,9 +762,9 @@ delete analyzer;
|
|||||||
```
|
```
|
||||||
|
|
||||||
## ```{YourName}Analyzer::WorkerThread()```
|
## ```{YourName}Analyzer::WorkerThread()```
|
||||||
Ok, now that everything else is taken care of, let’s look at the most important part of the analyzer in detail. First, we’ll ```new``` our ```AnalyzerResults``` derived object.
|
Ok, now that everything else is taken care of, let’s look at the most important part of the analyzer in detail. First, we’ll reset our ```AnalyzerResults``` derived object. This is because your analyzer class instance may be re-used for multiple runs, so at the beginning of each run, the generated results must be reset.
|
||||||
```c++
|
```c++
|
||||||
mResults.reset( new {YourName}AnalyzerResults( this, mSettings.get() ) );
|
mResults.reset( new {YourName}AnalyzerResults( this, &mSettings ) );
|
||||||
```
|
```
|
||||||
Well provide a pointer to our results to the base class:
|
Well provide a pointer to our results to the base class:
|
||||||
```c++
|
```c++
|
||||||
@@ -779,7 +772,7 @@ SetAnalyzerResults( mResults.get() );
|
|||||||
```
|
```
|
||||||
Let’s indicate which channels we’ll be displaying results on (in the form of bubbles). Usually this will only be one channel. (Except in the case of SPI, where we’ll want to put bubbles on both the MISO and MISO lines.) Only indicate where we will display bubbles – other markup, like tick marks, arrows, etc, are not bubbles, and should not be reported here.
|
Let’s indicate which channels we’ll be displaying results on (in the form of bubbles). Usually this will only be one channel. (Except in the case of SPI, where we’ll want to put bubbles on both the MISO and MISO lines.) Only indicate where we will display bubbles – other markup, like tick marks, arrows, etc, are not bubbles, and should not be reported here.
|
||||||
```c++
|
```c++
|
||||||
mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
mResults->AddChannelBubblesWillAppearOn( mSettings.mInputChannel );
|
||||||
```
|
```
|
||||||
We’ll probably want to know (and save in a member variable) the sample rate.
|
We’ll probably want to know (and save in a member variable) the sample rate.
|
||||||
```c++
|
```c++
|
||||||
@@ -787,7 +780,7 @@ mSampleRateHz = GetSampleRate();
|
|||||||
```
|
```
|
||||||
Now we need to get access to the data itself. We’ll need to get pointers to ```AnalyzerChannelData``` objects for each channel we’ll need data from. For Serial, we’ll just need one. For SPI, we might need 4. Etc.
|
Now we need to get access to the data itself. We’ll need to get pointers to ```AnalyzerChannelData``` objects for each channel we’ll need data from. For Serial, we’ll just need one. For SPI, we might need 4. Etc.
|
||||||
```c++
|
```c++
|
||||||
mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
mSerial = GetAnalyzerChannelData( mSettings.mInputChannel );
|
||||||
```
|
```
|
||||||
|
|
||||||
# Traversing the Data
|
# Traversing the Data
|
||||||
@@ -892,7 +885,7 @@ void AddMarker( U64 sample_number, MarkerType marker_type, Channel& channel );
|
|||||||
```
|
```
|
||||||
For example, from ```SerialAnalyzer.cpp``` :
|
For example, from ```SerialAnalyzer.cpp``` :
|
||||||
```c++
|
```c++
|
||||||
mResults->AddMarker( marker_location, AnalyzerResults::Dot, mSettings->mInputChannel );
|
mResults->AddMarker( marker_location, AnalyzerResults::Dot, mSettings.mInputChannel );
|
||||||
```
|
```
|
||||||
Currently, the available graphical artifacts are
|
Currently, the available graphical artifacts are
|
||||||
|
|
||||||
@@ -1135,7 +1128,7 @@ SimpleSerialAnalyzerSettings* settings )
|
|||||||
{
|
{
|
||||||
mSimulationSampleRateHz = simulation_sample_rate;
|
mSimulationSampleRateHz = simulation_sample_rate;
|
||||||
mSettings = settings;
|
mSettings = settings;
|
||||||
mSerialSimulationData.SetChannel( mSettings->mInputChannel );
|
mSerialSimulationData.SetChannel( mSettings.mInputChannel );
|
||||||
mSerialSimulationData.SetSampleRate( simulation_sample_rate );
|
mSerialSimulationData.SetSampleRate( simulation_sample_rate );
|
||||||
mSerialSimulationData.SetInitialBitState( BIT_HIGH );
|
mSerialSimulationData.SetInitialBitState( BIT_HIGH );
|
||||||
}
|
}
|
||||||
@@ -1179,7 +1172,7 @@ simulation_channel )
|
|||||||
}
|
}
|
||||||
void SimpleSerialSimulationDataGenerator::CreateSerialByte()
|
void SimpleSerialSimulationDataGenerator::CreateSerialByte()
|
||||||
{
|
{
|
||||||
U32 samples_per_bit = mSimulationSampleRateHz / mSettings->mBitRate;
|
U32 samples_per_bit = mSimulationSampleRateHz / mSettings.mBitRate;
|
||||||
U8 byte = mSerialText[ mStringIndex ];
|
U8 byte = mSerialText[ mStringIndex ];
|
||||||
mStringIndex++;
|
mStringIndex++;
|
||||||
if( mStringIndex == mSerialText.size() )
|
if( mStringIndex == mSerialText.size() )
|
||||||
@@ -1254,22 +1247,22 @@ void SerialSimulationDataGenerator::CreateSerialByte( U64 value )
|
|||||||
// assume we start high
|
// assume we start high
|
||||||
mSerialSimulationData.Transition(); // low-going edge for start bit
|
mSerialSimulationData.Transition(); // low-going edge for start bit
|
||||||
mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() ); // add
|
mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() ); // add
|
||||||
start bit time if( mSettings->mInverted == true ) value = ~value;
|
start bit time if( mSettings.mInverted == true ) value = ~value;
|
||||||
U32 num_bits = mSettings->mBitsPerTransfer;
|
U32 num_bits = mSettings.mBitsPerTransfer;
|
||||||
BitExtractor bit_extractor( value, mSettings->mShiftOrder, num_bits );
|
BitExtractor bit_extractor( value, mSettings.mShiftOrder, num_bits );
|
||||||
for( U32 i = 0; i < num_bits; i++ )
|
for( U32 i = 0; i < num_bits; i++ )
|
||||||
{
|
{
|
||||||
mSerialSimulationData.TransitionIfNeeded( bit_extractor.GetNextBit() );
|
mSerialSimulationData.TransitionIfNeeded( bit_extractor.GetNextBit() );
|
||||||
mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() );
|
mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() );
|
||||||
}
|
}
|
||||||
if( mSettings->mParity == AnalyzerEnums::Even )
|
if( mSettings.mParity == AnalyzerEnums::Even )
|
||||||
{
|
{
|
||||||
if( AnalyzerHelpers::IsEven( AnalyzerHelpers::GetOnesCount( value ) ) == true )
|
if( AnalyzerHelpers::IsEven( AnalyzerHelpers::GetOnesCount( value ) ) == true )
|
||||||
mSerialSimulationData.TransitionIfNeeded( mBitLow ); // we want to
|
mSerialSimulationData.TransitionIfNeeded( mBitLow ); // we want to
|
||||||
add a zero bit else mSerialSimulationData.TransitionIfNeeded( mBitHigh ); // we want to
|
add a zero bit else mSerialSimulationData.TransitionIfNeeded( mBitHigh ); // we want to
|
||||||
add a one bit mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() );
|
add a one bit mSerialSimulationData.Advance( mClockGenerator.AdvanceByHalfPeriod() );
|
||||||
}
|
}
|
||||||
else if( mSettings->mParity == AnalyzerEnums::Odd )
|
else if( mSettings.mParity == AnalyzerEnums::Odd )
|
||||||
{
|
{
|
||||||
if( AnalyzerHelpers::IsOdd( AnalyzerHelpers::GetOnesCount( value ) ) == true )
|
if( AnalyzerHelpers::IsOdd( AnalyzerHelpers::GetOnesCount( value ) ) == true )
|
||||||
mSerialSimulationData.TransitionIfNeeded( mBitLow ); // we want to
|
mSerialSimulationData.TransitionIfNeeded( mBitLow ); // we want to
|
||||||
@@ -1355,9 +1348,9 @@ U32 I2cSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_reque
|
|||||||
```c++
|
```c++
|
||||||
void SpiSimulationDataGenerator::OutputWord_CPHA1( U64 mosi_data, U64 miso_data )
|
void SpiSimulationDataGenerator::OutputWord_CPHA1( U64 mosi_data, U64 miso_data )
|
||||||
{
|
{
|
||||||
BitExtractor mosi_bits( mosi_data, mSettings->mShiftOrder, mSettings - > mBitsPerTransfer );
|
BitExtractor mosi_bits( mosi_data, mSettings.mShiftOrder, mSettings - > mBitsPerTransfer );
|
||||||
BitExtractor miso_bits( miso_data, mSettings->mShiftOrder, mSettings - > mBitsPerTransfer );
|
BitExtractor miso_bits( miso_data, mSettings.mShiftOrder, mSettings - > mBitsPerTransfer );
|
||||||
U32 count = mSettings->mBitsPerTransfer;
|
U32 count = mSettings.mBitsPerTransfer;
|
||||||
for( U32 i = 0; i < count; i++ )
|
for( U32 i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
mClock->Transition(); // data invalid
|
mClock->Transition(); // data invalid
|
||||||
@@ -1381,7 +1374,7 @@ void SpiSimulationDataGenerator::CreateSpiTransaction()
|
|||||||
if( mEnable != NULL )
|
if( mEnable != NULL )
|
||||||
mEnable->Transition();
|
mEnable->Transition();
|
||||||
mSpiSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 2.0 ) );
|
mSpiSimulationChannels.AdvanceAll( mClockGenerator.AdvanceByHalfPeriod( 2.0 ) );
|
||||||
if( mSettings->mDataValidEdge == AnalyzerEnums::LeadingEdge )
|
if( mSettings.mDataValidEdge == AnalyzerEnums::LeadingEdge )
|
||||||
{
|
{
|
||||||
OutputWord_CPHA0( mValue, mValue + 1 );
|
OutputWord_CPHA0( mValue, mValue + 1 );
|
||||||
mValue++;
|
mValue++;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
SimpleSerialAnalyzer::SimpleSerialAnalyzer()
|
SimpleSerialAnalyzer::SimpleSerialAnalyzer()
|
||||||
: Analyzer2(),
|
: Analyzer2(),
|
||||||
mSettings( new SimpleSerialAnalyzerSettings() ),
|
mSettings(),
|
||||||
mSimulationInitilized( false )
|
mSimulationInitilized( false )
|
||||||
{
|
{
|
||||||
SetAnalyzerSettings( mSettings.get() );
|
SetAnalyzerSettings( &mSettings );
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleSerialAnalyzer::~SimpleSerialAnalyzer()
|
SimpleSerialAnalyzer::~SimpleSerialAnalyzer()
|
||||||
@@ -17,22 +17,23 @@ SimpleSerialAnalyzer::~SimpleSerialAnalyzer()
|
|||||||
|
|
||||||
void SimpleSerialAnalyzer::SetupResults()
|
void SimpleSerialAnalyzer::SetupResults()
|
||||||
{
|
{
|
||||||
mResults.reset( new SimpleSerialAnalyzerResults( this, mSettings.get() ) );
|
// SetupResults is called each time the analyzer is run. Because the same instance can be used for multiple runs, we need to clear the results each time.
|
||||||
|
mResults.reset(new SimpleSerialAnalyzerResults( this, &mSettings ));
|
||||||
SetAnalyzerResults( mResults.get() );
|
SetAnalyzerResults( mResults.get() );
|
||||||
mResults->AddChannelBubblesWillAppearOn( mSettings->mInputChannel );
|
mResults->AddChannelBubblesWillAppearOn( mSettings.mInputChannel );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleSerialAnalyzer::WorkerThread()
|
void SimpleSerialAnalyzer::WorkerThread()
|
||||||
{
|
{
|
||||||
mSampleRateHz = GetSampleRate();
|
mSampleRateHz = GetSampleRate();
|
||||||
|
|
||||||
mSerial = GetAnalyzerChannelData( mSettings->mInputChannel );
|
mSerial = GetAnalyzerChannelData( mSettings.mInputChannel );
|
||||||
|
|
||||||
if( mSerial->GetBitState() == BIT_LOW )
|
if( mSerial->GetBitState() == BIT_LOW )
|
||||||
mSerial->AdvanceToNextEdge();
|
mSerial->AdvanceToNextEdge();
|
||||||
|
|
||||||
U32 samples_per_bit = mSampleRateHz / mSettings->mBitRate;
|
U32 samples_per_bit = mSampleRateHz / mSettings.mBitRate;
|
||||||
U32 samples_to_first_center_of_first_data_bit = U32( 1.5 * double( mSampleRateHz ) / double( mSettings->mBitRate ) );
|
U32 samples_to_first_center_of_first_data_bit = U32( 1.5 * double( mSampleRateHz ) / double( mSettings.mBitRate ) );
|
||||||
|
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{
|
{
|
||||||
@@ -48,7 +49,7 @@ void SimpleSerialAnalyzer::WorkerThread()
|
|||||||
for( U32 i=0; i<8; i++ )
|
for( U32 i=0; i<8; i++ )
|
||||||
{
|
{
|
||||||
//let's put a dot exactly where we sample this bit:
|
//let's put a dot exactly where we sample this bit:
|
||||||
mResults->AddMarker( mSerial->GetSampleNumber(), AnalyzerResults::Dot, mSettings->mInputChannel );
|
mResults->AddMarker( mSerial->GetSampleNumber(), AnalyzerResults::Dot, mSettings.mInputChannel );
|
||||||
|
|
||||||
if( mSerial->GetBitState() == BIT_HIGH )
|
if( mSerial->GetBitState() == BIT_HIGH )
|
||||||
data |= mask;
|
data |= mask;
|
||||||
@@ -81,7 +82,7 @@ U32 SimpleSerialAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32
|
|||||||
{
|
{
|
||||||
if( mSimulationInitilized == false )
|
if( mSimulationInitilized == false )
|
||||||
{
|
{
|
||||||
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), mSettings.get() );
|
mSimulationDataGenerator.Initialize( GetSimulationSampleRate(), &mSettings );
|
||||||
mSimulationInitilized = true;
|
mSimulationInitilized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ U32 SimpleSerialAnalyzer::GenerateSimulationData( U64 minimum_sample_index, U32
|
|||||||
|
|
||||||
U32 SimpleSerialAnalyzer::GetMinimumSampleRateHz()
|
U32 SimpleSerialAnalyzer::GetMinimumSampleRateHz()
|
||||||
{
|
{
|
||||||
return mSettings->mBitRate * 4;
|
return mSettings.mBitRate * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SimpleSerialAnalyzer::GetAnalyzerName() const
|
const char* SimpleSerialAnalyzer::GetAnalyzerName() const
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
#define SIMPLESERIAL_ANALYZER_H
|
#define SIMPLESERIAL_ANALYZER_H
|
||||||
|
|
||||||
#include <Analyzer.h>
|
#include <Analyzer.h>
|
||||||
|
#include "SimpleSerialAnalyzerSettings.h"
|
||||||
#include "SimpleSerialAnalyzerResults.h"
|
#include "SimpleSerialAnalyzerResults.h"
|
||||||
#include "SimpleSerialSimulationDataGenerator.h"
|
#include "SimpleSerialSimulationDataGenerator.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class SimpleSerialAnalyzerSettings;
|
|
||||||
class ANALYZER_EXPORT SimpleSerialAnalyzer : public Analyzer2
|
class ANALYZER_EXPORT SimpleSerialAnalyzer : public Analyzer2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -22,8 +23,8 @@ public:
|
|||||||
virtual bool NeedsRerun();
|
virtual bool NeedsRerun();
|
||||||
|
|
||||||
protected: //vars
|
protected: //vars
|
||||||
std::auto_ptr< SimpleSerialAnalyzerSettings > mSettings;
|
SimpleSerialAnalyzerSettings mSettings;
|
||||||
std::auto_ptr< SimpleSerialAnalyzerResults > mResults;
|
std::unique_ptr<SimpleSerialAnalyzerResults> mResults;
|
||||||
AnalyzerChannelData* mSerial;
|
AnalyzerChannelData* mSerial;
|
||||||
|
|
||||||
SimpleSerialSimulationDataGenerator mSimulationDataGenerator;
|
SimpleSerialSimulationDataGenerator mSimulationDataGenerator;
|
||||||
|
|||||||
@@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
SimpleSerialAnalyzerSettings::SimpleSerialAnalyzerSettings()
|
SimpleSerialAnalyzerSettings::SimpleSerialAnalyzerSettings()
|
||||||
: mInputChannel( UNDEFINED_CHANNEL ),
|
: mInputChannel( UNDEFINED_CHANNEL ),
|
||||||
mBitRate( 9600 )
|
mBitRate( 9600 ),
|
||||||
|
mInputChannelInterface(),
|
||||||
|
mBitRateInterface()
|
||||||
{
|
{
|
||||||
mInputChannelInterface.reset( new AnalyzerSettingInterfaceChannel() );
|
mInputChannelInterface.SetTitleAndTooltip( "Serial", "Standard Simple Serial" );
|
||||||
mInputChannelInterface->SetTitleAndTooltip( "Serial", "Standard Simple Serial" );
|
mInputChannelInterface.SetChannel( mInputChannel );
|
||||||
mInputChannelInterface->SetChannel( mInputChannel );
|
|
||||||
|
|
||||||
mBitRateInterface.reset( new AnalyzerSettingInterfaceInteger() );
|
mBitRateInterface.SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
|
||||||
mBitRateInterface->SetTitleAndTooltip( "Bit Rate (Bits/S)", "Specify the bit rate in bits per second." );
|
mBitRateInterface.SetMax( 6000000 );
|
||||||
mBitRateInterface->SetMax( 6000000 );
|
mBitRateInterface.SetMin( 1 );
|
||||||
mBitRateInterface->SetMin( 1 );
|
mBitRateInterface.SetInteger( mBitRate );
|
||||||
mBitRateInterface->SetInteger( mBitRate );
|
|
||||||
|
|
||||||
AddInterface( mInputChannelInterface.get() );
|
AddInterface( &mInputChannelInterface );
|
||||||
AddInterface( mBitRateInterface.get() );
|
AddInterface( &mBitRateInterface );
|
||||||
|
|
||||||
AddExportOption( 0, "Export as text/csv file" );
|
AddExportOption( 0, "Export as text/csv file" );
|
||||||
AddExportExtension( 0, "text", "txt" );
|
AddExportExtension( 0, "text", "txt" );
|
||||||
@@ -33,8 +33,8 @@ SimpleSerialAnalyzerSettings::~SimpleSerialAnalyzerSettings()
|
|||||||
|
|
||||||
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
||||||
{
|
{
|
||||||
mInputChannel = mInputChannelInterface->GetChannel();
|
mInputChannel = mInputChannelInterface.GetChannel();
|
||||||
mBitRate = mBitRateInterface->GetInteger();
|
mBitRate = mBitRateInterface.GetInteger();
|
||||||
|
|
||||||
ClearChannels();
|
ClearChannels();
|
||||||
AddChannel( mInputChannel, "Simple Serial", true );
|
AddChannel( mInputChannel, "Simple Serial", true );
|
||||||
@@ -44,8 +44,8 @@ bool SimpleSerialAnalyzerSettings::SetSettingsFromInterfaces()
|
|||||||
|
|
||||||
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
void SimpleSerialAnalyzerSettings::UpdateInterfacesFromSettings()
|
||||||
{
|
{
|
||||||
mInputChannelInterface->SetChannel( mInputChannel );
|
mInputChannelInterface.SetChannel( mInputChannel );
|
||||||
mBitRateInterface->SetInteger( mBitRate );
|
mBitRateInterface.SetInteger( mBitRate );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleSerialAnalyzerSettings::LoadSettings( const char* settings )
|
void SimpleSerialAnalyzerSettings::LoadSettings( const char* settings )
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ public:
|
|||||||
U32 mBitRate;
|
U32 mBitRate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::auto_ptr< AnalyzerSettingInterfaceChannel > mInputChannelInterface;
|
AnalyzerSettingInterfaceChannel mInputChannelInterface;
|
||||||
std::auto_ptr< AnalyzerSettingInterfaceInteger > mBitRateInterface;
|
AnalyzerSettingInterfaceInteger mBitRateInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SIMPLESERIAL_ANALYZER_SETTINGS
|
#endif //SIMPLESERIAL_ANALYZER_SETTINGS
|
||||||
|
|||||||
Reference in New Issue
Block a user