Watchdog avec date/time et reporting fonctionnel.
This commit is contained in:
@@ -93,17 +93,6 @@ int CCANDevice::Init()
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
if(mDeviceConfigInfo.mDeviceWatchdogActivated == true)
|
||||
{
|
||||
if(mCANWatchdog.Init(mCANDriverIF,mDeviceHandle,mDeviceConfigInfo.mWatchdogPeriod,mDeviceConfigInfo.mWatchdogCANMsgID) != RET_OK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Impossible d'initialiser un watchdog CAN","CCANDevice",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
}
|
||||
mCANWatchdog.StartWDT();
|
||||
|
||||
QString Log = QString("Watchdog CAN initialisé pour le module sur le channel %1").arg(mDeviceConfigInfo.mCANDeviceID);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(Log,"CCANDevice",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
|
||||
}
|
||||
|
||||
mIsCANInitialized = true;
|
||||
|
||||
@@ -120,6 +109,25 @@ int CCANDevice::Init()
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CCANDevice::StartWatchdog(CDeviceDetectionConfig *DeviceMonitorConfig)
|
||||
{
|
||||
if(mDeviceConfigInfo.mDeviceWatchdogActivated == true)
|
||||
{
|
||||
if(mCANWatchdog.Init(mCANDriverIF,mDeviceHandle,mDeviceConfigInfo.mWatchdogPeriod,DeviceMonitorConfig) != RET_OK)
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Impossible d'initialiser un watchdog CAN","CCANDevice",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
mCANWatchdog.StartWDT();
|
||||
|
||||
QString Log = QString("Watchdog CAN initialisé pour le module sur le channel %1").arg(mDeviceConfigInfo.mCANDeviceID);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(Log,"CCANDevice",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CCANDevice::Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBaudrate CANDeviceBaudRate, QString DevDescription, QString DeviceName, unsigned int DevicePollPeriod)
|
||||
{
|
||||
mDeviceConfigInfo.mCANDeviceID = CANDeviceID;
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
#include "CANDataLogger.h"
|
||||
#include "MQTTMessage.h"
|
||||
#include "CANWatchdog.h"
|
||||
//#include "MQTTClientWrapper.h"
|
||||
|
||||
|
||||
class CMQTTClientWrapper;
|
||||
class COtarcikCan;
|
||||
class CDeviceDetectionConfig;
|
||||
|
||||
class CCANDevice : public QObject
|
||||
{
|
||||
@@ -28,6 +29,7 @@ public:
|
||||
|
||||
int Init(QString DatabaseFileName, TPCANHandle CANDeviceID, TPCANBaudrate CANDeviceBaudRate, QString DevDescription, QString DeviceName, unsigned int DevicePollPeriod);
|
||||
int Init();
|
||||
int StartWatchdog(CDeviceDetectionConfig *DeviceMonitorConfig);
|
||||
QList<CCANMessage*> *GetCANMessagesList(){return &mMessageList;}
|
||||
|
||||
public:
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
unsigned int mWatchdogPeriod;
|
||||
|
||||
CCANDeviceConfig &operator=(const CCANDeviceConfig &source);
|
||||
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CCANDeviceConfig &source);
|
||||
|
||||
@@ -4,21 +4,29 @@
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QFloat16>
|
||||
#include "MQTTClientWrapper.h"
|
||||
#include "InternetMonitor.h"
|
||||
#include "LANDevicesPresenceMonitor.h"
|
||||
#include "DeviceDetectionConfig.h"
|
||||
|
||||
CCANWatchdog::CCANWatchdog()
|
||||
{
|
||||
mCANDriverIF = new CPCANInterface;
|
||||
//mCANDriverIF = new CPCANInterface;
|
||||
mIsCANInitialized = false;
|
||||
|
||||
mWatchdogTimer = new QTimer;
|
||||
mWatchdogTimer->setSingleShot(false);
|
||||
mCANDriverIF = 0;
|
||||
mWDTInitialized = false;
|
||||
// mMQTTPresenceMonitor = 0;
|
||||
// mLANDevicesMonitor = 0;
|
||||
// mInternetMonitor = 0;
|
||||
mDevicesMonitorConfig = 0;
|
||||
|
||||
connect(mWatchdogTimer,&QTimer::timeout,this,&CCANWatchdog::WatchdogTimeoutTimerExpired);
|
||||
}
|
||||
|
||||
int CCANWatchdog::Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle, unsigned int WDTPeriod, unsigned int CANMsgID)
|
||||
int CCANWatchdog::Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle, unsigned int WDTPeriod, CDeviceDetectionConfig *DevicesMonitorConfig)
|
||||
{
|
||||
if(WDTPeriod < 200)
|
||||
{
|
||||
@@ -27,6 +35,7 @@ int CCANWatchdog::Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle,
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mDevicesMonitorConfig = DevicesMonitorConfig;
|
||||
mCANDeviceHandle = CANDeviceHandle;
|
||||
mWDTPeriod = WDTPeriod;
|
||||
mCANDriverIF = CANDriverIF;
|
||||
@@ -35,7 +44,7 @@ int CCANWatchdog::Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle,
|
||||
mWatchdogTimer->setInterval(mWDTPeriod);
|
||||
mWatchdogTimer->setSingleShot(false);
|
||||
|
||||
mWDTCANMsg.mCANMsgID = CANMsgID;
|
||||
mWDTCANMsg.mCANMsgID = DevicesMonitorConfig->mReportingCANMsgID;
|
||||
mWDTCANMsg.mCANMsgLength = 8;
|
||||
mWDTCANMsg.mCANMsgData.clear();
|
||||
mWDTCANMsg.mCANMsgData.append(8,(char)0x00);
|
||||
@@ -65,7 +74,30 @@ void CCANWatchdog::WatchdogTimeoutTimerExpired()
|
||||
// BigData |= 0x100000000;
|
||||
|
||||
BigData = GetCANDateTimeBuffer();
|
||||
if(mDevicesMonitorConfig != 0)
|
||||
{
|
||||
if(mDevicesMonitorConfig->mInternetMonitor != 0)
|
||||
{
|
||||
BigData |= mDevicesMonitorConfig->mInternetMonitor->GetCANInternetStatusMask();
|
||||
}
|
||||
}
|
||||
if(mDevicesMonitorConfig != 0)
|
||||
{
|
||||
if(mDevicesMonitorConfig->mMQTTPresenceMonitor != 0)
|
||||
{
|
||||
BigData |= mDevicesMonitorConfig->mMQTTPresenceMonitor->GetMQTTServerPresenceCANMask();
|
||||
}
|
||||
}
|
||||
if(mDevicesMonitorConfig != 0)
|
||||
{
|
||||
if(mDevicesMonitorConfig->mLANDevicesMonitor != 0)
|
||||
{
|
||||
|
||||
BigData |= mDevicesMonitorConfig->mLANDevicesMonitor->GetDevicesPresenceCANMask();
|
||||
}
|
||||
}
|
||||
|
||||
mWDTCANMsg.mCANMsgID = mDevicesMonitorConfig->mReportingCANMsgID;
|
||||
mWDTCANMsg.SetRawData(BigData,CCANSignal::CAN_SIGNAL_ENCODING_INTEL);
|
||||
mCANDriverIF->SendCANMessage(mCANDeviceHandle,mWDTCANMsg);
|
||||
|
||||
@@ -93,6 +125,11 @@ quint64 CCANWatchdog::GetCANDateTimeBuffer()
|
||||
return OutputBuffer;
|
||||
}
|
||||
|
||||
int CCANWatchdog::SetDevicesDetectionConfig(CDeviceDetectionConfig *DeviceMonitoringConfig)
|
||||
{
|
||||
mDevicesMonitorConfig = DeviceMonitoringConfig;
|
||||
}
|
||||
|
||||
int CCANWatchdog::StartWDT()
|
||||
{
|
||||
if(mWDTInitialized == false)
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
//Parker controller. This controller uses this update as a watchdog signal, but the register contains
|
||||
//some useful data for the Parker controller as well.
|
||||
|
||||
class CMQTTClientWrapper;
|
||||
class CLANDevicesPresenceMonitor;
|
||||
class CInternetMonitor;
|
||||
class CDeviceDetectionConfig;
|
||||
|
||||
class CCANWatchdog: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -18,11 +23,12 @@ class CCANWatchdog: public QObject
|
||||
public:
|
||||
CCANWatchdog();
|
||||
|
||||
int Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle, unsigned int WDTPeriod,unsigned int CANMsgID);
|
||||
int StartWDT();
|
||||
int StopWDT();
|
||||
bool IsInitialized(){return mWDTInitialized;}
|
||||
quint64 GetCANDateTimeBuffer();
|
||||
int Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle, unsigned int WDTPeriod, CDeviceDetectionConfig *DevicesMonitorConfig);
|
||||
int StartWDT();
|
||||
int StopWDT();
|
||||
bool IsInitialized(){return mWDTInitialized;}
|
||||
quint64 GetCANDateTimeBuffer();
|
||||
int SetDevicesDetectionConfig(CDeviceDetectionConfig *DeviceMonitoringConfig);
|
||||
|
||||
CPCANInterface *mCANDriverIF;
|
||||
unsigned int mWDTPeriod;
|
||||
@@ -30,10 +36,17 @@ public:
|
||||
bool mWDTInitialized;
|
||||
CCANMessage mWDTCANMsg;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool mIsCANInitialized;
|
||||
TPCANHandle mCANDeviceHandle;
|
||||
|
||||
// CMQTTClientWrapper *mMQTTPresenceMonitor;
|
||||
// CLANDevicesPresenceMonitor *mLANDevicesMonitor;
|
||||
// CInternetMonitor *mInternetMonitor;
|
||||
CDeviceDetectionConfig *mDevicesMonitorConfig;
|
||||
|
||||
|
||||
public slots:
|
||||
void WatchdogTimeoutTimerExpired();
|
||||
|
||||
Reference in New Issue
Block a user