Set heartbeat on startup. Fix logic in ShmValid
This commit is contained in:
parent
e38e8a2775
commit
46bf765f80
|
@ -410,12 +410,15 @@ public:
|
|||
bool disconnect();
|
||||
|
||||
inline int ShmValid() const {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
return shared_data && shared_data->valid && ((now.tv_sec - shared_data->zmc_heartbeat_time) > config.watch_max_delay);
|
||||
if ( shared_data && shared_data->valid ) {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
if ((now.tv_sec - shared_data->zmc_heartbeat_time) < config.watch_max_delay)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline unsigned int Id() const { return id; }
|
||||
inline const char *Name() const { return name; }
|
||||
inline unsigned int ServerId() { return server_id; }
|
||||
|
@ -520,6 +523,7 @@ public:
|
|||
TriggerState GetTriggerState() const { return trigger_data ? trigger_data->trigger_state : TRIGGER_CANCEL; }
|
||||
inline time_t getStartupTime() const { return shared_data->startup_time; }
|
||||
inline void setStartupTime( time_t p_time ) { shared_data->startup_time = p_time; }
|
||||
inline void setHeartbeatTime( time_t p_time ) { shared_data->zmc_heartbeat_time = p_time; }
|
||||
void get_ref_image();
|
||||
|
||||
int LabelSize() const { return label_size; }
|
||||
|
|
|
@ -245,6 +245,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
time_t now = (time_t)time(nullptr);
|
||||
monitor->setStartupTime(now);
|
||||
monitor->setHeartbeatTime(now);
|
||||
|
||||
snprintf(sql, sizeof(sql),
|
||||
"INSERT INTO Monitor_Status (MonitorId,Status,CaptureFPS,AnalysisFPS)"
|
||||
|
|
Loading…
Reference in New Issue