- started to implement functional naming for LDs

v1.6_develop_rgoose_sntp
Michael Zillgith 4 years ago
parent fe39cc9b24
commit 9a2fd3e23e

@ -17,7 +17,7 @@
#define DEBUG_COTP 0 #define DEBUG_COTP 0
#define DEBUG_ISO_SERVER 0 #define DEBUG_ISO_SERVER 0
#define DEBUG_ISO_CLIENT 0 #define DEBUG_ISO_CLIENT 0
#define DEBUG_IED_SERVER 0 #define DEBUG_IED_SERVER 1
#define DEBUG_IED_CLIENT 0 #define DEBUG_IED_CLIENT 0
#define DEBUG_MMS_CLIENT 0 #define DEBUG_MMS_CLIENT 0
#define DEBUG_MMS_SERVER 0 #define DEBUG_MMS_SERVER 0

@ -177,6 +177,7 @@ main(int argc, char** argv)
if (((int) t % 2) == 0) if (((int) t % 2) == 0)
Timestamp_setClockNotSynchronized(&iecTimestamp, true); Timestamp_setClockNotSynchronized(&iecTimestamp, true);
#if 1
IedServer_lockDataModel(iedServer); IedServer_lockDataModel(iedServer);
IedServer_updateTimestampAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn1_t, &iecTimestamp); IedServer_updateTimestampAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn1_t, &iecTimestamp);
@ -192,6 +193,7 @@ main(int argc, char** argv)
IedServer_updateFloatAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn4_mag_f, an4); IedServer_updateFloatAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn4_mag_f, an4);
IedServer_unlockDataModel(iedServer); IedServer_unlockDataModel(iedServer);
#endif
Thread_sleep(100); Thread_sleep(100);
} }

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

