- IED server: implemented functional naming

v1.6_develop_rgoose_sntp
Michael Zillgith 4 years ago
parent 25394b11e1
commit 8755019986

@ -52,7 +52,7 @@
<AccessPoint name="accessPoint1"> <AccessPoint name="accessPoint1">
<Server> <Server>
<Authentication /> <Authentication />
<LDevice inst="GenericIO" ldName="Q1E1P2"> <LDevice inst="GenericIO">
<LN0 lnClass="LLN0" lnType="LLN01" inst=""> <LN0 lnClass="LLN0" lnType="LLN01" inst="">
<DataSet name="Events" desc="Events"> <DataSet name="Events" desc="Events">

@ -51,10 +51,10 @@ main(int argc, char** argv)
/* Access to data attributes by object reference */ /* Access to data attributes by object reference */
DataAttribute* anIn1_mag_f = (DataAttribute*) DataAttribute* anIn1_mag_f = (DataAttribute*)
IedModel_getModelNodeByObjectReference(model, "simpleIOGenericIO/GGIO1.AnIn1.mag.f"); IedModel_getModelNodeByShortObjectReference(model, "GenericIO/GGIO1.AnIn1.mag.f");
DataAttribute* anIn1_t = (DataAttribute*) DataAttribute* anIn1_t = (DataAttribute*)
IedModel_getModelNodeByObjectReference(model, "simpleIOGenericIO/GGIO1.AnIn1.t"); IedModel_getModelNodeByShortObjectReference(model, "GenericIO/GGIO1.AnIn1.t");
if (anIn1_mag_f == NULL) if (anIn1_mag_f == NULL)
printf("Error getting AnIn1.mag.f data attribute!\n"); printf("Error getting AnIn1.mag.f data attribute!\n");

