|
|
|
@ -740,8 +740,14 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
private void printDataAttributeDefinitions(String doName, List<DataAttribute> dataAttributes, boolean isTransient, int arrayIdx) {
|
|
|
|
|
for (int i = 0; i < dataAttributes.size(); i++) {
|
|
|
|
|
boolean isArray = false;
|
|
|
|
|
|
|
|
|
|
DataAttribute dataAttribute = dataAttributes.get(i);
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getCount() > 0) {
|
|
|
|
|
isArray = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String daName = doName + "_" + dataAttribute.getName();
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getFc() == FunctionalConstraint.SE) {
|
|
|
|
@ -771,6 +777,125 @@ public class StaticModelGenerator {
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
if (isArray) {
|
|
|
|
|
|
|
|
|
|
/* first child is array element 0 */
|
|
|
|
|
cOut.println(" (ModelNode*) &" + daName + "_0,");
|
|
|
|
|
|
|
|
|
|
cOut.println(" " + dataAttribute.getCount() + ",");
|
|
|
|
|
cOut.println(" -1,");
|
|
|
|
|
|
|
|
|
|
cOut.println(" IEC61850_FC_" + dataAttribute.getFc().toString() + ",");
|
|
|
|
|
cOut.println(" IEC61850_" + dataAttribute.getType() + ",");
|
|
|
|
|
|
|
|
|
|
/* print trigger options */
|
|
|
|
|
cOut.print(" 0");
|
|
|
|
|
|
|
|
|
|
TriggerOptions trgOps = dataAttribute.getTriggerOptions();
|
|
|
|
|
|
|
|
|
|
if (trgOps.isDchg())
|
|
|
|
|
cOut.print(" + TRG_OPT_DATA_CHANGED");
|
|
|
|
|
|
|
|
|
|
if (trgOps.isDupd())
|
|
|
|
|
cOut.print(" + TRG_OPT_DATA_UPDATE");
|
|
|
|
|
|
|
|
|
|
if (trgOps.isQchg())
|
|
|
|
|
cOut.print(" + TRG_OPT_QUALITY_CHANGED");
|
|
|
|
|
|
|
|
|
|
if (isTransient)
|
|
|
|
|
cOut.print(" + TRG_OPT_TRANSIENT");
|
|
|
|
|
|
|
|
|
|
cOut.println(",");
|
|
|
|
|
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
//TODO REMOVE sAddr code >>>>>
|
|
|
|
|
Long sAddr = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (dataAttribute.getShortAddress() != null)
|
|
|
|
|
sAddr = new Long(dataAttribute.getShortAddress());
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
System.out.println("WARNING: short address \"" + dataAttribute.getShortAddress() + "\" is not valid for libIEC61850!\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sAddr != null)
|
|
|
|
|
cOut.print(" " + sAddr.longValue());
|
|
|
|
|
else
|
|
|
|
|
cOut.print(" 0");
|
|
|
|
|
|
|
|
|
|
// <<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
|
|
|
|
|
cOut.println("};\n");
|
|
|
|
|
|
|
|
|
|
//if (dataAttribute.getSubDataAttributes() != null)
|
|
|
|
|
// printDataAttributeDefinitions(daName, dataAttribute.getSubDataAttributes(), isTransient, -1);
|
|
|
|
|
|
|
|
|
|
//TODO implement ARRAY case!
|
|
|
|
|
|
|
|
|
|
/* Print array elements */
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < dataAttribute.getCount(); idx++) {
|
|
|
|
|
|
|
|
|
|
String arrayElementdaName = daName + "_" + idx;
|
|
|
|
|
|
|
|
|
|
variablesList.add(arrayElementdaName);
|
|
|
|
|
|
|
|
|
|
cOut.println("DataAttribute " + arrayElementdaName + " = {");
|
|
|
|
|
cOut.println(" DataAttributeModelType,");
|
|
|
|
|
cOut.println(" \"" + dataAttribute.getName() + "\",");
|
|
|
|
|
cOut.println(" (ModelNode*) &" + daName + ",");
|
|
|
|
|
|
|
|
|
|
if (idx != dataAttribute.getCount() - 1) {
|
|
|
|
|
String nextArrayElementdaName = daName + "_" + (idx + 1);
|
|
|
|
|
|
|
|
|
|
cOut.println(" (ModelNode*) &" + nextArrayElementdaName + ",");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
if ((dataAttribute.getSubDataAttributes() != null) && (dataAttribute.getSubDataAttributes().size() > 0))
|
|
|
|
|
cOut.println(" (ModelNode*) &" + arrayElementdaName + "_" + dataAttribute.getSubDataAttributes().get(0).getName() + ",");
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
cOut.println(" 0,"); /* number of array elements = 0 */
|
|
|
|
|
cOut.println(" " + idx + ",");
|
|
|
|
|
|
|
|
|
|
cOut.println(" IEC61850_FC_" + dataAttribute.getFc().toString() + ",");
|
|
|
|
|
cOut.println(" IEC61850_" + dataAttribute.getType() + ",");
|
|
|
|
|
|
|
|
|
|
/* print trigger options */
|
|
|
|
|
cOut.print(" 0");
|
|
|
|
|
|
|
|
|
|
trgOps = dataAttribute.getTriggerOptions();
|
|
|
|
|
|
|
|
|
|
if (trgOps.isDchg())
|
|
|
|
|
cOut.print(" + TRG_OPT_DATA_CHANGED");
|
|
|
|
|
|
|
|
|
|
if (trgOps.isDupd())
|
|
|
|
|
cOut.print(" + TRG_OPT_DATA_UPDATE");
|
|
|
|
|
|
|
|
|
|
if (trgOps.isQchg())
|
|
|
|
|
cOut.print(" + TRG_OPT_QUALITY_CHANGED");
|
|
|
|
|
|
|
|
|
|
if (isTransient)
|
|
|
|
|
cOut.print(" + TRG_OPT_TRANSIENT");
|
|
|
|
|
|
|
|
|
|
cOut.println(",");
|
|
|
|
|
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
cOut.print(" 0"); /* sAddr --> REMOVE */
|
|
|
|
|
|
|
|
|
|
cOut.println("};\n");
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getSubDataAttributes() != null)
|
|
|
|
|
printDataAttributeDefinitions(arrayElementdaName, dataAttribute.getSubDataAttributes(), isTransient, -1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if ((dataAttribute.getSubDataAttributes() != null) && (dataAttribute.getSubDataAttributes().size() > 0))
|
|
|
|
|
cOut.println(" (ModelNode*) &" + daName + "_" + dataAttribute.getSubDataAttributes().get(0).getName() + ",");
|
|
|
|
|
else
|
|
|
|
@ -778,6 +903,7 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
cOut.println(" " + dataAttribute.getCount() + ",");
|
|
|
|
|
cOut.println(" -1,");
|
|
|
|
|
|
|
|
|
|
cOut.println(" IEC61850_FC_" + dataAttribute.getFc().toString() + ",");
|
|
|
|
|
cOut.println(" IEC61850_" + dataAttribute.getType() + ",");
|
|
|
|
|
|
|
|
|
@ -802,6 +928,7 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
//TODO REMOVE sAddr code >>>>>
|
|
|
|
|
Long sAddr = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -816,6 +943,8 @@ public class StaticModelGenerator {
|
|
|
|
|
else
|
|
|
|
|
cOut.print(" 0");
|
|
|
|
|
|
|
|
|
|
// <<<<<<<<<<<<<<<<<<<<<<<<
|
|
|
|
|
|
|
|
|
|
cOut.println("};\n");
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getSubDataAttributes() != null)
|
|
|
|
@ -836,6 +965,8 @@ public class StaticModelGenerator {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
printValue(daName, dataAttribute, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1007,9 +1138,22 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
hOut.println("extern DataAttribute " + daName + ";");
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getCount() > 0) {
|
|
|
|
|
for (int idx = 0; idx < dataAttribute.getCount(); idx++) {
|
|
|
|
|
String arrayElemDaName = daName + "_" + idx;
|
|
|
|
|
|
|
|
|
|
hOut.println("extern DataAttribute " + arrayElemDaName + ";");
|
|
|
|
|
|
|
|
|
|
if (dataAttribute.getSubDataAttributes() != null)
|
|
|
|
|
printDataAttributeForwardDeclarations(arrayElemDaName, dataAttribute.getSubDataAttributes());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (dataAttribute.getSubDataAttributes() != null)
|
|
|
|
|
printDataAttributeForwardDeclarations(daName, dataAttribute.getSubDataAttributes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printCFileHeader(String filename) {
|
|
|
|
|