MNE-CPP  beta 1.0
babymegclient.h
1 //=============================================================================================================
37 #ifndef BABYMEGCLIENT_H
38 #define BABYMEGCLIENT_H
39 
40 //*************************************************************************************************************
41 //=============================================================================================================
42 // QT INCLUDES
43 //=============================================================================================================
44 
45 #include <QObject>
46 #include <QTcpSocket>
47 #include <QMutex>
48 #include <QThread>
49 #include <QDataStream>
50 
51 
52 //*************************************************************************************************************
53 //=============================================================================================================
54 // INCLUDES
55 //=============================================================================================================
56 
57 #include "babymeginfo.h"
58 
59 
60 class QTcpSocket;
61 class QNetworkSession;
62 
63 
64 //=============================================================================================================
70 class BabyMEGClient : public QThread
71 {
72  Q_OBJECT
73 
74 public:
75  //=========================================================================================================
79  explicit BabyMEGClient(int myPort, QObject *parent = 0);
80 
81  ~BabyMEGClient();
82 
83  //=========================================================================================================
90  QByteArray MGH_LM_Int2Byte(int a);
91 
92  //=========================================================================================================
99  int MGH_LM_Byte2Int(QByteArray InByte);
100 
101  //=========================================================================================================
108  double MGH_LM_Byte2Double(QByteArray InByte);
109 
110  //=========================================================================================================
116  void HexDisplay(double a);
117 
118  //=========================================================================================================
124  void SetInfo(QSharedPointer<BabyMEGInfo> pInfo);
125 
126  //=========================================================================================================
132  void DispatchDataPackage(int tmp);
133 
134  //=========================================================================================================
140  void ReadNextBlock(int tmp);
141 
142  //=========================================================================================================
148  void SendCommand(QString s);
149 
150  //=========================================================================================================
156  void handleBuffer();
157 
158  inline bool isConnected() const;
159 
160 signals:
161  void DataAcq();
162  void error(int socketError, const QString &message);
163 
164 public slots:
165  //=========================================================================================================
171  void ConnectToBabyMEG();
172 
173  //=========================================================================================================
179  void DisConnectBabyMEG();
180 
181  //=========================================================================================================
187  void SendCommandToBabyMEG();
188  void DisplayError(int socketError, const QString &message);
189 
190  //=========================================================================================================
196  void ReadToBuffer();
197  void run();
198 
199  //=========================================================================================================
205  void SendCommandToBabyMEGShortConnection(QByteArray s);
206 
207 public:
208  QString name;
209  int port;
210  bool SkipLoop;
211  bool DataAcqStartFlag;
212  QSharedPointer<BabyMEGInfo> myBabyMEGInfo;
213 
214  QByteArray buffer;
215  int numBlock;
216  bool DataACK;
217 
218 private:
219  bool m_bSocketIsConnected;
220  QTcpSocket *tcpSocket;
221  QMutex m_qMutex;
222 
223 };
224 
225 //*************************************************************************************************************
226 //=============================================================================================================
227 // INLINE DEFINITIONS
228 //=============================================================================================================
229 
230 inline bool BabyMEGClient::isConnected() const
231 {
232  return m_bSocketIsConnected;
233 }
234 
235 #endif // BABYMEGCLIENT_H
BabyMEGClient(int myPort, QObject *parent=0)
void SendCommandToBabyMEG()
void ReadNextBlock(int tmp)
void HexDisplay(double a)
void DisConnectBabyMEG()
void SendCommandToBabyMEGShortConnection(QByteArray s)
void SetInfo(BabyMEGInfo *pInfo)
void ConnectToBabyMEG()
double MGH_LM_Byte2Double(QByteArray InByte)
int MGH_LM_Byte2Int(QByteArray InByte)
void SendCommand(QString s)
The BabyMEGClient class provides a TCP/IP communication between Qt and Labview.
Definition: babymegclient.h:70
QByteArray MGH_LM_Int2Byte(int a)
void DispatchDataPackage(int tmp)