|
|
@ -47,11 +47,6 @@
|
|
|
|
#define CONFIG_IEC61850_BRCB_WITH_RESVTMS 0
|
|
|
|
#define CONFIG_IEC61850_BRCB_WITH_RESVTMS 0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef CONFIG_IEC61850_EDITION_1
|
|
|
|
|
|
|
|
#define CONFIG_IEC61850_EDITION_1 0
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static ReportBuffer*
|
|
|
|
static ReportBuffer*
|
|
|
|
ReportBuffer_create(int bufferSize)
|
|
|
|
ReportBuffer_create(int bufferSize)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -84,7 +79,7 @@ ReportBuffer_destroy(ReportBuffer* self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ReportControl*
|
|
|
|
ReportControl*
|
|
|
|
ReportControl_create(bool buffered, LogicalNode* parentLN, int reportBufferSize)
|
|
|
|
ReportControl_create(bool buffered, LogicalNode* parentLN, int reportBufferSize, IedServer iedServer)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ReportControl* self = (ReportControl*) GLOBAL_MALLOC(sizeof(ReportControl));
|
|
|
|
ReportControl* self = (ReportControl*) GLOBAL_MALLOC(sizeof(ReportControl));
|
|
|
|
self->name = NULL;
|
|
|
|
self->name = NULL;
|
|
|
@ -119,6 +114,8 @@ ReportControl_create(bool buffered, LogicalNode* parentLN, int reportBufferSize)
|
|
|
|
self->valueReferences = NULL;
|
|
|
|
self->valueReferences = NULL;
|
|
|
|
self->lastEntryId = 0;
|
|
|
|
self->lastEntryId = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self->server = iedServer;
|
|
|
|
|
|
|
|
|
|
|
|
if (buffered) {
|
|
|
|
if (buffered) {
|
|
|
|
self->reportBuffer = ReportBuffer_create(reportBufferSize);
|
|
|
|
self->reportBuffer = ReportBuffer_create(reportBufferSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -251,17 +248,21 @@ ReportControl_getRCBValue(ReportControl* rc, char* elementName)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 11);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 11);
|
|
|
|
else if (strcmp(elementName, "TimeofEntry") == 0)
|
|
|
|
else if (strcmp(elementName, "TimeofEntry") == 0)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 12);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 12);
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
|
|
|
|
|
|
|
|
if (rc->server->edition >= IEC_61850_EDITION_2) {
|
|
|
|
#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1)
|
|
|
|
#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1)
|
|
|
|
else if (strcmp(elementName, "ResvTms") == 0)
|
|
|
|
if (strcmp(elementName, "ResvTms") == 0)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 13);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 13);
|
|
|
|
else if (strcmp(elementName, "Owner") == 0)
|
|
|
|
if (strcmp(elementName, "Owner") == 0)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 14);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 14);
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
else if (strcmp(elementName, "Owner") == 0)
|
|
|
|
if (strcmp(elementName, "Owner") == 0)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 13);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 13);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (strcmp(elementName, "RptID") == 0)
|
|
|
|
if (strcmp(elementName, "RptID") == 0)
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 0);
|
|
|
|
return MmsValue_getElement(rc->rcbValues, 0);
|
|
|
@ -819,11 +820,12 @@ createUnbufferedReportControlBlock(ReportControlBlock* reportControlBlock,
|
|
|
|
mmsValue->deleteValue = false;
|
|
|
|
mmsValue->deleteValue = false;
|
|
|
|
mmsValue->type = MMS_STRUCTURE;
|
|
|
|
mmsValue->type = MMS_STRUCTURE;
|
|
|
|
|
|
|
|
|
|
|
|
#if ((CONFIG_IEC61850_EDITION_1 == 0))
|
|
|
|
int structSize;
|
|
|
|
int structSize = 12;
|
|
|
|
|
|
|
|
#else
|
|
|
|
if (reportControl->server->edition >= IEC_61850_EDITION_2)
|
|
|
|
int structSize = 11;
|
|
|
|
structSize = 12;
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
|
|
|
|
structSize = 11;
|
|
|
|
|
|
|
|
|
|
|
|
mmsValue->value.structure.size = structSize;
|
|
|
|
mmsValue->value.structure.size = structSize;
|
|
|
|
mmsValue->value.structure.components = (MmsValue**) GLOBAL_CALLOC(structSize, sizeof(MmsValue*));
|
|
|
|
mmsValue->value.structure.components = (MmsValue**) GLOBAL_CALLOC(structSize, sizeof(MmsValue*));
|
|
|
@ -925,14 +927,14 @@ createUnbufferedReportControlBlock(ReportControlBlock* reportControlBlock,
|
|
|
|
rcb->typeSpec.structure.elements[10] = namedVariable;
|
|
|
|
rcb->typeSpec.structure.elements[10] = namedVariable;
|
|
|
|
mmsValue->value.structure.components[10] = MmsValue_newBoolean(false);
|
|
|
|
mmsValue->value.structure.components[10] = MmsValue_newBoolean(false);
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
if (reportControl->server->edition >= IEC_61850_EDITION_2) {
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable->name = StringUtils_copyString("Owner");
|
|
|
|
namedVariable->name = StringUtils_copyString("Owner");
|
|
|
|
namedVariable->type = MMS_OCTET_STRING;
|
|
|
|
namedVariable->type = MMS_OCTET_STRING;
|
|
|
|
namedVariable->typeSpec.octetString = -64;
|
|
|
|
namedVariable->typeSpec.octetString = -64;
|
|
|
|
rcb->typeSpec.structure.elements[11] = namedVariable;
|
|
|
|
rcb->typeSpec.structure.elements[11] = namedVariable;
|
|
|
|
mmsValue->value.structure.components[11] = MmsValue_newOctetString(0, 128);
|
|
|
|
mmsValue->value.structure.components[11] = MmsValue_newOctetString(0, 128);
|
|
|
|
#endif /* (CONFIG_IEC61850_EDITION_1 == 0) */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reportControl->rcbValues = mmsValue;
|
|
|
|
reportControl->rcbValues = mmsValue;
|
|
|
|
|
|
|
|
|
|
|
@ -955,13 +957,14 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock,
|
|
|
|
|
|
|
|
|
|
|
|
int brcbElementCount = 13;
|
|
|
|
int brcbElementCount = 13;
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
if (reportControl->server->edition >= IEC_61850_EDITION_2) {
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1)
|
|
|
|
#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1)
|
|
|
|
brcbElementCount++;
|
|
|
|
brcbElementCount++;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
brcbElementCount++;
|
|
|
|
brcbElementCount++;
|
|
|
|
#endif /* (CONFIG_IEC61850_EDITION_1 == 0) */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MmsValue* mmsValue = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
MmsValue* mmsValue = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
|
|
|
|
mmsValue->deleteValue = false;
|
|
|
|
mmsValue->deleteValue = false;
|
|
|
@ -1083,11 +1086,10 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock,
|
|
|
|
|
|
|
|
|
|
|
|
reportControl->timeOfEntry = mmsValue->value.structure.components[12];
|
|
|
|
reportControl->timeOfEntry = mmsValue->value.structure.components[12];
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
if (reportControl->server->edition >= IEC_61850_EDITION_2) {
|
|
|
|
int currentIndex = 13;
|
|
|
|
int currentIndex = 13;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ((CONFIG_IEC61850_EDITION_1 == 0) && (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1))
|
|
|
|
#if (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1)
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable->name = StringUtils_copyString("ResvTms");
|
|
|
|
namedVariable->name = StringUtils_copyString("ResvTms");
|
|
|
|
namedVariable->type = MMS_INTEGER;
|
|
|
|
namedVariable->type = MMS_INTEGER;
|
|
|
@ -1097,14 +1099,13 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock,
|
|
|
|
currentIndex++;
|
|
|
|
currentIndex++;
|
|
|
|
#endif /* (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1) */
|
|
|
|
#endif /* (CONFIG_IEC61850_BRCB_WITH_RESVTMS == 1) */
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
|
|
|
|
namedVariable->name = StringUtils_copyString("Owner");
|
|
|
|
namedVariable->name = StringUtils_copyString("Owner");
|
|
|
|
namedVariable->type = MMS_OCTET_STRING;
|
|
|
|
namedVariable->type = MMS_OCTET_STRING;
|
|
|
|
namedVariable->typeSpec.octetString = -64;
|
|
|
|
namedVariable->typeSpec.octetString = -64;
|
|
|
|
rcb->typeSpec.structure.elements[currentIndex] = namedVariable;
|
|
|
|
rcb->typeSpec.structure.elements[currentIndex] = namedVariable;
|
|
|
|
mmsValue->value.structure.components[currentIndex] = MmsValue_newOctetString(0, 128); /* size 4 is enough to store client IPv4 address */
|
|
|
|
mmsValue->value.structure.components[currentIndex] = MmsValue_newOctetString(0, 128); /* size 4 is enough to store client IPv4 address */
|
|
|
|
#endif /* (CONFIG_IEC61850_EDITION_1 == 0) */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
reportControl->rcbValues = mmsValue;
|
|
|
|
reportControl->rcbValues = mmsValue;
|
|
|
|
|
|
|
|
|
|
|
@ -1158,7 +1159,7 @@ Reporting_createMmsBufferedRCBs(MmsMapping* self, MmsDomain* domain,
|
|
|
|
int currentReport = 0;
|
|
|
|
int currentReport = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while (currentReport < reportsCount) {
|
|
|
|
while (currentReport < reportsCount) {
|
|
|
|
ReportControl* rc = ReportControl_create(true, logicalNode, self->iedServer->reportBufferSize);
|
|
|
|
ReportControl* rc = ReportControl_create(true, logicalNode, self->iedServer->reportBufferSize, self->iedServer);
|
|
|
|
|
|
|
|
|
|
|
|
rc->domain = domain;
|
|
|
|
rc->domain = domain;
|
|
|
|
|
|
|
|
|
|
|
@ -1195,7 +1196,7 @@ Reporting_createMmsUnbufferedRCBs(MmsMapping* self, MmsDomain* domain,
|
|
|
|
int currentReport = 0;
|
|
|
|
int currentReport = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while (currentReport < reportsCount) {
|
|
|
|
while (currentReport < reportsCount) {
|
|
|
|
ReportControl* rc = ReportControl_create(false, logicalNode, self->iedServer->reportBufferSize);
|
|
|
|
ReportControl* rc = ReportControl_create(false, logicalNode, self->iedServer->reportBufferSize, self->iedServer);
|
|
|
|
|
|
|
|
|
|
|
|
rc->domain = domain;
|
|
|
|
rc->domain = domain;
|
|
|
|
|
|
|
|
|
|
|
@ -1221,7 +1222,8 @@ updateOwner(ReportControl* rc, MmsServerConnection connection)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rc->clientConnection = connection;
|
|
|
|
rc->clientConnection = connection;
|
|
|
|
|
|
|
|
|
|
|
|
#if (CONFIG_IEC61850_EDITION_1 == 0)
|
|
|
|
if (rc->server->edition >= IEC_61850_EDITION_2) {
|
|
|
|
|
|
|
|
|
|
|
|
MmsValue* owner = ReportControl_getRCBValue(rc, "Owner");
|
|
|
|
MmsValue* owner = ReportControl_getRCBValue(rc, "Owner");
|
|
|
|
|
|
|
|
|
|
|
|
if (owner != NULL) {
|
|
|
|
if (owner != NULL) {
|
|
|
@ -1272,7 +1274,7 @@ updateOwner(ReportControl* rc, MmsServerConnection connection)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* (CONFIG_IEC61850_EDITION_1 == 0) */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|