@@ -10198,78 +10198,83 @@ void MainWorker::HeartbeatCheck()
10198
10198
for (itt = m_hardwaredevices.begin (); itt != m_hardwaredevices.end (); ++itt)
10199
10199
{
10200
10200
CDomoticzHardwareBase *pHardware = (CDomoticzHardwareBase *)(*itt);
10201
- // Skip Dummy Hardware
10202
- bool bDoCheck = (pHardware->HwdType != HTYPE_Dummy) && (pHardware->HwdType != HTYPE_Domoticz) && (pHardware->HwdType != HTYPE_EVOHOME_SCRIPT);
10203
- if (bDoCheck)
10204
- {
10205
- // Check Thread Timeout
10206
- double diff = difftime (now, pHardware->m_LastHeartbeat );
10207
- // _log.Log(LOG_STATUS, "%d last checkin %.2lf seconds ago", iterator->first, dif);
10208
- if (diff > 60 )
10201
+ if (!pHardware->m_bSkipReceiveCheck )
10202
+ {
10203
+ // Skip Dummy Hardware
10204
+ bool bDoCheck = (pHardware->HwdType != HTYPE_Dummy) && (pHardware->HwdType != HTYPE_Domoticz) && (pHardware->HwdType != HTYPE_EVOHOME_SCRIPT);
10205
+ if (bDoCheck)
10209
10206
{
10210
- char szTmp[100 ];
10211
- std::vector<std::vector<std::string> > result;
10212
- sprintf (szTmp, " SELECT Name FROM Hardware WHERE (ID='%d')" , pHardware->m_HwdID );
10213
- result = m_sql.query (szTmp);
10214
- if (result.size () == 1 )
10207
+ // Check Thread Timeout
10208
+ double diff = difftime (now, pHardware->m_LastHeartbeat );
10209
+ // _log.Log(LOG_STATUS, "%d last checkin %.2lf seconds ago", iterator->first, dif);
10210
+ if (diff > 60 )
10215
10211
{
10216
- std::vector<std::string> sd = result[0 ];
10217
- _log.Log (LOG_ERROR, " %s hardware (%d) thread seems to have ended unexpectedly" , sd[0 ].c_str (), pHardware->m_HwdID );
10212
+ char szTmp[100 ];
10213
+ std::vector<std::vector<std::string> > result;
10214
+ sprintf (szTmp, " SELECT Name FROM Hardware WHERE (ID='%d')" , pHardware->m_HwdID );
10215
+ result = m_sql.query (szTmp);
10216
+ if (result.size () == 1 )
10217
+ {
10218
+ std::vector<std::string> sd = result[0 ];
10219
+ _log.Log (LOG_ERROR, " %s hardware (%d) thread seems to have ended unexpectedly" , sd[0 ].c_str (), pHardware->m_HwdID );
10220
+ }
10218
10221
}
10219
10222
}
10220
- }
10221
- if ((!pHardware->m_bSkipReceiveCheck ) && (pHardware->m_DataTimeout >0 ))
10222
- {
10223
- // Check Receive Timeout
10224
- double diff = difftime (now, pHardware->m_LastHeartbeatReceive );
10225
- if (diff > pHardware->m_DataTimeout )
10223
+
10224
+ if (pHardware->m_DataTimeout > 0 )
10226
10225
{
10227
- char szTmp[100 ];
10228
- std::vector<std::vector<std::string> > result;
10229
- sprintf (szTmp, " SELECT Name FROM Hardware WHERE (ID='%d')" , pHardware->m_HwdID );
10230
- result = m_sql.query (szTmp);
10231
- if (result.size () == 1 )
10226
+ // Check Receive Timeout
10227
+ double diff = difftime (now, pHardware->m_LastHeartbeatReceive );
10228
+ if (diff > pHardware->m_DataTimeout )
10232
10229
{
10233
- std::vector<std::string> sd = result[0 ];
10230
+ char szTmp[100 ];
10231
+ std::vector<std::vector<std::string> > result;
10232
+ sprintf (szTmp, " SELECT Name FROM Hardware WHERE (ID='%d')" , pHardware->m_HwdID );
10233
+ result = m_sql.query (szTmp);
10234
+ if (result.size () == 1 )
10235
+ {
10236
+ std::vector<std::string> sd = result[0 ];
10234
10237
10235
- std::string sDataTimeout = " " ;
10236
- int totNum = 0 ;
10237
- if (pHardware->m_DataTimeout < 60 ) {
10238
- totNum = pHardware->m_DataTimeout ;
10239
- sDataTimeout = " Seconds" ;
10240
- }
10241
- else if (pHardware->m_DataTimeout < 3600 ) {
10242
- totNum = pHardware->m_DataTimeout / 60 ;
10243
- if (totNum == 1 ) {
10244
- sDataTimeout = " Minute" ;
10245
- }
10246
- else {
10247
- sDataTimeout = " Minutes" ;
10248
- }
10249
- }
10250
- else if (pHardware->m_DataTimeout < 86400 ) {
10251
- totNum = pHardware->m_DataTimeout / 3600 ;
10252
- if (totNum == 1 ) {
10253
- sDataTimeout = " Hour" ;
10238
+ std::string sDataTimeout = " " ;
10239
+ int totNum = 0 ;
10240
+ if (pHardware->m_DataTimeout < 60 ) {
10241
+ totNum = pHardware->m_DataTimeout ;
10242
+ sDataTimeout = " Seconds" ;
10254
10243
}
10255
- else {
10256
- sDataTimeout = " Hours" ;
10244
+ else if (pHardware->m_DataTimeout < 3600 ) {
10245
+ totNum = pHardware->m_DataTimeout / 60 ;
10246
+ if (totNum == 1 ) {
10247
+ sDataTimeout = " Minute" ;
10248
+ }
10249
+ else {
10250
+ sDataTimeout = " Minutes" ;
10251
+ }
10257
10252
}
10258
- }
10259
- else {
10260
- totNum = pHardware->m_DataTimeout / 60 ;
10261
- if (totNum == 1 ) {
10262
- sDataTimeout = " Day" ;
10253
+ else if (pHardware->m_DataTimeout < 86400 ) {
10254
+ totNum = pHardware->m_DataTimeout / 3600 ;
10255
+ if (totNum == 1 ) {
10256
+ sDataTimeout = " Hour" ;
10257
+ }
10258
+ else {
10259
+ sDataTimeout = " Hours" ;
10260
+ }
10263
10261
}
10264
10262
else {
10265
- sDataTimeout = " Days" ;
10263
+ totNum = pHardware->m_DataTimeout / 60 ;
10264
+ if (totNum == 1 ) {
10265
+ sDataTimeout = " Day" ;
10266
+ }
10267
+ else {
10268
+ sDataTimeout = " Days" ;
10269
+ }
10266
10270
}
10267
- }
10268
10271
10269
- _log.Log (LOG_ERROR, " %s hardware (%d) nothing received for more then %d %s!...." , sd[0 ].c_str (), pHardware->m_HwdID ,totNum,sDataTimeout .c_str ());
10270
- m_devicestorestart.push_back (pHardware->m_HwdID );
10272
+ _log.Log (LOG_ERROR, " %s hardware (%d) nothing received for more then %d %s!...." , sd[0 ].c_str (), pHardware->m_HwdID , totNum, sDataTimeout .c_str ());
10273
+ m_devicestorestart.push_back (pHardware->m_HwdID );
10274
+ }
10271
10275
}
10272
10276
}
10277
+
10273
10278
}
10274
10279
}
10275
10280
}
0 commit comments