@ -220,7 +220,8 @@ LogicalDevice iedModel_GenericIO = {
"GenericIO", "GenericIO",
(ModelNode*) &iedModel, (ModelNode*) &iedModel,
NULL, NULL,
(ModelNode*) &iedModel_GenericIO_LLN0 (ModelNode*) &iedModel_GenericIO_LLN0,
"Q1E1P2"
}; };
LogicalNode iedModel_GenericIO_LLN0 = { LogicalNode iedModel_GenericIO_LLN0 = {

@ -187,6 +187,7 @@ struct sLogicalDevice {
ModelNode* parent; ModelNode* parent;
ModelNode* sibling; ModelNode* sibling;
ModelNode* firstChild; ModelNode* firstChild;
char* ldName;
}; };
struct sModelNode { struct sModelNode {
@ -212,7 +213,8 @@ struct sDataObject {
ModelNode* sibling; ModelNode* sibling;
ModelNode* firstChild; ModelNode* firstChild;
int elementCount; /* > 0 if this is an array */ int elementCount; /* value > 0 if this is an array */
//int arrayIndex; /* value > -1 when this is an array element */
}; };
struct sDataAttribute { struct sDataAttribute {
@ -222,7 +224,8 @@ struct sDataAttribute {
ModelNode* sibling; ModelNode* sibling;
ModelNode* firstChild; ModelNode* firstChild;
int elementCount; /* > 0 if this is an array */ int elementCount; /* value > 0 if this is an array */
// int arrayIndex; /* value > -1 when this is an array element */
FunctionalConstraint fc; FunctionalConstraint fc;
DataAttributeType type; DataAttributeType type;
@ -235,7 +238,7 @@ struct sDataAttribute {
}; };
typedef struct sDataSetEntry { typedef struct sDataSetEntry {
char* logicalDeviceName; char* logicalDeviceName; /* logical device instance name */
bool isLDNameDynamicallyAllocated; bool isLDNameDynamicallyAllocated;
char* variableName; char* variableName;
int index; int index;
@ -245,7 +248,7 @@ typedef struct sDataSetEntry {
} DataSetEntry; } DataSetEntry;
struct sDataSet { struct sDataSet {
char* logicalDeviceName; char* logicalDeviceName; /* logical device instance name */
char* name; /* eg. MMXU1$dataset1 */ char* name; /* eg. MMXU1$dataset1 */
int elementCount; int elementCount;
DataSetEntry* fcdas; DataSetEntry* fcdas;
@ -425,6 +428,8 @@ IedModel_setIedName(IedModel* self, const char* iedName);
* This function uses the full logical device name as part of the object reference * This function uses the full logical device name as part of the object reference
* as it happens to appear on the wire. E.g. if IED name in SCL file would be "IED1" * as it happens to appear on the wire. E.g. if IED name in SCL file would be "IED1"
* and the logical device "WD1" the resulting LD name would be "IED1WD". * and the logical device "WD1" the resulting LD name would be "IED1WD".
* When using functional naming in the LD (with ldName attribute) then the logical
* device name is identical with the ldName attribute.
* *
* \param self the IedModel instance that holds the model node * \param self the IedModel instance that holds the model node
* \param objectReference the IEC 61850 object reference * \param objectReference the IEC 61850 object reference

@ -221,7 +221,7 @@ createMmsServerCache(IedServer self)
goto exit_function; goto exit_function;
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("ied_server.c: Insert into cache %s - %s\n", logicalDevice->domainName, variableName); printf("IED_SERVER: Insert into cache %s - %s\n", logicalDevice->domainName, variableName);
MmsServer_insertIntoCache(self->mmsServer, logicalDevice, variableName, defaultValue); MmsServer_insertIntoCache(self->mmsServer, logicalDevice, variableName, defaultValue);
} }
@ -236,7 +236,7 @@ exit_function:
} }
static void static void
installDefaultValuesForDataAttribute(IedServer self, DataAttribute* dataAttribute, installDefaultValuesForDataAttribute(IedServer self, LogicalDevice* ld, DataAttribute* dataAttribute,
char* objectReference, int position) char* objectReference, int position)
{ {
sprintf(objectReference + position, ".%s", dataAttribute->name); sprintf(objectReference + position, ".%s", dataAttribute->name);
@ -248,8 +248,12 @@ installDefaultValuesForDataAttribute(IedServer self, DataAttribute* dataAttribut
MmsMapping_createMmsVariableNameFromObjectReference(objectReference, dataAttribute->fc, mmsVariableName); MmsMapping_createMmsVariableNameFromObjectReference(objectReference, dataAttribute->fc, mmsVariableName);
char domainName[65]; char domainName[65];
domainName[0] = 0;
if (ld->ldName == NULL) {
strncpy(domainName, self->model->name, 64); strncpy(domainName, self->model->name, 64);
domainName[64] = 0;
}
MmsMapping_getMmsDomainFromObjectReference(objectReference, domainName + strlen(domainName)); MmsMapping_getMmsDomainFromObjectReference(objectReference, domainName + strlen(domainName));
@ -284,14 +288,14 @@ installDefaultValuesForDataAttribute(IedServer self, DataAttribute* dataAttribut
DataAttribute* subDataAttribute = (DataAttribute*) dataAttribute->firstChild; DataAttribute* subDataAttribute = (DataAttribute*) dataAttribute->firstChild;
while (subDataAttribute != NULL) { while (subDataAttribute != NULL) {
installDefaultValuesForDataAttribute(self, subDataAttribute, objectReference, childPosition); installDefaultValuesForDataAttribute(self, ld, subDataAttribute, objectReference, childPosition);
subDataAttribute = (DataAttribute*) subDataAttribute->sibling; subDataAttribute = (DataAttribute*) subDataAttribute->sibling;
} }
} }
static void static void
installDefaultValuesForDataObject(IedServer self, DataObject* dataObject, installDefaultValuesForDataObject(IedServer self, LogicalDevice* ld, DataObject* dataObject,
char* objectReference, int position) char* objectReference, int position)
{ {
if (dataObject->elementCount > 0) { if (dataObject->elementCount > 0) {
@ -309,10 +313,10 @@ installDefaultValuesForDataObject(IedServer self, DataObject* dataObject,
while (childNode != NULL) { while (childNode != NULL) {
if (childNode->modelType == DataObjectModelType) { if (childNode->modelType == DataObjectModelType) {
installDefaultValuesForDataObject(self, (DataObject*) childNode, objectReference, childPosition); installDefaultValuesForDataObject(self, ld, (DataObject*) childNode, objectReference, childPosition);
} }
else if (childNode->modelType == DataAttributeModelType) { else if (childNode->modelType == DataAttributeModelType) {
installDefaultValuesForDataAttribute(self, (DataAttribute*) childNode, objectReference, childPosition); installDefaultValuesForDataAttribute(self, ld, (DataAttribute*) childNode, objectReference, childPosition);
} }
childNode = childNode->sibling; childNode = childNode->sibling;
@ -329,6 +333,10 @@ installDefaultValuesInCache(IedServer self)
LogicalDevice* logicalDevice = model->firstChild; LogicalDevice* logicalDevice = model->firstChild;
while (logicalDevice != NULL) { while (logicalDevice != NULL) {
if (logicalDevice->ldName)
sprintf(objectReference, "%s", logicalDevice->ldName);
else
sprintf(objectReference, "%s", logicalDevice->name); sprintf(objectReference, "%s", logicalDevice->name);
LogicalNode* logicalNode = (LogicalNode*) logicalDevice->firstChild; LogicalNode* logicalNode = (LogicalNode*) logicalDevice->firstChild;
@ -343,7 +351,7 @@ installDefaultValuesInCache(IedServer self)
int refPosition = strlen(objectReference); int refPosition = strlen(objectReference);
while (dataObject != NULL) { while (dataObject != NULL) {
installDefaultValuesForDataObject(self, dataObject, objectReference, refPosition); installDefaultValuesForDataObject(self, logicalDevice, dataObject, objectReference, refPosition);
dataObject = (DataObject*) dataObject->sibling; dataObject = (DataObject*) dataObject->sibling;
} }
@ -370,12 +378,30 @@ updateDataSetsWithCachedValues(IedServer self)
while (dataSetEntry != NULL) { while (dataSetEntry != NULL) {
MmsDomain* domain = NULL;
LogicalDevice* ld = IedModel_getDeviceByInst(self->model, dataSetEntry->logicalDeviceName);
if (ld) {
if (ld->ldName) {
domain = MmsDevice_getDomain(self->mmsDevice, ld->ldName);
}
if (domain == NULL) {
char domainName[65]; char domainName[65];
strncpy(domainName, self->model->name, 64); strncpy(domainName, self->model->name, 64);
strncat(domainName, dataSetEntry->logicalDeviceName, 64 - iedNameLength); strncat(domainName, dataSetEntry->logicalDeviceName, 64 - iedNameLength);
MmsDomain* domain = MmsDevice_getDomain(self->mmsDevice, domainName); domain = MmsDevice_getDomain(self->mmsDevice, domainName);
}
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: ERROR - LD %s not found\n", dataSetEntry->logicalDeviceName);
}
char variableName[66]; char variableName[66];

@ -1790,6 +1790,7 @@ createMmsDomainFromIedDevice(MmsMapping* self, LogicalDevice* logicalDevice)
MmsDomain* domain = NULL; MmsDomain* domain = NULL;
char domainName[65]; char domainName[65];
if (logicalDevice->ldName == NULL) {
int modelNameLength = strlen(self->model->name); int modelNameLength = strlen(self->model->name);
if (modelNameLength > 64) if (modelNameLength > 64)
@ -1797,6 +1798,15 @@ createMmsDomainFromIedDevice(MmsMapping* self, LogicalDevice* logicalDevice)
strncpy(domainName, self->model->name, 64); strncpy(domainName, self->model->name, 64);
strncat(domainName, logicalDevice->name, 64 - modelNameLength); strncat(domainName, logicalDevice->name, 64 - modelNameLength);
domainName[64] = 0;
}
else {
if (strlen(logicalDevice->ldName) > 64)
goto exit_function;
strncpy(domainName, logicalDevice->ldName, 64);
domainName[64] = 0;
}
domain = MmsDomain_create(domainName); domain = MmsDomain_create(domainName);
@ -1902,19 +1912,34 @@ createDataSets(MmsDevice* mmsDevice, IedModel* iedModel)
} }
while (dataset != NULL) { while (dataset != NULL) {
LogicalDevice* ld = IedModel_getDeviceByInst(iedModel, dataset->logicalDeviceName);
if (ld) {
if (ld->ldName) {
strncpy(domainName, ld->ldName, 64);
domainName[64] = 0;
}
else {
strncpy(domainName, iedModel->name, 64); strncpy(domainName, iedModel->name, 64);
strncat(domainName, dataset->logicalDeviceName, 64 - iedModelNameLength); strncat(domainName, dataset->logicalDeviceName, 64 - iedModelNameLength);
domainName[64] = 0;
}
MmsDomain* dataSetDomain = MmsDevice_getDomain(mmsDevice, domainName); MmsDomain* dataSetDomain = MmsDevice_getDomain(mmsDevice, domainName);
if (dataSetDomain == NULL) { if (dataSetDomain == NULL) {
if (DEBUG_IED_SERVER) if (DEBUG_IED_SERVER)
printf("IED_SERVER: LD for dataset does not exist!\n"); printf("IED_SERVER: MMS domain for dataset does not exist!\n");
goto exit_function; goto exit_function;
} }
if (DEBUG_IED_SERVER)
printf("IED_SERVER: create dataset: %s/%s\n", domainName, dataset->name);
MmsNamedVariableList varList = MmsNamedVariableList_create(dataSetDomain, dataset->name, false); MmsNamedVariableList varList = MmsNamedVariableList_create(dataSetDomain, dataset->name, false);
DataSetEntry* dataSetEntry = dataset->fcdas; DataSetEntry* dataSetEntry = dataset->fcdas;
@ -1923,8 +1948,15 @@ createDataSets(MmsDevice* mmsDevice, IedModel* iedModel)
MmsAccessSpecifier accessSpecifier; MmsAccessSpecifier accessSpecifier;
if (ld->ldName) {
strncpy(domainName, ld->ldName, 64);
domainName[64] = 0;
}
else {
strncpy(domainName, iedModel->name, 64); strncpy(domainName, iedModel->name, 64);
strncat(domainName, dataSetEntry->logicalDeviceName, 64 - iedModelNameLength); strncat(domainName, dataset->logicalDeviceName, 64 - iedModelNameLength);
domainName[64] = 0;
}
accessSpecifier.domain = MmsDevice_getDomain(mmsDevice, domainName); accessSpecifier.domain = MmsDevice_getDomain(mmsDevice, domainName);
@ -1941,6 +1973,11 @@ createDataSets(MmsDevice* mmsDevice, IedModel* iedModel)
} }
MmsDomain_addNamedVariableList(dataSetDomain, varList); MmsDomain_addNamedVariableList(dataSetDomain, varList);
}
else {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: LD for dataset does not exist!\n");
}
dataset = dataset->sibling; dataset = dataset->sibling;
} }

@ -73,8 +73,6 @@ IedModel_setAttributeValuesToNull(IedModel* iedModel)
} }
} }
int int
IedModel_getLogicalDeviceCount(IedModel* self) IedModel_getLogicalDeviceCount(IedModel* self)
{ {
@ -113,6 +111,10 @@ IedModel_lookupDataSet(IedModel* self, const char* dataSetReference /* e.g. ied
while (dataSet != NULL) { while (dataSet != NULL) {
LogicalDevice* ld = IedModel_getDeviceByInst(self, dataSet->logicalDeviceName);
if (ld) {
if (ld->ldName == NULL) {
domainName[modelNameLen] = 0; domainName[modelNameLen] = 0;
strncat(domainName, dataSet->logicalDeviceName, 64); strncat(domainName, dataSet->logicalDeviceName, 64);
@ -122,6 +124,17 @@ IedModel_lookupDataSet(IedModel* self, const char* dataSetReference /* e.g. ied
return dataSet; return dataSet;
} }
} }
}
else {
/* functional naming */
if (strncmp(ld->ldName, dataSetReference, ldNameLen) == 0) {
if (strcmp(dataSet->name, separator + 1) == 0) {
return dataSet;
}
}
}
}
dataSet = dataSet->sibling; dataSet = dataSet->sibling;
} }
@ -136,13 +149,21 @@ IedModel_getDevice(IedModel* self, const char* deviceName)
while (device != NULL) { while (device != NULL) {
if (device->ldName) {
/* functional naming */
if (strcmp(device->ldName, deviceName) == 0)
return device;
}
else {
char domainName[65]; char domainName[65];
strncpy(domainName, self->name, 64); strncpy(domainName, self->name, 64);
strncat(domainName, device->name, 64); strncat(domainName, device->name, 64);
domainName[64] = 0;
if (strcmp(domainName, deviceName) == 0) if (strcmp(domainName, deviceName) == 0)
return device; return device;
}
device = (LogicalDevice*) device->sibling; device = (LogicalDevice*) device->sibling;
} }

@ -295,9 +295,9 @@ public class StaticModelGenerator {
} }
} }
private String getLogicalDeviceInst(LogicalDevice logicalDevice) { // private String getLogicalDeviceInst(LogicalDevice logicalDevice) {
return logicalDevice.getInst(); // return logicalDevice.getInst();
} // }
private void printDeviceModelDefinitions() { private void printDeviceModelDefinitions() {
@ -321,17 +321,17 @@ public class StaticModelGenerator {
LogicalDevice logicalDevice = logicalDevices.get(i); LogicalDevice logicalDevice = logicalDevices.get(i);
String ldInst = logicalDevice.getInst();
String ldName = modelPrefix + "_" + logicalDevice.getInst(); String ldName = modelPrefix + "_" + logicalDevice.getInst();
variablesList.add(ldName); variablesList.add(ldName);
String logicalDeviceName = getLogicalDeviceInst(logicalDevice);
cOut.println("\nLogicalDevice " + ldName + " = {"); cOut.println("\nLogicalDevice " + ldName + " = {");
cOut.println(" LogicalDeviceModelType,"); cOut.println(" LogicalDeviceModelType,");
cOut.println(" \"" + logicalDeviceName + "\","); cOut.println(" \"" + ldInst + "\",");
cOut.println(" (ModelNode*) &" + modelPrefix + ","); cOut.println(" (ModelNode*) &" + modelPrefix + ",");
@ -342,7 +342,13 @@ public class StaticModelGenerator {
String firstChildName = ldName + "_" + logicalDevice.getLogicalNodes().get(0).getName(); String firstChildName = ldName + "_" + logicalDevice.getLogicalNodes().get(0).getName();
cOut.println(" (ModelNode*) &" + firstChildName); cOut.println(" (ModelNode*) &" + firstChildName + ",");
if (logicalDevice.getLdName() != null)
cOut.println(" \"" + logicalDevice.getLdName() + "\"");
else
cOut.println(" NULL");
cOut.println("};\n"); cOut.println("};\n");
printLogicalNodeDefinitions(ldName, logicalDevice, logicalDevice.getLogicalNodes()); printLogicalNodeDefinitions(ldName, logicalDevice, logicalDevice.getLogicalNodes());

Loading…
Cancel
Save