- started programming logging trigger logic

pull/6/head
Michael Zillgith 9 years ago
parent 2a96d5b40c
commit 4b3a9dc850

@ -28,8 +28,10 @@
typedef struct {
char* name;
LogControlBlock* logControlBlock;
MmsMapping* mmsMapping;
DataSet* dataSet;
char* dataSetRef;
LogicalNode* logicalNode;
MmsDomain* domain;
@ -37,6 +39,7 @@ typedef struct {
MmsValue* mmsValue;
MmsVariableSpecification* mmsType;
bool enabled;
int triggerOps;
@ -44,7 +47,7 @@ typedef struct {
} LogControl;
LogControl*
LogControl_create(LogicalNode* parentLN);
LogControl_create(LogicalNode* parentLN, MmsMapping* mmsMapping);
void
LogControl_destroy(LogControl* self);

@ -1,7 +1,7 @@
/*
* mms_mapping.h
*
* Copyright 2013, 2014 Michael Zillgith
* Copyright 2013-2016 Michael Zillgith
*
* This file is part of libIEC61850.
*
@ -25,7 +25,6 @@
#define MMS_MAPPING_H_
#include "iec61850_model.h"
//#include "mms_server_connection.h"
#include "mms_device_model.h"
#include "control.h"
@ -36,6 +35,13 @@ typedef enum {
REPORT_CONTROL_QUALITY_CHANGED
} ReportInclusionFlag;
typedef enum {
LOG_CONTROL_NONE,
LOG_CONTROL_VALUE_UPDATE,
LOG_CONTROL_VALUE_CHANGED,
LOG_CONTROL_QUALITY_CHANGED
} LogInclusionFlag;
typedef struct sMmsMapping MmsMapping;
MmsMapping*
@ -86,6 +92,9 @@ MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableLi
void
MmsMapping_triggerReportObservers(MmsMapping* self, MmsValue* value, ReportInclusionFlag flag);
void
MmsMapping_triggerLogging(MmsMapping* self, MmsValue* value, LogInclusionFlag flag);
void
MmsMapping_triggerGooseObservers(MmsMapping* self, MmsValue* value);

@ -786,8 +786,8 @@ checkForUpdateTrigger(IedServer self, DataAttribute* dataAttribute)
#endif
#if (CONFIG_IEC61850_LOG_SERVICE == 1)
//MmsMapping_triggerLogObserver(self->mmsMapping, dataAttribute->mmsValue,...)
MmsMapping_triggerLogging(self->mmsMapping, dataAttribute->mmsValue,
LOG_CONTROL_VALUE_UPDATE);
#endif
@ -809,6 +809,11 @@ checkForChangedTriggers(IedServer self, DataAttribute* dataAttribute)
MmsMapping_triggerReportObservers(self->mmsMapping, dataAttribute->mmsValue,
REPORT_CONTROL_VALUE_CHANGED);
#endif
#if (CONFIG_IEC61850_LOG_SERVICE == 1)
MmsMapping_triggerLogging(self->mmsMapping, dataAttribute->mmsValue,
LOG_CONTROL_VALUE_CHANGED);
#endif
}
else if (dataAttribute->triggerOptions & TRG_OPT_QUALITY_CHANGED) {
@ -821,6 +826,12 @@ checkForChangedTriggers(IedServer self, DataAttribute* dataAttribute)
MmsMapping_triggerReportObservers(self->mmsMapping, dataAttribute->mmsValue,
REPORT_CONTROL_QUALITY_CHANGED);
#endif
#if (CONFIG_IEC61850_LOG_SERVICE == 1)
MmsMapping_triggerLogging(self->mmsMapping, dataAttribute->mmsValue,
LOG_CONTROL_QUALITY_CHANGED);
#endif
}
#endif /* (CONFIG_IEC61850_REPORT_SERVICE== 1) || (CONFIG_INCLUDE_GOOSE_SUPPORT == 1) */
@ -1034,6 +1045,13 @@ IedServer_updateQuality(IedServer self, DataAttribute* dataAttribute, Quality qu
MmsMapping_triggerReportObservers(self->mmsMapping, dataAttribute->mmsValue,
REPORT_CONTROL_QUALITY_CHANGED);
#endif
#if (CONFIG_IEC61850_LOG_SERVICE == 1)
if (dataAttribute->triggerOptions & TRG_OPT_QUALITY_CHANGED)
MmsMapping_triggerLogging(self->mmsMapping, dataAttribute->mmsValue,
LOG_CONTROL_QUALITY_CHANGED);
#endif
}

@ -37,7 +37,7 @@
LogControl*
LogControl_create(LogicalNode* parentLN)
LogControl_create(LogicalNode* parentLN, MmsMapping* mmsMapping)
{
LogControl* self = (LogControl*) GLOBAL_MALLOC(sizeof(LogControl));
@ -45,6 +45,8 @@ LogControl_create(LogicalNode* parentLN)
self->dataSet = NULL;
self->triggerOps = 0;
self->logicalNode = parentLN;
self->mmsMapping = mmsMapping;
self->dataSetRef = NULL;
return self;
}
@ -175,13 +177,25 @@ createTrgOps(LogControlBlock* reportControlBlock) {
if (triggerOps & TRG_OPT_INTEGRITY)
MmsValue_setBitStringBit(trgOps, 4, true);
//TODO remove - GI doesn't exist here!
if (triggerOps & TRG_OPT_GI)
MmsValue_setBitStringBit(trgOps, 5, true);
return trgOps;
}
static bool
enableLogging(LogControl* logControl)
{
printf("enableLogging\n");
DataSet* dataSet = IedModel_lookupDataSet(logControl->mmsMapping->model, logControl->dataSetRef);
if (dataSet == NULL) {
printf(" data set (%s) not found!\n", logControl->dataSetRef);
return false;
}
return true;
}
static MmsVariableSpecification*
createLogControlBlock(LogControlBlock* logControlBlock,
LogControl* logControl)
@ -243,8 +257,12 @@ createLogControlBlock(LogControlBlock* logControlBlock,
if (logControlBlock->dataSetName != NULL) {
char* dataSetReference = createDataSetReferenceForDefaultDataSet(logControlBlock, logControl);
printf("createLogControlBlock dataSetRef: %s\n", dataSetReference);
logControl->dataSetRef = dataSetReference;
mmsValue->value.structure.components[2] = MmsValue_newVisibleString(dataSetReference);
GLOBAL_FREEMEM(dataSetReference);
//GLOBAL_FREEMEM(dataSetReference);
}
else
mmsValue->value.structure.components[2] = MmsValue_newVisibleString("");
@ -309,6 +327,12 @@ createLogControlBlock(LogControlBlock* logControlBlock,
logControl->mmsValue = mmsValue;
logControl->logControlBlock = logControlBlock;
logControl->enabled = logControlBlock->logEna;
if (logControl->enabled) {
enableLogging(logControl);
}
return lcb;
}
@ -331,7 +355,7 @@ Logging_createLCBs(MmsMapping* self, MmsDomain* domain, LogicalNode* logicalNode
while (currentLcb < lcbCount) {
LogControl* logControl = LogControl_create(logicalNode);
LogControl* logControl = LogControl_create(logicalNode, self);
LogControlBlock* logControlBlock = getLCBForLogicalNodeWithIndex(self, logicalNode, currentLcb);

@ -2482,6 +2482,8 @@ variableListChangedHandler (void* parameter, bool create, MmsVariableListType li
}
}
}
//TODO check if data set is referenced in a log control block
}
return allow;
@ -2608,6 +2610,33 @@ MmsMapping_triggerReportObservers(MmsMapping* self, MmsValue* value, ReportInclu
#if (CONFIG_INCLUDE_GOOSE_SUPPORT == 1)
#if (CONFIG_IEC61850_LOG_SERVICE == 1)
void
MmsMapping_triggerLogging(MmsMapping* self, MmsValue* value, LogInclusionFlag flag)
{
LinkedList element = self->logControls;
while ((element = LinkedList_getNext(element)) != NULL) {
LogControl* lc = (LogControl*) element->data;
if ((lc->enabled) && (lc->dataSet != NULL)) {
// switch (flag) {
int index;
if (DataSet_isMemberValue(lc->dataSet, value, &index)) {
printf("Log value\n");
}
}
}
}
#endif /* (CONFIG_IEC61850_LOG_SERVICE == 1) */
void
MmsMapping_triggerGooseObservers(MmsMapping* self, MmsValue* value)
{

Loading…
Cancel
Save