source: pacpusframework/branches/2.0-beta1/include/Pacpus/PacpusTools/PacpusSerialPort.h@ 152

Last change on this file since 152 was 152, checked in by Marek Kurdej, 11 years ago

Major update.
Renamed: addInput -> addInputs, addOutput -> addOutputs and made pure virtual (=0).
Transformed macro definitions into template methods: ADD_INPUT -> ComponentBase::addInput, ADD_OUTPUT -> ComponentBase::addOutput, GET_INPUT -> ComponentBase::getTypedInput, GET_OUTPUT -> ComponentBase::getTypedOutput.
Fixed: added public/protected set/get methods in ComponentBase, made member fields private.

File size: 1.7 KB
RevLine 
[120]1/*********************************************************************
2// created: 2013/07/10
3// filename: PacpusSerialPort.h
4//
5// author: Julien Moras
6//
7// version: $Id: $
8//
9// purpose: This class defines a Qt 5.1 driver for serial port
10*********************************************************************/
11#ifndef _PacpusSerialPort_H_
12#define _PacpusSerialPort_H_
13
14#include <QtSerialPort/QSerialPort>
15#include <QtSerialPort/QSerialPortInfo>
16#include <QThread>
17
18#include <Pacpus/kernel/ComponentBase.h>
19
20namespace pacpus {
21
[152]22class PacpusSerialPort
23 : public QObject
24 , public ComponentBase
[120]25{
26 Q_OBJECT
27
28public:
[152]29 typedef enum {
30 ASCII,
31 BINARY
32 } DataMode;
[120]33
34 PacpusSerialPort(QString name);
35 ~PacpusSerialPort();
36
37protected:
38 void startActivity(); /*!< to start the processing thread */
39 void stopActivity(); /*!< to stop the processing thread */
40 ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
41
[152]42 virtual void addInputs();
43 virtual void addOutputs();
[120]44 void processInputFrame(const QByteArray &);
45
[152]46private Q_SLOTS:
[120]47 void readData();
48
49private:
50 QThread thread_;
51
52 QSerialPort * serialPort;
53
54 QString portName;
55 QSerialPort::Direction direction;
56 QSerialPort::BaudRate baudRate;
57 QSerialPort::DataBits dataBits;
58 QSerialPort::Parity parity;
59 QSerialPort::StopBits stopBits;
60 QSerialPort::FlowControl flowControl;
61 QSerialPort::DataErrorPolicy errorPolicy;
62 DataMode dataMode;
63
64 QByteArray buffer;
65
66 QString sepChar;
[121]67 QString startChar;
68 QString stopChar;
[120]69
[122]70 int minPacketSize;
[120]71
[122]72 bool log;
[120]73};
74
75} // end namespace
76
77#endif
Note: See TracBrowser for help on using the repository browser.