|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* dynamic_model.c
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2014-2022 Michael Zillgith
|
|
|
|
|
* Copyright 2014-2023 Michael Zillgith
|
|
|
|
|
*
|
|
|
|
|
* This file is part of libIEC61850.
|
|
|
|
|
*
|
|
|
|
@ -202,12 +202,15 @@ LogicalDevice_create(const char* name, IedModel* parent)
|
|
|
|
|
{
|
|
|
|
|
LogicalDevice* self = (LogicalDevice*) GLOBAL_CALLOC(1, sizeof(LogicalDevice));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->modelType = LogicalDeviceModelType;
|
|
|
|
|
self->parent = (ModelNode*) parent;
|
|
|
|
|
self->sibling = NULL;
|
|
|
|
|
|
|
|
|
|
IedModel_addLogicalDevice(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -268,7 +271,6 @@ LogicalNode_getLastDataObject(LogicalNode* self)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return lastNode;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
@ -296,11 +298,14 @@ Log_create(const char* name, LogicalNode* parent)
|
|
|
|
|
{
|
|
|
|
|
Log* self = (Log*) GLOBAL_MALLOC(sizeof(Log));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
self->sibling = NULL;
|
|
|
|
|
|
|
|
|
|
LogicalNode_addLog(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -319,6 +324,8 @@ LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSe
|
|
|
|
|
{
|
|
|
|
|
LogControlBlock* self = (LogControlBlock*) GLOBAL_MALLOC(sizeof(LogControlBlock));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
self->sibling = NULL;
|
|
|
|
@ -339,6 +346,7 @@ LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSe
|
|
|
|
|
self->reasonCode = reasonCode;
|
|
|
|
|
|
|
|
|
|
LogicalNode_addLogControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -357,6 +365,8 @@ ReportControlBlock_create(const char* name, LogicalNode* parent, const char* rpt
|
|
|
|
|
{
|
|
|
|
|
ReportControlBlock* self = (ReportControlBlock*) GLOBAL_MALLOC(sizeof(ReportControlBlock));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
|
|
|
|
@ -381,6 +391,7 @@ ReportControlBlock_create(const char* name, LogicalNode* parent, const char* rpt
|
|
|
|
|
self->clientReservation[0] = 0; /* no pre-configured client */
|
|
|
|
|
|
|
|
|
|
LogicalNode_addReportControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -436,6 +447,8 @@ SettingGroupControlBlock_create(LogicalNode* parent, uint8_t actSG, uint8_t numO
|
|
|
|
|
|
|
|
|
|
SettingGroupControlBlock* self = (SettingGroupControlBlock*) GLOBAL_MALLOC(sizeof(SettingGroupControlBlock));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
self->actSG = actSG;
|
|
|
|
|
self->numOfSGs = numOfSGs;
|
|
|
|
@ -443,6 +456,7 @@ SettingGroupControlBlock_create(LogicalNode* parent, uint8_t actSG, uint8_t numO
|
|
|
|
|
self->editSG = 0;
|
|
|
|
|
|
|
|
|
|
LogicalNode_addSettingGroupControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -462,6 +476,8 @@ GSEControlBlock_create(const char* name, LogicalNode* parent, const char* appId,
|
|
|
|
|
{
|
|
|
|
|
GSEControlBlock* self = (GSEControlBlock*) GLOBAL_MALLOC(sizeof(GSEControlBlock));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
|
|
|
|
@ -486,6 +502,7 @@ GSEControlBlock_create(const char* name, LogicalNode* parent, const char* appId,
|
|
|
|
|
|
|
|
|
|
if (parent != NULL)
|
|
|
|
|
LogicalNode_addGSEControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -504,6 +521,8 @@ SVControlBlock_create(const char* name, LogicalNode* parent, const char* svID, c
|
|
|
|
|
{
|
|
|
|
|
SVControlBlock* self = (SVControlBlock*) GLOBAL_MALLOC(sizeof(SVControlBlock));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = parent;
|
|
|
|
|
|
|
|
|
@ -527,6 +546,7 @@ SVControlBlock_create(const char* name, LogicalNode* parent, const char* svID, c
|
|
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
|
LogicalNode_addSMVControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -548,11 +568,14 @@ PhyComAddress_create(uint8_t vlanPriority, uint16_t vlanId, uint16_t appId, uint
|
|
|
|
|
{
|
|
|
|
|
PhyComAddress* self = (PhyComAddress*) GLOBAL_MALLOC(sizeof(PhyComAddress));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->vlanPriority = vlanPriority;
|
|
|
|
|
self->vlanId = vlanId;
|
|
|
|
|
self->appId = appId;
|
|
|
|
|
|
|
|
|
|
memcpy(self->dstAddress, dstAddress, 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -589,6 +612,8 @@ DataObject_create(const char* name, ModelNode* parent, int arrayElements)
|
|
|
|
|
{
|
|
|
|
|
DataObject* self = (DataObject*) GLOBAL_MALLOC(sizeof(DataObject));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->modelType = DataObjectModelType;
|
|
|
|
|
self->elementCount = arrayElements;
|
|
|
|
@ -600,6 +625,7 @@ DataObject_create(const char* name, ModelNode* parent, int arrayElements)
|
|
|
|
|
LogicalNode_addDataObject((LogicalNode*) parent, self);
|
|
|
|
|
else if (parent->modelType == DataObjectModelType)
|
|
|
|
|
DataObject_addChild((DataObject*) parent, (ModelNode*) self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -637,6 +663,8 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type
|
|
|
|
|
{
|
|
|
|
|
DataAttribute* self = (DataAttribute*) GLOBAL_MALLOC(sizeof(DataAttribute));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->elementCount = arrayElements;
|
|
|
|
|
self->modelType = DataAttributeModelType;
|
|
|
|
@ -653,6 +681,7 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type
|
|
|
|
|
DataObject_addChild((DataObject*) parent, (ModelNode*) self);
|
|
|
|
|
else if (parent->modelType == DataAttributeModelType)
|
|
|
|
|
DataAttribute_addChild((DataAttribute*) parent, (ModelNode*) self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -691,6 +720,8 @@ DataSet_create(const char* name, LogicalNode* parent)
|
|
|
|
|
{
|
|
|
|
|
DataSet* self = (DataSet*) GLOBAL_MALLOC(sizeof(DataSet));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
LogicalDevice* ld = (LogicalDevice*) parent->parent;
|
|
|
|
|
|
|
|
|
|
self->name = StringUtils_createString(3, parent->name, "$", name);
|
|
|
|
@ -700,6 +731,7 @@ DataSet_create(const char* name, LogicalNode* parent)
|
|
|
|
|
self->fcdas = NULL;
|
|
|
|
|
|
|
|
|
|
IedModel_addDataSet((IedModel*) ld->parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -755,6 +787,8 @@ DataSetEntry_create(DataSet* dataSet, const char* variable, int index, const cha
|
|
|
|
|
{
|
|
|
|
|
DataSetEntry* self = (DataSetEntry*) GLOBAL_MALLOC(sizeof(DataSetEntry));
|
|
|
|
|
|
|
|
|
|
if (self)
|
|
|
|
|
{
|
|
|
|
|
char variableName[130];
|
|
|
|
|
|
|
|
|
|
StringUtils_copyStringMax(variableName, 130, variable);
|
|
|
|
@ -786,6 +820,7 @@ DataSetEntry_create(DataSet* dataSet, const char* variable, int index, const cha
|
|
|
|
|
self->value = NULL;
|
|
|
|
|
|
|
|
|
|
DataSet_addEntry(dataSet, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|