diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index 25823dc7..525b0d06 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -3287,6 +3287,7 @@ processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs) if (rc->triggerOps & TRG_OPT_INTEGRITY) { if (rc->intgPd > 0) { + if (currentTimeInMs >= rc->nextIntgReportTime) { /* send current events in event buffer before integrity report */ @@ -3295,12 +3296,24 @@ processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs) rc->triggered = false; } - rc->nextIntgReportTime = currentTimeInMs + rc->intgPd; + rc->nextIntgReportTime = rc->nextIntgReportTime + rc->intgPd; + + /* check for system time change effects */ + if ((rc->nextIntgReportTime < currentTimeInMs) || (rc->nextIntgReportTime > currentTimeInMs + rc->intgPd)) { + rc->nextIntgReportTime = currentTimeInMs + rc->intgPd; + } enqueueReport(rc, true, false, currentTimeInMs); rc->triggered = false; } + else { + /* check for system time change effects */ + if ((rc->nextIntgReportTime < currentTimeInMs) || (rc->nextIntgReportTime > currentTimeInMs + rc->intgPd)) { + rc->nextIntgReportTime = currentTimeInMs + rc->intgPd; + } + + } } }