52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#ifndef DATASOURCE_H
|
|
#define DATASOURCE_H
|
|
|
|
#include <QObject>
|
|
#include <QSerialPort>
|
|
#include <QVector>
|
|
#include <QPoint>
|
|
#include "structures.h"
|
|
|
|
enum ParserState {
|
|
StateIdle = 0,
|
|
StateHeader,
|
|
StateData,
|
|
};
|
|
/**
|
|
*/
|
|
class DataSource : public QObject {
|
|
Q_OBJECT
|
|
QSerialPort usart;
|
|
TrigerSettings trigerSettings;
|
|
char * in_buffer;
|
|
ParserState state;
|
|
char * packet_buf;
|
|
int packet_cnt;
|
|
SendHeader header;
|
|
bool catching;
|
|
public:
|
|
explicit DataSource (QObject * p = nullptr);
|
|
virtual ~DataSource ();
|
|
TrigerSettings * getTrigger () {
|
|
return & trigerSettings;
|
|
}
|
|
void SendTrigerMode (int n);
|
|
void SendTrigerEdge (int n);
|
|
void SendTrigerChan (int n);
|
|
void SendBaseRange (int n);
|
|
void Start ();
|
|
public slots:
|
|
void read_data ();
|
|
void SettingChanged (int n);
|
|
signals:
|
|
void Channels_received(QVector<int>, QVector<int>);
|
|
void PaketTriggered ();
|
|
protected:
|
|
void parse_input (const char * data, const long len);
|
|
void parse_packet ();
|
|
void parse_header ();
|
|
protected:
|
|
void send_trig_mode ();
|
|
};
|
|
|
|
#endif // DATASOURCE_H
|