Développement page config Modbus
-Ajout d'options dans la page de config modbus
This commit is contained in:
parent
5cac0fc8f3
commit
57a920ad77
@ -75,7 +75,7 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
|
|||||||
Dot->setFont(font);
|
Dot->setFont(font);
|
||||||
|
|
||||||
|
|
||||||
int IpSettingsPosx = 120, IpSettingsPosy = 200;
|
int IpSettingsPosx = 100, IpSettingsPosy = 200;
|
||||||
Title = new QGraphicsTextItem("Adresse IP",this);
|
Title = new QGraphicsTextItem("Adresse IP",this);
|
||||||
font.setPointSize(16);
|
font.setPointSize(16);
|
||||||
Title->setFont(font);
|
Title->setFont(font);
|
||||||
@ -127,23 +127,28 @@ CModbusSettingsPage::CModbusSettingsPage(QGraphicsWidget *Parent)
|
|||||||
Proxy->setWidget(mUseModbusChkBox);
|
Proxy->setWidget(mUseModbusChkBox);
|
||||||
Proxy->setPos(100,100);
|
Proxy->setPos(100,100);
|
||||||
|
|
||||||
|
IpSettingsPosx = 100;
|
||||||
|
IpSettingsPosy += 50;
|
||||||
|
font.setPointSize(14);
|
||||||
|
mModbusCCLinkState = new QGraphicsTextItem("Lien Modbus CC: Non établi",this);
|
||||||
|
mModbusCCLinkState->setFont(font);
|
||||||
|
mModbusCCLinkState->setPos(IpSettingsPosx+30,IpSettingsPosy);
|
||||||
|
|
||||||
|
mCCModbusLinkLED = new QGraphicsPixmapItem(QPixmap("./Images/red-led-on-md.png").scaled(25,25),this);
|
||||||
|
mCCModbusLinkLED->setPos(IpSettingsPosx,IpSettingsPosy+5);
|
||||||
|
|
||||||
|
IpSettingsPosy += 30;
|
||||||
|
mModbusCCConnectionState = new QGraphicsTextItem("Connection HPC: DÉCONNECTÉE",this);
|
||||||
|
mModbusCCConnectionState->setFont(font);
|
||||||
|
mModbusCCConnectionState->setPos(IpSettingsPosx+30,IpSettingsPosy);
|
||||||
|
mCCConnectionLED = new QGraphicsPixmapItem(QPixmap("./Images/red-led-on-md.png").scaled(25,25),this);
|
||||||
|
mCCConnectionLED->setPos(IpSettingsPosx,IpSettingsPosy+5);
|
||||||
|
|
||||||
// mCalendarWidget = new QCalendarWidget();
|
|
||||||
// Proxy->setWidget(mCalendarWidget);
|
|
||||||
// Proxy->setPos(100,150);
|
|
||||||
|
|
||||||
QGraphicsRectItem *Frame = new QGraphicsRectItem(80,70,600,400,this);
|
QGraphicsRectItem *Frame = new QGraphicsRectItem(80,70,600,400,this);
|
||||||
QPen FramePen;
|
QPen FramePen;
|
||||||
FramePen.setWidth(3);
|
FramePen.setWidth(3);
|
||||||
Frame->setPen(FramePen);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -214,6 +219,31 @@ int CModbusSettingsPage::SetActualSettings(bool UseModbus, QHostAddress CCHostAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CModbusSettingsPage::ModbusCCConnected(qint32 LocalIP, qint32 RemoteIP)
|
||||||
|
{
|
||||||
|
mCCConnectionLED->setPixmap(QPixmap("./Images/green-led-on-md.png").scaled(25,25));
|
||||||
|
mModbusCCConnectionState->setPlainText(QString("Connection HPC: Connectée. \nIP: Local[%1] - HPC[%2]").arg(QHostAddress(LocalIP).toString()).arg(QHostAddress(RemoteIP).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModbusSettingsPage::ModbusCCDisconnected()
|
||||||
|
{
|
||||||
|
mCCConnectionLED->setPixmap(QPixmap("./Images/red-led-on-md.png").scaled(25,25));
|
||||||
|
mModbusCCConnectionState->setPlainText("Connection HPC: DÉCONNECTÉE");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModbusSettingsPage::ModbusCCLinkUP()
|
||||||
|
{
|
||||||
|
mCCModbusLinkLED->setPixmap(QPixmap("./Images/green-led-on-md.png").scaled(25,25));
|
||||||
|
mModbusCCLinkState->setPlainText("Lien Modbus CC: Établi");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModbusSettingsPage::ModbusCCLinkDown()
|
||||||
|
{
|
||||||
|
mCCModbusLinkLED->setPixmap(QPixmap("./Images/red-led-on-md.png").scaled(25,25));
|
||||||
|
mModbusCCLinkState->setPlainText("Lien Modbus CC: Non établi");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Grab the mouse if the user clicks outside buttons
|
//Grab the mouse if the user clicks outside buttons
|
||||||
void CModbusSettingsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void CModbusSettingsPage::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
|
||||||
|
|
||||||
class CZoneTest;
|
class CZoneTest;
|
||||||
@ -65,11 +66,17 @@ private:
|
|||||||
QSpinBox *mIPChunk1, *mIPChunk2, *mIPChunk3, *mIPChunk4;
|
QSpinBox *mIPChunk1, *mIPChunk2, *mIPChunk3, *mIPChunk4;
|
||||||
QString mCurIP;
|
QString mCurIP;
|
||||||
QCheckBox *mUseModbusChkBox;
|
QCheckBox *mUseModbusChkBox;
|
||||||
|
QGraphicsTextItem *mModbusCCConnectionState, *mModbusCCLinkState;
|
||||||
|
QGraphicsPixmapItem *mCCConnectionLED, *mCCModbusLinkLED;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ButtonClicked(CTextButtonWidget *);
|
void ButtonClicked(CTextButtonWidget *);
|
||||||
|
void ModbusCCConnected(qint32 LocalIP, qint32 RemoteIP);
|
||||||
|
void ModbusCCDisconnected();
|
||||||
|
void ModbusCCLinkUP();
|
||||||
|
void ModbusCCLinkDown();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -111,9 +111,11 @@ void CModbusCCMgr::NewModbusConnection()
|
|||||||
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);
|
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 = false;
|
||||||
|
mCCWatchdogState = 0xBEEF;
|
||||||
|
|
||||||
emit ModbusCCConnected();
|
emit ModbusCCConnected(mModbusTCPSocketHandle->localAddress().toIPv4Address(),mModbusTCPSocketHandle->peerAddress().toIPv4Address());
|
||||||
|
//emit ModbusCCLinkRecovered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +125,7 @@ void CModbusCCMgr::ConnectionLost()
|
|||||||
mZTWatchdogTimer->stop();
|
mZTWatchdogTimer->stop();
|
||||||
mCCWatchdogTimer->stop();
|
mCCWatchdogTimer->stop();
|
||||||
emit ModbusCCDisconnected();
|
emit ModbusCCDisconnected();
|
||||||
|
emit ModbusCCLinkLost();
|
||||||
ResetCCRepository();
|
ResetCCRepository();
|
||||||
CZTLog::instance()->AddLogString(QString("Connection Modbus (Ethernet) avec la CC rompue."),true);
|
CZTLog::instance()->AddLogString(QString("Connection Modbus (Ethernet) avec la CC rompue."),true);
|
||||||
}
|
}
|
||||||
@ -147,7 +150,7 @@ void CModbusCCMgr::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length
|
|||||||
if(mCCLinkState == false)
|
if(mCCLinkState == false)
|
||||||
{
|
{
|
||||||
mCCLinkState = true;
|
mCCLinkState = true;
|
||||||
emit ModbusCCConnected();
|
emit ModbusCCLinkRecovered();
|
||||||
CZTLog::instance()->AddLogString("Lien de communication (Watchdog) avec la CC rétabli",true);
|
CZTLog::instance()->AddLogString("Lien de communication (Watchdog) avec la CC rétabli",true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,22 +169,22 @@ void CModbusCCMgr::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length
|
|||||||
quint8 Secs, Minutes, Hours, Month, Day;
|
quint8 Secs, Minutes, Hours, Month, Day;
|
||||||
quint8 temp;
|
quint8 temp;
|
||||||
temp = (quint8)(DateTime.at(0) >> 8);
|
temp = (quint8)(DateTime.at(0) >> 8);
|
||||||
Secs = BCDToIntByte(temp);
|
Secs = BCDToDecByte(temp);
|
||||||
|
|
||||||
temp = (quint8)(DateTime.at(1) & 0x00FF);
|
temp = (quint8)(DateTime.at(1) & 0x00FF);
|
||||||
Minutes = BCDToIntByte(temp);
|
Minutes = BCDToDecByte(temp);
|
||||||
|
|
||||||
temp = (qint8)(DateTime.at(1) >> 8);
|
temp = (qint8)(DateTime.at(1) >> 8);
|
||||||
Hours = BCDToIntByte(temp);
|
Hours = BCDToDecByte(temp);
|
||||||
|
|
||||||
temp = (quint8)(DateTime.at(2) & 0x00FF);
|
temp = (quint8)(DateTime.at(2) & 0x00FF);
|
||||||
Day = BCDToIntByte(temp);
|
Day = BCDToDecByte(temp);
|
||||||
|
|
||||||
temp = (quint8)(DateTime.at(2) >> 8);
|
temp = (quint8)(DateTime.at(2) >> 8);
|
||||||
Month = BCDToIntByte(temp);
|
Month = BCDToDecByte(temp);
|
||||||
|
|
||||||
quint16 Year = DateTime.at(3);
|
quint16 Year = DateTime.at(3);
|
||||||
Year = BCDToIntWord(Year);
|
Year = BCDToDecWord(Year);
|
||||||
|
|
||||||
qDebug("Secs [%d], Minutes[%d], Hours[%d], Month[%d], Day[%d], Year[%d]",Secs,Minutes,Hours,Month,Day,Year);
|
qDebug("Secs [%d], Minutes[%d], Hours[%d], Month[%d], Day[%d], Year[%d]",Secs,Minutes,Hours,Month,Day,Year);
|
||||||
|
|
||||||
@ -225,7 +228,7 @@ void CModbusCCMgr::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length
|
|||||||
emit RepoHasChanged();
|
emit RepoHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
quint8 CModbusCCMgr::BCDToIntByte(const quint8 byte)
|
quint8 CModbusCCMgr::BCDToDecByte(const quint8 byte)
|
||||||
{
|
{
|
||||||
quint8 out = 0;
|
quint8 out = 0;
|
||||||
quint8 temp = 0;
|
quint8 temp = 0;
|
||||||
@ -238,7 +241,7 @@ quint8 CModbusCCMgr::BCDToIntByte(const quint8 byte)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 CModbusCCMgr::BCDToIntWord(const quint16 word)
|
quint16 CModbusCCMgr::BCDToDecWord(const quint16 word)
|
||||||
{
|
{
|
||||||
quint16 out = 0;
|
quint16 out = 0;
|
||||||
quint16 temp = 0;
|
quint16 temp = 0;
|
||||||
@ -265,8 +268,10 @@ void CModbusCCMgr::ModbusCCWatchdogTimeout()
|
|||||||
{
|
{
|
||||||
CZTLog::instance()->AddLogString("Perte du lien de communication avec la CC: Watchdog CC Expiré",true);
|
CZTLog::instance()->AddLogString("Perte du lien de communication avec la CC: Watchdog CC Expiré",true);
|
||||||
ResetCCRepository();
|
ResetCCRepository();
|
||||||
emit ModbusCCDisconnected();
|
// emit ModbusCCDisconnected();
|
||||||
|
emit ModbusCCLinkLost();
|
||||||
mCCLinkState = false;
|
mCCLinkState = false;
|
||||||
|
mCCWatchdogState = 0xBEEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModbusCCMgr::ModbusZTWatchdogTimeout()
|
void CModbusCCMgr::ModbusZTWatchdogTimeout()
|
||||||
@ -303,9 +308,6 @@ int CModbusCCMgr::ResetCCRepository()
|
|||||||
mModbusRepo->WriteMultipleRegs(MODBUS_CC_ZT1_TRAIN_ID_1_REG_ADD,ResetValues);
|
mModbusRepo->WriteMultipleRegs(MODBUS_CC_ZT1_TRAIN_ID_1_REG_ADD,ResetValues);
|
||||||
|
|
||||||
//Do not clear the TK (write) regisers, they will clear themselves when needed.
|
//Do not clear the TK (write) regisers, they will clear themselves when needed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,12 +64,12 @@ private:
|
|||||||
bool mZTWatchdogEnabled;
|
bool mZTWatchdogEnabled;
|
||||||
|
|
||||||
int ResetCCRepository();
|
int ResetCCRepository();
|
||||||
quint8 BCDToIntByte(const quint8 byte);
|
quint8 BCDToDecByte(const quint8 byte);
|
||||||
quint16 BCDToIntWord(const quint16 word);
|
quint16 BCDToDecWord(const quint16 word);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void RepoHasChanged();
|
void RepoHasChanged();
|
||||||
void ModbusCCConnected();
|
void ModbusCCConnected(qint32 LocalIP, qint32 RemoteIP);
|
||||||
void ModbusCCDisconnected();
|
void ModbusCCDisconnected();
|
||||||
void ModbusCCLinkLost();
|
void ModbusCCLinkLost();
|
||||||
void ModbusCCLinkRecovered();
|
void ModbusCCLinkRecovered();
|
||||||
|
|||||||
@ -576,9 +576,13 @@ unsigned int CZoneTest::InitZT()
|
|||||||
|
|
||||||
mZTStateMachine->BindModbusCCMgrPtr(mModbusCCMgr);
|
mZTStateMachine->BindModbusCCMgrPtr(mModbusCCMgr);
|
||||||
// connect(mModbusCCMgr,SIGNAL(RepoHasChanged()),mZTStateMachine,SLOT(ModbusCCANUpdate()));
|
// connect(mModbusCCMgr,SIGNAL(RepoHasChanged()),mZTStateMachine,SLOT(ModbusCCANUpdate()));
|
||||||
connect(mModbusCCMgr,SIGNAL(ModbusCCConnected()),panel.mZTMainPage,SLOT(ModbusCCConnected()));
|
connect(mModbusCCMgr,SIGNAL(ModbusCCLinkRecovered()),panel.mZTMainPage,SLOT(ModbusCCConnected()));
|
||||||
connect(mModbusCCMgr,SIGNAL(ModbusCCDisconnected()),panel.mZTMainPage,SLOT(ModbusCCDisconnected()));
|
connect(mModbusCCMgr,SIGNAL(ModbusCCLinkLost()),panel.mZTMainPage,SLOT(ModbusCCDisconnected()));
|
||||||
connect(mModbusCCMgr,SIGNAL(ModbusDateTimeReceived(QDateTime*)),this,SLOT(ModbusDateTimeUpdate(QDateTime*)));
|
connect(mModbusCCMgr,SIGNAL(ModbusDateTimeReceived(QDateTime*)),this,SLOT(ModbusDateTimeUpdate(QDateTime*)));
|
||||||
|
connect(mModbusCCMgr,SIGNAL(ModbusCCConnected(qint32,qint32)),panel.mModbusSettingsPage,SLOT(ModbusCCConnected(qint32,qint32)));
|
||||||
|
connect(mModbusCCMgr,SIGNAL(ModbusCCDisconnected()),panel.mModbusSettingsPage,SLOT(ModbusCCDisconnected()));
|
||||||
|
connect(mModbusCCMgr,SIGNAL(ModbusCCLinkLost()),panel.mModbusSettingsPage,SLOT(ModbusCCLinkDown()));
|
||||||
|
connect(mModbusCCMgr,SIGNAL(ModbusCCLinkRecovered()),panel.mModbusSettingsPage,SLOT(ModbusCCLinkUP()));
|
||||||
panel.mZTMainPage->ModbusCCDisconnected();
|
panel.mZTMainPage->ModbusCCDisconnected();
|
||||||
panel.mZTMainPage->mZT1Stats->Init(true);
|
panel.mZTMainPage->mZT1Stats->Init(true);
|
||||||
panel.mZTMainPage->mZT2Stats->Init(true);
|
panel.mZTMainPage->mZT2Stats->Init(true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user