Set cause = LINKED_CAUSE regardless of whether we are in an event, as we may be ending an idle event to start a new one. Use MonitorLinkExpression.result to get score from the expression instead of just using 20. Imrpove logic around close events to prevent them from lasting too long

This commit is contained in:
Isaac Connor
2024-01-22 12:30:32 -05:00
parent 44862adb8a
commit d81b98da25

View File

@@ -2063,18 +2063,16 @@ bool Monitor::Analyse() {
} // end if linked_monitors
#else
if (linked_monitors) {
bool eval = linked_monitors->evaluate();
Debug(4, "evaluate %d", eval ? 1 : 0);
if (eval) {
if (!event) {
if (cause.length())
cause += ", ";
cause += LINKED_CAUSE;
}
//bool eval = linked_monitors->evaluate();
MonitorLinkExpression::Result result = linked_monitors->result();
if (result.score > 0) {
if (cause.length())
cause += ", ";
cause += LINKED_CAUSE;
//Event::StringSet noteSet;
//noteSet.insert(linked_monitors[i]->Name());
//score += linked_monitors->score();
score += 20;
score += result.score;
}
} else {
Debug(4, "Not linked_monitors");
@@ -2239,7 +2237,7 @@ bool Monitor::Analyse() {
} else {
shared_data->state = state = TAPE;
}
Info("%s: %03d - Left alert state (%" PRIu64 ") - %d(%d) images",
Info("%s: %03d - Left alert state event id:%" PRIu64 " event frames:%d alarm frames:%d",
name.c_str(), analysis_image_count, event->Id(), event->Frames(), event->AlarmFrames());
} else {
shared_data->state = state = IDLE;
@@ -2287,10 +2285,10 @@ bool Monitor::Analyse() {
if (event_close_mode == CLOSE_ALARM) {
if (state == ALARM) {
// If we should end then previous continuous event and start a new non-continuous event
if (event->Frames() && (event->AlarmFrames() < alarm_frame_count)) {
Info("%s: %03d - Closing event %" PRIu64 ", continuous end, alarm begins",
name.c_str(), snap->image_index, event->Id());
// If we should end the previous continuous event and start a new non-continuous event
if (event->AlarmFrames() < alarm_frame_count) {
Info("%s: %03d - Closing event %" PRIu64 ", continuous end, alarm begins. Event alarm frames %d < alarm_frame_count %d",
name.c_str(), snap->image_index, event->Id(), event->AlarmFrames(), alarm_frame_count);
closeEvent();
}
} else if (state == IDLE) {
@@ -2325,7 +2323,7 @@ bool Monitor::Analyse() {
closeEvent();
}
} else if (event_close_mode == CLOSE_IDLE) {
if (state == IDLE) {
if (state == IDLE and std::chrono::duration_cast<Seconds>(snap->timestamp.time_since_epoch()) % section_length == Seconds(0)) {
Info("%s: %03d - Closing event %" PRIu64 ", section end forced %" PRIi64 " - %" PRIi64 " = %" PRIi64 " >= %" PRIi64 ,
name.c_str(),
snap->image_index,