MNE-CPP  beta 1.0
serialport.h
Go to the documentation of this file.
1 //=============================================================================================================
37 #ifndef SERIALPORT_H
38 #define SERIALPORT_H
39 
40 
41 //*************************************************************************************************************
42 //=============================================================================================================
43 // INCLUDES
44 //=============================================================================================================
45 #include "triggercontrol.h"
46 
47 //*************************************************************************************************************
48 //=============================================================================================================
49 // QT INCLUDES
50 //=============================================================================================================
51 
52 #include <QSerialPort>
53 #include <QVector>
54 
55 //*************************************************************************************************************
56 //=============================================================================================================
57 // DEFINE NAMESPACE TriggerControlPlugin
58 //=============================================================================================================
59 
60 namespace TriggerControlPlugin
61 {
62 
63 
64 //*************************************************************************************************************
65 //=============================================================================================================
66 // USED NAMESPACES
67 //=============================================================================================================
68 
69 
70 
71 //*************************************************************************************************************
72 //=============================================================================================================
73 // FORWARD DECLARATIONS
74 //=============================================================================================================
75 
76 
77 
78 
79 //=============================================================================================================
89 class SerialPort : public QObject
90 {
91  Q_OBJECT
92 public:
93  //=========================================================================================================
97  SerialPort();
98 
99  //=========================================================================================================
103  ~SerialPort();
104 
105  //=========================================================================================================
110  void initSettings();
111 
112  //=========================================================================================================
117  void initPort();
118 
119  //=========================================================================================================
124  bool open();
125 
126  //=========================================================================================================
131  void close();
132 
133  //=========================================================================================================
138  void encodedig();
139 
140  //=========================================================================================================
145  void encodeana();
146 
147  //=========================================================================================================
152  void encoderetr();
153 
154  //=========================================================================================================
159  void decodedig(QByteArray &t_incomingArray);
160 
161  //=========================================================================================================
167  void decodeana(QByteArray &t_incomingArray);
168 
169  //=========================================================================================================
174  void sendData(const QByteArray &data);
175 
176  //=========================================================================================================
181  void readData();
182 
183 
184 
185  QByteArray m_data;
186  QVector<int> m_digchannel;
187  int m_motor;
188  int m_analval;
190  QVector<int> m_InAnChannelVal;
191  QVector<int> m_InActiveDig;
198  //=========================================================================================================
213  struct Settings {
214  QString name;
215  qint32 baudRate;
216  QString stringBaudRate;
217  QSerialPort::DataBits dataBits;
218  QString stringDataBits;
219  QSerialPort::Parity parity;
220  QString stringParity;
221  QSerialPort::StopBits stopBits;
222  QString stringStopBits;
223  QSerialPort::FlowControl flowControl;
224  QString stringFlowControl;
225  };
226 
227 
228 //=========================================================================================================
233  inline Settings& settings()
234  {
235  return m_currentSettings;
236  }
237 
238 //=========================================================================================================
239 
240 signals:
241  void dataAvailable(const QByteArray);
243  void byteReceived();
246 protected:
247 
248 private:
249  Settings m_currentSettings;
250  QSerialPort m_qSerialPort;
251 };
252 
253 } // Namespace
254 
255 #endif // SERIALPORT_H
256 
257 
258 
259 
260 
261 
The SerialPort is a class which holds all properties and methods necesarry to open, communicate and close a serial port. In most cases you want to open the port, encode your output information (digital, analog or retrieve) and decode input information (digital or analog). When you are done, close the serial port.
Definition: serialport.h:89
void dataAvailable(const QByteArray)
void decodedig(QByteArray &t_incomingArray)
Definition: serialport.cpp:208
void decodeana(QByteArray &t_incomingArray)
Definition: serialport.cpp:123
void sendData(const QByteArray &data)
Definition: serialport.cpp:522
Contains the declaration of the TriggerControl class.