- IED server: added configuration file support for data set entries with array elements or array element components

pull/265/head
Michael Zillgith 5 years ago
parent 131fcf5236
commit 2bc47a6a6c

@ -434,10 +434,36 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
}
}
else if (StringUtils_startsWith((char*) lineBuffer, "DE")) {
sscanf((char*) lineBuffer, "DE(%s)", nameString);
terminateString(nameString, ')');
char* start = strchr(lineBuffer, '(');
if (start) {
start++;
strncpy(nameString, start, 129);
terminateString(nameString, ')');
int indexVal = -1;
char* componentVal = NULL;
/* check for index */
char* sep = strchr(nameString, ' ');
if (sep) {
char* indexStr = sep + 1;
*sep = 0;
/* check for component */
char* sep = strchr(indexStr, ' ');
DataSetEntry_create(currentDataSet, nameString, -1, NULL);
if (sep) {
componentVal = sep + 1;
*sep = 0;
}
indexVal = atoi(indexStr);
}
DataSetEntry_create(currentDataSet, nameString, indexVal, componentVal);
}
}
else if (StringUtils_startsWith((char*) lineBuffer, "PA")) {
uint32_t vlanPrio;

@ -96,7 +96,7 @@ public class DynamicModelGenerator {
output.println("}");
}
private void exportLogicalNodes(PrintStream output, LogicalDevice logicalDevice) {
private void exportLogicalNodes(PrintStream output, LogicalDevice logicalDevice) throws SclParserException {
for (LogicalNode logicalNode : logicalDevice.getLogicalNodes()) {
output.print("LN(" + logicalNode.getName() + "){\n");
@ -110,7 +110,7 @@ public class DynamicModelGenerator {
return iecString.replace('.', '$');
}
private void exportLogicalNode(PrintStream output, LogicalNode logicalNode, LogicalDevice logicalDevice) {
private void exportLogicalNode(PrintStream output, LogicalNode logicalNode, LogicalDevice logicalDevice) throws SclParserException {
for (SettingControl sgcb : logicalNode.getSettingGroupControlBlocks()) {
output.print("SG(" + sgcb.getActSG() + " " + sgcb.getNumOfSGs() + ")\n");
@ -271,7 +271,7 @@ public class DynamicModelGenerator {
output.println(");");
}
private void exportDataSet(PrintStream output, DataSet dataSet, LogicalNode logicalNode) {
private void exportDataSet(PrintStream output, DataSet dataSet, LogicalNode logicalNode) throws SclParserException {
output.print("DS(" + dataSet.getName() + "){\n");
for (FunctionalConstraintData fcda : dataSet.getFcda()) {
String mmsVariableName = "";
@ -291,6 +291,40 @@ public class DynamicModelGenerator {
if (fcda.getDaName() != null)
mmsVariableName += "$" + toMmsString(fcda.getDaName());
/* check for array index and component */
int arrayStart = mmsVariableName.indexOf('(');
String variableName = mmsVariableName;
int arrayIndex = -1;
String componentName = null;
if (arrayStart != -1) {
variableName = mmsVariableName.substring(0, arrayStart);
int arrayEnd = mmsVariableName.indexOf(')');
String arrayIndexStr = mmsVariableName.substring(arrayStart + 1, arrayEnd);
arrayIndex = Integer.parseInt(arrayIndexStr);
if (arrayIndex < 0) {
throw new SclParserException("Array index out of range in data set entry definition");
}
String componentNamePart = mmsVariableName.substring(arrayEnd + 1);
if ((componentNamePart != null) && (componentNamePart.length() > 0)) {
if (componentNamePart.charAt(0) == '$') {
componentNamePart = componentNamePart.substring(1);
}
if ((componentNamePart != null) && (componentNamePart.length() > 0))
componentName = componentNamePart;
}
}
/* check for LD name */
String logicalDeviceName = null;
if (fcda.getLdInstance() != null) {
@ -300,12 +334,18 @@ public class DynamicModelGenerator {
}
}
if (logicalDeviceName != null)
variableName = logicalDeviceName + "/" + variableName;
if (logicalDeviceName != null)
output.print("DE(" + logicalDeviceName + "/" + mmsVariableName + ");\n");
else
output.print("DE(" + mmsVariableName + ");\n");
if (variableName != null && arrayIndex != -1 && componentName != null) {
output.print("DE(" + variableName + " " + arrayIndex + " " + componentName + ");\n");
}
else if (variableName != null && arrayIndex != -1) {
output.print("DE(" + variableName + " " + arrayIndex + ");\n");
}
else if (variableName != null) {
output.print("DE(" + variableName + ");\n");
}
}
output.println("}");
}

@ -1566,6 +1566,8 @@ public class StaticModelGenerator {
if (fcda.getDaName() != null)
mmsVariableName += "$" + toMmsString(fcda.getDaName());
/* check for array index and component */
int arrayStart = mmsVariableName.indexOf('(');
String variableName = mmsVariableName;

Loading…
Cancel
Save