Commentaires

Ajout de commentaires
Amélioration de l'affichate de l'état du modbus.
This commit is contained in:
jfmartel 2017-12-07 07:41:14 -05:00
parent 57a920ad77
commit a76e681e73
10 changed files with 125 additions and 17 deletions

Binary file not shown.

View File

@ -67,6 +67,7 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
mApplyButton = new CTextButtonWidget("Appliquer");
mApplyButton->setParentItem(this);
mApplyButton->setPos(650,550);
mApplyButton->hide();
connect(mApplyButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*)));
@ -89,6 +90,7 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
mIPChunk1->setMaximum(255);
IpSettingsPosx += 90;
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy-5);
connect(mIPChunk1,SIGNAL(valueChanged(int)),this,SLOT(SpinBoxValueChanged(int)));
Proxy = new QGraphicsProxyWidget(this);
Dot = new QGraphicsTextItem(".",this);
@ -101,6 +103,7 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
mIPChunk2->setMaximum(255);
IpSettingsPosx += 90;
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy-5);
connect(mIPChunk2,SIGNAL(valueChanged(int)),this,SLOT(SpinBoxValueChanged(int)));
Proxy = new QGraphicsProxyWidget(this);
Dot = new QGraphicsTextItem(".",this);
@ -113,6 +116,7 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
mIPChunk3->setMaximum(255);
IpSettingsPosx += 90;
Dot->setPos(IpSettingsPosx-17,IpSettingsPosy - 5);
connect(mIPChunk3,SIGNAL(valueChanged(int)),this,SLOT(SpinBoxValueChanged(int)));
Proxy = new QGraphicsProxyWidget(this);
mIPChunk4 = new QSpinBox();
@ -121,11 +125,13 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
mIPChunk4->setMaximum(255);
Proxy->setPos(IpSettingsPosx,IpSettingsPosy);
mIPChunk4->resize(70,30);
connect(mIPChunk4,SIGNAL(valueChanged(int)),this,SLOT(SpinBoxValueChanged(int)));
Proxy = new QGraphicsProxyWidget(this);
mUseModbusChkBox = new QCheckBox("Activer la communication Modbus avec la Commande Centralisée");
Proxy->setWidget(mUseModbusChkBox);
Proxy->setPos(100,100);
connect(mUseModbusChkBox,SIGNAL(stateChanged(int)),this,SLOT(CheckBoxStatedChanged(int)));
IpSettingsPosx = 100;
IpSettingsPosy += 50;
@ -215,6 +221,7 @@ int CModbusSettingsPage::SetActualSettings(bool UseModbus, QHostAddress CCHostAd
add >>= 8;
mIPChunk1->setValue(add & 0x000000FF);
mApplyButton->hide();
return RET_OK;
}
@ -243,6 +250,20 @@ void CModbusSettingsPage::ModbusCCLinkDown()
mModbusCCLinkState->setPlainText("Lien Modbus CC: Non établi");
}
void CModbusSettingsPage::CheckBoxStatedChanged(int state)
{
ShowApplyButton();
}
void CModbusSettingsPage::SpinBoxValueChanged(int value)
{
ShowApplyButton();
}
void CModbusSettingsPage::ShowApplyButton()
{
mApplyButton->show();
}
//Grab the mouse if the user clicks outside buttons
void CModbusSettingsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)

View File

@ -69,6 +69,8 @@ private:
QGraphicsTextItem *mModbusCCConnectionState, *mModbusCCLinkState;
QGraphicsPixmapItem *mCCConnectionLED, *mCCModbusLinkLED;
void ShowApplyButton();
public slots:
@ -77,6 +79,8 @@ public slots:
void ModbusCCDisconnected();
void ModbusCCLinkUP();
void ModbusCCLinkDown();
void SpinBoxValueChanged(int);
void CheckBoxStatedChanged(int);
};

View File

@ -47,8 +47,8 @@ CStatusBar::CStatusBar(QGraphicsItem *Parent):
mZT1Status = mZT2Status = SB_ZT_INACTIVE_STATUS;
mCCModbusState = SB_MODBUS_NOT_PRESENT;
mSEIModbusState = SB_MODBUS_CONNECTED;//SB_MODBUS_NOT_PRESENT;
mHistoModbusState = SB_MODBUS_CONNECTED;
mSEIModbusState = SB_MODBUS_NOT_PRESENT;
mHistoModbusState = SB_MODBUS_NOT_PRESENT;
mCCModbusONOFF.setParentItem(this);
mCCModbusONOFF.setPos(730,3);
@ -227,6 +227,15 @@ void CStatusBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
}*/
}
else if(mCCModbusState == SB_MODBUS_NOT_PRESENT)
{
painter->setPen(Qt::black);
Text.clear();
Text.sprintf("Modbus: Désactivé");
TextRect.adjust(20,0,0,0);
painter->drawText(TextRect, Qt::AlignLeft, Text);
TextRect.adjust(painter->fontMetrics().width(Text),0,0,0);
}
}

View File

