ahbuartplugin.h
99 lines
| 3.2 KiB
| text/x-c
|
CLexer
/ ahbuartplugin / ahbuartplugin.h
r0 | /*------------------------------------------------------------------------------ | |||
Jeandet Alexis
|
r4 | -- This file is a part of the SocExplorer Software | ||
Jeandet Alexis
|
r11 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS | ||
r0 | -- | |||
-- This program 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. | ||||
-- | ||||
-- This program 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 this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@lpp.polytechnique.fr | ||||
----------------------------------------------------------------------------*/ | ||||
#ifndef AHBUARTPLUGIN_H | ||||
#define AHBUARTPLUGIN_H | ||||
#include <QMenuBar> | ||||
#include <QMenu> | ||||
#include <QAction> | ||||
#include <QLayout> | ||||
#include <QMutex> | ||||
#include <QProgressDialog> | ||||
#include <QStringListModel> | ||||
#include <QTime> | ||||
#include <socexplorerplugin.h> | ||||
#include "ahbuartpluginui.h" | ||||
Jeandet Alexis
|
r27 | #include <RS232.h> | ||
r33 | #include <unistd.h> | |||
r0 | ||||
#define SAFEWRITE(data,count,timer,timeout,error) \ | ||||
r33 | while(1)\ | |||
r0 | {\ | |||
unsigned int __writen__=0; \ | ||||
(timer).restart(); \ | ||||
while(__writen__!=(count)) \ | ||||
r33 | {\ | |||
__writen__ += rs232write(this->port,((data)+__writen__),((count)-__writen__)); \ | ||||
if((timer).elapsed()>(timeout)) \ | ||||
{\ | ||||
this->port = (rs232port_t)NULL; \ | ||||
this->Connected = false; \ | ||||
emit this->activateSig(false); \ | ||||
error; \ | ||||
} \ | ||||
r0 | } \ | |||
break;\ | ||||
r33 | } | |||
r0 | ||||
class ahbuartplugin : public socexplorerplugin | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
ahbuartplugin(QWidget *parent = 0); | ||||
~ahbuartplugin(); | ||||
int registermenu(QMainWindow *menuHolder); | ||||
int VID(){return driver_VID;} | ||||
int PID(){return driver_PID;} | ||||
public slots: | ||||
void togglePort(QString PortName,int baudrate); | ||||
unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); | ||||
unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); | ||||
void closeMe(); | ||||
void close(); | ||||
bool open(QString PortName,int baudrate); | ||||
void updatePortList(); | ||||
QVariantList ReadBytes(unsigned int address,unsigned int count); | ||||
void WriteBytes(unsigned int address,QList<QVariant> dataList); | ||||
signals: | ||||
void setProgressValue(int progress); | ||||
r31 | void addWritenBytes(int count); | |||
void addReadBytes(int count); | ||||
r0 | private: | |||
bool scanDone; | ||||
QProgressDialog* progress; | ||||
QLayout * mainLayout; | ||||
ahbUartPluginUI* UI; | ||||
QMutex* portMutex; | ||||
rs232port_t port; | ||||
QCompleter *portListcompleter; | ||||
QStringListModel *portListcompleterModel; | ||||
void connectPort(QString PortName,int baudrate); | ||||
bool checkConnection(); | ||||
}; | ||||
#endif // AHBUARTPLUGIN_H | ||||