Développement page config Modbus

-Ajout d'options dans la page de config modbus
This commit is contained in:
jfmartel
2017-11-28 14:59:18 -05:00
parent 5cac0fc8f3
commit 57a920ad77
5 changed files with 74 additions and 31 deletions
+17 -15
View File
@@ -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);
mZTWatchdogTimer->start();
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();
mCCWatchdogTimer->stop();
emit ModbusCCDisconnected();
emit ModbusCCLinkLost();
ResetCCRepository();
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)
{
mCCLinkState = true;
emit ModbusCCConnected();
emit ModbusCCLinkRecovered();
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 temp;
temp = (quint8)(DateTime.at(0) >> 8);
Secs = BCDToIntByte(temp);
Secs = BCDToDecByte(temp);
temp = (quint8)(DateTime.at(1) & 0x00FF);
Minutes = BCDToIntByte(temp);
Minutes = BCDToDecByte(temp);
temp = (qint8)(DateTime.at(1) >> 8);
Hours = BCDToIntByte(temp);
Hours = BCDToDecByte(temp);
temp = (quint8)(DateTime.at(2) & 0x00FF);
Day = BCDToIntByte(temp);
Day = BCDToDecByte(temp);
temp = (quint8)(DateTime.at(2) >> 8);
Month = BCDToIntByte(temp);
Month = BCDToDecByte(temp);
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);
@@ -225,7 +228,7 @@ void CModbusCCMgr::RegistersDatabaseUpdated(quint16 StartAddress, quint16 Length
emit RepoHasChanged();
}
quint8 CModbusCCMgr::BCDToIntByte(const quint8 byte)
quint8 CModbusCCMgr::BCDToDecByte(const quint8 byte)
{
quint8 out = 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 temp = 0;
@@ -265,8 +268,10 @@ void CModbusCCMgr::ModbusCCWatchdogTimeout()
{
CZTLog::instance()->AddLogString("Perte du lien de communication avec la CC: Watchdog CC Expiré",true);
ResetCCRepository();
emit ModbusCCDisconnected();
// emit ModbusCCDisconnected();
emit ModbusCCLinkLost();
mCCLinkState = false;
mCCWatchdogState = 0xBEEF;
}
void CModbusCCMgr::ModbusZTWatchdogTimeout()
@@ -303,9 +308,6 @@ int CModbusCCMgr::ResetCCRepository()
mModbusRepo->WriteMultipleRegs(MODBUS_CC_ZT1_TRAIN_ID_1_REG_ADD,ResetValues);
//Do not clear the TK (write) regisers, they will clear themselves when needed.
return RET_OK;
}
+3 -3
View File
@@ -64,12 +64,12 @@ private:
bool mZTWatchdogEnabled;
int ResetCCRepository();
quint8 BCDToIntByte(const quint8 byte);
quint16 BCDToIntWord(const quint16 word);
quint8 BCDToDecByte(const quint8 byte);
quint16 BCDToDecWord(const quint16 word);
signals:
void RepoHasChanged();
void ModbusCCConnected();
void ModbusCCConnected(qint32 LocalIP, qint32 RemoteIP);
void ModbusCCDisconnected();
void ModbusCCLinkLost();
void ModbusCCLinkRecovered();