Configuration des paramètres réseau
+ Options de configuration de l'adresse IP du réseau exploitation. + Option d'activation du réseau Modbus CC
This commit is contained in:
parent
1282e37311
commit
5cac0fc8f3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
/interfaces_tmp
|
||||||
/ZT.pro.user.Pj2362
|
/ZT.pro.user.Pj2362
|
||||||
/Escape.ZT
|
/Escape.ZT
|
||||||
/LOG/LogZT.txt
|
/LOG/LogZT.txt
|
||||||
|
|||||||
Binary file not shown.
8
ZT.pro
8
ZT.pro
@ -116,7 +116,9 @@ SOURCES += \
|
|||||||
sources/Modbus/ModbusCCMgr.cpp \
|
sources/Modbus/ModbusCCMgr.cpp \
|
||||||
sources/Modbus/ModbusTKTransport.cpp \
|
sources/Modbus/ModbusTKTransport.cpp \
|
||||||
sources/Stations/DuCollege.cpp \
|
sources/Stations/DuCollege.cpp \
|
||||||
sources/GuiElements/EthConnWidget.cpp
|
sources/GuiElements/EthConnWidget.cpp \
|
||||||
|
sources/GuiElements/ModbusSettingsPage.cpp \
|
||||||
|
sources/Modbus/NetworkCfgMgr.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
sources/MainPanel.h \
|
sources/MainPanel.h \
|
||||||
@ -232,7 +234,9 @@ HEADERS += \
|
|||||||
sources/Modbus/ModbusCCDefs.h \
|
sources/Modbus/ModbusCCDefs.h \
|
||||||
sources/Modbus/ModbusTKTransport.h \
|
sources/Modbus/ModbusTKTransport.h \
|
||||||
sources/Stations/DuCollege.h \
|
sources/Stations/DuCollege.h \
|
||||||
sources/GuiElements/EthConnWidget.h
|
sources/GuiElements/EthConnWidget.h \
|
||||||
|
sources/GuiElements/ModbusSettingsPage.h \
|
||||||
|
sources/Modbus/NetworkCfgMgr.h
|
||||||
|
|
||||||
#QMAKE_LIBDIR += ./ExtLib
|
#QMAKE_LIBDIR += ./ExtLib
|
||||||
#QT += network
|
#QT += network
|
||||||
|
|||||||
34
interfaces
Normal file
34
interfaces
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Fichier généré par le programme de la ZT
|
||||||
|
# Ce fichier est modifié par le programme ZT lors de la configuration Modbus.
|
||||||
|
# Si vous devez faire des modifications au réseau, ne pas oublier de modifier le
|
||||||
|
# fichier template /home/zonetest/ZT/interfaces pour ne pas que vos modifications
|
||||||
|
# ne soit écrasées.
|
||||||
|
|
||||||
|
# The loopback network interface
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
# The primary network interface
|
||||||
|
# eth0 est la carte réseau d'accès Modbus avec la CC
|
||||||
|
auto eth0
|
||||||
|
allow-hotplug eth0
|
||||||
|
iface eth0 inet static
|
||||||
|
address [TELETRANS_IP]
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway [TELETRANS_GATEWAY]
|
||||||
|
dns-nameservers 10.133.3.5 10.134.3.5
|
||||||
|
|
||||||
|
# Secondary interface
|
||||||
|
# eth1 est la carte réseau d'accès aux modules d'I/O
|
||||||
|
auto eth1
|
||||||
|
allow-hotplug eth1
|
||||||
|
iface eth1 inet static
|
||||||
|
address 192.168.2.54
|
||||||
|
netmask 255.255.255.0
|
||||||
|
gateway 192.168.0.1
|
||||||
|
|
||||||
|
# Third interface
|
||||||
|
# Cette interface DOIT être désactivée (sécurité réseautique TRCP)
|
||||||
|
#auto eth2
|
||||||
|
#allow-hotplug eth2
|
||||||
|
iface eth2 inet manual
|
||||||
225
sources/GuiElements/ModbusSettingsPage.cpp
Normal file
225
sources/GuiElements/ModbusSettingsPage.cpp
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Page offrant différentes option pour l'entretien de la ZT
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20131021 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#include "ModbusSettingsPage.h"
|
||||||
|
#include <QPainter>
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "Zonetest.h"
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QMessageBox>
|
||||||
|
//#include <sys/time.h>
|
||||||
|
#include "ZTLog.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(Parent)
|
||||||
|
|
||||||
|
|
||||||
|
mProgramHandle = 0;
|
||||||
|
|
||||||
|
mBackgroundRect = new QGraphicsRectItem(boundingRect(), this);
|
||||||
|
QBrush BackgroundBrush(QColor(245, 245, 255));
|
||||||
|
mBackgroundRect->setBrush(BackgroundBrush);
|
||||||
|
|
||||||
|
QGraphicsTextItem *Title = new QGraphicsTextItem("Paramètres Modbus",this);
|
||||||
|
QFont font;
|
||||||
|
font.setPointSize(18);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(40,10);
|
||||||
|
|
||||||
|
mCancelButton = new CTextButtonWidget("Annuler");
|
||||||
|
mCancelButton->setParentItem(this);
|
||||||
|
mCancelButton->setPos(550,550);
|
||||||
|
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mApplyButton = new CTextButtonWidget("Appliquer");
|
||||||
|
mApplyButton->setParentItem(this);
|
||||||
|
mApplyButton->setPos(650,550);
|
||||||
|
connect(mApplyButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
|
QGraphicsProxyWidget *Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
QGraphicsTextItem *Dot = new QGraphicsTextItem(".",this);
|
||||||
|
Dot->setFont(font);
|
||||||
|
|
||||||
|
|
||||||
|
int IpSettingsPosx = 120, IpSettingsPosy = 200;
|
||||||
|
Title = new QGraphicsTextItem("Adresse IP",this);
|
||||||
|
font.setPointSize(16);
|
||||||
|
Title->setFont(font);
|
||||||
|
Title->setPos(IpSettingsPosx,IpSettingsPosy-35);
|
||||||
|
|
||||||
|
mIPChunk1 = new QSpinBox();
|
||||||
|
Proxy->setWidget(mIPChunk1);
|
||||||
|
Proxy->setPos(IpSettingsPosx,IpSettingsPosy);
|
||||||
|
mIPChunk1->resize(70,30);
|
||||||
|
mIPChunk1->setMinimum(0);
|
||||||
|
mIPChunk1->setMaximum(255);
|
||||||
|
IpSettingsPosx += 90;
|
||||||
|
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy-5);
|
||||||
|
|
||||||
|
Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
Dot = new QGraphicsTextItem(".",this);
|
||||||
|
Dot->setFont(font);
|
||||||
|
mIPChunk2 = new QSpinBox();
|
||||||
|
Proxy->setWidget(mIPChunk2);
|
||||||
|
Proxy->setPos(IpSettingsPosx,IpSettingsPosy);
|
||||||
|
mIPChunk2->resize(70,30);
|
||||||
|
mIPChunk2->setMinimum(0);
|
||||||
|
mIPChunk2->setMaximum(255);
|
||||||
|
IpSettingsPosx += 90;
|
||||||
|
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy-5);
|
||||||
|
|
||||||
|
Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
Dot = new QGraphicsTextItem(".",this);
|
||||||
|
Dot->setFont(font);
|
||||||
|
mIPChunk3 = new QSpinBox();
|
||||||
|
Proxy->setWidget(mIPChunk3);
|
||||||
|
Proxy->setPos(IpSettingsPosx,IpSettingsPosy);
|
||||||
|
mIPChunk3->resize(70,30);
|
||||||
|
mIPChunk3->setMinimum(0);
|
||||||
|
mIPChunk3->setMaximum(255);
|
||||||
|
IpSettingsPosx += 90;
|
||||||
|
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy - 5);
|
||||||
|
|
||||||
|
Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
mIPChunk4 = new QSpinBox();
|
||||||
|
Proxy->setWidget(mIPChunk4);
|
||||||
|
mIPChunk4->setMinimum(0);
|
||||||
|
mIPChunk4->setMaximum(255);
|
||||||
|
Proxy->setPos(IpSettingsPosx,IpSettingsPosy);
|
||||||
|
mIPChunk4->resize(70,30);
|
||||||
|
|
||||||
|
Proxy = new QGraphicsProxyWidget(this);
|
||||||
|
mUseModbusChkBox = new QCheckBox("Activer la communication Modbus avec la Commande Centralisée");
|
||||||
|
Proxy->setWidget(mUseModbusChkBox);
|
||||||
|
Proxy->setPos(100,100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// mCalendarWidget = new QCalendarWidget();
|
||||||
|
// Proxy->setWidget(mCalendarWidget);
|
||||||
|
// Proxy->setPos(100,150);
|
||||||
|
|
||||||
|
QGraphicsRectItem *Frame = new QGraphicsRectItem(80,70,600,400,this);
|
||||||
|
QPen FramePen;
|
||||||
|
FramePen.setWidth(3);
|
||||||
|
Frame->setPen(FramePen);
|
||||||
|
|
||||||
|
|
||||||
|
// Title = new QGraphicsTextItem("Seuil Pneu de Guidage",this);
|
||||||
|
// Title->setFont(font);
|
||||||
|
// Title->setPos(270,400);
|
||||||
|
// Frame = new QGraphicsRectItem(80,405,600,175,this);
|
||||||
|
// Frame->setPen(FramePen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CModbusSettingsPage::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
mBackgroundRect->setRect(boundingRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModbusSettingsPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
||||||
|
{
|
||||||
|
if(BtnPtr == mCancelButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->CloseModbusSettingsPage();
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
else if(BtnPtr == mApplyButton)
|
||||||
|
{
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText("Redémarrage requis");
|
||||||
|
msgBox.setInformativeText("Les paramètres modbus ont été changés\nVoulez-vous vraiment redémarrer l'ordinateur ZT?");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||||
|
int ret = msgBox.exec();
|
||||||
|
|
||||||
|
if(ret == QMessageBox::Ok)
|
||||||
|
{
|
||||||
|
qint32 Address = 0;
|
||||||
|
Address = (mIPChunk1->value() & 0x000000FF);
|
||||||
|
Address <<= 8;
|
||||||
|
Address |= (mIPChunk2->value() & 0x000000FF);
|
||||||
|
Address <<= 8;
|
||||||
|
Address |= (mIPChunk3->value() & 0x000000FF);
|
||||||
|
Address <<= 8;
|
||||||
|
Address |= (mIPChunk4->value() & 0x000000FF);
|
||||||
|
QHostAddress IPAddress(Address);
|
||||||
|
|
||||||
|
bool UseModbus = (mUseModbusChkBox->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
QString LogEntry = QString("Changement des paramètres Modbus CC -> Modbus Activé : %1, Adresse IP %2").arg(UseModbus).arg(IPAddress.toString().toAscii().data());
|
||||||
|
CZTLog::instance()->AddLogString(LogEntry,true);
|
||||||
|
|
||||||
|
mProgramHandle->ModbusSettingsChangedReboot(UseModbus,IPAddress);
|
||||||
|
// mProgramHandle->CloseModbusSettingsPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModbusSettingsPage::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
|
||||||
|
int CModbusSettingsPage::SetActualSettings(bool UseModbus, QHostAddress CCHostAdd)
|
||||||
|
{
|
||||||
|
mUseModbusChkBox->setChecked(UseModbus);
|
||||||
|
|
||||||
|
qint32 add = CCHostAdd.toIPv4Address();
|
||||||
|
mIPChunk4->setValue(add & 0x000000FF);
|
||||||
|
add >>= 8;
|
||||||
|
mIPChunk3->setValue(add & 0x000000FF);
|
||||||
|
add >>= 8;
|
||||||
|
mIPChunk2->setValue(add & 0x000000FF);
|
||||||
|
add >>= 8;
|
||||||
|
mIPChunk1->setValue(add & 0x000000FF);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Grab the mouse if the user clicks outside buttons
|
||||||
|
void CModbusSettingsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
|
void CModbusSettingsPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
}
|
||||||
76
sources/GuiElements/ModbusSettingsPage.h
Normal file
76
sources/GuiElements/ModbusSettingsPage.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* *
|
||||||
|
* Société de Transports de Montréal. *
|
||||||
|
* 2012 *
|
||||||
|
* *
|
||||||
|
* Projet Zones Tests *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
* *
|
||||||
|
*******************************************************************************/
|
||||||
|
/*
|
||||||
|
Description:
|
||||||
|
Description du fichier si nécessaire.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* Revision:
|
||||||
|
### 20171124 JFM
|
||||||
|
Verision d'origine.
|
||||||
|
|
||||||
|
### YYYMMDD Description du besoin ou du bug
|
||||||
|
Description du changement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef MODBUSSETTINGSPAGE_H
|
||||||
|
#define MODBUSSETTINGSPAGE_H
|
||||||
|
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
#include <QGraphicsWidget>
|
||||||
|
#include "Guipage.h"
|
||||||
|
#include <QString>
|
||||||
|
#include "PushButton.h"
|
||||||
|
#include "ZTSimulator.h"
|
||||||
|
#include "TextButtonWidget.h"
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
|
||||||
|
class CZoneTest;
|
||||||
|
|
||||||
|
class CModbusSettingsPage : public CGuiPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CModbusSettingsPage(QGraphicsWidget *Parent = 0);
|
||||||
|
|
||||||
|
CZoneTest *mProgramHandle;
|
||||||
|
|
||||||
|
int SetActualSettings(bool UseModbus, QHostAddress CCHostAdd);
|
||||||
|
|
||||||
|
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
virtual void showEvent ( QShowEvent * event );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGraphicsRectItem *mBackgroundRect;
|
||||||
|
CTextButtonWidget *mCancelButton, *mApplyButton;
|
||||||
|
QSpinBox *mIPChunk1, *mIPChunk2, *mIPChunk3, *mIPChunk4;
|
||||||
|
QString mCurIP;
|
||||||
|
QCheckBox *mUseModbusChkBox;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GENERALSETTINGSPAGE_H
|
||||||
@ -77,15 +77,21 @@ COptionsPage::COptionsPage(QGraphicsWidget *Parent)
|
|||||||
mZTGeneralSettingsButton->setPos(50,180);
|
mZTGeneralSettingsButton->setPos(50,180);
|
||||||
connect(mZTGeneralSettingsButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
connect(mZTGeneralSettingsButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
mModbusSettingsButton = new CTextButtonWidget("Modbus");
|
||||||
|
mModbusSettingsButton->setParentItem(this);
|
||||||
|
mModbusSettingsButton->setPos(50,220);
|
||||||
|
connect(mModbusSettingsButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
mZTLogViewButton = new CTextButtonWidget("Fichier LOG");
|
mZTLogViewButton = new CTextButtonWidget("Fichier LOG");
|
||||||
mZTLogViewButton->setParentItem(this);
|
mZTLogViewButton->setParentItem(this);
|
||||||
mZTLogViewButton->setPos(50,220);
|
mZTLogViewButton->setPos(50,260);
|
||||||
connect(mZTLogViewButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
connect(mZTLogViewButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
|
|
||||||
mCancelButton = new CTextButtonWidget("Fermer");
|
mCancelButton = new CTextButtonWidget("Fermer");
|
||||||
mCancelButton->setParentItem(this);
|
mCancelButton->setParentItem(this);
|
||||||
mCancelButton->setPos(50,260);
|
mCancelButton->setPos(50,300);
|
||||||
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
connect(mCancelButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -119,6 +125,10 @@ void COptionsPage::ButtonClicked(CTextButtonWidget *BtnPtr)
|
|||||||
{
|
{
|
||||||
mProgramHandle->OpenGeneralSettingsPage();
|
mProgramHandle->OpenGeneralSettingsPage();
|
||||||
}
|
}
|
||||||
|
else if(BtnPtr == mModbusSettingsButton)
|
||||||
|
{
|
||||||
|
mProgramHandle->OpenModbusSettingsPage();
|
||||||
|
}
|
||||||
else if(BtnPtr == mZTLogViewButton)
|
else if(BtnPtr == mZTLogViewButton)
|
||||||
{
|
{
|
||||||
mProgramHandle->ShowZTLogViewerPage();
|
mProgramHandle->ShowZTLogViewerPage();
|
||||||
|
|||||||
@ -61,6 +61,7 @@ private:
|
|||||||
CTextButtonWidget *mZTMaintenanceModeButton;
|
CTextButtonWidget *mZTMaintenanceModeButton;
|
||||||
CTextButtonWidget *mZTEngineeringButton;
|
CTextButtonWidget *mZTEngineeringButton;
|
||||||
CTextButtonWidget *mZTGeneralSettingsButton;
|
CTextButtonWidget *mZTGeneralSettingsButton;
|
||||||
|
CTextButtonWidget *mModbusSettingsButton;
|
||||||
CTextButtonWidget *mZTLogViewButton;
|
CTextButtonWidget *mZTLogViewButton;
|
||||||
CTextButtonWidget *mCancelButton;
|
CTextButtonWidget *mCancelButton;
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,7 @@ Panel::Panel()
|
|||||||
mMaintenancePage = new CMaintenancePage();
|
mMaintenancePage = new CMaintenancePage();
|
||||||
mGeneralSettingsPage = new CGeneralSettingsPage();
|
mGeneralSettingsPage = new CGeneralSettingsPage();
|
||||||
mZTLogViewerPage = new CZTLogViewerPage();
|
mZTLogViewerPage = new CZTLogViewerPage();
|
||||||
|
mModbusSettingsPage = new CModbusSettingsPage();
|
||||||
|
|
||||||
scene->addItem(mWelcomePage);
|
scene->addItem(mWelcomePage);
|
||||||
scene->addItem(mZTMainPage);
|
scene->addItem(mZTMainPage);
|
||||||
@ -111,6 +112,7 @@ Panel::Panel()
|
|||||||
scene->addItem(mEngineeringPage);
|
scene->addItem(mEngineeringPage);
|
||||||
scene->addItem(mMaintenancePage);
|
scene->addItem(mMaintenancePage);
|
||||||
scene->addItem(mGeneralSettingsPage);
|
scene->addItem(mGeneralSettingsPage);
|
||||||
|
scene->addItem(mModbusSettingsPage);
|
||||||
scene->addItem(mZTLogViewerPage);
|
scene->addItem(mZTLogViewerPage);
|
||||||
|
|
||||||
mZTMainPage->setPos(0,0);
|
mZTMainPage->setPos(0,0);
|
||||||
@ -158,6 +160,11 @@ Panel::Panel()
|
|||||||
mGeneralSettingsPage->resize(800,600);
|
mGeneralSettingsPage->resize(800,600);
|
||||||
mGeneralSettingsPage->setZValue(1);
|
mGeneralSettingsPage->setZValue(1);
|
||||||
|
|
||||||
|
mModbusSettingsPage->setPos(112,84);
|
||||||
|
mModbusSettingsPage->hide();
|
||||||
|
mModbusSettingsPage->resize(800,600);
|
||||||
|
mModbusSettingsPage->setZValue(1);
|
||||||
|
|
||||||
mZTLogViewerPage->setPos(112,84);
|
mZTLogViewerPage->setPos(112,84);
|
||||||
mZTLogViewerPage->hide();
|
mZTLogViewerPage->hide();
|
||||||
mZTLogViewerPage->resize(800,600);
|
mZTLogViewerPage->resize(800,600);
|
||||||
@ -189,6 +196,6 @@ void Panel::HideMainPAge()
|
|||||||
void Panel::closeEvent(QCloseEvent *event)
|
void Panel::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
mProgramHandle->ApplicationQuit();
|
mProgramHandle->ApplicationQuit(EXIT_REASON_USER_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
#include "MaintenancePage.h"
|
#include "MaintenancePage.h"
|
||||||
#include "GeneralSettingsPage.h"
|
#include "GeneralSettingsPage.h"
|
||||||
#include "ZTLogViewerPage.h"
|
#include "ZTLogViewerPage.h"
|
||||||
|
#include "ModbusSettingsPage.h"
|
||||||
|
|
||||||
class CZoneTest;
|
class CZoneTest;
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ public:
|
|||||||
CMaintenancePage *mMaintenancePage;
|
CMaintenancePage *mMaintenancePage;
|
||||||
CGeneralSettingsPage *mGeneralSettingsPage;
|
CGeneralSettingsPage *mGeneralSettingsPage;
|
||||||
CZTLogViewerPage *mZTLogViewerPage;
|
CZTLogViewerPage *mZTLogViewerPage;
|
||||||
|
CModbusSettingsPage *mModbusSettingsPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PANEL_H
|
#endif // PANEL_H
|
||||||
|
|||||||
@ -108,7 +108,7 @@ void CModbusCCMgr::NewModbusConnection()
|
|||||||
connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
|
connect(mModbusTCPSocketHandle,SIGNAL(readyRead()),this,SLOT(ModbusDataReady()));
|
||||||
connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(ConnectionLost()));
|
connect(mModbusTCPSocketHandle,SIGNAL(disconnected()),this,SLOT(ConnectionLost()));
|
||||||
//qDebug("ModbusCC: Connection with CC established");
|
//qDebug("ModbusCC: Connection with CC established");
|
||||||
CZTLog::instance()->AddLogString(QString("Connection Modbus avec la CC établie. IP[%1]").arg(mModbusTCPSocketHandle->peerAddress().toString()),true);
|
CZTLog::instance()->AddLogString(QString("Connection Modbus avec la CC établie. IP locale [%1] - IP HPC [%2]").arg(mModbusTCPSocketHandle->localAddress().toString()).arg(mModbusTCPSocketHandle->peerAddress().toString()),true);
|
||||||
mZTWatchdogTimer->start();
|
mZTWatchdogTimer->start();
|
||||||
mCCWatchdogTimer->start(MODBUS_CC_WATCHDOG_TIMEOUT*2); //Allow twice the time for the first watchdog reset.
|
mCCWatchdogTimer->start(MODBUS_CC_WATCHDOG_TIMEOUT*2); //Allow twice the time for the first watchdog reset.
|
||||||
mCCLinkState = true;
|
mCCLinkState = true;
|
||||||
|
|||||||
80
sources/Modbus/NetworkCfgMgr.cpp
Normal file
80
sources/Modbus/NetworkCfgMgr.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include "NetworkCfgMgr.h"
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include "ZTLog.h"
|
||||||
|
|
||||||
|
CNetworkCfgMgr::CNetworkCfgMgr()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int CNetworkCfgMgr::SetTRCPNetworkAddress(QHostAddress Address)
|
||||||
|
{
|
||||||
|
if(QFile::exists("./interfaces") == false)
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: Le fichier template de configuration réseau est inexistant",true);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Open the template file
|
||||||
|
QFile *TemplateFile = new QFile("./interfaces");
|
||||||
|
if(TemplateFile)
|
||||||
|
{
|
||||||
|
if(TemplateFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered | QIODevice::Text) == false)
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: impossible d'ouvrir le fichier template de configuration réseau",true);
|
||||||
|
delete TemplateFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: impossible d'ouvrir le fichier template de configuration réseau",true);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Create a temporary file
|
||||||
|
QFile *TempInterfaceFile = new QFile("./interfaces_tmp");
|
||||||
|
if(TempInterfaceFile)
|
||||||
|
{
|
||||||
|
if(TempInterfaceFile->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text | QIODevice::Unbuffered) == false)
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: impossible de créer le fichier temporaire de configuration réseau",true);
|
||||||
|
delete TempInterfaceFile;
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: impossible de créer le fichier temporaire de configuration réseau",true);
|
||||||
|
return RET_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ConfigText(TemplateFile->readAll());
|
||||||
|
QString WorkString;
|
||||||
|
QHostAddress Gateway(Address.toIPv4Address() & 0xFFFFFF01);
|
||||||
|
|
||||||
|
WorkString = ConfigText.replace("[TELETRANS_IP]",Address.toString());
|
||||||
|
ConfigText = WorkString.replace("[TELETRANS_GATEWAY]",Gateway.toString());
|
||||||
|
|
||||||
|
if(TempInterfaceFile->write(ConfigText.toAscii()) < 0)
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("ERREUR: impossible de créer le fichier temporaire de configuration réseau",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
TemplateFile->close();
|
||||||
|
delete TemplateFile;
|
||||||
|
|
||||||
|
TempInterfaceFile->close();
|
||||||
|
delete TempInterfaceFile;
|
||||||
|
|
||||||
|
|
||||||
|
system("cp -f ./interfaces_tmp /etc/network/interfaces");
|
||||||
|
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
|
||||||
|
}
|
||||||
14
sources/Modbus/NetworkCfgMgr.h
Normal file
14
sources/Modbus/NetworkCfgMgr.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef NETWORKCFGMGR_H
|
||||||
|
#define NETWORKCFGMGR_H
|
||||||
|
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
|
class CNetworkCfgMgr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CNetworkCfgMgr();
|
||||||
|
|
||||||
|
int SetTRCPNetworkAddress(QHostAddress Address);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKCFGMGR_H
|
||||||
@ -119,39 +119,39 @@ unsigned int CDuCollegeStation::BuildStationCDVList()
|
|||||||
CCDV *NewCDV;
|
CCDV *NewCDV;
|
||||||
mCDVList.empty();
|
mCDVList.empty();
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14C_MASK,CDV_NORMAL_TYPE,"14C",2,9);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14C_MASK,CDV_NORMAL_TYPE,"14C",1,1);
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14B_MASK,CDV_NORMAL_TYPE,"14B",2,8);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14B_MASK,CDV_NORMAL_TYPE,"14B",1,2);
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14A_MASK,CDV_NORMAL_TYPE,"14A",2,7);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_14A_MASK,CDV_NORMAL_TYPE,"14A",1,3);
|
||||||
mZT1AlarmAutoAcquireCDV = NewCDV;
|
mZT1AlarmAutoAcquireCDV = NewCDV;
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_13B_MASK,CDV_NORMAL_TYPE,"13B",2,6);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_13B_MASK,CDV_NORMAL_TYPE,"13B",1,4);
|
||||||
mZT1SubsequentCDV = NewCDV;
|
mZT1SubsequentCDV = NewCDV;
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_13A_MASK,CDV_NORMAL_TYPE,"13A ZT",2,5);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_13A_MASK,CDV_NORMAL_TYPE,"13A ZT",1,5);
|
||||||
mZT1CDV = NewCDV;
|
mZT1CDV = NewCDV;
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_12A_MASK,CDV_NORMAL_TYPE,"12A",2,3);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_12A_MASK,CDV_NORMAL_TYPE,"12A",1,6);
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
NewCDV->SetCDVDeck(true);
|
NewCDV->SetCDVDeck(true);
|
||||||
|
|
||||||
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_12B_MASK,CDV_NORMAL_TYPE,"12B",2,4);
|
NewCDV = new CCDV(DUCOLLEGE_IN_ZT1_ITI_MASK,DUCOLLEGE_IN_CDV_12B_MASK,CDV_NORMAL_TYPE,"12B",1,7);
|
||||||
NewCDV->SetCDVDeck(true);
|
NewCDV->SetCDVDeck(true);
|
||||||
mZT1ApproachCDV = NewCDV;
|
mZT1ApproachCDV = NewCDV;
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NewCDV = new CCDV(0,DUCOLLEGE_IN_CDV_11B_MASK,CDV_NORMAL_TYPE,"11B",2,2);
|
NewCDV = new CCDV(0,DUCOLLEGE_IN_CDV_11B_MASK,CDV_NORMAL_TYPE,"11B",1,8);
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
|
|
||||||
NewCDV = new CCDV(0,DUCOLLEGE_IN_CDV_11A_MASK,CDV_NORMAL_TYPE,"11A",2,1);
|
NewCDV = new CCDV(0,DUCOLLEGE_IN_CDV_11A_MASK,CDV_NORMAL_TYPE,"11A",1,9);
|
||||||
mCDVList.append(NewCDV);
|
mCDVList.append(NewCDV);
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
enum eZTLOGType
|
enum eZTLOGType
|
||||||
{
|
{
|
||||||
@ -338,6 +339,10 @@ class CZTSettingsData
|
|||||||
bool mKeepAllZT1Logs;
|
bool mKeepAllZT1Logs;
|
||||||
bool mKeepAllZT2Logs;
|
bool mKeepAllZT2Logs;
|
||||||
bool mUseNetworkTime;
|
bool mUseNetworkTime;
|
||||||
|
bool mUseModbusCC;
|
||||||
|
QHostAddress mModbusCCHostAddress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ unsigned int CZTSettingsFileMgr::LoadSettings(CZTSettingsData *SettingsData)
|
|||||||
|
|
||||||
*InputStream >> MagicNbr;
|
*InputStream >> MagicNbr;
|
||||||
|
|
||||||
if(MagicNbr != 0xBAADCAFE + 2)
|
if(MagicNbr != 0xBAADCAFE + 3)
|
||||||
{
|
{
|
||||||
CEngLog::instance()->AddLogString("Fichier de settings invalide (mauvais magic number). Chargement des paramètres par défaut");
|
CEngLog::instance()->AddLogString("Fichier de settings invalide (mauvais magic number). Chargement des paramètres par défaut");
|
||||||
LoadDefaultSettings(SettingsData);
|
LoadDefaultSettings(SettingsData);
|
||||||
@ -81,6 +81,9 @@ unsigned int CZTSettingsFileMgr::LoadSettings(CZTSettingsData *SettingsData)
|
|||||||
*InputStream >> SettingsData->mKeepAllZT1Logs;
|
*InputStream >> SettingsData->mKeepAllZT1Logs;
|
||||||
*InputStream >> SettingsData->mKeepAllZT2Logs;
|
*InputStream >> SettingsData->mKeepAllZT2Logs;
|
||||||
*InputStream >> SettingsData->mUseNetworkTime;
|
*InputStream >> SettingsData->mUseNetworkTime;
|
||||||
|
*InputStream >> SettingsData->mUseModbusCC;
|
||||||
|
*InputStream >> SettingsData->mModbusCCHostAddress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SettingsFile->close();
|
SettingsFile->close();
|
||||||
@ -111,7 +114,7 @@ unsigned int CZTSettingsFileMgr::SaveSettings(CZTSettingsData *SettingsData)
|
|||||||
|
|
||||||
QDataStream * OutputStream = new QDataStream(SettingsFile);
|
QDataStream * OutputStream = new QDataStream(SettingsFile);
|
||||||
|
|
||||||
quint32 MagicNbr = 0xBAADCAFE + 2;
|
quint32 MagicNbr = 0xBAADCAFE + 3;
|
||||||
|
|
||||||
*OutputStream << MagicNbr;
|
*OutputStream << MagicNbr;
|
||||||
|
|
||||||
@ -125,6 +128,8 @@ unsigned int CZTSettingsFileMgr::SaveSettings(CZTSettingsData *SettingsData)
|
|||||||
*OutputStream << SettingsData->mKeepAllZT1Logs;
|
*OutputStream << SettingsData->mKeepAllZT1Logs;
|
||||||
*OutputStream << SettingsData->mKeepAllZT2Logs;
|
*OutputStream << SettingsData->mKeepAllZT2Logs;
|
||||||
*OutputStream << SettingsData->mUseNetworkTime;
|
*OutputStream << SettingsData->mUseNetworkTime;
|
||||||
|
*OutputStream << SettingsData->mUseModbusCC;
|
||||||
|
*OutputStream << SettingsData->mModbusCCHostAddress;
|
||||||
|
|
||||||
SettingsFile->flush();
|
SettingsFile->flush();
|
||||||
SettingsFile->close();
|
SettingsFile->close();
|
||||||
@ -165,6 +170,9 @@ void CZTSettingsFileMgr::LoadDefaultSettings(CZTSettingsData *SettingsData)
|
|||||||
|
|
||||||
SettingsData->mUseNetworkTime = false;
|
SettingsData->mUseNetworkTime = false;
|
||||||
|
|
||||||
|
SettingsData->mUseModbusCC = false;
|
||||||
|
SettingsData->mModbusCCHostAddress.setAddress("10.158.224.27");
|
||||||
|
|
||||||
}
|
}
|
||||||
void CZTSettingsFileMgr::SetStationName(QString StationName)
|
void CZTSettingsFileMgr::SetStationName(QString StationName)
|
||||||
{
|
{
|
||||||
@ -232,6 +240,12 @@ void CZTSettingsFileMgr::LogSettings(CZTSettingsData *SettingsData, bool LogStat
|
|||||||
stream << QString().fromUtf8(" Utilisation de l'heure réseau = ") << SettingsData->mUseNetworkTime;
|
stream << QString().fromUtf8(" Utilisation de l'heure réseau = ") << SettingsData->mUseNetworkTime;
|
||||||
CZTLog::instance()->AddLogString(temp,true);
|
CZTLog::instance()->AddLogString(temp,true);
|
||||||
temp.clear();
|
temp.clear();
|
||||||
|
stream << QString().fromUtf8(" Utilisation communication Modbus CC = ") << SettingsData->mUseModbusCC;
|
||||||
|
CZTLog::instance()->AddLogString(temp,true);
|
||||||
|
temp.clear();
|
||||||
|
stream << QString().fromUtf8(" Adresse IP réseau TLT = ") << SettingsData->mModbusCCHostAddress.toString();
|
||||||
|
CZTLog::instance()->AddLogString(temp,true);
|
||||||
|
temp.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,6 +215,16 @@ unsigned int CZoneTest::ExecStateMachine(eZTSMEvents_t)
|
|||||||
|
|
||||||
QApplication::exit(79); //Quit the application
|
QApplication::exit(79); //Quit the application
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case ZT_SYSTEM_REBOOT_EXIT_STATE:
|
||||||
|
{
|
||||||
|
//Initiate a system reboot
|
||||||
|
mZTStateMachineTimer->stop();
|
||||||
|
mInternalWatchdog->StopWatchdog();
|
||||||
|
system("reboot");
|
||||||
|
|
||||||
|
QApplication::exit(80); //Quit the application
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -245,6 +255,7 @@ unsigned int CZoneTest::Start()
|
|||||||
panel.mLogViewPage->mProgramHandle = this;
|
panel.mLogViewPage->mProgramHandle = this;
|
||||||
panel.mMaintenancePage->mProgramHandle = this;
|
panel.mMaintenancePage->mProgramHandle = this;
|
||||||
panel.mGeneralSettingsPage->mProgramHandle = this;
|
panel.mGeneralSettingsPage->mProgramHandle = this;
|
||||||
|
panel.mModbusSettingsPage->mProgramHandle = this;
|
||||||
panel.mZTLogViewerPage->mProgramHandle = this;
|
panel.mZTLogViewerPage->mProgramHandle = this;
|
||||||
panel.mEngineeringPage->mDisablePassword = mDisablePassword;
|
panel.mEngineeringPage->mDisablePassword = mDisablePassword;
|
||||||
mInternalWatchdog = new CWatchdogCtrl(mUseWatchdog);
|
mInternalWatchdog = new CWatchdogCtrl(mUseWatchdog);
|
||||||
@ -483,58 +494,58 @@ unsigned int CZoneTest::InitZT()
|
|||||||
|
|
||||||
mExtIOThread->start(QThread::NormalPriority);
|
mExtIOThread->start(QThread::NormalPriority);
|
||||||
|
|
||||||
bool UseModbusInterface = false;
|
bool UseModbusInterface = mZTSettings->mUseModbusCC;
|
||||||
if(CZTConfigMgr::instance()->GetModbusCCEnabled() != ZT_CONFIG_MODBUS_ENABLE_FORCE_OFF)
|
// if(CZTConfigMgr::instance()->GetModbusCCEnabled() != ZT_CONFIG_MODBUS_ENABLE_FORCE_OFF)
|
||||||
{
|
|
||||||
if(CZTConfigMgr::instance()->GetModbusCCEnabled() == ZT_CONFIG_MODBUS_ENABLE_FORCE_ON)
|
|
||||||
{
|
|
||||||
CEngLog::instance()->AddLogString("Interface Modbus activée (forcée)",1);
|
|
||||||
UseModbusInterface = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// //autodetect modbus interface...
|
|
||||||
int ModbusPort = CZTConfigMgr::instance()->GetModbusCCPort();
|
|
||||||
mWelcomePagePtr->InsertTextBoxString(QString("Détection Modbus CC..."));
|
|
||||||
if(CModbusCCMgr::CheckForCCPartner(3000,ModbusPort) == true)
|
|
||||||
{
|
|
||||||
UseModbusInterface = true;
|
|
||||||
mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC détecté et activé"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC non-détecté"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// CEngLog::instance()->AddLogString("Auto-Détection de l'interface Modbus",1);
|
|
||||||
// QString IFName = CZTConfigMgr::instance()->GetModbusCCIFName();
|
|
||||||
// if(IFName != "INVALID")
|
|
||||||
// {
|
// {
|
||||||
// QString CarrierFile = QString("/sys/class/net/%1/carrier").arg(IFName);
|
// if(CZTConfigMgr::instance()->GetModbusCCEnabled() == ZT_CONFIG_MODBUS_ENABLE_FORCE_ON)
|
||||||
// QFile *EthIfStateFile = new QFile(CarrierFile);
|
|
||||||
// if(EthIfStateFile)
|
|
||||||
// {
|
// {
|
||||||
// CEngLog::instance()->AddLogString(QString("Ouverture du fichier %1 ...").arg(IFName),3);
|
// CEngLog::instance()->AddLogString("Interface Modbus activée (forcée)",1);
|
||||||
// if(EthIfStateFile->open(QIODevice::ReadOnly | QIODevice::Text) == true)
|
|
||||||
// {
|
|
||||||
// QByteArray val = EthIfStateFile->readAll();
|
|
||||||
// QString State(val);
|
|
||||||
// if(State.contains("1"))
|
|
||||||
// {
|
|
||||||
// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC détectée sur %1").arg(IFName),true);
|
|
||||||
// UseModbusInterface = true;
|
// UseModbusInterface = true;
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC inactive ou non-détectée sur %1").arg(IFName),true);
|
//// //autodetect modbus interface...
|
||||||
|
// int ModbusPort = CZTConfigMgr::instance()->GetModbusCCPort();
|
||||||
|
// mWelcomePagePtr->InsertTextBoxString(QString("Détection Modbus CC..."));
|
||||||
|
// if(CModbusCCMgr::CheckForCCPartner(3000,ModbusPort) == true)
|
||||||
|
// {
|
||||||
|
// UseModbusInterface = true;
|
||||||
|
// mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC détecté et activé"));
|
||||||
// }
|
// }
|
||||||
// EthIfStateFile->close();
|
// else
|
||||||
|
// {
|
||||||
|
// mWelcomePagePtr->InsertTextBoxString(QString("Modbus CC non-détecté"));
|
||||||
// }
|
// }
|
||||||
// delete EthIfStateFile;
|
|
||||||
|
//// CEngLog::instance()->AddLogString("Auto-Détection de l'interface Modbus",1);
|
||||||
|
//// QString IFName = CZTConfigMgr::instance()->GetModbusCCIFName();
|
||||||
|
//// if(IFName != "INVALID")
|
||||||
|
//// {
|
||||||
|
//// QString CarrierFile = QString("/sys/class/net/%1/carrier").arg(IFName);
|
||||||
|
//// QFile *EthIfStateFile = new QFile(CarrierFile);
|
||||||
|
//// if(EthIfStateFile)
|
||||||
|
//// {
|
||||||
|
//// CEngLog::instance()->AddLogString(QString("Ouverture du fichier %1 ...").arg(IFName),3);
|
||||||
|
//// if(EthIfStateFile->open(QIODevice::ReadOnly | QIODevice::Text) == true)
|
||||||
|
//// {
|
||||||
|
//// QByteArray val = EthIfStateFile->readAll();
|
||||||
|
//// QString State(val);
|
||||||
|
//// if(State.contains("1"))
|
||||||
|
//// {
|
||||||
|
//// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC détectée sur %1").arg(IFName),true);
|
||||||
|
//// UseModbusInterface = true;
|
||||||
|
//// }
|
||||||
|
//// else
|
||||||
|
//// {
|
||||||
|
//// CZTLog::instance()->AddLogString(QString("Connexion Ethernet CC inactive ou non-détectée sur %1").arg(IFName),true);
|
||||||
|
//// }
|
||||||
|
//// EthIfStateFile->close();
|
||||||
|
//// }
|
||||||
|
//// delete EthIfStateFile;
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(UseModbusInterface == true)
|
if(UseModbusInterface == true)
|
||||||
{
|
{
|
||||||
@ -847,7 +858,7 @@ bool CZoneTest::eventFilter(QObject *obj, QEvent *event)
|
|||||||
{
|
{
|
||||||
CZTLog::instance()->AddLogString("Mot de passe désactivé. Sortie du programme.",true);
|
CZTLog::instance()->AddLogString("Mot de passe désactivé. Sortie du programme.",true);
|
||||||
|
|
||||||
ApplicationQuit();
|
ApplicationQuit(EXIT_REASON_USER_REQUEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -893,7 +904,7 @@ void CZoneTest::LogsPageSelected()
|
|||||||
void CZoneTest::ProgramExitRequest()
|
void CZoneTest::ProgramExitRequest()
|
||||||
{
|
{
|
||||||
CZTLog::instance()->AddLogString("Mot de passe valide. Fin du programme.",true);
|
CZTLog::instance()->AddLogString("Mot de passe valide. Fin du programme.",true);
|
||||||
ApplicationQuit();
|
ApplicationQuit(EXIT_REASON_USER_REQUEST);
|
||||||
QApplication::exit(79);
|
QApplication::exit(79);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1113,6 +1124,35 @@ void CZoneTest::UseNetworkTime(bool UseNetworkTime)
|
|||||||
mZTSettingsFileMgr.SaveSettings(mZTSettings);
|
mZTSettingsFileMgr.SaveSettings(mZTSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Messages from Modbus settings page
|
||||||
|
void CZoneTest::OpenModbusSettingsPage()
|
||||||
|
{
|
||||||
|
panel.mModbusSettingsPage->SetActualSettings(mZTSettings->mUseModbusCC,mZTSettings->mModbusCCHostAddress);
|
||||||
|
panel.mModbusSettingsPage->show();
|
||||||
|
panel.mOptionsPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZoneTest::CloseModbusSettingsPage()
|
||||||
|
{
|
||||||
|
panel.mModbusSettingsPage->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CZoneTest::ModbusSettingsChangedReboot(bool UseModbus, QHostAddress CCHostAdd)
|
||||||
|
{
|
||||||
|
mZTSettings->mUseModbusCC = UseModbus;
|
||||||
|
mZTSettings->mModbusCCHostAddress = CCHostAdd;
|
||||||
|
mZTSettingsFileMgr.SaveSettings(mZTSettings);
|
||||||
|
|
||||||
|
if(mNetworkCfgMgr.SetTRCPNetworkAddress(CCHostAdd) == RET_OK)
|
||||||
|
{
|
||||||
|
if(mDoNotReboot == false)
|
||||||
|
{
|
||||||
|
ApplicationQuit(EXIT_REASON_SYSTEM_REBOOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
///Messages from ZTLog viewer page
|
///Messages from ZTLog viewer page
|
||||||
void CZoneTest::ShowZTLogViewerPage()
|
void CZoneTest::ShowZTLogViewerPage()
|
||||||
{
|
{
|
||||||
@ -1321,8 +1361,29 @@ int CZoneTest::SetZT2InhibitionState(bool InhibitionON)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CZoneTest::ApplicationQuit(bool PowerButton)
|
void CZoneTest::ApplicationQuit(int Reason)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(Reason == EXIT_REASON_USER_REQUEST)
|
||||||
|
{
|
||||||
|
mZtState = ZT_EXIT_APPLICATION_STATE;
|
||||||
|
}
|
||||||
|
else if(Reason == EXIT_REASON_POWER_BUTTON)
|
||||||
|
{
|
||||||
|
mZtState = ZT_POWER_BUTTON_EXIT_STATE;
|
||||||
|
}
|
||||||
|
else if(Reason == EXIT_REASON_SYSTEM_REBOOT)
|
||||||
|
{
|
||||||
|
CZTLog::instance()->AddLogString("Redémarrage de l'ordinateur suite à un changement de paramètres.");
|
||||||
|
mZtState = ZT_SYSTEM_REBOOT_EXIT_STATE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("Trying to exit app with unknown reason... Ignoring");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mExtIOWorkerThread->SetOutput((quint32)0);
|
mExtIOWorkerThread->SetOutput((quint32)0);
|
||||||
mExtIOWorkerThread->StopAcquisition();
|
mExtIOWorkerThread->StopAcquisition();
|
||||||
|
|
||||||
@ -1347,11 +1408,6 @@ void CZoneTest::ApplicationQuit(bool PowerButton)
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if(PowerButton == false)
|
|
||||||
mZtState = ZT_EXIT_APPLICATION_STATE;
|
|
||||||
else
|
|
||||||
mZtState = ZT_POWER_BUTTON_EXIT_STATE;
|
|
||||||
|
|
||||||
if(mModbusCCMgr != 0)
|
if(mModbusCCMgr != 0)
|
||||||
{
|
{
|
||||||
if(mModbusCCMgr->CloseModbusCCServer() != 0)
|
if(mModbusCCMgr->CloseModbusCCServer() != 0)
|
||||||
@ -1386,7 +1442,7 @@ void CZoneTest::ACPISocketEvent()
|
|||||||
{
|
{
|
||||||
CZTLog::instance()->AddLogString("Activation du bouton << Power >>, sortie du programme",true);
|
CZTLog::instance()->AddLogString("Activation du bouton << Power >>, sortie du programme",true);
|
||||||
mACPISocket.close();
|
mACPISocket.close();
|
||||||
ApplicationQuit(true);
|
ApplicationQuit(EXIT_REASON_POWER_BUTTON);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -57,9 +57,16 @@
|
|||||||
#include "DiscreteTKTransport.h"
|
#include "DiscreteTKTransport.h"
|
||||||
#include "ModbusRepository.h"
|
#include "ModbusRepository.h"
|
||||||
#include "ModbusCCMgr.h"
|
#include "ModbusCCMgr.h"
|
||||||
|
#include "NetworkCfgMgr.h"
|
||||||
|
|
||||||
#include "TCPProtocol.h"
|
#include "TCPProtocol.h"
|
||||||
|
|
||||||
|
enum eAppExitReason
|
||||||
|
{
|
||||||
|
EXIT_REASON_USER_REQUEST = 0,
|
||||||
|
EXIT_REASON_POWER_BUTTON,
|
||||||
|
EXIT_REASON_SYSTEM_REBOOT
|
||||||
|
};
|
||||||
|
|
||||||
class CZoneTest : public QObject
|
class CZoneTest : public QObject
|
||||||
{
|
{
|
||||||
@ -76,6 +83,7 @@ public:
|
|||||||
bool mIgnoreStationPhysicalKey;
|
bool mIgnoreStationPhysicalKey;
|
||||||
bool mDisablePassword;
|
bool mDisablePassword;
|
||||||
bool mUseWatchdog; //internal CPU watchdog
|
bool mUseWatchdog; //internal CPU watchdog
|
||||||
|
bool mDoNotReboot;
|
||||||
|
|
||||||
CWelcomePage *mWelcomePagePtr;
|
CWelcomePage *mWelcomePagePtr;
|
||||||
|
|
||||||
@ -117,6 +125,10 @@ public:
|
|||||||
void CloseGeneralSettingsPage();
|
void CloseGeneralSettingsPage();
|
||||||
void UseNetworkTime(bool UseNetworkTime);
|
void UseNetworkTime(bool UseNetworkTime);
|
||||||
|
|
||||||
|
void OpenModbusSettingsPage();
|
||||||
|
void CloseModbusSettingsPage();
|
||||||
|
void ModbusSettingsChangedReboot(bool UseModbus, QHostAddress CCHostAdd);
|
||||||
|
|
||||||
void ShowZTLogViewerPage();
|
void ShowZTLogViewerPage();
|
||||||
void HideZTLogViewerPage();
|
void HideZTLogViewerPage();
|
||||||
|
|
||||||
@ -125,7 +137,7 @@ public:
|
|||||||
|
|
||||||
void LogZTSettingsRequest(bool LogStationName = false);
|
void LogZTSettingsRequest(bool LogStationName = false);
|
||||||
|
|
||||||
void ApplicationQuit(bool PowerButton = false);
|
void ApplicationQuit(int Reason);
|
||||||
|
|
||||||
unsigned int PauseInternalWatchdog();
|
unsigned int PauseInternalWatchdog();
|
||||||
unsigned int ResumeInternalWatchdog();
|
unsigned int ResumeInternalWatchdog();
|
||||||
@ -179,6 +191,7 @@ private:
|
|||||||
CTKTransportInterface *mTKTransportInterface;
|
CTKTransportInterface *mTKTransportInterface;
|
||||||
CModbusRepository *mCCModbusRepository;
|
CModbusRepository *mCCModbusRepository;
|
||||||
CModbusCCMgr *mModbusCCMgr;
|
CModbusCCMgr *mModbusCCMgr;
|
||||||
|
CNetworkCfgMgr mNetworkCfgMgr;
|
||||||
|
|
||||||
QLocalSocket mACPISocket;
|
QLocalSocket mACPISocket;
|
||||||
// CWatchdogCtrl mWatchdogCtrl;
|
// CWatchdogCtrl mWatchdogCtrl;
|
||||||
@ -195,6 +208,7 @@ private:
|
|||||||
ZT_DEADLOCK_STATE,
|
ZT_DEADLOCK_STATE,
|
||||||
ZT_EXIT_APPLICATION_STATE,
|
ZT_EXIT_APPLICATION_STATE,
|
||||||
ZT_POWER_BUTTON_EXIT_STATE,
|
ZT_POWER_BUTTON_EXIT_STATE,
|
||||||
|
ZT_SYSTEM_REBOOT_EXIT_STATE,
|
||||||
ZT_MAX_STATE
|
ZT_MAX_STATE
|
||||||
}eZTSMStates_t;
|
}eZTSMStates_t;
|
||||||
|
|
||||||
|
|||||||
@ -48,6 +48,7 @@ int main(int argc, char *argv[])
|
|||||||
bool IgnoreStationKey = false;
|
bool IgnoreStationKey = false;
|
||||||
bool DisablePassword = false;
|
bool DisablePassword = false;
|
||||||
bool UseWatchdog = true;
|
bool UseWatchdog = true;
|
||||||
|
bool NoReboot = false;
|
||||||
|
|
||||||
for ( int i = 1 ; i < argc ; i ++ )
|
for ( int i = 1 ; i < argc ; i ++ )
|
||||||
{
|
{
|
||||||
@ -72,6 +73,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
UseWatchdog = false;
|
UseWatchdog = false;
|
||||||
}
|
}
|
||||||
|
else if ( strcmp(argv[i],"-noreboot") == 0 )
|
||||||
|
{
|
||||||
|
NoReboot = true;
|
||||||
|
}
|
||||||
else if ( strcmp(argv[i],"-version") == 0 )
|
else if ( strcmp(argv[i],"-version") == 0 )
|
||||||
{
|
{
|
||||||
qDebug("ZoneTest version: %s",ZT_SOFT_VERSION);
|
qDebug("ZoneTest version: %s",ZT_SOFT_VERSION);
|
||||||
@ -86,6 +91,7 @@ int main(int argc, char *argv[])
|
|||||||
ZoneTest.mIgnoreStationPhysicalKey = IgnoreStationKey;
|
ZoneTest.mIgnoreStationPhysicalKey = IgnoreStationKey;
|
||||||
ZoneTest.mDisablePassword = DisablePassword;
|
ZoneTest.mDisablePassword = DisablePassword;
|
||||||
ZoneTest.mUseWatchdog = UseWatchdog;
|
ZoneTest.mUseWatchdog = UseWatchdog;
|
||||||
|
ZoneTest.mDoNotReboot = NoReboot;
|
||||||
|
|
||||||
|
|
||||||
//setup stdout for screen printing.
|
//setup stdout for screen printing.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user