Changeset - 902281c3698d
[Not reviewed]
default
0 10 0
Mehmet ASLAN - 7 years ago 2018-06-24 01:00:31
aaslan.mehmet@hotmail.com
pause common in all readers, abstracted
10 files changed with 7 insertions and 35 deletions:
0 comments (0 inline, 0 general)
src/abstractreader.cpp
Show inline comments
 
@@ -21,6 +21,11 @@
 

	
 
AbstractReader::AbstractReader(QIODevice* device, QObject* parent) :
 
    QObject(parent)
 
{
 
    _device = device;
 
}
 

	
 
void AbstractReader::pause(bool enabled)
 
{
 
    paused = enabled;
 
}
src/abstractreader.h
Show inline comments
 
@@ -57,13 +57,14 @@ public slots:
 
    /**
 
     * Pauses the reading.
 
     *
 
     * Reader should actually continue reading to keep the
 
     * synchronization but shouldn't commit data.
 
     */
 
    virtual void pause(bool) = 0;
 
    void pause(bool enabled);
 

	
 
protected:
 
    QIODevice* _device;
 
    bool paused;
 
};
 

	
 
#endif // ABSTRACTREADER_H
src/asciireader.cpp
Show inline comments
 
@@ -81,17 +81,12 @@ void AsciiReader::enable(bool enabled)
 
    {
 
        QObject::disconnect(_device, 0, this, 0);
 
        disconnectSinks();
 
    }
 
}
 

	
 
void AsciiReader::pause(bool enabled)
 
{
 
    paused = enabled;
 
}
 

	
 
void AsciiReader::onDataReady()
 
{
 
    while(_device->canReadLine())
 
    {
 
        QString line = QString(_device->readLine());
 

	
src/asciireader.h
Show inline comments
 
@@ -36,22 +36,18 @@ public:
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    AsciiReaderSettings _settingsWidget;
 
    unsigned _numChannels;
 
    /// number of channels will be determined from incoming data
 
    unsigned autoNumOfChannels;
 
    QChar delimiter; ///< selected column delimiter
 
    bool paused;
 

	
 
    // We may have (usually true) started reading in the middle of a
 
    // line, so its a better idea to just discard first line.
 
    bool discardFirstLine;
 

	
 
private slots:
src/binarystreamreader.cpp
Show inline comments
 
@@ -73,17 +73,12 @@ void BinaryStreamReader::enable(bool ena
 
    {
 
        QObject::disconnect(_device, 0, this, 0);
 
        disconnectSinks();
 
    }
 
}
 

	
 
void BinaryStreamReader::pause(bool enabled)
 
{
 
    paused = enabled;
 
}
 

	
 
void BinaryStreamReader::onNumberFormatChanged(NumberFormat numberFormat)
 
{
 
    switch(numberFormat)
 
    {
 
        case NumberFormat_uint8:
 
            sampleSize = 1;
src/binarystreamreader.h
Show inline comments
 
@@ -40,20 +40,16 @@ public:
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    BinaryStreamReaderSettings _settingsWidget;
 
    unsigned _numChannels;
 
    unsigned sampleSize;
 
    bool paused;
 
    bool skipByteRequested;
 
    bool skipSampleRequested;
 

	
 
    /// points to the readSampleAs function for currently selected number format
 
    double (BinaryStreamReader::*readSample)();
 

	
src/demoreader.cpp
Show inline comments
 
@@ -64,17 +64,12 @@ unsigned DemoReader::numChannels() const
 

	
 
void DemoReader::setNumChannels(unsigned value)
 
{
 
    _settingsWidget.setNumChannels(value);
 
}
 

	
 
void DemoReader::pause(bool enabled)
 
{
 
    paused = enabled;
 
}
 

	
 
void DemoReader::demoTimerTimeout()
 
{
 
    const double period = 100;
 
    count++;
 
    if (count >= 100) count = 0;
 

	
src/demoreader.h
Show inline comments
 
@@ -43,19 +43,17 @@ public:
 

	
 
    QWidget* settingsWidget();
 
    unsigned numChannels() const;
 
    void enable(bool enabled = true);
 

	
 
public slots:
 
    void pause(bool);
 
    void setNumChannels(unsigned value);
 

	
 
private:
 
    DemoReaderSettings _settingsWidget;
 

	
 
    bool paused;
 
    unsigned _numChannels;
 
    QTimer timer;
 
    int count;
 

	
 
private slots:
 
    void demoTimerTimeout();
src/framedreader.cpp
Show inline comments
 
@@ -83,17 +83,12 @@ QWidget* FramedReader::settingsWidget()
 

	
 
unsigned FramedReader::numChannels() const
 
{
 
    return _numChannels;
 
}
 

	
 
void FramedReader::pause(bool enabled)
 
{
 
    paused = enabled;
 
}
 

	
 
void FramedReader::onNumberFormatChanged(NumberFormat numberFormat)
 
{
 
    switch(numberFormat)
 
    {
 
        case NumberFormat_uint8:
 
            sampleSize = 1;
src/framedreader.h
Show inline comments
 
@@ -39,28 +39,24 @@ public:
 
    void enable(bool enabled = true);
 
    /// Stores settings into a `QSettings`
 
    void saveSettings(QSettings* settings);
 
    /// Loads settings from a `QSettings`.
 
    void loadSettings(QSettings* settings);
 

	
 
public slots:
 
    void pause(bool);
 

	
 
private:
 
    /// bit wise fields for `settingsValid` member
 
    enum SettingInvalidFlag
 
    {
 
        SYNCWORD_INVALID = 1,
 
        FRAMESIZE_INVALID = 2
 
    };
 

	
 
    // settings related members
 
    FramedReaderSettings _settingsWidget;
 
    unsigned _numChannels;
 
    unsigned sampleSize;
 
    bool paused;
 
    unsigned settingsInvalid;   /// settings are all valid if this is 0, if not no reading is done
 
    QByteArray syncWord;
 
    bool checksumEnabled;
 
    bool hasSizeByte;
 
    unsigned frameSize;
 
    bool debugModeEnabled;
0 comments (0 inline, 0 general)