Changeset - 556aa6f24713
[Not reviewed]
default
0 5 0
Hasan Yavuz Ă–ZDERYA - 9 years ago 2016-06-14 20:30:20
hy@ozderya.net
added skip sample button
5 files changed with 30 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/binarystreamreader.cpp
Show inline comments
 
@@ -28,6 +28,7 @@ BinaryStreamReader::BinaryStreamReader(Q
 
{
 
    paused = false;
 
    skipByteRequested = false;
 
    skipSampleRequested = false;
 
    sampleCount = 0;
 

	
 
    _numOfChannels = _settingsWidget.numOfChannels();
 
@@ -41,12 +42,17 @@ BinaryStreamReader::BinaryStreamReader(Q
 
    connect(&_settingsWidget, &BinaryStreamReaderSettings::numberFormatChanged,
 
            this, &BinaryStreamReader::onNumberFormatChanged);
 

	
 
    // enable skip byte button
 
    // enable skip byte and sample buttons
 
    connect(&_settingsWidget, &BinaryStreamReaderSettings::skipByteRequested,
 
            [this]()
 
            {
 
                skipByteRequested = true;
 
            });
 
    connect(&_settingsWidget, &BinaryStreamReaderSettings::skipSampleRequested,
 
            [this]()
 
            {
 
                skipSampleRequested = true;
 
            });
 
}
 

	
 
QWidget* BinaryStreamReader::settingsWidget()
 
@@ -123,6 +129,7 @@ void BinaryStreamReader::onDataReady()
 
    int packageSize = sampleSize * _numOfChannels;
 
    int bytesAvailable = _device->bytesAvailable();
 

	
 
    // skip 1 byte if requested
 
    if (bytesAvailable > 0 && skipByteRequested)
 
    {
 
        _device->read(1);
 
@@ -130,6 +137,14 @@ void BinaryStreamReader::onDataReady()
 
        bytesAvailable--;
 
    }
 

	
 
    // skip 1 sample (channel) if requested
 
    if (bytesAvailable >= (int) sampleSize && skipSampleRequested)
 
    {
 
        _device->read(sampleSize);
 
        skipSampleRequested = false;
 
        bytesAvailable--;
 
    }
 

	
 
    if (bytesAvailable < packageSize) return;
 

	
 
    int numOfPackagesToRead =
src/binarystreamreader.h
Show inline comments
 
@@ -46,6 +46,7 @@ private:
 
    unsigned sampleSize;
 
    bool paused;
 
    bool skipByteRequested;
 
    bool skipSampleRequested;
 

	
 
    /// points to the readSampleAs function for currently selected number format
 
    double (BinaryStreamReader::*readSample)();
src/binarystreamreadersettings.cpp
Show inline comments
 
@@ -39,6 +39,7 @@ BinaryStreamReaderSettings::BinaryStream
 
            this, SIGNAL(numberFormatChanged(NumberFormat)));
 

	
 
    connect(ui->pbSkipByte, SIGNAL(clicked()), this, SIGNAL(skipByteRequested()));
 
    connect(ui->pbSkipSample, SIGNAL(clicked()), this, SIGNAL(skipSampleRequested()));
 
}
 

	
 
BinaryStreamReaderSettings::~BinaryStreamReaderSettings()
src/binarystreamreadersettings.h
Show inline comments
 
@@ -44,6 +44,7 @@ signals:
 
    void numOfChannelsChanged(unsigned);
 
    void numberFormatChanged(NumberFormat);
 
    void skipByteRequested();
 
    void skipSampleRequested();
 

	
 
private:
 
    Ui::BinaryStreamReaderSettings *ui;
src/binarystreamreadersettings.ui
Show inline comments
 
@@ -73,13 +73,23 @@
 
     <item>
 
      <widget class="QPushButton" name="pbSkipByte">
 
       <property name="toolTip">
 
        <string>Skip reading 1 byte to correct the alignment</string>
 
        <string>Skip 1 byte while reading to correct the alignment</string>
 
       </property>
 
       <property name="text">
 
        <string>Skip Byte</string>
 
       </property>
 
      </widget>
 
     </item>
 
     <item>
 
      <widget class="QPushButton" name="pbSkipSample">
 
       <property name="toolTip">
 
        <string>Skip reading 1 sample while reading to shift channel order</string>
 
       </property>
 
       <property name="text">
 
        <string>Skip Sample</string>
 
       </property>
 
      </widget>
 
     </item>
 
    </layout>
 
   </item>
 
   <item>
0 comments (0 inline, 0 general)