Développements
ajout status de comm dans get statud
This commit is contained in:
@@ -13,6 +13,9 @@ CChaletMainStatus::CChaletMainStatus()
|
||||
mStatusToggleBit = 0;
|
||||
mLostRequestPercentage = 0;
|
||||
mChaletTemperature = -100;
|
||||
mTotalNbChaletRxCmds = 0;
|
||||
mTotalNbMasterTxCmds = 0;
|
||||
mMasterLostRequestCount = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +62,9 @@ QByteArray CChaletMainStatus::ToByteArray()
|
||||
Strm << mLastLoraStatus;
|
||||
Strm << mStatusToggleBit;
|
||||
Strm << mChaletTemperature;
|
||||
Strm << mTotalNbChaletRxCmds;
|
||||
Strm << mTotalNbMasterTxCmds;
|
||||
Strm << mMasterLostRequestCount;
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ public:
|
||||
|
||||
float mChaletTemperature;
|
||||
|
||||
int mTotalNbChaletRxCmds;
|
||||
int mTotalNbMasterTxCmds;
|
||||
int mMasterLostRequestCount;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -110,6 +110,14 @@ int CChaletInterface::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, in
|
||||
case CHALET_INTERFACE_GET_FIRMWARE_VERSION_REQUEST:
|
||||
{
|
||||
mChaletLoraDevice->SendGetFirmwareVersion();
|
||||
break;
|
||||
}
|
||||
case CHALET_INTERFACE_CLEAR_COMMS_STATS_REQUEST:
|
||||
{
|
||||
|
||||
mChaletLoraDevice->SendClearCommStatsRequest();
|
||||
// mChaletLoraDevice->ResetCommStats();
|
||||
break;
|
||||
}
|
||||
case CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_RESPONSE:
|
||||
case CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_RESPONSE:
|
||||
@@ -120,6 +128,7 @@ int CChaletInterface::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, in
|
||||
case CHALET_INTERFACE_AC_POWER_SET_STATE_RESPONSE:
|
||||
case CHALET_INTERFACE_BATTERY_VOLTAGE_RESPONSE:
|
||||
case CHALET_INTERFACE_WIFI_SET_STATE_RESPONSE:
|
||||
case CHALET_INTERFACE_CLEAR_COMMS_STATS_RESPONSE:
|
||||
{
|
||||
break;
|
||||
|
||||
|
||||
@@ -57,9 +57,11 @@ int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, i
|
||||
{
|
||||
float temp;
|
||||
qint16 temp2;
|
||||
quint32 temp3;
|
||||
// qDebug("Chalet Status RX");
|
||||
char VoltageArray[4];
|
||||
char TemperatureArray[4];
|
||||
char TotalRequestsArray[4];
|
||||
char SolarPanelCurrentArray[2];
|
||||
char BatterySOCArray[2];
|
||||
|
||||
@@ -91,6 +93,13 @@ int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, i
|
||||
memcpy(&temp,TemperatureArray,4);
|
||||
mChaletMainStatus.mChaletTemperature = temp;
|
||||
|
||||
TotalRequestsArray[0] = Data[14];
|
||||
TotalRequestsArray[1] = Data[15];
|
||||
TotalRequestsArray[2] = Data[16];
|
||||
TotalRequestsArray[3] = Data[17];
|
||||
memcpy(&temp3,TotalRequestsArray,4);
|
||||
mChaletMainStatus.mTotalNbChaletRxCmds = temp3;
|
||||
|
||||
mChaletMainStatus.mStatusToggleBit = !mChaletMainStatus.mStatusToggleBit;
|
||||
mChaletMainStatus.mLastLoraStatus = QDateTime::currentDateTime();
|
||||
|
||||
@@ -99,6 +108,7 @@ int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, i
|
||||
// qDebug("Current: %d",mChaletMainStatus.mBatteryCurrent);
|
||||
// qDebug("SOC: %d",mChaletMainStatus.mBatterySOC);
|
||||
// qDebug("Inverter: %d",mChaletMainStatus.mInverterRelayStatus);
|
||||
// qDebug("Chalet Rx Nb Cmd: %d",mChaletMainStatus.mTotalNbChaletRxCmds);
|
||||
|
||||
mChaletDataLogger.LogChaletLORAData(&mChaletMainStatus);
|
||||
|
||||
@@ -218,6 +228,12 @@ int CChaletLoraDevice::NewDeviceFrameReceived(int DeviceID, int DeviceAddress, i
|
||||
emit DeviceFirmwareVersionReceived();
|
||||
break;
|
||||
}
|
||||
case CHALET_CLEAR_COMMS_STATISTICS_RESPONSE:
|
||||
{
|
||||
ResetCommStats();
|
||||
CmdResponseReceived(CHALET_CLEAR_COMMS_STATISTICS_REQUEST);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
@@ -257,6 +273,7 @@ void CChaletLoraDevice::CommTimerExpired()
|
||||
}
|
||||
mPendingNetworkMsgList[0].ResendCounter++;
|
||||
mNbLostRequest++;
|
||||
mChaletMainStatus.mMasterLostRequestCount = mNbLostRequest;
|
||||
ComputeCommStats();
|
||||
}
|
||||
|
||||
@@ -265,6 +282,7 @@ void CChaletLoraDevice::CommTimerExpired()
|
||||
mPendingNetworkMsgList[0].PendingResponse = true;
|
||||
SendChaletCommand(mPendingNetworkMsgList.at(0).mMessageID,mPendingNetworkMsgList.at(0).mData.size(),mPendingNetworkMsgList.at(0).mData);
|
||||
|
||||
|
||||
//Harakiri and Reboot commands should not stay in the queue...
|
||||
if(mPendingNetworkMsgList.at(0).mMessageID == CHALET_DO_HARAKIRI_REQUEST ||
|
||||
mPendingNetworkMsgList.at(0).mMessageID == CHALET_REBOOT_CPU_REQUEST)
|
||||
@@ -347,10 +365,16 @@ int CChaletLoraDevice::SendGetFirmwareVersion()
|
||||
return ScheduleChaletCommand(CHALET_GET_FIRMWARE_VERSION_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendClearCommStatsRequest()
|
||||
{
|
||||
return ScheduleChaletCommand(CHALET_CLEAR_COMMS_STATISTICS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChaletLoraDevice::SendChaletCommand(int CmdID, int DataSize, QByteArray Data)
|
||||
{
|
||||
mNetworkInterfacePtr->SendNetworkMessage(ID_CHALET_DEVICE,mDeviceAddress,CmdID,DataSize,&Data);
|
||||
mTotalNbRequest++;
|
||||
mChaletMainStatus.mTotalNbMasterTxCmds++;
|
||||
ComputeCommStats();
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -445,6 +469,8 @@ int CChaletLoraDevice::ResetCommStats()
|
||||
mLostRequestPercentage = 0.0;
|
||||
mTotalNbRequest = 0;
|
||||
mNbLostRequest = 0;
|
||||
mChaletMainStatus.mTotalNbMasterTxCmds = 0;
|
||||
mChaletMainStatus.mMasterLostRequestCount = 0;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
int SendGetWifiParams();
|
||||
int SendSetWifiParams(QByteArray Data);
|
||||
int SendGetFirmwareVersion();
|
||||
int SendClearCommStatsRequest();
|
||||
|
||||
int CmdResponseReceived(int CmdID);
|
||||
int ScheduleChaletStatusRequest();
|
||||
|
||||
@@ -136,7 +136,7 @@ void CThingsBoardInterface::ThingsBoardServerFinished(QNetworkReply *NetworkRepl
|
||||
|
||||
if(NetworkReply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
qDebug("Network error... %d", NetworkReply->error());
|
||||
// qDebug("Network error... %d", NetworkReply->error());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user