From 7215756fed4a428e0514e9173114a1703cbc6f68 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 3 Jan 2022 19:03:04 -0500 Subject: [PATCH] Introduce a method update the noteSetMap after event creation (addNote). --- src/zm_event.cpp | 4 ++++ src/zm_event.h | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index f927eac5c..7db8f84f3 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -291,6 +291,10 @@ void Event::createNotes(std::string ¬es) { } } // void Event::createNotes(std::string ¬es) +void Event::addNote(const char *cause, const std::string ¬e) { + noteSetMap[cause].insert(note); +} + bool Event::WriteFrameImage(Image *image, SystemTimePoint timestamp, const char *event_file, bool alarm_frame) const { int thisquality = (alarm_frame && (config.jpeg_alarm_file_quality > config.jpeg_file_quality)) ? diff --git a/src/zm_event.h b/src/zm_event.h index a26c029b5..4fb5c7469 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -110,6 +110,7 @@ class Event { uint64_t Id() const { return id; } const std::string &Cause() const { return cause; } + void addNote(const char *cause, const std::string ¬e); int Frames() const { return frames; } int AlarmFrames() const { return alarm_frames; } @@ -123,7 +124,7 @@ class Event { void updateNotes(const StringSetMap &stringSetMap); - void AddFrame(Image *image, + void AddFrame(Image *image, SystemTimePoint timestamp, const std::vector &stats, int score = 0, @@ -134,17 +135,17 @@ class Event { bool SetPath(Storage *storage); public: - static std::string getSubPath(tm time) { - std::string subpath = stringtf("%02d/%02d/%02d/%02d/%02d/%02d", - time.tm_year - 100, time.tm_mon + 1, time.tm_mday, - time.tm_hour, time.tm_min, time.tm_sec); - return subpath; - } - static std::string getSubPath(time_t *time) { - tm time_tm = {}; - localtime_r(time, &time_tm); - return Event::getSubPath(time_tm); - } + static std::string getSubPath(tm time) { + std::string subpath = stringtf("%02d/%02d/%02d/%02d/%02d/%02d", + time.tm_year - 100, time.tm_mon + 1, time.tm_mday, + time.tm_hour, time.tm_min, time.tm_sec); + return subpath; + } + static std::string getSubPath(time_t *time) { + tm time_tm = {}; + localtime_r(time, &time_tm); + return Event::getSubPath(time_tm); + } const char* getEventFile() const { return video_file.c_str();