Ajout de plein d'affaires.
This commit is contained in:
@@ -137,8 +137,12 @@ Makefile: OutilModbus.pro C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qma
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_gui_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_help.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_help_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_httpserver.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_httpserver_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_location.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_location_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_mqtt.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_mqtt_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimedia.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimedia_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimediawidgets.pri \
|
||||
@@ -194,6 +198,8 @@ Makefile: OutilModbus.pro C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qma
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_serialport_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sql.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sql_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sslserver.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sslserver_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_svg.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_svg_private.pri \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_testlib.pri \
|
||||
@@ -223,6 +229,7 @@ Makefile: OutilModbus.pro C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qma
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/qt_config.prf \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qmake.conf \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/spec_post.prf \
|
||||
.qmake.stash \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/exclusive_builds.prf \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/toolchain.prf \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/default_pre.prf \
|
||||
@@ -252,7 +259,6 @@ Makefile: OutilModbus.pro C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qma
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Network.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Core.prl \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/qtmain.prl \
|
||||
.qmake.stash \
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/build_pass.prf
|
||||
$(QMAKE) -o Makefile OutilModbus.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/spec_pre.prf:
|
||||
@@ -322,8 +328,12 @@ C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_gui.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_gui_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_help.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_help_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_httpserver.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_httpserver_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_location.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_location_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_mqtt.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_mqtt_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimedia.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimedia_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_multimediawidgets.pri:
|
||||
@@ -379,6 +389,8 @@ C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_serialport.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_serialport_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sql.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sql_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sslserver.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_sslserver_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_svg.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_svg_private.pri:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/modules/qt_lib_testlib.pri:
|
||||
@@ -408,6 +420,7 @@ C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/qt_functions.prf:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/qt_config.prf:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/win32-g++/qmake.conf:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/spec_post.prf:
|
||||
.qmake.stash:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/exclusive_builds.prf:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/toolchain.prf:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/default_pre.prf:
|
||||
@@ -437,7 +450,6 @@ C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Gui.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Network.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/Qt5Core.prl:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/lib/qtmain.prl:
|
||||
.qmake.stash:
|
||||
C:/Qt/Qt5.14.2/5.14.2/mingw73_64/mkspecs/features/build_pass.prf:
|
||||
qmake: FORCE
|
||||
@$(QMAKE) -o Makefile OutilModbus.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
|
||||
+773
-22
File diff suppressed because one or more lines are too long
+892
-46
File diff suppressed because one or more lines are too long
Binary file not shown.
+12
-3
@@ -31,7 +31,11 @@ SOURCES += \
|
||||
Sources/LazerProbeSimulator.cpp \
|
||||
Sources/SerialPort/qextserialport/src/qextserialport_win.cpp \
|
||||
Sources/SerialPort/qextserialport/src/qextserialport.cpp \
|
||||
Sources/SEIModbusPage.cpp
|
||||
Sources/SEIModbusPage.cpp \
|
||||
Sources/ZTAlarmGenerator.cpp \
|
||||
Sources/ZTAlarmGeneratorPage.cpp \
|
||||
Sources/ZTAlarms.cpp \
|
||||
Sources/ModbusZTMaster.cpp
|
||||
|
||||
HEADERS += \
|
||||
Sources/MainWindow.h \
|
||||
@@ -50,13 +54,18 @@ HEADERS += \
|
||||
Sources/SerialPort/qextserialport/src/qextserialport_p.h \
|
||||
Sources/SerialPort/qextserialport/src/qextserialport_global.h \
|
||||
Sources/SerialPort/qextserialport/src/qextserialport.h \
|
||||
Sources/SEIModbusPage.h
|
||||
Sources/SEIModbusPage.h \
|
||||
Sources/ZTAlarmGenerator.h \
|
||||
Sources/ZTAlarmGeneratorPage.h \
|
||||
Sources/ZTAlarms.h \
|
||||
Sources/ModbusZTMaster.h
|
||||
|
||||
FORMS += \
|
||||
Sources/CModbusPage.ui \
|
||||
Sources/MainPage.ui \
|
||||
Sources/LazerProbeSimPage.ui \
|
||||
Sources/SEIModbusPage.ui
|
||||
Sources/SEIModbusPage.ui \
|
||||
Sources/ZTAlarmGeneratorPage.ui
|
||||
|
||||
DEFINES -= Q_OS_UNIX
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "LazerProbeSimPage.h"
|
||||
#include "SEIModbusPage.h"
|
||||
#include "ui_MainPage.h"
|
||||
#include "ZTAlarmGenerator.h"
|
||||
|
||||
#include "OutilModbus.h"
|
||||
|
||||
@@ -18,12 +19,13 @@ CMainPage::~CMainPage()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int CMainPage::RegisterPagesTabs(CModbusPage *ModbusPage, CLazerProbeSimPage* LazerSimPage, CSEIModbusPage *SEIModbusPage)
|
||||
int CMainPage::RegisterPagesTabs(CModbusPage *ModbusPage, CLazerProbeSimPage* LazerSimPage, CSEIModbusPage *SEIModbusPage, CZTAlarmGeneratorPage* ZTAlarmGenPage)
|
||||
{
|
||||
ui->mMainPageTabs->clear();
|
||||
ui->mMainPageTabs->addTab((QWidget*)ModbusPage,"Modbus CC");
|
||||
ui->mMainPageTabs->addTab((QWidget*)SEIModbusPage,"Modbus SEI");
|
||||
ui->mMainPageTabs->addTab((QWidget*)LazerSimPage,"Sondes");
|
||||
ui->mMainPageTabs->addTab((QWidget*)ZTAlarmGenPage,"Générateur ZT");
|
||||
|
||||
//ModbusPage->show();
|
||||
ui->mMainPageTabs->setCurrentIndex(1);
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ class COutilModbus;
|
||||
class CModbusPage;
|
||||
class CLazerProbeSimPage;
|
||||
class CSEIModbusPage;
|
||||
class CZTAlarmGeneratorPage;
|
||||
|
||||
namespace Ui {
|
||||
class CMainPage;
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
~CMainPage();
|
||||
COutilModbus *mProgramHandle;
|
||||
|
||||
int RegisterPagesTabs(CModbusPage*, CLazerProbeSimPage*, CSEIModbusPage*);
|
||||
int RegisterPagesTabs(CModbusPage*, CLazerProbeSimPage*, CSEIModbusPage*, CZTAlarmGeneratorPage* ZTAlarmGen);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,11 +17,15 @@ MainWindow::MainWindow(QWidget *parent,COutilModbus* ProgramHandle)
|
||||
mModbusPage = new CModbusPage();
|
||||
mModbusPage->mProgramHandle = ProgramHandle;
|
||||
|
||||
mZTAlarmGeneratorPage = new CZTAlarmGeneratorPage();
|
||||
//mZTAlarmGeneratorPage->mProgramHandle = ProgramHandle;
|
||||
|
||||
|
||||
mLazerSimPage = new CLazerProbeSimPage;
|
||||
|
||||
setCentralWidget(mMainPage);
|
||||
|
||||
mMainPage->RegisterPagesTabs(mModbusPage,mLazerSimPage, mSEIModbusPage);
|
||||
mMainPage->RegisterPagesTabs(mModbusPage,mLazerSimPage, mSEIModbusPage, mZTAlarmGeneratorPage);
|
||||
|
||||
// setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||
|
||||
@@ -93,7 +97,10 @@ MainWindow::MainWindow(QWidget *parent,COutilModbus* ProgramHandle)
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
|
||||
delete mMainPage;
|
||||
delete mSEIModbusPage;
|
||||
delete mZTAlarmGeneratorPage;
|
||||
delete mLazerSimPage;
|
||||
}
|
||||
|
||||
void MainWindow::ButtonPushed()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "MainPage.h"
|
||||
#include "LazerProbeSimPage.h"
|
||||
#include "SEIModbusPage.h"
|
||||
#include "ZTAlarmGeneratorPage.h"
|
||||
|
||||
class COutilModbus;
|
||||
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
COutilModbus *mProgramHandle;
|
||||
CLazerProbeSimPage *mLazerSimPage;
|
||||
CSEIModbusPage *mSEIModbusPage;
|
||||
CZTAlarmGeneratorPage *mZTAlarmGeneratorPage;
|
||||
|
||||
// QGridLayout *mCCGridLayout, *mSEIGridLayout;
|
||||
// QPushButton *mConnectToSlaveBtn, *mSendWriteMultipleHR, *mSendReadHR, *mWriteSingleHR;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include "ModbusZTMaster.h"
|
||||
#include <QTcpSocket>
|
||||
#include "ProtocolDefs.h"
|
||||
|
||||
CModbusZTMaster::CModbusZTMaster(CModbusRepository *Repo):
|
||||
CModbusBackend(Repo)
|
||||
{
|
||||
// connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
|
||||
mModbusMode = MODBUS_MASTER_MODE;
|
||||
|
||||
mModbusTCPSocketHandle = new QTcpSocket();
|
||||
connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
|
||||
connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(SocketDisconnected()));
|
||||
connect(mModbusTCPSocketHandle,SIGNAL(connected()),this,SLOT(SocketConnected()));
|
||||
|
||||
}
|
||||
|
||||
CModbusZTMaster::~CModbusZTMaster()
|
||||
{
|
||||
if(mModbusTCPSocketHandle->state() != QAbstractSocket::UnconnectedState)
|
||||
{
|
||||
mModbusTCPSocketHandle->disconnectFromHost();
|
||||
mModbusTCPSocketHandle->waitForDisconnected(1000);
|
||||
}
|
||||
delete mModbusTCPSocketHandle;
|
||||
}
|
||||
|
||||
int CModbusZTMaster::ConnectToSlave(QString SlaveIP, int SlavePort)
|
||||
{
|
||||
if(mModbusTCPSocketHandle->state() != QAbstractSocket::UnconnectedState)
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
mModbusTCPSocketHandle->connectToHost(SlaveIP,SlavePort);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CModbusZTMaster::DisconnectFromSlave()
|
||||
{
|
||||
if(mModbusTCPSocketHandle->state() != QAbstractSocket::ConnectedState)
|
||||
{
|
||||
qDebug("Trying to disconnect a non connected socket");
|
||||
mModbusTCPSocketHandle->disconnectFromHost();
|
||||
return 0;
|
||||
}
|
||||
|
||||
qDebug("Requesting Disconnection...");
|
||||
mModbusTCPSocketHandle->disconnectFromHost();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CModbusZTMaster::SocketConnected()
|
||||
{
|
||||
emit ModbusMasterConnected(this);
|
||||
qDebug("Master: Connection established with slave");
|
||||
}
|
||||
|
||||
void CModbusZTMaster::SocketDisconnected()
|
||||
{
|
||||
ModbusLinkDisconnected();
|
||||
emit ModbusMasterDisconnected(this);
|
||||
mModbusTCPSocketHandle->flush();
|
||||
}
|
||||
|
||||
int CModbusZTMaster::ReadModbusRegisters()
|
||||
{
|
||||
return SendReadHoldingRegistersRequest(SEI_MODBUS_SEI_DATA_BASE_REG,SEI_MODBUS_SEI_TABLE_DATA_SIZE); //Read all registers from ZT (2037 - 2038)
|
||||
}
|
||||
|
||||
int CModbusZTMaster::SendModbusRegisters()
|
||||
{
|
||||
return SendWriteHoldingRegistersRequest(SEI_MODBUS_ZT_DATA_BASE_REG,SEI_MODBUS_ZT_TABLE_DATA_SIZE);
|
||||
}
|
||||
|
||||
void CModbusZTMaster::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length)
|
||||
{
|
||||
emit ModbusMasterRepositoryUpdated();
|
||||
// qDebug("Database updated with ZT data...");
|
||||
}
|
||||
|
||||
void CModbusZTMaster::ModbusResponseException(quint8 ExceptionCode, quint8 FctCode)
|
||||
{
|
||||
qDebug("Modbus MASTER exception: code:%d Fct:%d",ExceptionCode,FctCode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef CMODBUSZTMASTER_H
|
||||
#define CMODBUSZTMASTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "ModbusBackend.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class CModbusZTMaster : public CModbusBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CModbusZTMaster(CModbusRepository *Repo);
|
||||
~CModbusZTMaster();
|
||||
|
||||
int ConnectToSlave(QString SlaveIP, int SlavePort);
|
||||
int DisconnectFromSlave();
|
||||
int ReadModbusRegisters();
|
||||
int SendModbusRegisters();
|
||||
|
||||
virtual void RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length);
|
||||
virtual void ModbusResponseException(quint8 ExceptionCode, quint8 FctCode);
|
||||
|
||||
signals:
|
||||
void ModbusMasterConnected(CModbusZTMaster *);
|
||||
void ModbusMasterDisconnected(CModbusZTMaster *);
|
||||
void ModbusMasterRepositoryUpdated();
|
||||
void ModbusTransaction();
|
||||
|
||||
public slots:
|
||||
void SocketConnected();
|
||||
void SocketDisconnected();
|
||||
};
|
||||
|
||||
#endif // CMODBUSZTMASTER_H
|
||||
@@ -25,6 +25,9 @@ COutilModbus::COutilModbus(QObject *parent) :
|
||||
mSEIWatchdogTimer->setInterval(MODBUS_SEI_WATCHDOG_TIMEOUT);
|
||||
connect(mSEIWatchdogTimer,SIGNAL(timeout()),this,SLOT(SEIWatchdogExpired()));
|
||||
|
||||
mZTAlarmGenerator = new CZTAlarmGenerator;
|
||||
mZTAlarmGenerator->mAlarmGeneratorPageHandle = w->mZTAlarmGeneratorPage;
|
||||
w->mZTAlarmGeneratorPage->mProgramHandle = mZTAlarmGenerator;
|
||||
|
||||
mSEIWatchdogValue = 0;
|
||||
}
|
||||
@@ -36,6 +39,7 @@ COutilModbus::~COutilModbus()
|
||||
delete mWatchdogTimer;
|
||||
delete w;
|
||||
delete mSEIWatchdogTimer;
|
||||
delete mZTAlarmGenerator;
|
||||
}
|
||||
|
||||
int COutilModbus::Start()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "MainWindow.h"
|
||||
#include "ModbusRepository.h"
|
||||
#include "ZTInfo.h"
|
||||
#include "ZTAlarmGenerator.h"
|
||||
|
||||
class CMainPage;
|
||||
|
||||
@@ -28,6 +29,9 @@ public:
|
||||
CModbusPage *mModbusPageHandle;
|
||||
CSEIModbusPage *mSEIModbusPageHandle;
|
||||
|
||||
CZTAlarmGenerator *mZTAlarmGenerator;
|
||||
|
||||
|
||||
|
||||
|
||||
//Modules interfaces
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,47 @@
|
||||
syntax: glob
|
||||
*.pro.user*
|
||||
*.app
|
||||
*.moc
|
||||
*.prl
|
||||
Makefile*
|
||||
doc/html/
|
||||
*.framework/
|
||||
*.xcodeproj/
|
||||
debug/
|
||||
release/
|
||||
qtc-gdbmacros/
|
||||
*.rej
|
||||
*.orig
|
||||
*.obj
|
||||
*.swp
|
||||
*.dll
|
||||
*.exp
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.lib
|
||||
Thumbs.db
|
||||
moc_*.cpp
|
||||
qrc_*.cpp
|
||||
*.o
|
||||
*.so.*
|
||||
*.so
|
||||
*.pdb
|
||||
ui_*.h
|
||||
*~
|
||||
.qmake.cache
|
||||
extserialport.prf
|
||||
lib/*
|
||||
*.orig
|
||||
*.exe
|
||||
*.vcproj
|
||||
*.vcproj.*.user
|
||||
*_resource.rc
|
||||
*.sln
|
||||
*.idb
|
||||
*.ncb
|
||||
*.suo
|
||||
examples/enumerator/enumerator
|
||||
examples/event/event
|
||||
examples/qespta/qespta
|
||||
examples/uartassistant/uartassistant
|
||||
object_script.*
|
||||
@@ -0,0 +1,267 @@
|
||||
Change history for QextSerialPort (formerly QwSerialPort):
|
||||
(Lines beginning with + represent new functionality, * represent changed or
|
||||
fixed functionality, - represent removed or deprecated functionality)
|
||||
|
||||
Version 1.2 rc (2012 Debao Zhang)
|
||||
* Build-system refactor
|
||||
* Issue 145 : Custom baud support for MacOS
|
||||
* Issue 36 : Fix Devices Notification for Vista
|
||||
* Issue 54 and Issue 108 : Try detect more ports for windows
|
||||
* Issue 139 : Adjust the name of generated library
|
||||
- QextWinEventNotifier has been removed
|
||||
|
||||
Version 1.2 beta2 (2012 Debao Zhang)
|
||||
* Issue 124 : implement canReadLine
|
||||
* Issue 122 : make Dtr default to TRUE under Windows.
|
||||
* Issue 127 : fix QObject::MoveToThread brokes SerialPort on Windows
|
||||
* Issue 129 : Add custom baud support for Windows.
|
||||
* Issue 131 : Make sure portName returned by QextSerialEnumerator can be used by QextSerialPort
|
||||
* Issue 134 : Make "make install" really works
|
||||
* Issue 2: device discovery / removal notification on linux (read config_example.pri to figure out how to enable it.)
|
||||
|
||||
Version 1.2 beta1 (2012 Debao Zhang)
|
||||
* D-pointer and Q_PRIVATE_SLOT are used to moving private members from QextSerialPort to QextSerialPortPrivate
|
||||
* qdoc3 instead of doxygen is used for generating documents
|
||||
* MIT license header add to all sources files
|
||||
+ add a helper class QextWinEventNotifier for windows user, when user's SDK doesnot contain Qt's private files, this class will be auto selected.
|
||||
|
||||
Version 1.2win-alpha (2007 Michal Policht)
|
||||
+ Added QextSerialEnumerator pre-alpha. Works under W2k and later versions of Windows.
|
||||
+ Event driven mechanism (alternative to polling) is now available on Windows.
|
||||
- Removed default (=0) parameter from open() functions.
|
||||
* Fixed bug #1714917 in Win_QextSerialPort::close() method (by Kurt).
|
||||
* Fixed problem with lack of proper blocking in readData() on win32 (by Brandon Fosdick).
|
||||
* Removed QT_THREAD_SUPPORT option. Now QextSerialPort must be always compiled with threads support.
|
||||
* Mutexes are not static.
|
||||
* setTimeout() now accepts only one parameter.
|
||||
* bytesAvailable() on POSIX now shows 0 bytes instead of -1 when no bytes are available.
|
||||
* bytesAvailable() is const.
|
||||
* native POSIX file descriptors instead of QFile->handle() calls
|
||||
+ POSIX: Save and restore original termios when opening and closing the device
|
||||
* POSIX: Only disable special characters on systems that support it
|
||||
* POSIX: Use cfmakeraw(3) to get a non-canonical termios
|
||||
+ POSIX: Call close(2) in close() to actually close the device
|
||||
|
||||
Version 1.1 (official release)
|
||||
|
||||
Version 1.0.1
|
||||
* Minor changes (mostly in test application)
|
||||
|
||||
Version 1.0.0e (by Micha? Policht)
|
||||
* Fixed bytesAvailable(). Includes buffered bytes to the result.
|
||||
+ Added isSequential() method.
|
||||
+ Provided test application
|
||||
|
||||
Version 1.0.0d ( changes by Micha? Policht )
|
||||
- Removed isOpen() overriden declaration/implementation from qextserialport's classes. isOpen() relies on QIODevice now.
|
||||
- Removed bool portOpen variable. Replaced by internal QIODevice.openMode.
|
||||
- Removed getChar(), putChar() overriden declaration/implementation. QIODevice can handle this.
|
||||
* Calling open() with specified OpenMode invokes QIODevice::open() which result in proper openMode setting.
|
||||
* readData(), writeData() are protected as in QIODevice declaration.
|
||||
* QIODevice:: read() and write() function are working now (use them instead of readData() writeData()).
|
||||
* readData(), writeData() don't check if port is open any more (read() and write() assures that). The same behaviour can be found in QFile for example.
|
||||
* Fixed readLine().
|
||||
|
||||
* Fixed randomly crash on deletion bug on Windows ( by Stuart Nixon )
|
||||
http://lists.trolltech.com/qt-interest/2007-02/thread00340-0.html#msg00351
|
||||
|
||||
Version 0.9 (March 3, 2005) Stefan Sander <stefan-sander@users.sf.net>:
|
||||
+ Added a new precompiler constant, _TTY_FREEBSD_
|
||||
to support FreeBSD port names.
|
||||
+ Added _TTY_WIN_ constant in qextserialport.pro win32:DEFINES
|
||||
to have Windows port names as default when compiling on it.
|
||||
- Removed construct() call from QextSerialBase constructors,
|
||||
it is called indirectly through Win_QextSerialPort::construct()
|
||||
and Posix_QextSerialPort::construct().
|
||||
+ Added construct() call to Win_QextSerialPort constructors.
|
||||
+ Added setTimeout(0, 500) call to Win_QextSerialPort::construct().
|
||||
- Removed setTimeout(0, 500) call from Win_QextSerialPort(const char* name).
|
||||
* Fixed Posix_QextSerialPort::open(int) control flow, now the port settings
|
||||
are only applied if the associated file could be opened.
|
||||
* Fixed masking CR to NL, in Posix_CommConfig.c_iflag
|
||||
|
||||
Version 0.8 (, 2003) (Alpha release):
|
||||
* Added code to set the port timeouts in Win_QextSerialPort's default
|
||||
constructor.
|
||||
* Fixed Posix_QextSerialPort::construct() to set up the port correctly.
|
||||
* Fixed syntax errors in 2 ioctl() calls in posix_QextSerialPort.
|
||||
* lastError is now initialized to E_NO_ERROR in the QextSerialBase
|
||||
constructor.
|
||||
* The select() call in posix_QextSerialPort::bytesWaiting() is now
|
||||
properly coded. Previously it would always time out.
|
||||
* Fixed runtime errors in the ioctl() calls for
|
||||
Posix_QextSerialPort::setDtr() and Posix_QextSerialPort::setRts().
|
||||
Thanks to Marc Pignat.
|
||||
|
||||
Version 0.7 (June 15, 2002) <Bugfix release>:
|
||||
(0.61 - unofficial release)
|
||||
* Fixed a small bug in the initializations of the static members when
|
||||
QT_THREAD_SUPPORT was defined.
|
||||
* Fixed a bug that caused Borland's compiler to choke on Windows platforms
|
||||
(which perversely actually stemmed from a shortcoming of Visual C++ that
|
||||
Borland doesn't have).
|
||||
|
||||
(0.62 - unofficial release)
|
||||
* Fixed a bug that gave Q_LONG the wrong typedef for QT versions prior to
|
||||
3.0.
|
||||
|
||||
(0.63 - unofficial release)
|
||||
* Fixed 2 incorrect references to Posix_Comm_Config.
|
||||
* Fixed scoping of Posix_QextSerialPort::operator=().
|
||||
* Posix_QextSerialPort::construct should now be coded correctly.
|
||||
* Fixed return type for Posix_QextSerialPort::size().
|
||||
|
||||
(0.64 - unofficial release)
|
||||
* Fixed all the port settings functions to work properly when opening the
|
||||
port for the first time - previously none of the settings were being
|
||||
applied when the port was opened.
|
||||
* Fixed an oversight in Win_QextSerialPort::open() that caused the setting
|
||||
of port parameters to fail on NT and 2000 systems.
|
||||
|
||||
(0.7 - official release)
|
||||
* Fixed some calls to QextSerialBase constructors that no longer exist on
|
||||
the POSIX side.
|
||||
* Fixed the bad memcpy()'s in the POSIX copy constructor.
|
||||
* Fixed the Offset scoping problem under gcc 2.95.
|
||||
* The CBAUD flag has been deprecated on some POSIX systems. Fixed
|
||||
Posix_QextSerialPort::setBaudRate() to reflect this.
|
||||
* Added construct() calls to all of the Posix_QextSerialPort constructors.
|
||||
* Fixed double (and conflicting) typedefs of Offset when using QT versions
|
||||
prior to 3.0
|
||||
* Changed the call to CreateFile() to CreateFileA() in
|
||||
Win_QextSerialPort.cpp. This should get rid of problems for those using
|
||||
Unicode or other multibyte character sets for their string literals.
|
||||
* A few tweaks to the documentation.
|
||||
|
||||
- Removed the protected Posix_Handle variable from Posix_QextSerialPort.
|
||||
|
||||
Version 0.6 (March 11, 2002) <Bugfix release>:
|
||||
+ Added a new precompiler constant, QTVER_PRE_30. QT3 changed the return
|
||||
types of some QIODevice functions. Therefore, if compiling on versions
|
||||
of QT prior to 3.0, you should always define QTVER_PRE_30 in your project.
|
||||
Also had to add some preprocessor blocks to support both 3.0 and earlier
|
||||
versions of QT.
|
||||
+ Added implementations of 2 of the new constructors added in 0.5 to both
|
||||
Win_QextSerialPort and Posix_QextSerialPort.
|
||||
|
||||
* The scoping of the enums used in the PortSettings struct has been fixed.
|
||||
* QObject inheritance has been removed. This should not affect the
|
||||
functionality of the classes.
|
||||
* Replaced a few stray references to mutex->unlock() with UNLOCK_MUTEX() in
|
||||
the Windows code.
|
||||
* Fixed several runtime errors caused by calling nonexistent members of
|
||||
QextSerialBase.
|
||||
* Fixed a whole bunch of little things that were causing MSVC to choke when
|
||||
compiling for Windows.
|
||||
|
||||
Version 0.5 (February 15, 2002):
|
||||
+ There are 4 new macros (LOCK_MUTEX, UNLOCK_MUTEX, TTY_WARNING, and
|
||||
TTY_PORTABILITY_WARNING) that replace most of those ugly #ifdef blocks in
|
||||
the code.
|
||||
+ In place of the old namingConvention stuff, there is a new function,
|
||||
setName(). It is used to set the name of the device to be associated with
|
||||
the object. The new name() function can be used to retrieve the device
|
||||
name, which is stored in the new member variable portName.
|
||||
+ There is a new version of open() that takes a const char* as a parameter.
|
||||
It can be used to specify the name of the device when it is opened rather
|
||||
than at construction time.
|
||||
|
||||
* 3 constructors have been removed and 3 more added. There is now a copy
|
||||
constructor (and operator=()) as well as a constructor that takes a
|
||||
PortSettings structure as a parameter, and another that takes both a
|
||||
device name and a PortSettings structure. As a result of these changes
|
||||
the PortSettings structure declaration is no longer local to the
|
||||
QextSerialBase class. All of the removed constructors had to do with
|
||||
the setNamingConvention() system.
|
||||
* The static mutex member should now be reference-counted and only deleted
|
||||
when it is no longer referenced.
|
||||
* Most of the object construction duties have been pushed back into
|
||||
QextSerialBase
|
||||
* Fixed a couple resource leaks, mostly to do with unlocking the mutex
|
||||
properly
|
||||
|
||||
- Removed the setNamingConvention() nonsense.
|
||||
- Removed all QStrings and calls to sprintf() for thread compatibility.
|
||||
- Removed setNumber() functions as well as the portNumber member variable,
|
||||
as they were only necessary under the setNamingConvention() system.
|
||||
|
||||
I am grateful to Jorg Preiss (Preisz? Sorry, American keyboards don't have
|
||||
an ess-tset character ;)) for his invaluable input on most of the changes
|
||||
that went into this version.
|
||||
|
||||
Version 0.4 (March 20, 2001):
|
||||
+ All of the classes now derive from QObject as well as QIODevice. This
|
||||
is pretty much useless at the moment - signals and slots may be used
|
||||
to implement asynchronous communications in a future version
|
||||
+ Added configurable timeouts via the setTimeout() function. The default
|
||||
timeout for read and write operations is now 500 milliseconds
|
||||
+ There is now a functional .pro file for the library (thanks to
|
||||
Gunnstein Lye)
|
||||
+ The prefixes for all of the classes have changed from Qw to Qext, in
|
||||
compliance with the qt-addons project standard
|
||||
|
||||
* Fixed a bug that caused port settings to be restored incorrectly when
|
||||
switching ports with setNumber()
|
||||
* Minor changes to QextSerialBase::setNumber(). Functionality should now
|
||||
reflect the documentation, which has also been updated to reflect the
|
||||
changes that went in on version 0.3.
|
||||
* Some fixes to the documentation. The Posix_QextSerialPort and
|
||||
Win_QextSerialPort classes should no longer have any unnecessary
|
||||
references to inapplicable platforms, and the documentation for open() has
|
||||
been updated.
|
||||
* Should now compile without QT_THREAD_SUPPORT defined (ie, in single-
|
||||
threaded environments), although it will require slight changes to the
|
||||
makefile (tmake "CONFIG-=thread" should work)
|
||||
* Fixed a few compilation issues, especially on the POSIX side (should
|
||||
compile under Linux now :))
|
||||
* POSIX code is a little cleaner and more efficient
|
||||
* Various small fixes to the documentation
|
||||
* Constants now follow a consistent naming convention, with underscores at
|
||||
the beginning and end of each. For example TTY_POSIX has become
|
||||
_TTY_POSIX_
|
||||
|
||||
Version 0.3 (Feb. 14, 2001):
|
||||
+ Added a warning that appears when QwSerialPort is compiled on a POSIX
|
||||
platform that does not implement 76800 baud operation. In this situation
|
||||
QwSerialPort will also switch to 57600 baud.
|
||||
+ Major code reorganization - there are now 4 classes instead of 1. This
|
||||
should remove a lot of the #ifdef...#else...#endif constructs and
|
||||
hopefully make the code easier to read. Including the class in your
|
||||
project is still done by including QwSerialPort.h and instantiating a
|
||||
QwSerialPort object.
|
||||
|
||||
* The serial port associated with a QwSerialPort object is no longer
|
||||
opened on construction, or upon calling the setNumber() function. You
|
||||
must now explicitly call open() to open the port.
|
||||
|
||||
Version 0.2 (Jan. 3, 2001):
|
||||
+ Added lastError() function with rudimentary error codes
|
||||
+ Better documentation
|
||||
+ Added ability to examine the empty/not empty state of a port's input
|
||||
buffer with atEnd()
|
||||
+ Added ability to retrieve the number of bytes in a port's input buffer
|
||||
with size() (thanks to Olivier Tubach)
|
||||
+ Added ability to turn off portability warnings by defining
|
||||
TTY_NOWARN_PORT in your project
|
||||
+ Added ability to turn off all warning messages by defining TTY_NOWARN
|
||||
in your project
|
||||
+ Added ability to select POSIX serial functions in Windows NT/2000 by
|
||||
defining TTY_POSIX in your project (untested)
|
||||
+ Added control over RTS and DTR lines with setRts() and setDtr()
|
||||
respectively
|
||||
+ Added ability to query line status using lineStatus().
|
||||
+ Added readLine() functionality (thanks to Olivier Tubach)
|
||||
+ Added bytesWaiting(), a non-const/thread-safe version of size()
|
||||
+ The class should now be thread-safe through the use of a recursive
|
||||
QMutex (untested)
|
||||
|
||||
* Fixed a bug that could cause hardware flow control not to work on some
|
||||
POSIX systems
|
||||
* Put in a few missing fileno() calls in the POSIX code
|
||||
* Fixed a few syntax errors that caused compilation to fail on POSIX systems
|
||||
|
||||
- BAUD0 is no longer a valid baud rate setting - to drop the DTR line,
|
||||
call setDtr(FALSE)
|
||||
|
||||
Version 0.1 (Dec. 11, 2000):
|
||||
Initial public release.
|
||||
@@ -0,0 +1,94 @@
|
||||
From QextSerialPort 1.2-beta on, we use MIT license for QextSerialPort project.
|
||||
|
||||
== License ==
|
||||
|
||||
Copyright (c) 2000-2003 Wayne Roth
|
||||
Copyright (c) 2004-2007 Stefan Sander
|
||||
Copyright (c) 2007 Michal Policht
|
||||
Copyright (c) 2008 Brandon Fosdick
|
||||
Copyright (c) 2009-2010 Liam Staskawicz
|
||||
Copyright (c) 2011 Debao Zhang
|
||||
|
||||
Web: http://code.google.com/p/qextserialport/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
== Why license needed? ==
|
||||
|
||||
Many users complains that, without a proper licence they can not use this library.
|
||||
|
||||
* http://groups.google.com/group/qextserialport/browse_thread/thread/0e8756920b01da82
|
||||
|
||||
Hi,
|
||||
we are considering using a modified version of QExtSerialPort in one of our
|
||||
projects (Qt Creator, http://qt.gitorious.org/qt-creator).
|
||||
Would it be possible to add license header information or a license file to the
|
||||
QExtSerialPort code base? - This would make re-use of the code base easier.
|
||||
If that is not possible, could we redistribute the source code with BSD-
|
||||
license headers manually added?
|
||||
|
||||
And
|
||||
|
||||
I am also considering packaging the software for Debian, but I
|
||||
couldn't do it yet just because of the license.
|
||||
|
||||
* http://code.google.com/p/qextserialport/issues/detail?id=8
|
||||
|
||||
Questions:
|
||||
Can I use qextserialport in a commercial product?
|
||||
If yes, how?
|
||||
Compile it in? I guess no.
|
||||
If I can use it as a library, how should the README be formulated?
|
||||
Is the "MIT license" from 2008 appropriate?
|
||||
|
||||
== Why can we use MIT? ==
|
||||
|
||||
Form the history of [http://lists.trolltech.com/qt-interest/2004-12/msg01022.html qt-interest mail list]
|
||||
|
||||
* Wayne Roth, the original author of the project, had said that:
|
||||
|
||||
the code is in the public domain. Do whatever you like with it. Right
|
||||
now I have too many other things to do to put any serious time into
|
||||
fixing it. Trolltech should be aware of this already; they asked
|
||||
about a license when they offered to host the tarball.
|
||||
|
||||
* Stefan Sander, the maintainer of qextserialport on sourceforge, said that
|
||||
|
||||
Hello,
|
||||
My project registration at !SourceForge have been approved.
|
||||
http://www.sf.net/projects/qextserialport
|
||||
I thought an initial licence of Public Domain would be best solution.
|
||||
Someone wrote: - Because its public domain, some could fork it under different licenses -
|
||||
|
||||
And from [http://groups.google.com/group/qextserialport/browse_thread/thread/fbcddbfb4a0b5a51?pli=1 this thread] on qesp mail list, we can see that, current maintainers and users agree with a MIT licence.
|
||||
|
||||
* Brandon Fosdick,
|
||||
|
||||
I would vote for BSD or MIT :)
|
||||
|
||||
* Liam Staskawicz,
|
||||
|
||||
That works for me - let's call it MIT and go for it :)
|
||||
|
||||
And from [[https://groups.google.com/forum/?fromgroups#!topic/qextserialport/P_5TrNHBICE this other thread]] on the same mailing list:
|
||||
|
||||
* Michal Policht,
|
||||
|
||||
I agree to license.
|
||||
@@ -0,0 +1,64 @@
|
||||
= About QextSerialPort =
|
||||
|
||||
QextSerialPort provides an interface to old fashioned serial ports for Qt-based applications. It currently supports Mac OS X, Windows, Linux, FreeBSD.
|
||||
|
||||
http://code.google.com/p/qextserialport/
|
||||
|
||||
== How to use (1) ==
|
||||
|
||||
* Download the source code.
|
||||
|
||||
* Put the source code in any directory you like. For example, 3rdparty:
|
||||
|
||||
|-- project.pro
|
||||
|-- ....
|
||||
|-- 3rdparty\
|
||||
| |-- qextserialport\
|
||||
| |
|
||||
|
||||
* Add following line to your qmake project file:
|
||||
|
||||
include(3rdparty/qextserialport/src/qextserialport.pri)
|
||||
|
||||
* Using QextSerialPort in your code. Enjoy it!
|
||||
|
||||
#include "qextserialport.h"
|
||||
....
|
||||
QextSerialPort * port = new QextSerialPort();
|
||||
....
|
||||
|
||||
== How to use (2) ==
|
||||
It's very easy to compile QextSerialPort directly into your application
|
||||
(see above section), however, we would prefer to use it as a shared library.
|
||||
|
||||
* Download the source code, and put it in any location you like.
|
||||
|
||||
* Run following command to generate library.
|
||||
|
||||
qmake
|
||||
make (or nmake)
|
||||
sudo make install (or nmake install)
|
||||
|
||||
* Add following line to your project's file
|
||||
|
||||
CONFIG += extserialport
|
||||
|
||||
* Using QextSerialPort in your code. Enjoy it!
|
||||
|
||||
#include "qextserialport.h"
|
||||
....
|
||||
QextSerialPort * port = new QextSerialPort();
|
||||
....
|
||||
|
||||
== Build Documents ==
|
||||
* Run
|
||||
qmake
|
||||
make docs
|
||||
|
||||
* Note: More information can be found in doc/readme.txt
|
||||
|
||||
== Build examples ==
|
||||
* Goto examples directory, then run
|
||||
qmake (or qmake -r)
|
||||
make (or nmake)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
OTHER_FILES += $$PWD/qextserialport.qdocconf
|
||||
|
||||
#name of qdoc3 has been changed to qdoc under Qt5
|
||||
QESP_QDOC = qdoc
|
||||
lessThan(QT_MAJOR_VERSION, 5):QESP_QDOC = qdoc3
|
||||
|
||||
docs_target.target = docs
|
||||
docs_target.commands = $$QESP_QDOC $$PWD/qextserialport.qdocconf
|
||||
|
||||
QMAKE_EXTRA_TARGETS = docs_target
|
||||
QMAKE_CLEAN += "-r $$PWD/html"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/*!
|
||||
\example examples/enumerator
|
||||
\title enumerator Demo
|
||||
|
||||
The example demonstrates how to use QextSerialEnumerator.
|
||||
|
||||
Include the proper header file
|
||||
\snippet examples/enumerator/main.cpp 0
|
||||
|
||||
Get available ports in the system.
|
||||
\snippet examples/enumerator/main.cpp 1
|
||||
|
||||
Output
|
||||
\snippet examples/enumerator/main.cpp 2
|
||||
*/
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
\example examples/qespta
|
||||
\title qespta Demo
|
||||
|
||||
The example demonstrates how to use QextSerialPort.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*!
|
||||
\example examples/uartassistant
|
||||
\title UartAssistant Demo
|
||||
|
||||
The example demonstrates how to use QextSerialPort.
|
||||
|
||||
Initialze UI element.
|
||||
\snippet examples/uartassistant/dialog.cpp 0
|
||||
|
||||
Initialize serial port
|
||||
\snippet examples/uartassistant/dialog.cpp 1
|
||||
|
||||
port Settings
|
||||
\snippet examples/uartassistant/dialog.cpp 2
|
||||
|
||||
Open or Close the port.
|
||||
\snippet examples/uartassistant/dialog.cpp 3
|
||||
|
||||
Read from or Write to the port
|
||||
\snippet examples/uartassistant/dialog.cpp 4
|
||||
|
||||
\image uartassistant.png
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
/*!
|
||||
\page index.html
|
||||
\title QextSerialPort Manual
|
||||
|
||||
\section1 Overview
|
||||
QextSerialPort provides an interface to old fashioned serial ports for
|
||||
Qt-based applications. It currently supports Mac OS X, Windows, Linux, FreeBSD.
|
||||
|
||||
From QextSerialPort 1.2-beta on, license of the project has been changed to MIT.
|
||||
|
||||
\list
|
||||
\o Revision 0.9.x is Qt 2 & 3 compatible.
|
||||
\o Revision 1.x.x is Qt 4 compatible.
|
||||
\o From revision 1.2beta1 on, Qt 5 support is added.
|
||||
\endlist
|
||||
|
||||
|
||||
\section1 Classes
|
||||
\list
|
||||
\o \l QextSerialPort encapsulates a serial port on both POSIX and Windows systems.
|
||||
\o \l QextSerialEnumerator enumerates ports currently available in the system.
|
||||
\endlist
|
||||
|
||||
\section1 Getting Started
|
||||
|
||||
|
||||
\section2 Usage(1): Source Code Only
|
||||
|
||||
The package contains a qextserialport.pri file that allows you to integrate the component into programs that use qmake for the build step.
|
||||
|
||||
Download the source code.
|
||||
Put the source code in any directory you like. For example, 3rdparty:
|
||||
|
||||
\code
|
||||
|-- project.pro
|
||||
|-- ....
|
||||
|-- 3rdparty\
|
||||
| |-- qextserialport\
|
||||
| |
|
||||
\endcode
|
||||
|
||||
Add following line to your qmake project file:
|
||||
\code
|
||||
include(pathToPri/qextserialport.pri)
|
||||
\endcode
|
||||
|
||||
Then, using QextSerialPort in your code
|
||||
\code
|
||||
#include "qextserialport.h"
|
||||
...
|
||||
MyClass::MyClass()
|
||||
{
|
||||
port = new QextSerialPort("COM1");
|
||||
connect(port, SIGNAL(readyRead()), this, SLOT(onDataAvailable()));
|
||||
port->open();
|
||||
}
|
||||
|
||||
void MyClass::onDataAvailable()
|
||||
{
|
||||
QByteArray data = port->readAll();
|
||||
processNewData(usbdata);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\section2 Usage(2): shared library
|
||||
Although QextSerialPort can be directly compiled into your application, You may prefer
|
||||
to use QextSerailPort as an library, which is very easy too.
|
||||
|
||||
1. Download the source code, and put it in any location you like.
|
||||
|
||||
2. Goto the top level directory ,run following command to generate library.
|
||||
|
||||
\code
|
||||
qmake
|
||||
sudo make install (or nmake install)
|
||||
\endcode
|
||||
|
||||
3. Add following line to your project's file
|
||||
|
||||
\code
|
||||
CONFIG += extserialport
|
||||
\endcode
|
||||
|
||||
4. Using QextSerialPort in your code. Enjoy it!
|
||||
|
||||
\code
|
||||
#include "qextserialport.h"
|
||||
....
|
||||
QextSerialPort * port = new QextSerialPort();
|
||||
....
|
||||
\endcode
|
||||
|
||||
\section2 Usage(3): Static library
|
||||
|
||||
Someone prefer to use QextSerailPort as static library.
|
||||
|
||||
Open the project file: qextserialport.pro, add uncomment follow line
|
||||
|
||||
\code
|
||||
# CONFIG += qesp_static
|
||||
\endcode
|
||||
|
||||
Then follow the same steps as shared library
|
||||
|
||||
\code
|
||||
qmake
|
||||
sudo make install
|
||||
\endcode
|
||||
|
||||
The static library, the header files, and the feature file will be installed to your system.
|
||||
|
||||
Add following line to your qmake's project file:
|
||||
|
||||
\code
|
||||
CONFIG += extserialport
|
||||
\endcode
|
||||
|
||||
\section1 Platform Special
|
||||
|
||||
\section2 For MacX: Build as framework
|
||||
|
||||
Open the project file: *qextserialport.pro*, and uncomment follow line
|
||||
|
||||
\code
|
||||
# CONFIG += qesp_mac_framework
|
||||
\endcode
|
||||
|
||||
Then follow the same steps as shared library, Goto the top level directory , and run
|
||||
|
||||
\code
|
||||
qmake
|
||||
sudo make install
|
||||
\endcode
|
||||
|
||||
The framework which includes libraries and the header files, and the feature file will be installed to your system.
|
||||
|
||||
Add following line to your qmake's project file:
|
||||
|
||||
\code
|
||||
CONFIG += extserialport
|
||||
\endcode
|
||||
|
||||
\section2 For Linux: Enable udev
|
||||
|
||||
Open the project file: *qextserialport.pro*, uncomment follow line
|
||||
|
||||
\code
|
||||
#linux*:CONFIG += qesp_linux_udev
|
||||
\endcode
|
||||
|
||||
Note, If you are using the usage(1), Add following line before include the qextserialport.pri file.
|
||||
\code
|
||||
CONFIG += qesp_linux_udev
|
||||
\endcode
|
||||
|
||||
|
||||
\section2 Build documents
|
||||
\code
|
||||
make docs
|
||||
\endcode
|
||||
|
||||
\section1 Examples
|
||||
\list
|
||||
\o \l examples/enumerator
|
||||
\o \l examples/qespta
|
||||
\o \l examples/uartassistant
|
||||
\endlist
|
||||
|
||||
\section1 Resources
|
||||
\section2 Nokia(Trolltech)
|
||||
\list
|
||||
\o \l {http://doc.trolltech.com/qq/qq12-iodevice.html} {Writing a Custom I/O Device}
|
||||
\o \l {http://doc.trolltech.com/3.3/qiodevice.html} {Qt 3.3: QIODevice Class Reference}
|
||||
\o \l {http://doc.trolltech.com/4.7/qiodevice.html} {Qt 4.7: QIODevice Class Reference}
|
||||
\endlist
|
||||
\section2 MSDN
|
||||
\list
|
||||
\o \l {http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp} {Communications Resources}
|
||||
\o \l {http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/about_communications_resources.asp} {About Communications Resources}
|
||||
\o \l {http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/using_communications_resources.asp}{Using Communications Resources}
|
||||
\o \l {http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_functions.asp} {Communications Functions}
|
||||
\o \l {http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_structures.asp} {Communications Structures}
|
||||
\endlist
|
||||
\section2 TLDP
|
||||
\list
|
||||
\o \l {http://www.tldp.org/HOWTO/Serial-HOWTO.html}{Serial HOWTO}
|
||||
\o \l {http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/}{Serial Programming HOWTO}
|
||||
\endlist
|
||||
\section2 Other
|
||||
\list
|
||||
\o \l {http://www.easysw.com/~mike/serial/serial.html} {Serial Programming Guide for POSIX Operating Systems}
|
||||
\endlist
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
\page classes.html
|
||||
\generatelist annotatedclasses
|
||||
*/
|
||||
@@ -0,0 +1,53 @@
|
||||
# Run qdoc3 from the directory that contains this file.
|
||||
project = qesp
|
||||
description = QextSerialPort Reference Documentation
|
||||
url = http://code.google.com/p/qextserialport
|
||||
|
||||
outputencoding = UTF-8
|
||||
language = Cpp
|
||||
|
||||
#Paths are relative to the location of this file
|
||||
headerdirs = . ../src
|
||||
sourcedirs = . ../src
|
||||
exampledirs = ../examples ..
|
||||
imagedirs = ./examples/images images
|
||||
|
||||
Cpp.ignoretokens = QEXTSERIALPORT_EXPORT
|
||||
|
||||
indexes = $QTDIR/doc/html/qt.index
|
||||
|
||||
qhp.projects = qesp
|
||||
qhp.qesp.file = qesp.qhp
|
||||
qhp.qesp.namespace = com.google.code.qextserialport.120
|
||||
qhp.qesp.virtualFolder = qdoc
|
||||
qhp.qesp.indexTitle = QextSerialPort Reference Documentation
|
||||
qhp.qesp.indexRoot =
|
||||
qhp.qesp.extraFiles = style/style.css
|
||||
|
||||
|
||||
#------------------------------------------------------------------
|
||||
outputdir = html
|
||||
outputformats = HTML
|
||||
|
||||
headers.fileextensions = "*.h"
|
||||
sources.fileextensions = "*.cpp *.qdoc"
|
||||
|
||||
HTML.templatedir = .
|
||||
HTML.stylesheets = style/style.css
|
||||
|
||||
HTML.headerstyles = " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/style.css\" />\n"
|
||||
HTML.endheader = "</head>\n"
|
||||
|
||||
HTML.postheader = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n" \
|
||||
"<tr>\n" \
|
||||
"<td class=\"postheader\" valign=\"center\">" \
|
||||
"<a href=\"index.html\">Home</a> ·" \
|
||||
" <a href=\"classes.html\">All Classes</a> ·" \
|
||||
"</td></tr></table>"
|
||||
|
||||
HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \
|
||||
"<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \
|
||||
"<td width=\"40%\" align=\"left\">Copyright © 2000-2012</td>\n" \
|
||||
"<td width=\"20%\" align=\"center\"><a href=\"http://code.google.com/p/qextserialport\">QextSerialPort Project</a></td>\n" \
|
||||
"<td width=\"40%\" align=\"right\"><div align=\"right\">QextSerialPort Manual</div></td>\n" \
|
||||
"</tr></table></div></address>"
|
||||
@@ -0,0 +1,35 @@
|
||||
Note:
|
||||
|
||||
If you are using qextserialport-XXX.tar.gz, the qesp.qch and
|
||||
html files have been provided.
|
||||
|
||||
Open the file "html/index.html" using your web browser.
|
||||
Or integrated the "html/qesp.qch" into your QtCreator.
|
||||
|
||||
|
||||
== How to generate help files? ==
|
||||
|
||||
Simply run following commands at toplevel directory.
|
||||
qmake
|
||||
make docs
|
||||
|
||||
Or run the following command at this directory
|
||||
qdoc3 qextserialport.qdocconf
|
||||
|
||||
Then a folder called "html" will be generated.
|
||||
Open the file "html/index.html" using your web browser.
|
||||
|
||||
== How to integrated into Qt Creator or Qt Assistant? ==
|
||||
|
||||
Once the html files are generated. run following commands
|
||||
cd doc/html
|
||||
qhelpgenerator qesp.qhp
|
||||
|
||||
A file called "qesp.qch" will be generated.
|
||||
|
||||
For Qt Assistant:
|
||||
Edit ==> Preferences ==> Documentations ==> Add...
|
||||
|
||||
For Qt Creator
|
||||
Tools ==> Options ==> Help ==> Documentations ==> Add...
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
a:link, a:visited {
|
||||
color: #00732F;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
body {
|
||||
font: normal 400 14px/1.2 Arial;
|
||||
margin-top: 85px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font: 500 20px/1.2 Arial;
|
||||
}
|
||||
|
||||
h3.fn, span.fn {
|
||||
-moz-border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-radius: 7px 7px 7px 7px;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
background-color: #F6F6F6;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #E6E6E6;
|
||||
word-spacing: 3px;
|
||||
padding: 3px 5px;
|
||||
}
|
||||
|
||||
table, pre {
|
||||
-moz-border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-radius: 7px 7px 7px 7px;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
background-color: #F6F6F6;
|
||||
border: 1px solid #E6E6E6;
|
||||
border-collapse: separate;
|
||||
font-size: 12px;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 25px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
table td {
|
||||
padding: 3px 15px 3px 20px;
|
||||
}
|
||||
|
||||
table tr.even {
|
||||
background-color: white;
|
||||
color: #66666E;
|
||||
}
|
||||
|
||||
table tr.odd {
|
||||
background-color: #F6F6F6;
|
||||
color: #66666E;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-bottom: 10px;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.cpp {
|
||||
display: block;
|
||||
margin: 10;
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
padding: 20px 0 20px 0;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.memItemLeft {
|
||||
padding-right: 3px;
|
||||
}
|
||||
|
||||
.memItemRight {
|
||||
padding: 3px 15px 3px 0;
|
||||
}
|
||||
|
||||
.qml {
|
||||
display: block;
|
||||
margin: 10;
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
overflow-y: hidden;
|
||||
padding: 20px 0 20px 0;
|
||||
}
|
||||
|
||||
.qmldefault {
|
||||
padding-left: 5px;
|
||||
float: right;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.qmlreadonly {
|
||||
padding-left: 5px;
|
||||
float: right;
|
||||
color: #254117;
|
||||
}
|
||||
|
||||
.rightAlign {
|
||||
padding: 3px 5px 3px 10px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.title {
|
||||
background-color: white;
|
||||
color: #44A51C;
|
||||
font-family: Verdana;
|
||||
font-size: 35px;
|
||||
font-weight: normal;
|
||||
left: 0;
|
||||
padding-bottom: 5px;
|
||||
padding-left: 16px;
|
||||
padding-top: 20px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.toc {
|
||||
float: right;
|
||||
-moz-border-radius: 7px 7px 7px 7px;
|
||||
-webkit-border-radius: 7px 7px 7px 7px;
|
||||
border-radius: 7px 7px 7px 7px;
|
||||
background-color: #F6F6F6;
|
||||
border: 1px solid #DDD;
|
||||
margin: 0 20px 10px 10px;
|
||||
padding: 20px 15px 20px 20px;
|
||||
height: auto;
|
||||
width: 200px;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += .
|
||||
CONFIG += console
|
||||
include(../../src/qextserialport.pri)
|
||||
SOURCES += main.cpp
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @brief Main file.
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
//! [0]
|
||||
#include "qextserialenumerator.h"
|
||||
//! [0]
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QDebug>
|
||||
int main()
|
||||
{
|
||||
//! [1]
|
||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||
//! [1]
|
||||
qDebug() << "List of ports:";
|
||||
//! [2]
|
||||
foreach (QextPortInfo info, ports) {
|
||||
qDebug() << "port name:" << info.portName;
|
||||
qDebug() << "friendly name:" << info.friendName;
|
||||
qDebug() << "physical name:" << info.physName;
|
||||
qDebug() << "enumerator name:" << info.enumName;
|
||||
qDebug() << "vendor ID:" << info.vendorID;
|
||||
qDebug() << "product ID:" << info.productID;
|
||||
|
||||
qDebug() << "===================================";
|
||||
}
|
||||
//! [2]
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
#include "PortListener.h"
|
||||
#include <QtDebug>
|
||||
|
||||
PortListener::PortListener(const QString &portName)
|
||||
{
|
||||
qDebug() << "hi there";
|
||||
this->port = new QextSerialPort(portName, QextSerialPort::EventDriven);
|
||||
port->setBaudRate(BAUD38400);
|
||||
port->setFlowControl(FLOW_OFF);
|
||||
port->setParity(PAR_NONE);
|
||||
port->setDataBits(DATA_8);
|
||||
port->setStopBits(STOP_1);
|
||||
|
||||
if (port->open(QIODevice::ReadWrite) == true) {
|
||||
connect(port, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
||||
connect(port, SIGNAL(dsrChanged(bool)), this, SLOT(onDsrChanged(bool)));
|
||||
if (!(port->lineStatus() & LS_DSR))
|
||||
qDebug() << "warning: device is not turned on";
|
||||
qDebug() << "listening for data on" << port->portName();
|
||||
}
|
||||
else {
|
||||
qDebug() << "device failed to open:" << port->errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void PortListener::onReadyRead()
|
||||
{
|
||||
QByteArray bytes;
|
||||
int a = port->bytesAvailable();
|
||||
bytes.resize(a);
|
||||
port->read(bytes.data(), bytes.size());
|
||||
qDebug() << "bytes read:" << bytes.size();
|
||||
qDebug() << "bytes:" << bytes;
|
||||
}
|
||||
|
||||
void PortListener::onDsrChanged(bool status)
|
||||
{
|
||||
if (status)
|
||||
qDebug() << "device was turned on";
|
||||
else
|
||||
qDebug() << "device was turned off";
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
#ifndef PORTLISTENER_H_
|
||||
#define PORTLISTENER_H_
|
||||
|
||||
#include <QObject>
|
||||
#include "qextserialport.h"
|
||||
|
||||
class PortListener : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PortListener(const QString &portName);
|
||||
|
||||
private:
|
||||
QextSerialPort *port;
|
||||
|
||||
private slots:
|
||||
void onReadyRead();
|
||||
void onDsrChanged(bool status);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /*PORTLISTENER_H_*/
|
||||
@@ -0,0 +1,7 @@
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += .
|
||||
CONFIG += console
|
||||
include(../../src/qextserialport.pri)
|
||||
|
||||
SOURCES += main.cpp PortListener.cpp
|
||||
HEADERS += PortListener.h
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @brief Main file.
|
||||
* @author Michal Policht
|
||||
*/
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include "PortListener.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
QString portName = QLatin1String("/dev/ttyS0"); // update this to use your port of choice
|
||||
PortListener listener(portName); // signals get hooked up internally
|
||||
|
||||
// start the event loop and wait for signals
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = qespta enumerator \
|
||||
uartassistant
|
||||
win32:SUBDIRS += event
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file MainWindow.cpp
|
||||
* @brief MainWindow Implementation.
|
||||
* @see MainWindow.h
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QMenuBar>
|
||||
#include "MainWindow.h"
|
||||
#include "MessageWindow.h"
|
||||
#include "QespTest.h"
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
//central widget
|
||||
QespTest *qespTest = new QespTest();
|
||||
setCentralWidget(qespTest);
|
||||
//bottom dock widget
|
||||
MessageWindow *msgWindow = new MessageWindow();
|
||||
addDockWidget(Qt::BottomDockWidgetArea, msgWindow);
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
setWindowTitle(tr("QextSerialPort Test Application"));
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About "),
|
||||
tr("<B>""</B><BR>"
|
||||
"author: Michal Policht<br>"
|
||||
"<a href='mailto:xpolik@users.sourceforge.net'>xpolik@users.sourceforge.net</a>"));
|
||||
}
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
//File actions
|
||||
exitAct = new QAction(tr("E&xit"), this);
|
||||
exitAct->setShortcut(tr("CTRL+D"));
|
||||
exitAct->setStatusTip(tr("Exit the application"));
|
||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
//Help actions
|
||||
aboutAct = new QAction(tr("&About"), this);
|
||||
aboutAct->setShortcut(tr("CTRL+A"));
|
||||
aboutAct->setStatusTip(tr("About application"));
|
||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||
}
|
||||
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(exitAct);
|
||||
|
||||
helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(aboutAct);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file MainWindow.h
|
||||
* @brief Application's Main Window.
|
||||
* @see MainWindow
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
|
||||
#ifndef MAINWINDOW_H_
|
||||
#define MAINWINDOW_H_
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QMenu *fileMenu;
|
||||
QAction *exitAct;
|
||||
QMenu *helpMenu;
|
||||
QAction *aboutAct;
|
||||
|
||||
private:
|
||||
void createMenus();
|
||||
void createActions();
|
||||
|
||||
private slots:
|
||||
void about();
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
};
|
||||
|
||||
#endif /*MAINWINDOW_H_*/
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @file MessageWindow.cpp
|
||||
* @brief MessageWindow Implementation.
|
||||
* @see MessageWindow.h
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "MessageWindow.h"
|
||||
#include <QMessageBox>
|
||||
#include <QCoreApplication>
|
||||
#include <QMutexLocker>
|
||||
|
||||
const char *MessageWindow::WINDOW_TITLE = "Message Window";
|
||||
MessageWindow *MessageWindow::MsgHandler = NULL;
|
||||
|
||||
MessageWindow::MessageWindow(QWidget *parent, Qt::WindowFlags flags)
|
||||
: QDockWidget(parent, flags),
|
||||
msgTextEdit(this)
|
||||
{
|
||||
setWindowTitle(tr(WINDOW_TITLE));
|
||||
msgTextEdit.setReadOnly(true);
|
||||
setWidget(&msgTextEdit);
|
||||
|
||||
MessageWindow::MsgHandler = this;
|
||||
}
|
||||
|
||||
//static
|
||||
QString MessageWindow::QtMsgToQString(QtMsgType type, const char *msg)
|
||||
{
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
return QLatin1String("Debug: ")+QLatin1String(msg);
|
||||
case QtWarningMsg:
|
||||
return QLatin1String("Warning: ")+QLatin1String(msg);
|
||||
case QtCriticalMsg:
|
||||
return QLatin1String("Critical: ")+QLatin1String(msg);
|
||||
case QtFatalMsg:
|
||||
return QLatin1String("Fatal: ")+QLatin1String(msg);
|
||||
default:
|
||||
return QLatin1String("Unrecognized message type: ")+QLatin1String(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void MessageWindow::AppendMsgWrapper(QtMsgType type, const char *msg)
|
||||
{
|
||||
static QMutex mutex;
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (MessageWindow::MsgHandler != NULL)
|
||||
return MessageWindow::MsgHandler->postMsgEvent(type, msg);
|
||||
else
|
||||
fprintf(stderr, "%s", MessageWindow::QtMsgToQString(type, msg).toLatin1().data());
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
void MessageWindow::AppendMsgWrapper(QtMsgType type, const QMessageLogContext & /*context*/, const QString &msg)
|
||||
{
|
||||
AppendMsgWrapper(type, msg.toLatin1().data());
|
||||
}
|
||||
#endif
|
||||
|
||||
void MessageWindow::customEvent(QEvent *event)
|
||||
{
|
||||
if (static_cast<MessageWindow::EventType>(event->type()) == MessageWindow::MessageEventType)
|
||||
msgTextEdit.append(dynamic_cast<MessageEvent *>(event)->msg);
|
||||
}
|
||||
|
||||
void MessageWindow::postMsgEvent(QtMsgType type, const char *msg)
|
||||
{
|
||||
QString qmsg = MessageWindow::QtMsgToQString(type, msg);
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
qmsg.prepend(QLatin1String("<FONT color=\"#FF0000\">"));
|
||||
qmsg.append(QLatin1String("</FONT>"));
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
if (QMessageBox::critical(this, QLatin1String("Critical Error"), qmsg,
|
||||
QMessageBox::Ignore,
|
||||
QMessageBox::Abort,
|
||||
QMessageBox::NoButton) == QMessageBox::Abort)
|
||||
abort(); // core dump
|
||||
qmsg.prepend(QLatin1String("<B><FONT color=\"#FF0000\">"));
|
||||
qmsg.append(QLatin1String("</FONT></B>"));
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
QMessageBox::critical(this, QLatin1String("Fatal Error"), qmsg, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
|
||||
abort(); // deliberately core dump
|
||||
}
|
||||
//it's impossible to change GUI directly from thread other than the main thread
|
||||
//so post message encapsulated by MessageEvent to the main thread's event queue
|
||||
QCoreApplication::postEvent(this, new MessageEvent(qmsg));
|
||||
}
|
||||
|
||||
MessageEvent::MessageEvent(QString &msg):
|
||||
QEvent(static_cast<QEvent::Type>(MessageWindow::MessageEventType))
|
||||
{
|
||||
this->msg = msg;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file MessageWindow.h
|
||||
* @brief Message Window.
|
||||
* @see MessageWindow
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
|
||||
#ifndef MESSAGEWINDOW_H_
|
||||
#define MESSAGEWINDOW_H_
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QEvent>
|
||||
|
||||
/**
|
||||
* Message Window. Handling errors and other messages.
|
||||
*/
|
||||
class MessageWindow: public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QTextEdit msgTextEdit; ///< Main widget.
|
||||
static MessageWindow *MsgHandler; ///< Set in constructor.
|
||||
static const char *WINDOW_TITLE; ///< Window title.
|
||||
|
||||
private:
|
||||
static QString QtMsgToQString(QtMsgType type, const char *msg);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handle custom events. MessageWindow hadles custom events listed in
|
||||
* EventType enum.
|
||||
*/
|
||||
virtual void customEvent(QEvent* event);
|
||||
|
||||
public:
|
||||
enum EventType {MessageEventType = QEvent::User}; ///< Custom event types.
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* @param parent parent widget.
|
||||
* @param flags widget flags.
|
||||
*/
|
||||
MessageWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0);
|
||||
|
||||
/**
|
||||
* Append message wrapper. Since ISO forbids casting member functions
|
||||
* to C functions, wrapper is needed to use this class as QtMsgHandler.
|
||||
* This method is thread-safe but not reentrant.
|
||||
* @param type message type.
|
||||
* @param msg message string.
|
||||
*/
|
||||
static void AppendMsgWrapper(QtMsgType type, const char *msg);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
static void AppendMsgWrapper(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
#endif
|
||||
/**
|
||||
* Post message event to the main event loop. This function encapsulates
|
||||
* message into MessageEvent object and passes it to the main event loop.
|
||||
* @param type message type.
|
||||
* @param msg message string.
|
||||
*/
|
||||
void postMsgEvent(QtMsgType type, const char *msg);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Message Event. Custom event used by @ref MessageWindow to provide multi-threaded
|
||||
* access. Encapsulates message inside @a msg variable.
|
||||
*/
|
||||
class MessageEvent: public QEvent
|
||||
{
|
||||
public:
|
||||
QString msg; ///< Message string.
|
||||
|
||||
/**
|
||||
* Contructor.
|
||||
* @param msg message to post.
|
||||
*/
|
||||
MessageEvent(QString &msg);
|
||||
};
|
||||
|
||||
#endif /*MESSAGEWINDOW_H_*/
|
||||
@@ -0,0 +1,128 @@
|
||||
/* QespTest.cpp
|
||||
**************************************/
|
||||
#include "QespTest.h"
|
||||
#include "qextserialport.h"
|
||||
#include <QLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
|
||||
QespTest::QespTest(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
||||
{
|
||||
//modify the port settings on your own
|
||||
#ifdef Q_OS_UNIX
|
||||
port = new QextSerialPort(QLatin1String("/dev/ttyS0"), QextSerialPort::Polling);
|
||||
#else
|
||||
port = new QextSerialPort(QLatin1String("COM1"), QextSerialPort::Polling);
|
||||
#endif /*Q_OS_UNIX*/
|
||||
port->setBaudRate(BAUD19200);
|
||||
port->setFlowControl(FLOW_OFF);
|
||||
port->setParity(PAR_NONE);
|
||||
port->setDataBits(DATA_8);
|
||||
port->setStopBits(STOP_2);
|
||||
//set timeouts to 500 ms
|
||||
port->setTimeout(500);
|
||||
|
||||
message = new QLineEdit(this);
|
||||
|
||||
// transmit receive
|
||||
QPushButton *transmitButton = new QPushButton(tr("Transmit"));
|
||||
connect(transmitButton, SIGNAL(clicked()), SLOT(transmitMsg()));
|
||||
QPushButton *receiveButton = new QPushButton(tr("Receive"));
|
||||
connect(receiveButton, SIGNAL(clicked()), SLOT(receiveMsg()));
|
||||
QHBoxLayout *trLayout = new QHBoxLayout;
|
||||
trLayout->addWidget(transmitButton);
|
||||
trLayout->addWidget(receiveButton);
|
||||
|
||||
//CR LF
|
||||
QPushButton *CRButton = new QPushButton(tr("CR"));
|
||||
connect(CRButton, SIGNAL(clicked()), SLOT(appendCR()));
|
||||
QPushButton *LFButton = new QPushButton(tr("LF"));
|
||||
connect(LFButton, SIGNAL(clicked()), SLOT(appendLF()));
|
||||
QHBoxLayout *crlfLayout = new QHBoxLayout;
|
||||
crlfLayout->addWidget(CRButton);
|
||||
crlfLayout->addWidget(LFButton);
|
||||
|
||||
//open close
|
||||
QPushButton *openButton = new QPushButton(tr("Open"));
|
||||
connect(openButton, SIGNAL(clicked()), SLOT(openPort()));
|
||||
QPushButton *closeButton = new QPushButton(tr("Close"));
|
||||
connect(closeButton, SIGNAL(clicked()), SLOT(closePort()));
|
||||
QHBoxLayout *ocLayout = new QHBoxLayout;
|
||||
ocLayout->addWidget(openButton);
|
||||
ocLayout->addWidget(closeButton);
|
||||
|
||||
received_msg = new QTextEdit();
|
||||
|
||||
QVBoxLayout *myVBox = new QVBoxLayout;
|
||||
myVBox->addWidget(message);
|
||||
myVBox->addLayout(crlfLayout);
|
||||
myVBox->addLayout(trLayout);
|
||||
myVBox->addLayout(ocLayout);
|
||||
myVBox->addWidget(received_msg);
|
||||
setLayout(myVBox);
|
||||
|
||||
qDebug("isOpen : %d", port->isOpen());
|
||||
}
|
||||
|
||||
QespTest::~QespTest()
|
||||
{
|
||||
delete port;
|
||||
port = NULL;
|
||||
}
|
||||
|
||||
void QespTest::transmitMsg()
|
||||
{
|
||||
int i = port->write(message->text().toLatin1());
|
||||
qDebug("trasmitted : %d", i);
|
||||
}
|
||||
|
||||
void QespTest::receiveMsg()
|
||||
{
|
||||
char buff[1024];
|
||||
int numBytes;
|
||||
|
||||
numBytes = port->bytesAvailable();
|
||||
if(numBytes > 1024)
|
||||
numBytes = 1024;
|
||||
|
||||
int i = port->read(buff, numBytes);
|
||||
if (i != -1)
|
||||
buff[i] = '\0';
|
||||
else
|
||||
buff[0] = '\0';
|
||||
QString msg = QLatin1String(buff);
|
||||
|
||||
received_msg->append(msg);
|
||||
received_msg->ensureCursorVisible();
|
||||
qDebug("bytes available: %d", numBytes);
|
||||
qDebug("received: %d", i);
|
||||
}
|
||||
|
||||
|
||||
void QespTest::appendCR()
|
||||
{
|
||||
message->insert(QLatin1String("\x0D"));
|
||||
}
|
||||
|
||||
void QespTest::appendLF()
|
||||
{
|
||||
message->insert(QLatin1String("\x0A"));
|
||||
}
|
||||
|
||||
void QespTest::closePort()
|
||||
{
|
||||
port->close();
|
||||
qDebug("is open: %d", port->isOpen());
|
||||
}
|
||||
|
||||
void QespTest::openPort()
|
||||
{
|
||||
port->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
|
||||
qDebug("is open: %d", port->isOpen());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* qesptest.h
|
||||
**************************************/
|
||||
#ifndef _QESPTEST_H_
|
||||
#define _QESPTEST_H_
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLineEdit;
|
||||
class QTextEdit;
|
||||
class QextSerialPort;
|
||||
class QSpinBox;
|
||||
|
||||
class QespTest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QespTest(QWidget *parent=0);
|
||||
|
||||
virtual ~QespTest();
|
||||
|
||||
private:
|
||||
QLineEdit *message;
|
||||
QSpinBox *delaySpinBox;
|
||||
QTextEdit *received_msg;
|
||||
QextSerialPort *port;
|
||||
|
||||
private slots:
|
||||
void transmitMsg();
|
||||
void receiveMsg();
|
||||
void appendCR();
|
||||
void appendLF();
|
||||
void closePort();
|
||||
void openPort();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
This is simple application using QextSerialPort library.
|
||||
|
||||
Port settings are in QespTest constructor (QespTest.cpp)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file main.cpp
|
||||
* @brief Main file.
|
||||
* @author Micha? Policht
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include "MainWindow.h"
|
||||
#include "MessageWindow.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
//! [0]
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
//redirect debug messages to the MessageWindow dialog
|
||||
qInstallMsgHandler(MessageWindow::AppendMsgWrapper);
|
||||
#else
|
||||
qInstallMessageHandler(MessageWindow::AppendMsgWrapper);
|
||||
#endif
|
||||
//! [0]
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += .
|
||||
QT += core gui
|
||||
contains(QT_VERSION, ^5\\..*\\..*): QT += widgets
|
||||
HEADERS += MainWindow.h \
|
||||
MessageWindow.h \
|
||||
QespTest.h
|
||||
|
||||
SOURCES += main.cpp \
|
||||
MainWindow.cpp \
|
||||
MessageWindow.cpp \
|
||||
QespTest.cpp
|
||||
|
||||
include(../../src/qextserialport.pri)
|
||||
@@ -0,0 +1,179 @@
|
||||
#include "qextserialport.h"
|
||||
#include "qextserialenumerator.h"
|
||||
#include "dialog.h"
|
||||
#include "ui_dialog.h"
|
||||
#include <QtCore>
|
||||
|
||||
Dialog::Dialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//! [0]
|
||||
foreach (QextPortInfo info, QextSerialEnumerator::getPorts())
|
||||
ui->portBox->addItem(info.portName);
|
||||
//make sure user can input their own port name!
|
||||
ui->portBox->setEditable(true);
|
||||
|
||||
ui->baudRateBox->addItem("1200", BAUD1200);
|
||||
ui->baudRateBox->addItem("2400", BAUD2400);
|
||||
ui->baudRateBox->addItem("4800", BAUD4800);
|
||||
ui->baudRateBox->addItem("9600", BAUD9600);
|
||||
ui->baudRateBox->addItem("19200", BAUD19200);
|
||||
ui->baudRateBox->setCurrentIndex(3);
|
||||
|
||||
ui->parityBox->addItem("NONE", PAR_NONE);
|
||||
ui->parityBox->addItem("ODD", PAR_ODD);
|
||||
ui->parityBox->addItem("EVEN", PAR_EVEN);
|
||||
|
||||
ui->dataBitsBox->addItem("5", DATA_5);
|
||||
ui->dataBitsBox->addItem("6", DATA_6);
|
||||
ui->dataBitsBox->addItem("7", DATA_7);
|
||||
ui->dataBitsBox->addItem("8", DATA_8);
|
||||
ui->dataBitsBox->setCurrentIndex(3);
|
||||
|
||||
ui->stopBitsBox->addItem("1", STOP_1);
|
||||
ui->stopBitsBox->addItem("2", STOP_2);
|
||||
|
||||
ui->queryModeBox->addItem("Polling", QextSerialPort::Polling);
|
||||
ui->queryModeBox->addItem("EventDriven", QextSerialPort::EventDriven);
|
||||
//! [0]
|
||||
|
||||
ui->led->turnOff();
|
||||
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(40);
|
||||
//! [1]
|
||||
PortSettings settings = {BAUD9600, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 10};
|
||||
port = new QextSerialPort(ui->portBox->currentText(), settings, QextSerialPort::Polling);
|
||||
//! [1]
|
||||
|
||||
enumerator = new QextSerialEnumerator(this);
|
||||
enumerator->setUpNotifications();
|
||||
|
||||
connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), SLOT(onBaudRateChanged(int)));
|
||||
connect(ui->parityBox, SIGNAL(currentIndexChanged(int)), SLOT(onParityChanged(int)));
|
||||
connect(ui->dataBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onDataBitsChanged(int)));
|
||||
connect(ui->stopBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onStopBitsChanged(int)));
|
||||
connect(ui->queryModeBox, SIGNAL(currentIndexChanged(int)), SLOT(onQueryModeChanged(int)));
|
||||
connect(ui->timeoutBox, SIGNAL(valueChanged(int)), SLOT(onTimeoutChanged(int)));
|
||||
connect(ui->portBox, SIGNAL(editTextChanged(QString)), SLOT(onPortNameChanged(QString)));
|
||||
connect(ui->openCloseButton, SIGNAL(clicked()), SLOT(onOpenCloseButtonClicked()));
|
||||
connect(ui->sendButton, SIGNAL(clicked()), SLOT(onSendButtonClicked()));
|
||||
connect(timer, SIGNAL(timeout()), SLOT(onReadyRead()));
|
||||
connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
|
||||
|
||||
connect(enumerator, SIGNAL(deviceDiscovered(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
|
||||
connect(enumerator, SIGNAL(deviceRemoved(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
|
||||
|
||||
setWindowTitle(tr("QextSerialPort Demo"));
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete ui;
|
||||
delete port;
|
||||
}
|
||||
|
||||
void Dialog::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::onPortNameChanged(const QString & /*name*/)
|
||||
{
|
||||
if (port->isOpen()) {
|
||||
port->close();
|
||||
ui->led->turnOff();
|
||||
}
|
||||
}
|
||||
//! [2]
|
||||
void Dialog::onBaudRateChanged(int idx)
|
||||
{
|
||||
port->setBaudRate((BaudRateType)ui->baudRateBox->itemData(idx).toInt());
|
||||
}
|
||||
|
||||
void Dialog::onParityChanged(int idx)
|
||||
{
|
||||
port->setParity((ParityType)ui->parityBox->itemData(idx).toInt());
|
||||
}
|
||||
|
||||
void Dialog::onDataBitsChanged(int idx)
|
||||
{
|
||||
port->setDataBits((DataBitsType)ui->dataBitsBox->itemData(idx).toInt());
|
||||
}
|
||||
|
||||
void Dialog::onStopBitsChanged(int idx)
|
||||
{
|
||||
port->setStopBits((StopBitsType)ui->stopBitsBox->itemData(idx).toInt());
|
||||
}
|
||||
|
||||
void Dialog::onQueryModeChanged(int idx)
|
||||
{
|
||||
port->setQueryMode((QextSerialPort::QueryMode)ui->queryModeBox->itemData(idx).toInt());
|
||||
}
|
||||
|
||||
void Dialog::onTimeoutChanged(int val)
|
||||
{
|
||||
port->setTimeout(val);
|
||||
}
|
||||
//! [2]
|
||||
//! [3]
|
||||
void Dialog::onOpenCloseButtonClicked()
|
||||
{
|
||||
if (!port->isOpen()) {
|
||||
port->setPortName(ui->portBox->currentText());
|
||||
port->open(QIODevice::ReadWrite);
|
||||
}
|
||||
else {
|
||||
port->close();
|
||||
}
|
||||
|
||||
//If using polling mode, we need a QTimer
|
||||
if (port->isOpen() && port->queryMode() == QextSerialPort::Polling)
|
||||
timer->start();
|
||||
else
|
||||
timer->stop();
|
||||
|
||||
//update led's status
|
||||
ui->led->turnOn(port->isOpen());
|
||||
}
|
||||
//! [3]
|
||||
//! [4]
|
||||
void Dialog::onSendButtonClicked()
|
||||
{
|
||||
if (port->isOpen() && !ui->sendEdit->toPlainText().isEmpty())
|
||||
port->write(ui->sendEdit->toPlainText().toLatin1());
|
||||
}
|
||||
|
||||
void Dialog::onReadyRead()
|
||||
{
|
||||
if (port->bytesAvailable()) {
|
||||
ui->recvEdit->moveCursor(QTextCursor::End);
|
||||
ui->recvEdit->insertPlainText(QString::fromLatin1(port->readAll()));
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::onPortAddedOrRemoved()
|
||||
{
|
||||
QString current = ui->portBox->currentText();
|
||||
|
||||
ui->portBox->blockSignals(true);
|
||||
ui->portBox->clear();
|
||||
foreach (QextPortInfo info, QextSerialEnumerator::getPorts())
|
||||
ui->portBox->addItem(info.portName);
|
||||
|
||||
ui->portBox->setCurrentIndex(ui->portBox->findText(current));
|
||||
|
||||
ui->portBox->blockSignals(false);
|
||||
}
|
||||
|
||||
//! [4]
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class Dialog;
|
||||
}
|
||||
class QTimer;
|
||||
class QextSerialPort;
|
||||
class QextSerialEnumerator;
|
||||
|
||||
class Dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = 0);
|
||||
~Dialog();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPortNameChanged(const QString &name);
|
||||
void onBaudRateChanged(int idx);
|
||||
void onParityChanged(int idx);
|
||||
void onDataBitsChanged(int idx);
|
||||
void onStopBitsChanged(int idx);
|
||||
void onQueryModeChanged(int idx);
|
||||
void onTimeoutChanged(int val);
|
||||
void onOpenCloseButtonClicked();
|
||||
void onSendButtonClicked();
|
||||
void onReadyRead();
|
||||
|
||||
void onPortAddedOrRemoved();
|
||||
|
||||
private:
|
||||
Ui::Dialog *ui;
|
||||
QTimer *timer;
|
||||
QextSerialPort *port;
|
||||
QextSerialEnumerator *enumerator;
|
||||
};
|
||||
|
||||
#endif // DIALOG_H
|
||||
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>604</width>
|
||||
<height>485</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="3,1">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="recvEdit">
|
||||
<property name="maximumBlockCount">
|
||||
<number>800</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="sendEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="portBox"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>BaudRate:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="baudRateBox"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>DataBits:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="dataBitsBox"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Parity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="parityBox"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>StopBits:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QComboBox" name="stopBitsBox"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>QueryMode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="queryModeBox"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="timeoutBox">
|
||||
<property name="suffix">
|
||||
<string> ms</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="HLed" name="led" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="openCloseButton">
|
||||
<property name="text">
|
||||
<string>Open/Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="sendButton">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HLed</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>hled.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,133 @@
|
||||
#include <QtGui>
|
||||
#include "hled.h"
|
||||
|
||||
struct HLed::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: darkerFactor(300), color(Qt::green), isOn(true)
|
||||
{ }
|
||||
|
||||
int darkerFactor;
|
||||
QColor color;
|
||||
bool isOn;
|
||||
};
|
||||
|
||||
HLed::HLed(QWidget *parent)
|
||||
:QWidget(parent), m_d(new Private)
|
||||
{
|
||||
}
|
||||
|
||||
HLed::~HLed()
|
||||
{
|
||||
delete m_d;
|
||||
}
|
||||
|
||||
QColor HLed::color() const
|
||||
{
|
||||
return m_d->color;
|
||||
}
|
||||
|
||||
void HLed::setColor(const QColor &color)
|
||||
{
|
||||
if (m_d->color == color)
|
||||
return;
|
||||
update();
|
||||
}
|
||||
|
||||
QSize HLed::sizeHint() const
|
||||
{
|
||||
return QSize(20, 20);
|
||||
}
|
||||
|
||||
QSize HLed::minimumSizeHint() const
|
||||
{
|
||||
return QSize(16, 16);
|
||||
}
|
||||
|
||||
void HLed::toggle()
|
||||
{
|
||||
m_d->isOn = !m_d->isOn;
|
||||
update();
|
||||
}
|
||||
|
||||
void HLed::turnOn(bool on)
|
||||
{
|
||||
m_d->isOn = on;
|
||||
update();
|
||||
}
|
||||
|
||||
void HLed::turnOff(bool off)
|
||||
{
|
||||
turnOn(!off);
|
||||
}
|
||||
|
||||
void HLed::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
int width = ledWidth();
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
QColor color = m_d->isOn ? m_d->color
|
||||
: m_d->color.darker(m_d->darkerFactor);
|
||||
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
brush.setColor(color);
|
||||
painter.setBrush(brush);
|
||||
// draw plain
|
||||
painter.drawEllipse(1, 1, width-1, width-1);
|
||||
|
||||
QPen pen;
|
||||
pen.setWidth(2);
|
||||
|
||||
int pos = width / 5 + 1;
|
||||
int lightWidth = width * 2 / 3;
|
||||
int lightQuote = 130 * 2 / (lightWidth ? lightWidth : 1) + 100;
|
||||
|
||||
// draw bright spot
|
||||
while (lightWidth) {
|
||||
color = color.lighter(lightQuote);
|
||||
pen.setColor(color);
|
||||
painter.setPen(pen);
|
||||
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
|
||||
lightWidth--;
|
||||
|
||||
if (!lightWidth)
|
||||
break;
|
||||
|
||||
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
|
||||
lightWidth--;
|
||||
|
||||
if (!lightWidth)
|
||||
break;
|
||||
|
||||
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
|
||||
pos++;
|
||||
lightWidth--;
|
||||
}
|
||||
|
||||
//draw border
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
|
||||
int angle = -720;
|
||||
color = palette().color(QPalette::Light);
|
||||
|
||||
for (int arc=120; arc<2880; arc+=240) {
|
||||
pen.setColor(color);
|
||||
painter.setPen(pen);
|
||||
int w = width - pen.width()/2;
|
||||
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle+arc, 240);
|
||||
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle-arc, 240);
|
||||
color = color.darker(110);
|
||||
}
|
||||
}
|
||||
|
||||
int HLed::ledWidth() const
|
||||
{
|
||||
int width = qMin(this->width(), this->height());
|
||||
width -= 2;
|
||||
return width > 0 ? width : 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef HLED_H
|
||||
#define HLED_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QColor;
|
||||
|
||||
class HLed : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HLed(QWidget *parent = 0);
|
||||
~HLed();
|
||||
|
||||
QColor color() const;
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
public slots:
|
||||
void setColor(const QColor &color);
|
||||
void toggle();
|
||||
void turnOn(bool on=true);
|
||||
void turnOff(bool off=true);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
int ledWidth() const;
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
Private * const m_d;
|
||||
};
|
||||
|
||||
#endif // HLED_H
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <QApplication>
|
||||
#include "dialog.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
Dialog w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2011-11-06T21:37:41
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
contains(QT_VERSION, ^5\\..*\\..*): QT += widgets
|
||||
|
||||
TARGET = uartassistant
|
||||
TEMPLATE = app
|
||||
|
||||
include(../../src/qextserialport.pri)
|
||||
|
||||
SOURCES += main.cpp\
|
||||
dialog.cpp\
|
||||
hled.cpp
|
||||
|
||||
HEADERS += dialog.h \
|
||||
hled.h
|
||||
|
||||
FORMS += dialog.ui
|
||||
@@ -0,0 +1,24 @@
|
||||
defineReplace(qextLibraryName) {
|
||||
unset(LIBRARY_NAME)
|
||||
LIBRARY_NAME = \$\$1
|
||||
greaterThan(QT_MAJOR_VERSION, 4):LIBRARY_NAME ~= s,^Qt,Qt\$\$QT_MAJOR_VERSION,
|
||||
CONFIG(debug, debug|release) {
|
||||
!debug_and_release|build_pass {
|
||||
mac:LIBRARY_NAME = \$\${LIBRARY_NAME}_debug
|
||||
else:win32:LIBRARY_NAME = \$\${LIBRARY_NAME}d
|
||||
}
|
||||
}
|
||||
return(\$\$LIBRARY_NAME)
|
||||
}
|
||||
|
||||
!!IF qesp_mac_framework
|
||||
LIBS += -framework $$QESP_LIB_BASENAME
|
||||
INCLUDEPATH += $$[QT_INSTALL_LIBS]/$${QESP_LIB_BASENAME}.framework/Headers
|
||||
!!ELSE
|
||||
LIBS += -l\$\$qextLibraryName($$QESP_LIB_BASENAME)
|
||||
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtExtSerialPort
|
||||
!!ENDIF
|
||||
|
||||
!!IF !qesp_static
|
||||
DEFINES += QEXTSERIALPORT_USING_SHARED
|
||||
!!ENDIF
|
||||
Binary file not shown.
@@ -0,0 +1,96 @@
|
||||
############################### *User Config* ###############################
|
||||
|
||||
# Uncomment following line if you want to build a static library
|
||||
#CONFIG += qesp_static
|
||||
|
||||
# Uncomment following line if you want to build framework for mac
|
||||
# macx:CONFIG += qesp_mac_framework
|
||||
|
||||
# Uncomment following line if you want to enable udev for linux
|
||||
# linux*:CONFIG += qesp_linux_udev
|
||||
|
||||
# Note: you can create a ".qmake.cache" file, then copy these lines to it.
|
||||
# If so, you can avoid to change this project file.
|
||||
############################### *User Config* ###############################
|
||||
|
||||
defineReplace(qextLibraryName) {
|
||||
unset(LIBRARY_NAME)
|
||||
LIBRARY_NAME = $$1
|
||||
macx:qesp_mac_framework {
|
||||
QMAKE_FRAMEWORK_BUNDLE_NAME = $$LIBRARY_NAME
|
||||
export(QMAKE_FRAMEWORK_BUNDLE_NAME)
|
||||
} else {
|
||||
greaterThan(QT_MAJOR_VERSION, 4):LIBRARY_NAME ~= s,^Qt,Qt$$QT_MAJOR_VERSION,
|
||||
}
|
||||
CONFIG(debug, debug|release) {
|
||||
!debug_and_release|build_pass {
|
||||
mac:LIBRARY_NAME = $${LIBRARY_NAME}_debug
|
||||
else:win32:LIBRARY_NAME = $${LIBRARY_NAME}d
|
||||
}
|
||||
}
|
||||
return($$LIBRARY_NAME)
|
||||
}
|
||||
|
||||
TEMPLATE=lib
|
||||
include(src/qextserialport.pri)
|
||||
|
||||
#create_prl is needed, otherwise, MinGW can't found libqextserialport1.a
|
||||
CONFIG += create_prl
|
||||
|
||||
#mac framework is designed for shared library
|
||||
macx:qesp_mac_framework:qesp_static: CONFIG -= qesp_static
|
||||
!macx:qesp_mac_framework:CONFIG -= qesp_mac_framework
|
||||
|
||||
qesp_static {
|
||||
CONFIG += static
|
||||
} else {
|
||||
CONFIG += shared
|
||||
macx:!qesp_mac_framework:CONFIG += absolute_library_soname
|
||||
DEFINES += QEXTSERIALPORT_BUILD_SHARED
|
||||
}
|
||||
|
||||
#Creare lib bundle for mac
|
||||
macx:qesp_mac_framework {
|
||||
CONFIG += lib_bundle
|
||||
FRAMEWORK_HEADERS.files = $$PUBLIC_HEADERS
|
||||
FRAMEWORK_HEADERS.path = Headers
|
||||
QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS
|
||||
}
|
||||
|
||||
win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all
|
||||
|
||||
#For non-windows system, only depends on QtCore module
|
||||
unix:QT = core
|
||||
else:QT = core gui
|
||||
|
||||
#generate proper library name
|
||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
QESP_LIB_BASENAME = QtExtSerialPort
|
||||
} else {
|
||||
QESP_LIB_BASENAME = qextserialport
|
||||
}
|
||||
TARGET = $$qextLibraryName($$QESP_LIB_BASENAME)
|
||||
VERSION = 1.2.0
|
||||
|
||||
# generate feature file by qmake based on this *.in file.
|
||||
QMAKE_SUBSTITUTES += extserialport.prf.in
|
||||
OTHER_FILES += extserialport.prf.in
|
||||
|
||||
# for make docs
|
||||
include(doc/doc.pri)
|
||||
|
||||
# for make install
|
||||
win32:!qesp_static {
|
||||
dlltarget.path = $$[QT_INSTALL_BINS]
|
||||
INSTALLS += dlltarget
|
||||
}
|
||||
!macx|!qesp_mac_framework {
|
||||
headers.files = $$PUBLIC_HEADERS
|
||||
headers.path = $$[QT_INSTALL_HEADERS]/QtExtSerialPort
|
||||
INSTALLS += headers
|
||||
}
|
||||
target.path = $$[QT_INSTALL_LIBS]
|
||||
|
||||
features.files = extserialport.prf
|
||||
features.path = $$[QMAKE_MKSPECS]/features
|
||||
INSTALLS += target features
|
||||
Binary file not shown.
@@ -0,0 +1,352 @@
|
||||
#include "ZTAlarmGenerator.h"
|
||||
#include "ZTAlarmGeneratorPage.h"
|
||||
#include "ZTAlarms.h"
|
||||
#include "ProtocolDefs.h"
|
||||
|
||||
CZTAlarmGenerator::CZTAlarmGenerator(QObject *parent)
|
||||
{
|
||||
mAlarmGeneratorPageHandle = 0;
|
||||
|
||||
mModbusZTEmulator = new CModbusZTMaster(&mZTModbusRepo);
|
||||
|
||||
mZTModbusRepo.AddHRDataMap(2000,128);
|
||||
connect(mModbusZTEmulator,SIGNAL(ModbusMasterConnected(CModbusZTMaster*)),this,SLOT(ModbusMasterConnected(CModbusZTMaster*)));
|
||||
connect(mModbusZTEmulator,SIGNAL(ModbusMasterDisconnected(CModbusZTMaster*)),this,SLOT(ModbusMasterDisconnected(CModbusZTMaster*)));
|
||||
connect(mModbusZTEmulator,SIGNAL(ModbusMasterRepositoryUpdated()),this,SLOT(ModbusMasterRepositoryUpdated()));
|
||||
|
||||
mModbusUpdateTimer = new QTimer();
|
||||
connect(mModbusUpdateTimer,&QTimer::timeout,this,&CZTAlarmGenerator::UpdateModbusTimerExpired);
|
||||
mModbusUpdateTimer->setSingleShot(false);
|
||||
mModbusUpdateTimer->setInterval(500);
|
||||
|
||||
|
||||
mWatchdogValue = false;
|
||||
mReadModbus = false;
|
||||
}
|
||||
|
||||
CZTAlarmGenerator::~CZTAlarmGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CZTAlarmGenerator::ModbusMasterConnected(CModbusZTMaster *ModbusZTMaster)
|
||||
{
|
||||
mAlarmGeneratorPageHandle->ModbusMasterConnected();
|
||||
mModbusUpdateTimer->start();
|
||||
}
|
||||
|
||||
void CZTAlarmGenerator::ModbusMasterDisconnected(CModbusZTMaster *ModbusMaster)
|
||||
{
|
||||
mAlarmGeneratorPageHandle->ModbusMasterDisconnected();
|
||||
mModbusUpdateTimer->stop();
|
||||
}
|
||||
|
||||
void CZTAlarmGenerator::ModbusMasterRepositoryUpdated()
|
||||
{
|
||||
quint16 SEIFlags, SEIWD;
|
||||
bool OK,AN1Active,AN2Active;
|
||||
|
||||
SEIWD = mZTModbusRepo.GetSingleReg(SEI_MODBUS_SEI_WATCHDOG_REG,&OK);
|
||||
SEIFlags = mZTModbusRepo.GetSingleReg(SEI_MODBUS_SEI_ALARMS_RESET_REG,&OK);
|
||||
|
||||
AN1Active = ( (SEIFlags & SEI_MODBUS_SEI_ZT1_ALARM_RESET_MASK) != 0);
|
||||
AN2Active = ( (SEIFlags & SEI_MODBUS_SEI_ZT2_ALARM_RESET_MASK) != 0);
|
||||
|
||||
mAlarmGeneratorPageHandle->UpdateSEIState(AN1Active,AN2Active,SEIWD);
|
||||
|
||||
}
|
||||
|
||||
int CZTAlarmGenerator::UpdateActiveAlarms(CZTAlarms *ActiveAlarms)
|
||||
{
|
||||
quint16 WorkingReg, RankReg;
|
||||
|
||||
ClearAllAlarms();
|
||||
|
||||
//Set Comptage and Panne équipement alarms
|
||||
|
||||
WorkingReg = 0;
|
||||
if(ActiveAlarms->mZT1AxleCountAlarm == true)
|
||||
{
|
||||
WorkingReg |= ZT1_V00_ALARM_FLAG_MASK;
|
||||
}
|
||||
if(ActiveAlarms->mZT1EquipmentFailureAlarm == true)
|
||||
{
|
||||
WorkingReg |= ZT1_PEQ1_ALARM_FLAG_MASK;
|
||||
}
|
||||
if(ActiveAlarms->mZT2AxleCountAlarm == true)
|
||||
{
|
||||
WorkingReg |= ZT2_V02_ALARM_FLAG_MASK;
|
||||
}
|
||||
if(ActiveAlarms->mZT2EquipmentFailureAlarm == true)
|
||||
{
|
||||
WorkingReg |= ZT2_PEQ2_ALARM_FLAG_MASK;
|
||||
}
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_MISC_DATA_BASE_REG_ADD,WorkingReg);
|
||||
|
||||
WorkingReg = 0;
|
||||
RankReg = 0;
|
||||
|
||||
for(int i = 0; i < ActiveAlarms->mZT1FNAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT1_FN_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT1FNAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_FN_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT1_FN_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT1FNAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_FN_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT1_FN_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT1FNAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_FN_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT1_FN_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT1FNAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_FN_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < ActiveAlarms->mZT1PGAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT1_PG_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT1PGAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PG_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT1_PG_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT1PGAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PG_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT1_PG_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT1PGAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PG_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT1_PG_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT1PGAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PG_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < ActiveAlarms->mZT1PPEAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_EXT_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT1PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_EXT_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_EXT_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT1PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_EXT_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_EXT_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT1PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_EXT_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_EXT_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT1PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_EXT_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < ActiveAlarms->mZT1PPIAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_INT_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT1PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_INT_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_INT_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT1PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_INT_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_INT_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT1PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_INT_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT1_PP_INT_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT1PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_RANK_PP_INT_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT1_ALARM_DATA_BASE_REG_ADD,WorkingReg);
|
||||
|
||||
WorkingReg = 0;
|
||||
for(int i = 0; i < ActiveAlarms->mZT2PPEAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_EXT_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT2PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_EXT_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_EXT_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT2PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_EXT_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_EXT_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT2PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_EXT_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_EXT_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT2PPEAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_EXT_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < ActiveAlarms->mZT2PPIAlarmRanks.size(); i++)
|
||||
{
|
||||
switch(i + 1)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_INT_FLAG_MASK_1;
|
||||
RankReg = ActiveAlarms->mZT2PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_INT_1_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_INT_FLAG_MASK_2;
|
||||
RankReg = ActiveAlarms->mZT2PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_INT_2_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_INT_FLAG_MASK_3;
|
||||
RankReg = ActiveAlarms->mZT2PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_INT_3_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
WorkingReg |= ZT2_PP_INT_FLAG_MASK_4;
|
||||
RankReg = ActiveAlarms->mZT2PPIAlarmRanks.at(i);
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_RANK_PP_INT_4_REG_ADD,RankReg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mZTModbusRepo.WriteSingleReg(MODBUS_ZT2_ALARM_DATA_BASE_REG_ADD,WorkingReg);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CZTAlarmGenerator::ClearAllAlarms()
|
||||
{
|
||||
QList<qint16> ClearData;
|
||||
ClearData.clear();
|
||||
for(int i = 0; i < MODBUS_ZT_TABLE_DATA_SIZE; i++)
|
||||
ClearData.append(0);
|
||||
|
||||
mZTModbusRepo.WriteMultipleRegs(MODBUS_ZT_DATA_BASE_REG,ClearData);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CZTAlarmGenerator::ConnectToSEIRequest()
|
||||
{
|
||||
mModbusZTEmulator->ConnectToSlave("192.168.50.110",503);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CZTAlarmGenerator::DisconnectFromSEIRequest()
|
||||
{
|
||||
mModbusZTEmulator->DisconnectFromSlave();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZTAlarmGenerator::UpdateModbusTimerExpired()
|
||||
{
|
||||
if(mReadModbus == false)
|
||||
{
|
||||
if(mWatchdogValue)
|
||||
{
|
||||
mZTModbusRepo.WriteSingleReg(SEI_MODBUS_ZT_WATCHDOG_REG,SEI_MODBUS_SEI_WATCHDOG_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
mZTModbusRepo.WriteSingleReg(SEI_MODBUS_ZT_WATCHDOG_REG,0);
|
||||
}
|
||||
mWatchdogValue = !mWatchdogValue;
|
||||
mModbusZTEmulator->ReadModbusRegisters();
|
||||
}
|
||||
else
|
||||
{
|
||||
mModbusZTEmulator->SendModbusRegisters();
|
||||
}
|
||||
mReadModbus = !mReadModbus;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef ZTALARMGENERATOR_H
|
||||
#define ZTALARMGENERATOR_H
|
||||
#include <QObject>
|
||||
|
||||
#include "ModbusZTMaster.h"
|
||||
#include "ModbusRepository.h"
|
||||
#include "ZTInfo.h"
|
||||
#include <QTimer>
|
||||
|
||||
class CZTAlarmGeneratorPage;
|
||||
class CZTAlarms;
|
||||
|
||||
class CZTAlarmGenerator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CZTAlarmGenerator(QObject *parent = 0);
|
||||
~CZTAlarmGenerator();
|
||||
int UpdateActiveAlarms(CZTAlarms *ActiveAlarms);
|
||||
int ClearAllAlarms();
|
||||
int ConnectToSEIRequest();
|
||||
int DisconnectFromSEIRequest();
|
||||
|
||||
CModbusZTMaster *mModbusZTEmulator;
|
||||
CModbusRepository mZTModbusRepo;
|
||||
CZTInfo mZTInfo;
|
||||
|
||||
CZTAlarmGeneratorPage *mAlarmGeneratorPageHandle;
|
||||
|
||||
private:
|
||||
bool mWatchdogValue;
|
||||
bool mReadModbus;
|
||||
QTimer *mModbusUpdateTimer;
|
||||
|
||||
public slots:
|
||||
void ModbusMasterConnected(CModbusZTMaster *ModbusZTMaster);
|
||||
void ModbusMasterDisconnected(CModbusZTMaster *);
|
||||
void ModbusMasterRepositoryUpdated();
|
||||
void UpdateModbusTimerExpired();
|
||||
|
||||
};
|
||||
|
||||
#endif // ZTALARMGENERATOR_H
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CZTAlarmGenerator</class>
|
||||
<widget class="QWidget" name="CZTAlarmGenerator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mSEISimTitleLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>60</y>
|
||||
<width>361</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Générateur d'alarmes ZT</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,246 @@
|
||||
#include "ZTAlarmGeneratorPage.h"
|
||||
#include "ui_ZTAlarmGeneratorPage.h"
|
||||
#include <QStringList>
|
||||
#include "ZTAlarmGenerator.h"
|
||||
|
||||
CZTAlarmGeneratorPage::CZTAlarmGeneratorPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CZTAlarmGeneratorPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
mProgramHandle = 0;
|
||||
|
||||
QStringList AlarmTypes;
|
||||
AlarmTypes << "Erreur de comptage ZT1"
|
||||
<< "Détection Frotteur Négatif"
|
||||
<< "Détection Pneu de Guidage"
|
||||
<< "Détection Pneu Porteur Intérieur ZT1"
|
||||
<< "Détection Pneu Porteur Extérieur ZT1"
|
||||
<< "Erreur de comptage ZT2"
|
||||
<< "Détection Pneu Porteur Intérieur ZT2"
|
||||
<< "Détection Pneu Porteur Extérieur ZT2"
|
||||
<< "Panne Équipement ZT1"
|
||||
<< "Panne Équipement ZT2";
|
||||
|
||||
ui->mAlarmComboBox->addItems(AlarmTypes);
|
||||
ui->mAlarmComboBox->setEditable(false);
|
||||
|
||||
AlarmSelectionChanged("Erreur de comptage ZT1");
|
||||
|
||||
ui->mConnectSEIBtn->setText("Connecter");
|
||||
|
||||
connect(ui->mAlarmComboBox,SIGNAL(activated(QString)),this,SLOT(AlarmSelectionChanged(QString)));
|
||||
|
||||
ui->mActiveAlarmsList->clear();
|
||||
|
||||
connect(ui->mSendAlarmBtn,&QPushButton::clicked,this,&CZTAlarmGeneratorPage::SendAlarmsBtnPressed);
|
||||
connect(ui->mResetAlarmsBtn,&QPushButton::clicked,this,&CZTAlarmGeneratorPage::ClearAlarmsBtnPressed);
|
||||
connect(ui->mConnectSEIBtn,&QPushButton::clicked,this,&CZTAlarmGeneratorPage::ConnectToSEIBtnPressed);
|
||||
|
||||
|
||||
}
|
||||
|
||||
CZTAlarmGeneratorPage::~CZTAlarmGeneratorPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::ClearAlarmsBtnPressed()
|
||||
{
|
||||
mActiveAlarms.ClearAllAlarms();
|
||||
ui->mActiveAlarmsList->clear();
|
||||
mProgramHandle->ClearAllAlarms();
|
||||
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::ActivateAlarmBtnPressed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::ConnectToSEIBtnPressed()
|
||||
{
|
||||
if(ui->mConnectSEIBtn->text() == "Connecter")
|
||||
{
|
||||
mProgramHandle->ConnectToSEIRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
mProgramHandle->DisconnectFromSEIRequest();
|
||||
}
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::AlarmSelectionChanged(QString text)
|
||||
{
|
||||
qDebug(qPrintable(text.toUtf8()));
|
||||
|
||||
if(text == "Erreur de comptage ZT1" ||
|
||||
text == "Panne Équipement ZT1" ||
|
||||
text == "Erreur de comptage ZT2" ||
|
||||
text == "Panne Équipement ZT2")
|
||||
{
|
||||
ui->mRankSpinBx->setRange(1,1);
|
||||
ui->mRankSpinBx->setValue(1);
|
||||
ui->mRankSpinBx->setEnabled(false);
|
||||
}
|
||||
else if(text == "Détection Frotteur Négatif")
|
||||
{
|
||||
ui->mRankSpinBx->setEnabled(true);
|
||||
ui->mRankSpinBx->setRange(1,36);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mRankSpinBx->setEnabled(true);
|
||||
if(ui->mRankSpinBx->value() > 18)
|
||||
{
|
||||
ui->mRankSpinBx->setValue(18);
|
||||
}
|
||||
ui->mRankSpinBx->setRange(1,18);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::SendAlarmsBtnPressed()
|
||||
{
|
||||
QString AlarmText = ui->mAlarmComboBox->currentText();
|
||||
if(AlarmText == "Erreur de comptage ZT1")
|
||||
{
|
||||
if(mActiveAlarms.mZT1AxleCountAlarm == true)
|
||||
{
|
||||
//Alarm already active... do nothing
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1AxleCountAlarm = true;
|
||||
ui->mActiveAlarmsList->addItem("Erreur de comptage ZT1");
|
||||
}
|
||||
if(AlarmText == "Détection Frotteur Négatif")
|
||||
{
|
||||
if(mActiveAlarms.mZT1FNAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1FNAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Détection Pneu de Guidage")
|
||||
{
|
||||
if(mActiveAlarms.mZT1PGAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1PGAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Détection Pneu Porteur Intérieur ZT1")
|
||||
{
|
||||
if(mActiveAlarms.mZT1PPIAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1PPIAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
|
||||
}
|
||||
if(AlarmText == "Détection Pneu Porteur Extérieur ZT1")
|
||||
{
|
||||
if(mActiveAlarms.mZT1PPEAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1PPEAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
|
||||
}
|
||||
if(AlarmText == "Erreur de comptage ZT2")
|
||||
{
|
||||
if(mActiveAlarms.mZT2AxleCountAlarm == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT2AxleCountAlarm = true;
|
||||
ui->mActiveAlarmsList->addItem(QString("%1").arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Détection Pneu Porteur Intérieur ZT2")
|
||||
{
|
||||
if(mActiveAlarms.mZT2PPIAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT2PPIAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Détection Pneu Porteur Extérieur ZT2")
|
||||
{
|
||||
if(mActiveAlarms.mZT2PPEAlarmRanks.size() == 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT2PPEAlarmRanks.append(ui->mRankSpinBx->value());
|
||||
ui->mActiveAlarmsList->addItem(QString("%2 au rang %1").arg(ui->mRankSpinBx->value()).arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Panne Équipement ZT1")
|
||||
{
|
||||
if(mActiveAlarms.mZT1EquipmentFailureAlarm == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT1EquipmentFailureAlarm = true;
|
||||
ui->mActiveAlarmsList->addItem(QString("%1").arg(AlarmText));
|
||||
}
|
||||
if(AlarmText == "Panne Équipement ZT2")
|
||||
{
|
||||
if(mActiveAlarms.mZT2EquipmentFailureAlarm == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mActiveAlarms.mZT2EquipmentFailureAlarm = true;
|
||||
ui->mActiveAlarmsList->addItem(QString("%1").arg(AlarmText));
|
||||
}
|
||||
|
||||
mProgramHandle->UpdateActiveAlarms(&mActiveAlarms);
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::ModbusMasterConnected()
|
||||
{
|
||||
ui->mSEIConnectStatusLbl->setText("SEI: Connecté");
|
||||
ui->mConnectSEIBtn->setText("Déconnecter");
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::ModbusMasterDisconnected()
|
||||
{
|
||||
ui->mSEIConnectStatusLbl->setText("SEI: Déconnecté");
|
||||
ui->mConnectSEIBtn->setText("Connecter");
|
||||
}
|
||||
|
||||
void CZTAlarmGeneratorPage::UpdateSEIState(bool AN1Flag, bool AN2Flag, quint16 Watchdog)
|
||||
{
|
||||
if(AN1Flag)
|
||||
{
|
||||
mActiveAlarms.ClearZT1Alarms();
|
||||
mProgramHandle->UpdateActiveAlarms(&mActiveAlarms);
|
||||
}
|
||||
if(AN2Flag)
|
||||
{
|
||||
mActiveAlarms.ClearZT2Alarms();
|
||||
mProgramHandle->UpdateActiveAlarms(&mActiveAlarms);
|
||||
}
|
||||
|
||||
if(Watchdog == 0)
|
||||
{
|
||||
ui->mSEIWatchdogValueLbl->setText("Watchdog SEI: 0");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mSEIWatchdogValueLbl->setText("Watchdog SEI: 1");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef ZTALARMGENERATORPAGE_H
|
||||
#define ZTALARMGENERATORPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ZTAlarms.h"
|
||||
class CZTAlarmGenerator;
|
||||
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class CZTAlarmGeneratorPage;
|
||||
}
|
||||
|
||||
class CZTAlarmGeneratorPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CZTAlarmGeneratorPage(QWidget *parent = 0);
|
||||
~CZTAlarmGeneratorPage();
|
||||
void ModbusMasterConnected();
|
||||
void ModbusMasterDisconnected();
|
||||
void UpdateSEIState(bool AN1Flag, bool AN2Flag, quint16 Watchdog);
|
||||
|
||||
CZTAlarmGenerator *mProgramHandle;
|
||||
|
||||
private:
|
||||
Ui::CZTAlarmGeneratorPage *ui;
|
||||
CZTAlarms mActiveAlarms;
|
||||
|
||||
public slots:
|
||||
void ConnectToSEIBtnPressed();
|
||||
void ActivateAlarmBtnPressed();
|
||||
void ClearAlarmsBtnPressed();
|
||||
void AlarmSelectionChanged(QString text);
|
||||
void SendAlarmsBtnPressed();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // ZTALARMGENERATORPAGE_H
|
||||
@@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CZTAlarmGeneratorPage</class>
|
||||
<widget class="QWidget" name="CZTAlarmGeneratorPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>979</width>
|
||||
<height>561</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mSEISimTitleLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>30</y>
|
||||
<width>411</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>18</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Générateur d'alarmes ZT au SEI</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mConnectSEIBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>70</y>
|
||||
<width>101</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connecter au SEI</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mAlarmComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>190</y>
|
||||
<width>301</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mSendAlarmBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>190</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Envoyer --></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mResetAlarmsBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
<y>460</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Acquiter tout</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="mRankSpinBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>190</y>
|
||||
<width>71</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>160</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alarme</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>400</x>
|
||||
<y>160</y>
|
||||
<width>41</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rang</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>610</x>
|
||||
<y>130</y>
|
||||
<width>291</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alarmes actives</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="mActiveAlarmsList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>595</x>
|
||||
<y>160</y>
|
||||
<width>351</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mSEIConnectStatusLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>70</y>
|
||||
<width>141</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SEI: Déconnecté</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mSEIWatchdogValueLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<y>250</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Watchdog SEI: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CZTAlarmGenerator</class>
|
||||
<widget class="QWidget" name="CZTAlarmGenerator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>693</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mSEISimTitleLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>60</y>
|
||||
<width>361</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Générateur d'alarmes ZT</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::AutoText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "ZTAlarms.h"
|
||||
|
||||
CZTAlarms::CZTAlarms()
|
||||
{
|
||||
mZT1AxleCountAlarm = mZT1EquipmentFailureAlarm = false;
|
||||
mZT2AxleCountAlarm = mZT2EquipmentFailureAlarm = false;
|
||||
}
|
||||
|
||||
void CZTAlarms::ClearAllAlarms()
|
||||
{
|
||||
// mZT1PPIAlarmRanks.clear();
|
||||
// mZT1PPEAlarmRanks.clear();
|
||||
// mZT1PGAlarmRanks.clear();
|
||||
// mZT1FNAlarmRanks.clear();
|
||||
// mZT2PPIAlarmRanks.clear();
|
||||
// mZT2PPEAlarmRanks.clear();
|
||||
// mZT1AxleCountAlarm = mZT1EquipmentFailureAlarm = false;
|
||||
// mZT2AxleCountAlarm = mZT2EquipmentFailureAlarm = false;
|
||||
ClearZT1Alarms();
|
||||
ClearZT2Alarms();
|
||||
}
|
||||
|
||||
void CZTAlarms::ClearZT1Alarms()
|
||||
{
|
||||
mZT1PPIAlarmRanks.clear();
|
||||
mZT1PPEAlarmRanks.clear();
|
||||
mZT1PGAlarmRanks.clear();
|
||||
mZT1FNAlarmRanks.clear();
|
||||
mZT1AxleCountAlarm = mZT1EquipmentFailureAlarm = false;
|
||||
}
|
||||
|
||||
void CZTAlarms::ClearZT2Alarms()
|
||||
{
|
||||
mZT2PPIAlarmRanks.clear();
|
||||
mZT2PPEAlarmRanks.clear();
|
||||
mZT2AxleCountAlarm = mZT2EquipmentFailureAlarm = false;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef ZTALARMS_H
|
||||
#define ZTALARMS_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
class CZTAlarms
|
||||
{
|
||||
public:
|
||||
CZTAlarms();
|
||||
void ClearAllAlarms();
|
||||
void ClearZT1Alarms();
|
||||
void ClearZT2Alarms();
|
||||
|
||||
QList<int> mZT1PPIAlarmRanks,mZT1PPEAlarmRanks,mZT1PGAlarmRanks,mZT1FNAlarmRanks;
|
||||
QList<int> mZT2PPIAlarmRanks,mZT2PPEAlarmRanks;
|
||||
bool mZT1AxleCountAlarm, mZT1EquipmentFailureAlarm;
|
||||
bool mZT2AxleCountAlarm, mZT2EquipmentFailureAlarm;
|
||||
};
|
||||
|
||||
#endif // ZTALARMS_H
|
||||
@@ -0,0 +1,114 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading UI file 'ZTAlarmGeneratorPage.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.14.2
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef UI_ZTALARMGENERATORPAGE_H
|
||||
#define UI_ZTALARMGENERATORPAGE_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QComboBox>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QListWidget>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_CZTAlarmGeneratorPage
|
||||
{
|
||||
public:
|
||||
QLabel *mSEISimTitleLabel;
|
||||
QPushButton *mConnectSEIBtn;
|
||||
QComboBox *mAlarmComboBox;
|
||||
QPushButton *mSendAlarmBtn;
|
||||
QPushButton *mResetAlarmsBtn;
|
||||
QSpinBox *mRankSpinBx;
|
||||
QLabel *label;
|
||||
QLabel *label_2;
|
||||
QLabel *label_3;
|
||||
QListWidget *mActiveAlarmsList;
|
||||
QLabel *mSEIConnectStatusLbl;
|
||||
QLabel *mSEIWatchdogValueLbl;
|
||||
|
||||
void setupUi(QWidget *CZTAlarmGeneratorPage)
|
||||
{
|
||||
if (CZTAlarmGeneratorPage->objectName().isEmpty())
|
||||
CZTAlarmGeneratorPage->setObjectName(QString::fromUtf8("CZTAlarmGeneratorPage"));
|
||||
CZTAlarmGeneratorPage->resize(979, 561);
|
||||
mSEISimTitleLabel = new QLabel(CZTAlarmGeneratorPage);
|
||||
mSEISimTitleLabel->setObjectName(QString::fromUtf8("mSEISimTitleLabel"));
|
||||
mSEISimTitleLabel->setGeometry(QRect(260, 30, 411, 31));
|
||||
QFont font;
|
||||
font.setPointSize(18);
|
||||
font.setBold(true);
|
||||
font.setWeight(75);
|
||||
mSEISimTitleLabel->setFont(font);
|
||||
mSEISimTitleLabel->setTextFormat(Qt::AutoText);
|
||||
mConnectSEIBtn = new QPushButton(CZTAlarmGeneratorPage);
|
||||
mConnectSEIBtn->setObjectName(QString::fromUtf8("mConnectSEIBtn"));
|
||||
mConnectSEIBtn->setGeometry(QRect(40, 70, 101, 22));
|
||||
mAlarmComboBox = new QComboBox(CZTAlarmGeneratorPage);
|
||||
mAlarmComboBox->setObjectName(QString::fromUtf8("mAlarmComboBox"));
|
||||
mAlarmComboBox->setGeometry(QRect(50, 190, 301, 21));
|
||||
mSendAlarmBtn = new QPushButton(CZTAlarmGeneratorPage);
|
||||
mSendAlarmBtn->setObjectName(QString::fromUtf8("mSendAlarmBtn"));
|
||||
mSendAlarmBtn->setGeometry(QRect(470, 190, 80, 22));
|
||||
mResetAlarmsBtn = new QPushButton(CZTAlarmGeneratorPage);
|
||||
mResetAlarmsBtn->setObjectName(QString::fromUtf8("mResetAlarmsBtn"));
|
||||
mResetAlarmsBtn->setGeometry(QRect(600, 460, 80, 22));
|
||||
mRankSpinBx = new QSpinBox(CZTAlarmGeneratorPage);
|
||||
mRankSpinBx->setObjectName(QString::fromUtf8("mRankSpinBx"));
|
||||
mRankSpinBx->setGeometry(QRect(380, 190, 71, 22));
|
||||
label = new QLabel(CZTAlarmGeneratorPage);
|
||||
label->setObjectName(QString::fromUtf8("label"));
|
||||
label->setGeometry(QRect(180, 160, 41, 16));
|
||||
label_2 = new QLabel(CZTAlarmGeneratorPage);
|
||||
label_2->setObjectName(QString::fromUtf8("label_2"));
|
||||
label_2->setGeometry(QRect(400, 160, 41, 16));
|
||||
label_3 = new QLabel(CZTAlarmGeneratorPage);
|
||||
label_3->setObjectName(QString::fromUtf8("label_3"));
|
||||
label_3->setGeometry(QRect(610, 130, 291, 16));
|
||||
mActiveAlarmsList = new QListWidget(CZTAlarmGeneratorPage);
|
||||
mActiveAlarmsList->setObjectName(QString::fromUtf8("mActiveAlarmsList"));
|
||||
mActiveAlarmsList->setGeometry(QRect(595, 160, 351, 291));
|
||||
mSEIConnectStatusLbl = new QLabel(CZTAlarmGeneratorPage);
|
||||
mSEIConnectStatusLbl->setObjectName(QString::fromUtf8("mSEIConnectStatusLbl"));
|
||||
mSEIConnectStatusLbl->setGeometry(QRect(170, 70, 141, 16));
|
||||
mSEIWatchdogValueLbl = new QLabel(CZTAlarmGeneratorPage);
|
||||
mSEIWatchdogValueLbl->setObjectName(QString::fromUtf8("mSEIWatchdogValueLbl"));
|
||||
mSEIWatchdogValueLbl->setGeometry(QRect(410, 250, 101, 16));
|
||||
|
||||
retranslateUi(CZTAlarmGeneratorPage);
|
||||
|
||||
QMetaObject::connectSlotsByName(CZTAlarmGeneratorPage);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QWidget *CZTAlarmGeneratorPage)
|
||||
{
|
||||
CZTAlarmGeneratorPage->setWindowTitle(QCoreApplication::translate("CZTAlarmGeneratorPage", "Form", nullptr));
|
||||
mSEISimTitleLabel->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "G\303\251n\303\251rateur d'alarmes ZT au SEI", nullptr));
|
||||
mConnectSEIBtn->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Connecter au SEI", nullptr));
|
||||
mSendAlarmBtn->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Envoyer -->", nullptr));
|
||||
mResetAlarmsBtn->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Acquiter tout", nullptr));
|
||||
label->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Alarme", nullptr));
|
||||
label_2->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Rang", nullptr));
|
||||
label_3->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Alarmes actives", nullptr));
|
||||
mSEIConnectStatusLbl->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "SEI: D\303\251connect\303\251", nullptr));
|
||||
mSEIWatchdogValueLbl->setText(QCoreApplication::translate("CZTAlarmGeneratorPage", "Watchdog SEI: ", nullptr));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class CZTAlarmGeneratorPage: public Ui_CZTAlarmGeneratorPage {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // UI_ZTALARMGENERATORPAGE_H
|
||||
Reference in New Issue
Block a user