From 2a0843fd21a43eb7f4fb5df36961dfcd2143901e Mon Sep 17 00:00:00 2001 From: Mr-Dave Date: Mon, 2 Jan 2023 15:39:36 -0700 Subject: [PATCH] Add eventid --- doc/motionplus_config.html | 4 ++-- src/motion_loop.cpp | 8 ++++++++ src/motionplus.hpp | 2 +- src/util.cpp | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/motionplus_config.html b/doc/motionplus_config.html index 439b2e13..945c8444 100644 --- a/doc/motionplus_config.html +++ b/doc/motionplus_config.html @@ -614,8 +614,8 @@ threshold %Q Number of labels from despeckle - %{dbeventid} - See sql_query_start + %{eventid} + Unique identifier for event (cam id + date/time) %$ diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 4ce03670..723d5e05 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -182,6 +182,9 @@ static void mlp_info_reset(ctx_cam *cam) /* Process the motion detected items*/ static void mlp_detected_trigger(ctx_cam *cam, ctx_image_data *img) { + time_t raw_time; + struct tm evt_tm; + if (img->flags & IMAGE_TRIGGER) { if (cam->event_nr != cam->prev_event) { mlp_info_reset(cam); @@ -191,6 +194,11 @@ static void mlp_detected_trigger(ctx_cam *cam, ctx_image_data *img) cam->algsec->isdetected = false; } + time(&raw_time); + localtime_r(&raw_time, &evt_tm); + sprintf(cam->eventid, "%05d", cam->camera_id); + strftime(cam->eventid+5, 15, "%Y%m%d%H%M%S", &evt_tm); + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Motion detected - starting event %d"), cam->event_nr); diff --git a/src/motionplus.hpp b/src/motionplus.hpp index cbf8ceec..07700d73 100644 --- a/src/motionplus.hpp +++ b/src/motionplus.hpp @@ -349,7 +349,7 @@ struct ctx_cam { int event_nr; int prev_event; - unsigned long long database_event_id; + char eventid[20]; /* Cam ID + Date/Time 99999yyyymmddhhmmss */ char text_event_string[PATH_MAX]; /* The text for conv. spec. %C - */ int text_scale; diff --git a/src/util.cpp b/src/util.cpp index fca5a531..12894d64 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -274,8 +274,8 @@ static void mystrftime_long (const ctx_cam *cam, sprintf(out, "%*d", width, cam->movie_fps); return; } - if (SPECIFIERWORD("dbeventid")) { - sprintf(out, "%*llu", width, cam->database_event_id); + if (SPECIFIERWORD("eventid")) { + sprintf(out, "%*s", width, cam->eventid); return; } if (SPECIFIERWORD("ver")) {