|
|
|
@ -242,6 +242,7 @@ LogicalNode_create(const char* name, LogicalDevice* parent)
|
|
|
|
|
{
|
|
|
|
|
LogicalNode* self = (LogicalNode*) GLOBAL_MALLOC(sizeof(LogicalNode));
|
|
|
|
|
|
|
|
|
|
if (self) {
|
|
|
|
|
self->name = StringUtils_copyString(name);
|
|
|
|
|
self->parent = (ModelNode*) parent;
|
|
|
|
|
self->modelType = LogicalNodeModelType;
|
|
|
|
@ -249,6 +250,7 @@ LogicalNode_create(const char* name, LogicalDevice* parent)
|
|
|
|
|
self->sibling = NULL;
|
|
|
|
|
|
|
|
|
|
LogicalDevice_addLogicalNode(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -294,11 +296,13 @@ 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;
|
|
|
|
|
}
|
|
|
|
@ -317,6 +321,7 @@ 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;
|
|
|
|
@ -337,6 +342,7 @@ LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSe
|
|
|
|
|
self->reasonCode = reasonCode;
|
|
|
|
|
|
|
|
|
|
LogicalNode_addLogControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -355,6 +361,7 @@ 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;
|
|
|
|
|
|
|
|
|
@ -379,6 +386,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;
|
|
|
|
|
}
|
|
|
|
@ -434,6 +442,7 @@ 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;
|
|
|
|
@ -441,6 +450,7 @@ SettingGroupControlBlock_create(LogicalNode* parent, uint8_t actSG, uint8_t numO
|
|
|
|
|
self->editSG = 0;
|
|
|
|
|
|
|
|
|
|
LogicalNode_addSettingGroupControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -460,6 +470,7 @@ 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;
|
|
|
|
|
|
|
|
|
@ -484,6 +495,7 @@ GSEControlBlock_create(const char* name, LogicalNode* parent, const char* appId,
|
|
|
|
|
|
|
|
|
|
if (parent != NULL)
|
|
|
|
|
LogicalNode_addGSEControlBlock(parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -494,6 +506,7 @@ 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;
|
|
|
|
|
|
|
|
|
@ -511,6 +524,7 @@ SVControlBlock_create(const char* name, LogicalNode* parent, const char* svID, c
|
|
|
|
|
|
|
|
|
|
self->optFlds = optFlds;
|
|
|
|
|
self->isUnicast = isUnicast;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -532,11 +546,13 @@ 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;
|
|
|
|
|
}
|
|
|
|
@ -573,6 +589,7 @@ 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->firstChild = NULL;
|
|
|
|
@ -588,6 +605,7 @@ DataObject_create(const char* name, ModelNode* parent, int arrayElements)
|
|
|
|
|
for (i = 0; i < arrayElements; i++) {
|
|
|
|
|
DataObject* arrayElement = (DataObject*) GLOBAL_MALLOC(sizeof(DataObject));
|
|
|
|
|
|
|
|
|
|
if (self) {
|
|
|
|
|
self->name = NULL;
|
|
|
|
|
self->modelType = DataObjectModelType;
|
|
|
|
|
self->firstChild = NULL;
|
|
|
|
@ -600,11 +618,13 @@ DataObject_create(const char* name, ModelNode* parent, int arrayElements)
|
|
|
|
|
DataObject_addChild(self, (ModelNode*) arrayElement);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parent->modelType == LogicalNodeModelType)
|
|
|
|
|
LogicalNode_addDataObject((LogicalNode*) parent, self);
|
|
|
|
|
else if (parent->modelType == DataObjectModelType)
|
|
|
|
|
DataObject_addChild((DataObject*) parent, (ModelNode*) self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -642,8 +662,10 @@ 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->arrayIndex = -1;
|
|
|
|
|
self->modelType = DataAttributeModelType;
|
|
|
|
|
self->type = type;
|
|
|
|
|
self->fc = fc;
|
|
|
|
@ -654,10 +676,36 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type
|
|
|
|
|
self->triggerOptions = triggerOptions;
|
|
|
|
|
self->sAddr = sAddr;
|
|
|
|
|
|
|
|
|
|
if ((arrayElements > 0) && (type != IEC61850_CONSTRUCTED)) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < arrayElements; i++) {
|
|
|
|
|
DataAttribute* arrayElement = (DataAttribute*) GLOBAL_MALLOC(sizeof(DataAttribute));
|
|
|
|
|
|
|
|
|
|
if (arrayElement) {
|
|
|
|
|
arrayElement->name = NULL;
|
|
|
|
|
arrayElement->elementCount = 0;
|
|
|
|
|
arrayElement->arrayIndex = i;
|
|
|
|
|
arrayElement->modelType = DataAttributeModelType;
|
|
|
|
|
arrayElement->type = type;
|
|
|
|
|
arrayElement->fc = fc;
|
|
|
|
|
arrayElement->firstChild = NULL;
|
|
|
|
|
arrayElement->mmsValue = NULL;
|
|
|
|
|
arrayElement->parent = parent;
|
|
|
|
|
arrayElement->sibling = NULL;
|
|
|
|
|
arrayElement->triggerOptions = triggerOptions;
|
|
|
|
|
arrayElement->sAddr = sAddr;
|
|
|
|
|
|
|
|
|
|
DataAttribute_addChild(self, arrayElement);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (parent->modelType == DataObjectModelType)
|
|
|
|
|
DataObject_addChild((DataObject*) parent, (ModelNode*) self);
|
|
|
|
|
else if (parent->modelType == DataAttributeModelType)
|
|
|
|
|
DataAttribute_addChild((DataAttribute*) parent, (ModelNode*) self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -696,6 +744,7 @@ 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);
|
|
|
|
@ -705,6 +754,7 @@ DataSet_create(const char* name, LogicalNode* parent)
|
|
|
|
|
self->fcdas = NULL;
|
|
|
|
|
|
|
|
|
|
IedModel_addDataSet((IedModel*) ld->parent, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -760,6 +810,7 @@ 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);
|
|
|
|
@ -791,6 +842,7 @@ DataSetEntry_create(DataSet* dataSet, const char* variable, int index, const cha
|
|
|
|
|
self->value = NULL;
|
|
|
|
|
|
|
|
|
|
DataSet_addEntry(dataSet, self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -838,9 +890,12 @@ IedModel_destroy(IedModel* model)
|
|
|
|
|
|
|
|
|
|
while (ld != NULL) {
|
|
|
|
|
|
|
|
|
|
if (ld->ldName)
|
|
|
|
|
if (ld->name)
|
|
|
|
|
GLOBAL_FREEMEM(ld->name);
|
|
|
|
|
|
|
|
|
|
if (ld->ldName)
|
|
|
|
|
GLOBAL_FREEMEM (ld->ldName);
|
|
|
|
|
|
|
|
|
|
LogicalNode* ln = (LogicalNode*) ld->firstChild;
|
|
|
|
|
|
|
|
|
|
while (ln != NULL) {
|
|
|
|
|