|
|
|
@ -143,6 +143,20 @@ ReportControl_unlockNotify(ReportControl* self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
purgeBuf(ReportControl* rc)
|
|
|
|
|
{
|
|
|
|
|
if (DEBUG_IED_SERVER) printf("IED_SERVER: reporting.c: run purgeBuf\n");
|
|
|
|
|
|
|
|
|
|
ReportBuffer* reportBuffer = rc->reportBuffer;
|
|
|
|
|
|
|
|
|
|
reportBuffer->lastEnqueuedReport = NULL;
|
|
|
|
|
reportBuffer->oldestReport = NULL;
|
|
|
|
|
reportBuffer->nextToTransmit = NULL;
|
|
|
|
|
reportBuffer->reportsCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
deleteDataSetValuesShadowBuffer(ReportControl* self)
|
|
|
|
|
{
|
|
|
|
@ -496,6 +510,11 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet,
|
|
|
|
|
if (strcmp(MmsValue_toString(newDatSet), "") == 0) {
|
|
|
|
|
success = true;
|
|
|
|
|
dataSetValue = NULL;
|
|
|
|
|
|
|
|
|
|
if (rc->buffered) {
|
|
|
|
|
rc->isBuffering = false;
|
|
|
|
|
purgeBuf(rc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
dataSetValue = newDatSet;
|
|
|
|
@ -670,19 +689,6 @@ refreshTriggerOptions(ReportControl* rc)
|
|
|
|
|
rc->triggerOps += TRG_OPT_GI;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
purgeBuf(ReportControl* rc)
|
|
|
|
|
{
|
|
|
|
|
if (DEBUG_IED_SERVER) printf("IED_SERVER: reporting.c: run purgeBuf\n");
|
|
|
|
|
|
|
|
|
|
ReportBuffer* reportBuffer = rc->reportBuffer;
|
|
|
|
|
|
|
|
|
|
reportBuffer->lastEnqueuedReport = NULL;
|
|
|
|
|
reportBuffer->oldestReport = NULL;
|
|
|
|
|
reportBuffer->nextToTransmit = NULL;
|
|
|
|
|
reportBuffer->reportsCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
refreshIntegrityPeriod(ReportControl* rc)
|
|
|
|
|
{
|
|
|
|
@ -1730,7 +1736,7 @@ enqueueReport(ReportControl* reportControl, bool isIntegrity, bool isGI, uint64_
|
|
|
|
|
if (DEBUG_IED_SERVER)
|
|
|
|
|
printf("IED_SERVER: enqueueReport: report buffer too small for report entry! Skip event!\n");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
goto exit_function;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isGI) removeAllGIReportsFromReportBuffer(buffer);
|
|
|
|
@ -1738,7 +1744,7 @@ enqueueReport(ReportControl* reportControl, bool isIntegrity, bool isGI, uint64_
|
|
|
|
|
uint8_t* entryBufPos = NULL;
|
|
|
|
|
uint8_t* entryStartPos;
|
|
|
|
|
|
|
|
|
|
//if (DEBUG_IED_SERVER)
|
|
|
|
|
if (DEBUG_IED_SERVER)
|
|
|
|
|
printf("IED_SERVER: number of buffered reports:%i\n", buffer->reportsCount);
|
|
|
|
|
|
|
|
|
|
if (buffer->lastEnqueuedReport == NULL) { /* buffer is empty - we start at the beginning of the memory block */
|
|
|
|
@ -2007,7 +2013,10 @@ enqueueReport(ReportControl* reportControl, bool isIntegrity, bool isGI, uint64_
|
|
|
|
|
buffer->oldestReport = buffer->lastEnqueuedReport;
|
|
|
|
|
|
|
|
|
|
reportControl->lastEntryId = entryId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit_function:
|
|
|
|
|
return;
|
|
|
|
|
} /* enqueuReport() */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
sendNextReportEntry(ReportControl* self)
|
|
|
|
@ -2029,11 +2038,11 @@ sendNextReportEntry(ReportControl* self)
|
|
|
|
|
|
|
|
|
|
ReportBufferEntry* report = self->reportBuffer->nextToTransmit;
|
|
|
|
|
|
|
|
|
|
//#if (DEBUG_IED_SERVER == 1)
|
|
|
|
|
#if (DEBUG_IED_SERVER == 1)
|
|
|
|
|
printf("IED_SERVER: SEND NEXT REPORT: ");
|
|
|
|
|
//printReportId(report);
|
|
|
|
|
printReportId(report);
|
|
|
|
|
printf(" size: %i\n", report->entryLength);
|
|
|
|
|
//#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MmsValue* entryIdValue = MmsValue_getElement(self->rcbValues, 11);
|
|
|
|
|
MmsValue_setOctetString(entryIdValue, (uint8_t*) report->entryId, 8);
|
|
|
|
@ -2356,6 +2365,7 @@ cleanup_and_return:
|
|
|
|
|
|
|
|
|
|
if (localStorage != NULL)
|
|
|
|
|
GLOBAL_FREEMEM(localStorage);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@ -2378,11 +2388,13 @@ Reporting_activateBufferedReports(MmsMapping* self)
|
|
|
|
|
static void
|
|
|
|
|
processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((rc->enabled) || (rc->isBuffering)) {
|
|
|
|
|
|
|
|
|
|
if (rc->triggerOps & TRG_OPT_GI) {
|
|
|
|
|
if (rc->gi) {
|
|
|
|
|
printf("rc->gi\n");
|
|
|
|
|
|
|
|
|
|
/* send current events in event buffer before GI report */
|
|
|
|
|
if (rc->triggered) {
|
|
|
|
|
if (rc->buffered)
|
|
|
|
@ -2408,12 +2420,9 @@ processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs)
|
|
|
|
|
|
|
|
|
|
if (rc->intgPd > 0) {
|
|
|
|
|
if (currentTimeInMs >= rc->nextIntgReportTime) {
|
|
|
|
|
printf("integrity\n");
|
|
|
|
|
|
|
|
|
|
/* send current events in event buffer before integrity report */
|
|
|
|
|
if (rc->triggered) {
|
|
|
|
|
|
|
|
|
|
printf("intg check triggered\n");
|
|
|
|
|
|
|
|
|
|
if (rc->buffered)
|
|
|
|
|
enqueueReport(rc, false, false, currentTimeInMs);
|
|
|
|
|
else
|
|
|
|
@ -2437,8 +2446,6 @@ processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs)
|
|
|
|
|
if (rc->triggered) {
|
|
|
|
|
if (currentTimeInMs >= rc->reportTime) {
|
|
|
|
|
|
|
|
|
|
printf("triggered\n");
|
|
|
|
|
|
|
|
|
|
if (rc->buffered)
|
|
|
|
|
enqueueReport(rc, false, false, currentTimeInMs);
|
|
|
|
|
else
|
|
|
|
@ -2450,8 +2457,9 @@ processEventsForReport(ReportControl* rc, uint64_t currentTimeInMs)
|
|
|
|
|
|
|
|
|
|
if (rc->buffered && rc->enabled)
|
|
|
|
|
sendNextReportEntry(rc);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|