make max_score an int to get rid of the casts. Move assignment of it above the event UPDATE sql so that it is immediately accurate.
This commit is contained in:
parent
a76128e9c4
commit
e2a81cc2c5
|
@ -55,7 +55,7 @@ Event::Event(
|
|||
alarm_frames(0),
|
||||
alarm_frame_written(false),
|
||||
tot_score(0),
|
||||
max_score(0),
|
||||
max_score(-1),
|
||||
//path(""),
|
||||
//snapshit_file(),
|
||||
//alarm_file(""),
|
||||
|
@ -486,12 +486,12 @@ void Event::AddFrame(Image *image,
|
|||
|
||||
Debug(1, "frames %d, score %d max_score %d", frames, score, max_score);
|
||||
// If this is the first frame, we should add a thumbnail to the event directory
|
||||
if ((frames == 1) || (score > (int)max_score)) {
|
||||
if ((frames == 1) || (score > max_score)) {
|
||||
write_to_db = true; // web ui might show this as thumbnail, so db needs to know about it.
|
||||
Debug(1, "Writing snapshot");
|
||||
WriteFrameImage(image, timestamp, snapshot_file.c_str());
|
||||
} else {
|
||||
Debug(1, "Not Writing snapshot because score %d > max %d", score, max_score);
|
||||
Debug(1, "Not Writing snapshot because frames %d score %d > max %d", frames, score, max_score);
|
||||
}
|
||||
|
||||
// We are writing an Alarm frame
|
||||
|
@ -523,11 +523,15 @@ void Event::AddFrame(Image *image,
|
|||
bool db_frame = ( frame_type == BULK )
|
||||
or ( frame_type == ALARM )
|
||||
or ( frames == 1 )
|
||||
or ( score > (int)max_score )
|
||||
or ( score > max_score )
|
||||
or ( monitor_state == Monitor::ALERT )
|
||||
or ( monitor_state == Monitor::ALARM )
|
||||
or ( monitor_state == Monitor::PREALARM );
|
||||
|
||||
if (score > max_score) {
|
||||
max_score = score;
|
||||
}
|
||||
|
||||
if (db_frame) {
|
||||
Microseconds delta_time = std::chrono::duration_cast<Microseconds>(timestamp - start_time);
|
||||
Debug(1, "Frame delta is %.2f s - %.2f s = %.2f s, score %u zone_stats.size %zu",
|
||||
|
@ -568,9 +572,6 @@ void Event::AddFrame(Image *image,
|
|||
} // end if frame_type == BULK
|
||||
} // end if db_frame
|
||||
|
||||
if (score > (int) max_score) {
|
||||
max_score = score;
|
||||
}
|
||||
end_time = timestamp;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ class Event {
|
|||
int frames;
|
||||
int alarm_frames;
|
||||
bool alarm_frame_written;
|
||||
unsigned int tot_score;
|
||||
unsigned int max_score;
|
||||
int tot_score;
|
||||
int max_score;
|
||||
std::string path;
|
||||
std::string snapshot_file;
|
||||
std::string alarm_file;
|
||||
|
|
Loading…
Reference in New Issue