Files
@ 48e24c542d4e
Branch filter:
Location: tempo-plotter/src/abstractreader.h - annotation
48e24c542d4e
2.3 KiB
text/plain
Change binary name
ecd02467c397 233fe22d52af ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 07ecd1b1fb2a ecd02467c397 14ef268b5d60 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 14ef268b5d60 ecd02467c397 ecd02467c397 ecd02467c397 14ef268b5d60 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 81a003dc29e2 ecd02467c397 14ef268b5d60 14ef268b5d60 e0c6c43cbcf5 a9a5e414ab54 a9a5e414ab54 a9a5e414ab54 ecd02467c397 14ef268b5d60 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 ecd02467c397 902281c3698d ecd02467c397 ecd02467c397 233fe22d52af ecd02467c397 233fe22d52af 233fe22d52af 233fe22d52af 902281c3698d 65256d18c617 233fe22d52af 233fe22d52af 233fe22d52af 233fe22d52af 233fe22d52af 233fe22d52af 233fe22d52af 233fe22d52af a9a5e414ab54 233fe22d52af 233fe22d52af 233fe22d52af ecd02467c397 ecd02467c397 ecd02467c397 | /*
Copyright © 2019 Hasan Yavuz Özderya
This file is part of serialplot.
serialplot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
serialplot is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with serialplot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ABSTRACTREADER_H
#define ABSTRACTREADER_H
#include <QObject>
#include <QIODevice>
#include <QWidget>
#include <QTimer>
#include "source.h"
/**
* All reader classes must inherit this class.
*/
class AbstractReader : public QObject, public Source
{
Q_OBJECT
public:
explicit AbstractReader(QIODevice* device, QObject* parent = 0);
/**
* Returns a widget to be shown in data format panel when reader
* is selected.
*/
virtual QWidget* settingsWidget() = 0;
/// Reader should only read when enabled. Default state should be
/// 'disabled'.
virtual void enable(bool enabled = true);
/// None of the current readers support X channel at the moment
bool hasX() const final { return false; };
/// Read and 'zero' the byte counter
unsigned getBytesRead();
signals:
// TODO: should we keep this?
void numOfChannelsChanged(unsigned);
public slots:
/**
* Pauses the reading.
*
* Reader should actually continue reading to keep the
* synchronization but shouldn't commit data.
*/
void pause(bool enabled);
protected:
/// Reader should read from this device in `readData()` function.
QIODevice* _device;
/// Reader should check this variable to determine if reading is
/// paused in `readData()`
bool paused;
/**
* Called when `readyRead` is signaled by the device. This is
* where the implementors should read the data and return the
* exact number of bytes read from the device.
*/
virtual unsigned readData() = 0;
private:
unsigned bytesRead;
private slots:
void onDataReady();
};
#endif // ABSTRACTREADER_H
|