Skip to content

Commit 145cf64

Browse files
committed
Skip thread check for 1Wire
1 parent ae8709b commit 145cf64

File tree

2 files changed

+64
-58
lines changed

2 files changed

+64
-58
lines changed

hardware/1Wire.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ C1Wire::C1Wire(const int ID) :
2929
m_stoprequested(false),
3030
m_system(NULL)
3131
{
32+
m_bSkipReceiveCheck = true;
3233
m_HwdID=ID;
33-
DetectSystem();
34+
DetectSystem();
3435
}
3536

3637
C1Wire::~C1Wire()

main/mainworker.cpp

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10198,78 +10198,83 @@ void MainWorker::HeartbeatCheck()
1019810198
for (itt = m_hardwaredevices.begin(); itt != m_hardwaredevices.end(); ++itt)
1019910199
{
1020010200
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)
1020910206
{
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)
1021510211
{
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+
}
1021810221
}
1021910222
}
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)
1022610225
{
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)
1023210229
{
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];
1023410237

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";
1025410243
}
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+
}
1025710252
}
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+
}
1026310261
}
1026410262
else {
10265-
sDataTimeout = "Days";
10263+
totNum = pHardware->m_DataTimeout / 60;
10264+
if (totNum == 1) {
10265+
sDataTimeout = "Day";
10266+
}
10267+
else {
10268+
sDataTimeout = "Days";
10269+
}
1026610270
}
10267-
}
1026810271

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+
}
1027110275
}
1027210276
}
10277+
1027310278
}
1027410279
}
1027510280
}

0 commit comments

Comments
 (0)