@ -444,6 +444,14 @@ unsigned int CZTPage::SetZT2Presence(bool IsPresent)
return RET_OK;
}
unsigned int CZTPage::SetModbusPresent(bool IsPresent)
{
if(IsPresent == true)
{
mStatusBar->SetCCModbusState(SB_MODBUS_CONNECTED);
}
}
void CZTPage::ModbusCCConnected()
{
mStatusBar->SetCCModbusState(SB_MODBUS_CONNECTED);

View File

@ -80,6 +80,7 @@ public:
unsigned int UpdateEventsList();
unsigned int RequestExitPassword();
unsigned int SetZT2Presence(bool IsPresent);
unsigned int SetModbusPresent(bool IsPresent);
private:

View File

@ -1,3 +1,21 @@
/*******************************************************************************/
/*
Description:
Classe qui gère la communication Modbus avec la Commande Centralisée
Elle sert à interpréter et construire les messages reçus ou destinés à la CC
*/
/* ************************************************************************** */
/* Revision:
### YYYMMDD JFM
Verision d'origine.
### YYYYMMDD Description du besoin ou du bug
Description du changement.
*/
/* ************************************************************************** */
#ifndef CMODBUSSLAVE_H
#define CMODBUSSLAVE_H
@ -42,24 +60,24 @@ public:
//Helper functions
QList<qint16> GetZT1TrainComposition();
QList<qint16> GetZT2TrainComposition();
bool GetZT1InhibitionFlag();
int ClearZT1InhibitionFlag();
bool GetZT2InhibitionFlag();
int ClearZT2InhibitionFlag();
qint16 GetZT1TrainType();
qint16 GetZT2TrainType();
int SetZTWatchdogEnabled(bool Enabled);
int SetActivatedITI(int ITI);
QList<qint16> GetZT1TrainComposition(); //Retourne la composition du train actuelle pour ZT1
QList<qint16> GetZT2TrainComposition(); //Retourne la composition du train actuelle pour ZT1
bool GetZT1InhibitionFlag(); //Retourne l'état de l'inhibition de ZT1
int ClearZT1InhibitionFlag(); //Désactive l'inhibition ZT1
bool GetZT2InhibitionFlag(); //Retourne l'état de l'inhibition de ZT2
int ClearZT2InhibitionFlag(); //Désactive l'inhibition ZT2
qint16 GetZT1TrainType(); //Retourne le type de train actuel ZT1
qint16 GetZT2TrainType(); //Retourne le type de train actuel ZT1
int SetZTWatchdogEnabled(bool Enabled); //Permet de désactiver le Watchdog de la ZT (pour le mode entretien)
int SetActivatedITI(int ITI); //Fixe l'itinéraire ZT1 cheminé par le train pour en informer la CC
private:
QTcpServer *mModbusServer;
int mModbusPort;
QTcpServer *mModbusServer; //L'instance du serveur TCP
int mModbusPort; //Le port Modbus
QTimer *mZTWatchdogTimer, *mCCWatchdogTimer;
quint16 mZTWatchdog;
qint16 mCCWatchdogState;
bool mCCLinkState;
qint16 mCCWatchdogState; //Valeur du watchdog
bool mCCLinkState; //État du lien modbus, false lorsque le watchdog CC expire.
QDateTime *mLastDateTime;
bool mZTWatchdogEnabled;

View File

@ -1,3 +1,22 @@
/*******************************************************************************/
/*
Description:
Classe qui implémente les TC/TK avec la CC via le lien Modbus
Gère l'émission des alarmes à la CC.
*/
/* ************************************************************************** */
/* Revision:
### YYYMMDD JFM
Verision d'origine.
### YYYYMMDD Description du besoin ou du bug
Description du changement.
*/
/* ************************************************************************** */
#ifndef MODBUSTKTRANSPORT_H
#define MODBUSTKTRANSPORT_H

View File

@ -9,6 +9,7 @@ CNetworkCfgMgr::CNetworkCfgMgr()
int CNetworkCfgMgr::SetTRCPNetworkAddress(QHostAddress Address)
{
//Verify if the template file exists
if(QFile::exists("./interfaces") == false)
{
CZTLog::instance()->AddLogString("ERREUR: Le fichier template de configuration réseau est inexistant",true);
@ -55,7 +56,7 @@ int CNetworkCfgMgr::SetTRCPNetworkAddress(QHostAddress Address)
QString ConfigText(TemplateFile->readAll());
QString WorkString;
QHostAddress Gateway(Address.toIPv4Address() & 0xFFFFFF01);
QHostAddress Gateway(Address.toIPv4Address() & 0xFFFFFF01); //compute the gateway address xxx.xxx.xxx.1
WorkString = ConfigText.replace("[TELETRANS_IP]",Address.toString());
ConfigText = WorkString.replace("[TELETRANS_GATEWAY]",Gateway.toString());
@ -72,6 +73,7 @@ int CNetworkCfgMgr::SetTRCPNetworkAddress(QHostAddress Address)
delete TempInterfaceFile;
//Replace the system file with the temp file.
system("cp -f ./interfaces_tmp /etc/network/interfaces");

View File

@ -1,3 +1,29 @@
/*******************************************************************************/
/*
Description:
Cette classe permet de modifier l'adresse IP de l'ordinateur
La classe modifie le fichier système /etc/network/interfaces afin de configurer
l'adresse IP statique de l'interface servant à communiquer avec le HPC.
Pour ce faire, elle utilise le fichier template ./interfaces dans lequel elle
insère l'adresse et le gateway (calculé à partir de l'adresse).
Un redémarrage de l'ordinateur est nécessaire pour que la nouvelle adresse soit
prise en compte.
sur le réseau.
*/
/* ************************************************************************** */
/* Revision:
### YYYMMDD JFM
Verision d'origine.
### YYYYMMDD Description du besoin ou du bug
Description du changement.
*/
/* ************************************************************************** */
#ifndef NETWORKCFGMGR_H
#define NETWORKCFGMGR_H