95 lines
2.8 KiB
C++
95 lines
2.8 KiB
C++
#ifndef CCHALETLORADEVICE_H
|
|
#define CCHALETLORADEVICE_H
|
|
#include <QByteArray>
|
|
#include <QObject>
|
|
#include <QSerialPort>
|
|
#include "LoraNetworkCommIF.h"
|
|
#include "NetworkDevice.h"
|
|
#include <QTimer>
|
|
#include "ChaletData.h"
|
|
#include "ChaletNetworkMessage.h"
|
|
#include <QList>
|
|
#include "BlynkCloudClient.h"
|
|
#include "ChaletDataLogger.h"
|
|
#include "ChaletUbidotsInterface.h"
|
|
#include "ThingsBoardInterface.h"
|
|
#include "ChaletModbusServer.h"
|
|
#include "ModbusRepository.h"
|
|
|
|
|
|
#define LORA_MAGIC_WORD 0xBAADCAFE
|
|
#define LORA_NORMAL_REQUEST_TIMEOUT 3000
|
|
#define LORA_IMMEDIATE_REQUEST_TIMEOUT 300
|
|
#define LORA_RETRY_REQUEST_TIMEOUT 2000
|
|
#define LORA_RESPONSE_TIME_TIMEOUT 3000
|
|
|
|
#define LORA_CHALET_STATUS_POWER_RELAY_MASK 0x01
|
|
#define LORA_CHALET_STATUS_CUR_SENSOR_MASK 0x02
|
|
|
|
class CChaletLoraDevice : public QObject, public CNetworkDevice
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CChaletLoraDevice(int Address,CAbstractNetworkCommIF *NetworkInterface);
|
|
~CChaletLoraDevice();
|
|
|
|
virtual int NewDeviceFrameReceived(int DeviceID, int DeviceAddress, int MessageID, int DataSize, QByteArray Data);
|
|
|
|
QTimer *mChaletStatusTimer;
|
|
int Start();
|
|
|
|
CChaletMainStatus GetChaletMainStatus() {return mChaletMainStatus;}
|
|
QByteArray GetDeviceWiFiStoredParams() {return mDeviceWiFiParameters;}
|
|
QByteArray GetDeviceFirmwareVersion() {return mDeviceFirmwareVersion;}
|
|
CBlynkCloudClient mBlynkInterface;
|
|
CThingsBoardInterface mThingsBoardInterface;
|
|
CChaletModbusServer *mChaletModbusServer;
|
|
CModbusRepository mChaletModbusRepo;
|
|
|
|
CChaletMainStatus mChaletMainStatus;
|
|
QList<CChaletNetworkMessage> mPendingNetworkMsgList;
|
|
CChaletDataLogger mChaletDataLogger;
|
|
CChaletJFUbidotsInterface *mJFUbidotsInterface;
|
|
|
|
unsigned long long int mNbLostRequest, mTotalNbRequest;
|
|
float mLostRequestPercentage;
|
|
|
|
CChaletDataLogger *GetDataLoggerHandle() {return &mChaletDataLogger;} //for Interface use...
|
|
|
|
QByteArray mDeviceWiFiParameters;
|
|
QByteArray mDeviceFirmwareVersion;
|
|
|
|
|
|
|
|
int SendWiFiModuleSetState(bool State);
|
|
int SendInverterPowerRelayState(bool State);
|
|
int SendDOHarakiri();
|
|
int SendRebootCmd();
|
|
int SendChaletCommand(int CmdID,int DataSize, QByteArray Data);
|
|
int ResetCommStats();
|
|
int ComputeCommStats();
|
|
int SendGetWifiParams();
|
|
int SendSetWifiParams(QByteArray Data);
|
|
int SendGetFirmwareVersion();
|
|
int SendClearCommStatsRequest();
|
|
|
|
int CmdResponseReceived(int CmdID);
|
|
int ScheduleChaletStatusRequest();
|
|
int ScheduleChaletCommand(int CmdID, int DataSize, QByteArray Data);
|
|
int ScheduleChaletCommand(int CmdID,QByteArray Data);
|
|
|
|
bool IsInverterON(){return mChaletMainStatus.mInverterRelayStatus == 1;}
|
|
|
|
signals:
|
|
void DeviceWifiStoredParamsReceived();
|
|
void DeviceWifiSetParamsResult(char);
|
|
void DeviceFirmwareVersionReceived();
|
|
|
|
public slots:
|
|
void CommTimerExpired();
|
|
|
|
};
|
|
|
|
#endif // CCHALETLORADEVICE_H
|