@ -82,7 +82,7 @@ LIB61850_API void
IedModel_destroy(IedModel* model); IedModel_destroy(IedModel* model);
/** /**
* \brief Create a new logical device model and add it to the IED model * \brief Create a new logical device and add it to the IED model
* *
* \param name the name of the new logical device * \param name the name of the new logical device
* \param parent the parent IED model * \param parent the parent IED model
@ -92,6 +92,17 @@ IedModel_destroy(IedModel* model);
LIB61850_API LogicalDevice* LIB61850_API LogicalDevice*
LogicalDevice_create(const char* name, IedModel* parent); LogicalDevice_create(const char* name, IedModel* parent);
/**
* \brief Create a new logical device and add it to the IED model
*
* \param name the name of the new logical device
* \param parent the parent IED model
* \param ldName when not NULL functional naming is used for this LD (ldName <= 64 chars)
*
* \return the newly created LogicalDevice instance
*/
LIB61850_API LogicalDevice*
LogicalDevice_createEx(const char* inst, IedModel* parent, const char* ldName);
/** /**
* \brief Create a new logical mode and add it to a logical device * \brief Create a new logical mode and add it to a logical device

@ -183,11 +183,11 @@ struct sIedModel {
struct sLogicalDevice { struct sLogicalDevice {
ModelNodeType modelType; ModelNodeType modelType;
char* name; char* name; /* LD instance */
ModelNode* parent; ModelNode* parent;
ModelNode* sibling; ModelNode* sibling;
ModelNode* firstChild; ModelNode* firstChild;
char* ldName; char* ldName; /* ldName (when using functional naming) */
}; };
struct sModelNode { struct sModelNode {
@ -489,7 +489,9 @@ IedModel_getSVControlBlock(IedModel* self, LogicalNode* parentLN, const char* sv
* \brief Lookup a model node by its short (normalized) reference * \brief Lookup a model node by its short (normalized) reference
* *
* This version uses the object reference that does not contain the * This version uses the object reference that does not contain the
* IED name as part of the logical device name. This function is useful for * IED name or functional name as part of the logical device name.
* Instead the LD part consists of the LD instance name ("inst" attribute).
* This function is useful for
* devices where the IED name can be configured. * devices where the IED name can be configured.
* *
* \param self the IedModel instance that holds the model node * \param self the IedModel instance that holds the model node

@ -172,13 +172,23 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
if (StringUtils_startsWith((char*) lineBuffer, "LD")) { if (StringUtils_startsWith((char*) lineBuffer, "LD")) {
indendation = 2; indendation = 2;
if (sscanf((char*) lineBuffer, "LD(%s)", nameString) < 1) char ldName[65];
ldName[0] = 0;
if (sscanf((char*) lineBuffer, "LD(%s %s)", nameString, ldName) < 1)
goto exit_error; goto exit_error;
terminateString(nameString, ')'); terminateString(nameString, ')');
if (ldName[0] != 0) {
terminateString(ldName, ')');
currentLD = LogicalDevice_createEx(nameString, model, ldName);
}
else {
currentLD = LogicalDevice_create(nameString, model); currentLD = LogicalDevice_create(nameString, model);
} }
}
else else
goto exit_error; goto exit_error;
} }

@ -180,20 +180,33 @@ IedModel_addGSEControlBlock(IedModel* self, GSEControlBlock* gcb)
} }
LogicalDevice* LogicalDevice*
LogicalDevice_create(const char* name, IedModel* parent) LogicalDevice_createEx(const char* inst, IedModel* parent, const char* ldName)
{ {
LogicalDevice* self = (LogicalDevice*) GLOBAL_CALLOC(1, sizeof(LogicalDevice)); LogicalDevice* self = (LogicalDevice*) GLOBAL_CALLOC(1, sizeof(LogicalDevice));
self->name = StringUtils_copyString(name); if (self) {
self->name = StringUtils_copyString(inst);
self->modelType = LogicalDeviceModelType; self->modelType = LogicalDeviceModelType;
self->parent = (ModelNode*) parent; self->parent = (ModelNode*) parent;
self->sibling = NULL; self->sibling = NULL;
if (ldName)
self->ldName = StringUtils_copyString(ldName);
else
self->ldName = NULL;
IedModel_addLogicalDevice(parent, self); IedModel_addLogicalDevice(parent, self);
}
return self; return self;
} }
LogicalDevice*
LogicalDevice_create(const char* inst, IedModel* parent)
{
return LogicalDevice_createEx(inst, parent, NULL);
}
static LogicalNode* static LogicalNode*
LogicalDevice_getLastLogicalNode(LogicalDevice* self) LogicalDevice_getLastLogicalNode(LogicalDevice* self)
{ {
@ -779,6 +792,9 @@ IedModel_destroy(IedModel* model)
while (ld != NULL) { while (ld != NULL) {
GLOBAL_FREEMEM (ld->name); GLOBAL_FREEMEM (ld->name);
if (ld->ldName)
GLOBAL_FREEMEM (ld->ldName);
LogicalNode* ln = (LogicalNode*) ld->firstChild; LogicalNode* ln = (LogicalNode*) ld->firstChild;
while (ln != NULL) { while (ln != NULL) {

@ -375,11 +375,11 @@ IedModel_getModelNodeByShortObjectReference(IedModel* model, const char* objectR
if (separator != NULL) if (separator != NULL)
*separator = 0; *separator = 0;
char ldName[65]; char ldInst[65];
strcpy(ldName, model->name); strncpy(ldInst, objRef, 64);
strcat(ldName, objRef); ldInst[64] = 0;
LogicalDevice* ld = IedModel_getDevice(model, ldName); LogicalDevice* ld = IedModel_getDeviceByInst(model, ldInst);
if (ld == NULL) return NULL; if (ld == NULL) return NULL;
@ -557,12 +557,22 @@ createObjectReference(ModelNode* node, char* objectReference, bool withoutIedNam
if (withoutIedName) { if (withoutIedName) {
nameLength = strlen(lDevice->name); nameLength = strlen(lDevice->name);
strncpy(objectReference, lDevice->name, 64); strncpy(objectReference, lDevice->name, 64);
objectReference[64] = 0;
}
else {
if (lDevice->ldName) {
nameLength = strlen(lDevice->ldName);
strncpy(objectReference, lDevice->ldName, 64);
objectReference[64] = 0;
} }
else { else {
nameLength = strlen (iedModel->name) + strlen(lDevice->name); nameLength = strlen (iedModel->name) + strlen(lDevice->name);
strncpy(objectReference, iedModel->name, 64); strncpy(objectReference, iedModel->name, 64);
strncat(objectReference, lDevice->name, 64); strncat(objectReference, lDevice->name, 64);
objectReference[64] = 0;
}
} }
bufPos += nameLength; bufPos += nameLength;

@ -100,7 +100,10 @@ public class DynamicModelGenerator {
output.println("MODEL(" + ied.getName() + "){"); output.println("MODEL(" + ied.getName() + "){");
for (LogicalDevice logicalDevice : logicalDevices) { for (LogicalDevice logicalDevice : logicalDevices) {
output.print("LD("); output.print("LD(");
output.print(logicalDevice.getInst() + "){\n"); output.print(logicalDevice.getInst());
if (logicalDevice.getLdName() != null)
output.print(" " + logicalDevice.getLdName());
output.print("){\n");
exportLogicalNodes(output, logicalDevice); exportLogicalNodes(output, logicalDevice);

Loading…
Cancel
Save