Interface chalet LTE fonctionnelle
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "ChaletLoraDevice.h"
|
||||
#include "ChaletDevice.h"
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
|
||||
CChaletLoraDevice::CChaletLoraDevice(int Address, CAbstractNetworkCommIF *NetworkInterface):
|
||||
CChaletDevice::CChaletDevice(int Address, CAbstractNetworkCommIF *NetworkInterface):
|
||||
CNetworkDevice(ID_CHALET_DEVICE,Address,NetworkInterface)
|
||||
{
|
||||
NetworkInterface->mDevicePtr = this;
|
||||
@@ -27,12 +27,12 @@ CChaletLoraDevice::CChaletLoraDevice(int Address, CAbstractNetworkCommIF *Networ
|
||||
ResetCommStats();
|
||||
}
|
||||
|
||||
CChaletLoraDevice::~CChaletLoraDevice()
|
||||
CChaletDevice::~CChaletDevice()
|
||||
{
|
||||
delete mChaletStatusTimer;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::Start()
|
||||
int CChaletDevice::Start()
|
||||
{
|
||||
ScheduleChaletStatusRequest();
|
||||
mChaletStatusTimer->start(1000);
|
||||
@@ -40,7 +40,7 @@ int CChaletLoraDevice::Start()
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
int CChaletDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
{
|
||||
Q_UNUSED(DeviceID)
|
||||
Q_UNUSED(DeviceAddress)
|
||||
@@ -245,7 +245,7 @@ int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, i
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CChaletLoraDevice::CommTimerExpired()
|
||||
void CChaletDevice::CommTimerExpired()
|
||||
{
|
||||
if(mPendingNetworkMsgList.isEmpty())
|
||||
{
|
||||
@@ -295,7 +295,7 @@ void CChaletLoraDevice::CommTimerExpired()
|
||||
// SendChaletCommand(CHALET_GENERAL_STATUS_REQUEST,0,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendWiFiModuleSetState(bool State)
|
||||
int CChaletDevice::SendWiFiModuleSetState(bool State)
|
||||
{
|
||||
QByteArray Data;
|
||||
Data.resize(1);
|
||||
@@ -311,7 +311,7 @@ int CChaletLoraDevice::SendWiFiModuleSetState(bool State)
|
||||
return ScheduleChaletCommand(CHALET_WIFI_SET_STATE_REQUEST,1,Data);
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendInverterPowerRelayState(bool State)
|
||||
int CChaletDevice::SendInverterPowerRelayState(bool State)
|
||||
{
|
||||
QByteArray Data;
|
||||
Data.resize(1);
|
||||
@@ -327,7 +327,7 @@ int CChaletLoraDevice::SendInverterPowerRelayState(bool State)
|
||||
return ScheduleChaletCommand(CHALET_AC_POWER_SET_STATE_REQUEST,Data);
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendDOHarakiri()
|
||||
int CChaletDevice::SendDOHarakiri()
|
||||
{
|
||||
QByteArray Data; //Magic word...
|
||||
Data.clear();
|
||||
@@ -339,7 +339,7 @@ int CChaletLoraDevice::SendDOHarakiri()
|
||||
return ScheduleChaletCommand(CHALET_DO_HARAKIRI_REQUEST,Data);
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendRebootCmd()
|
||||
int CChaletDevice::SendRebootCmd()
|
||||
{
|
||||
QByteArray Data; //Magic word...
|
||||
Data.clear();
|
||||
@@ -350,33 +350,38 @@ int CChaletLoraDevice::SendRebootCmd()
|
||||
|
||||
return ScheduleChaletCommand(CHALET_REBOOT_CPU_REQUEST,Data);
|
||||
}
|
||||
int CChaletLoraDevice::SendGetWifiParams()
|
||||
int CChaletDevice::SendGetWifiParams()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_GET_STORED_WIFI_SETTINGS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendSetWifiParams(QByteArray Data)
|
||||
int CChaletDevice::SendSetWifiParams(QByteArray Data)
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_SET_STORED_WIFI_SETTINGS_REQUEST,Data);
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendGetFirmwareVersion()
|
||||
int CChaletDevice::SendGetFirmwareVersion()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_GET_FIRMWARE_VERSION_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendClearCommStatsRequest()
|
||||
int CChaletDevice::SendClearCommStatsRequest()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_CLEAR_COMMS_STATISTICS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendGetWifiStatusRequest()
|
||||
int CChaletDevice::SendGetWifiStatusRequest()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_WIFI_STATUS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendChaletCommand(int CmdID, int DataSize, QByteArray Data)
|
||||
int CChaletDevice::SendChaletCommand(int CmdID, int DataSize, QByteArray Data)
|
||||
{
|
||||
if(mNetworkInterfacePtr == 0)
|
||||
{
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
||||
mNetworkInterfacePtr->SendNetworkMessage(ID_CHALET_DEVICE,mDeviceAddress,CmdID,DataSize,&Data);
|
||||
mTotalNbRequest++;
|
||||
mChaletMainStatus.mTotalNbMasterTxCmds++;
|
||||
@@ -384,7 +389,7 @@ int CChaletLoraDevice::SendChaletCommand(int CmdID, int DataSize, QByteArray Dat
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::CmdResponseReceived(int CmdID)
|
||||
int CChaletDevice::CmdResponseReceived(int CmdID)
|
||||
{
|
||||
Q_UNUSED(CmdID)
|
||||
|
||||
@@ -423,12 +428,12 @@ int CChaletLoraDevice::CmdResponseReceived(int CmdID)
|
||||
|
||||
|
||||
|
||||
int CChaletLoraDevice::ScheduleChaletStatusRequest()
|
||||
int CChaletDevice::ScheduleChaletStatusRequest()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_GENERAL_STATUS_REQUEST,0,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::ScheduleChaletCommand(int CmdID, int DataSize, QByteArray Data)
|
||||
int CChaletDevice::ScheduleChaletCommand(int CmdID, int DataSize, QByteArray Data)
|
||||
{
|
||||
Q_UNUSED(DataSize)
|
||||
|
||||
@@ -445,7 +450,7 @@ int CChaletLoraDevice::ScheduleChaletCommand(int CmdID, int DataSize, QByteArray
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::ScheduleChaletCommand(int CmdID, QByteArray Data)
|
||||
int CChaletDevice::ScheduleChaletCommand(int CmdID, QByteArray Data)
|
||||
{
|
||||
// if(mChaletMainStatus.mIsOnline == false)
|
||||
// {
|
||||
@@ -471,7 +476,7 @@ int CChaletLoraDevice::ScheduleChaletCommand(int CmdID, QByteArray Data)
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::ResetCommStats()
|
||||
int CChaletDevice::ResetCommStats()
|
||||
{
|
||||
mLostRequestPercentage = 0.0;
|
||||
mTotalNbRequest = 0;
|
||||
@@ -482,7 +487,7 @@ int CChaletLoraDevice::ResetCommStats()
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::ComputeCommStats()
|
||||
int CChaletDevice::ComputeCommStats()
|
||||
{
|
||||
mLostRequestPercentage = ((float)mNbLostRequest/(float)mTotalNbRequest)*100;
|
||||
mChaletMainStatus.mLostRequestPercentage = mLostRequestPercentage;
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef CCHALETLORADEVICE_H
|
||||
#define CCHALETLORADEVICE_H
|
||||
#ifndef CCHALETDEVICE_H
|
||||
#define CCHALETDEVICE_H
|
||||
#include <QByteArray>
|
||||
#include <QObject>
|
||||
#include <QSerialPort>
|
||||
#include "LoraNetworkCommIF.h"
|
||||
#include "NetworkProtocol.h"
|
||||
#include "NetworkDevice.h"
|
||||
#include <QTimer>
|
||||
#include "ChaletData.h"
|
||||
@@ -26,16 +26,17 @@
|
||||
#define LORA_CHALET_STATUS_POWER_RELAY_MASK 0x01
|
||||
#define LORA_CHALET_STATUS_CUR_SENSOR_MASK 0x02
|
||||
|
||||
class CChaletLoraDevice : public QObject, public CNetworkDevice
|
||||
class CChaletDevice : public QObject, public CNetworkDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CChaletLoraDevice(int Address,CAbstractNetworkCommIF *NetworkInterface);
|
||||
~CChaletLoraDevice();
|
||||
CChaletDevice(int Address,CAbstractNetworkCommIF *NetworkInterface);
|
||||
~CChaletDevice();
|
||||
|
||||
virtual int NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
|
||||
|
||||
QString mChaletName;
|
||||
QTimer *mChaletStatusTimer;
|
||||
int Start();
|
||||
|
||||
@@ -93,4 +94,4 @@ public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // CCHALETLORADEVICE_H
|
||||
#endif // CCHALETDEVICE_H
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ChaletInterface.h"
|
||||
#include "ChaletDataLogger.h"
|
||||
|
||||
CChaletInterface::CChaletInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CChaletLoraDevice *DevicePtr):
|
||||
CChaletInterface::CChaletInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CChaletDevice *DevicePtr):
|
||||
CNetworkDevice(ID_CHALET_INTERFACE,Address,NetworkInterface)
|
||||
{
|
||||
mChaletLoraDevice = DevicePtr;
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
|
||||
#include "NetworkDevice.h"
|
||||
|
||||
#include "ChaletLoraDevice.h"
|
||||
#include "ChaletDevice.h"
|
||||
|
||||
class CChaletInterface: public QObject, public CNetworkDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
CChaletInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CChaletLoraDevice *DevicePtr);
|
||||
CChaletInterface(int Address, CAbstractNetworkCommIF *NetworkInterface, CChaletDevice *DevicePtr);
|
||||
virtual int NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
|
||||
|
||||
void SendChaletCommActivityBeacon();
|
||||
private:
|
||||
CChaletLoraDevice *mChaletLoraDevice;
|
||||
CChaletDevice *mChaletLoraDevice;
|
||||
CChaletDataLogger *mChaletDataLogger;
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <ModbusBackend.h>
|
||||
|
||||
class CChaletLoraDevice;
|
||||
class CChaletDevice;
|
||||
|
||||
class CChaletModbusServer : public CModbusBackend
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include "ChaletLoraDevice.h"
|
||||
#include "ChaletDevice.h"
|
||||
|
||||
|
||||
CThingsBoardInterface::CThingsBoardInterface()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef THINGSBOARDINTERFACE_H
|
||||
#define THINGSBOARDINTERFACE_H
|
||||
|
||||
class CChaletLoraDevice;
|
||||
class CChaletDevice;
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
CThingsBoardInterface();
|
||||
~CThingsBoardInterface();
|
||||
|
||||
CChaletLoraDevice *mChaletLoraDevice;
|
||||
CChaletDevice *mChaletLoraDevice;
|
||||
|
||||
int RegisterThingsboardRPC();
|
||||
void UpdateChaletVoltage(float Voltage);
|
||||
|
||||
Reference in New Issue
Block a user