|
|
|
@ -48,6 +48,8 @@ import com.libiec61850.scl.model.FunctionalConstraint;
|
|
|
|
|
import com.libiec61850.scl.model.FunctionalConstraintData;
|
|
|
|
|
import com.libiec61850.scl.model.GSEControl;
|
|
|
|
|
import com.libiec61850.scl.model.IED;
|
|
|
|
|
import com.libiec61850.scl.model.Log;
|
|
|
|
|
import com.libiec61850.scl.model.LogControl;
|
|
|
|
|
import com.libiec61850.scl.model.LogicalDevice;
|
|
|
|
|
import com.libiec61850.scl.model.LogicalNode;
|
|
|
|
|
import com.libiec61850.scl.model.ReportControlBlock;
|
|
|
|
@ -70,7 +72,11 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
private StringBuffer logControlBlocks;
|
|
|
|
|
private List<String> lcbVariableNames;
|
|
|
|
|
private int currentLcbVariableNumber;
|
|
|
|
|
private int currentLcbVariableNumber = 0;
|
|
|
|
|
|
|
|
|
|
private StringBuffer logs;
|
|
|
|
|
private List<String> logVariableNames;
|
|
|
|
|
private int currentLogVariableNumber = 0;
|
|
|
|
|
|
|
|
|
|
private StringBuffer gseControlBlocks;
|
|
|
|
|
private List<String> gseVariableNames;
|
|
|
|
@ -104,9 +110,12 @@ public class StaticModelGenerator {
|
|
|
|
|
{
|
|
|
|
|
this.cOut = cOut;
|
|
|
|
|
this.hOut = hOut;
|
|
|
|
|
|
|
|
|
|
this.initializerBuffer = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
this.reportControlBlocks = new StringBuffer();
|
|
|
|
|
this.rcbVariableNames = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
|
this.gseControlBlocks = new StringBuffer();
|
|
|
|
|
this.gseVariableNames = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
@ -116,6 +125,12 @@ public class StaticModelGenerator {
|
|
|
|
|
this.settingGroupControlBlocks = new StringBuffer();
|
|
|
|
|
this.sgcbVariableNames = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
|
this.logControlBlocks = new StringBuffer();
|
|
|
|
|
this.lcbVariableNames = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
|
this.logs = new StringBuffer();
|
|
|
|
|
this.logVariableNames = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
|
SclParser sclParser = new SclParser(stream);
|
|
|
|
|
|
|
|
|
|
this.outputFileName = outputFileName;
|
|
|
|
@ -256,15 +271,6 @@ public class StaticModelGenerator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private String getLogicalDeviceName(LogicalDevice logicalDevice) {
|
|
|
|
|
// String logicalDeviceName = logicalDevice.getLdName();
|
|
|
|
|
//
|
|
|
|
|
// if (logicalDeviceName == null)
|
|
|
|
|
// logicalDeviceName = ied.getName() + logicalDevice.getInst();
|
|
|
|
|
//
|
|
|
|
|
// return logicalDeviceName;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private String getLogicalDeviceInst(LogicalDevice logicalDevice) {
|
|
|
|
|
return logicalDevice.getInst();
|
|
|
|
|
}
|
|
|
|
@ -277,6 +283,10 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
createReportVariableList(logicalDevices);
|
|
|
|
|
|
|
|
|
|
createLogControlVariableList(logicalDevices);
|
|
|
|
|
|
|
|
|
|
createLogVariableList(logicalDevices);
|
|
|
|
|
|
|
|
|
|
createGooseVariableList(logicalDevices);
|
|
|
|
|
|
|
|
|
|
createSmvVariableList(logicalDevices);
|
|
|
|
@ -322,6 +332,7 @@ public class StaticModelGenerator {
|
|
|
|
|
|
|
|
|
|
cOut.println(reportControlBlocks);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String smv : smvVariableNames)
|
|
|
|
|
cOut.println("extern SVControlBlock " + smv + ";");
|
|
|
|
|
|
|
|
|
@ -336,7 +347,17 @@ public class StaticModelGenerator {
|
|
|
|
|
cOut.println("extern SettingGroupControlBlock " + sgcb + ";");
|
|
|
|
|
|
|
|
|
|
cOut.println(settingGroupControlBlocks);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String lcb : lcbVariableNames)
|
|
|
|
|
cOut.println("extern LogControlBlock " + lcb + ";");
|
|
|
|
|
|
|
|
|
|
cOut.println(logControlBlocks);
|
|
|
|
|
|
|
|
|
|
for (String log : logVariableNames)
|
|
|
|
|
cOut.println("extern Log " + log + ";");
|
|
|
|
|
|
|
|
|
|
cOut.println(logs);
|
|
|
|
|
|
|
|
|
|
String firstLogicalDeviceName = logicalDevices.get(0).getInst();
|
|
|
|
|
cOut.println("\nIedModel " + modelPrefix + " = {");
|
|
|
|
|
cOut.println(" \"" + ied.getName() + "\",");
|
|
|
|
@ -367,6 +388,16 @@ public class StaticModelGenerator {
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
if (lcbVariableNames.size() > 0)
|
|
|
|
|
cOut.println(" &" + lcbVariableNames.get(0) + ",");
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
if (logVariableNames.size() > 0)
|
|
|
|
|
cOut.println(" &" + logVariableNames.get(0) + ",");
|
|
|
|
|
else
|
|
|
|
|
cOut.println(" NULL,");
|
|
|
|
|
|
|
|
|
|
cOut.println(" initializeValues\n};");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -442,6 +473,54 @@ public class StaticModelGenerator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createLogControlVariableList(List<LogicalDevice> logicalDevices)
|
|
|
|
|
{
|
|
|
|
|
for (LogicalDevice ld : logicalDevices) {
|
|
|
|
|
List<LogicalNode> lnodes = ld.getLogicalNodes();
|
|
|
|
|
|
|
|
|
|
String ldName = ld.getInst();
|
|
|
|
|
|
|
|
|
|
for (LogicalNode ln : lnodes) {
|
|
|
|
|
List<LogControl> lcbs = ln.getLogControlBlocks();
|
|
|
|
|
|
|
|
|
|
int lcbCount = 0;
|
|
|
|
|
|
|
|
|
|
for (LogControl logControl : lcbs) {
|
|
|
|
|
|
|
|
|
|
String lcbVariableName = modelPrefix + "_" + ldName + "_" + ln.getName() + "_lcb" + lcbCount;
|
|
|
|
|
|
|
|
|
|
lcbVariableNames.add(lcbVariableName);
|
|
|
|
|
|
|
|
|
|
lcbCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createLogVariableList(List<LogicalDevice> logicalDevices)
|
|
|
|
|
{
|
|
|
|
|
for (LogicalDevice ld : logicalDevices) {
|
|
|
|
|
List<LogicalNode> lnodes = ld.getLogicalNodes();
|
|
|
|
|
|
|
|
|
|
String ldName = ld.getInst();
|
|
|
|
|
|
|
|
|
|
for (LogicalNode ln : lnodes) {
|
|
|
|
|
List<Log> logs = ln.getLogs();
|
|
|
|
|
|
|
|
|
|
int logCount = 0;
|
|
|
|
|
|
|
|
|
|
for (Log log : logs) {
|
|
|
|
|
|
|
|
|
|
String logVariableName = modelPrefix + "_" + ldName + "_" + ln.getName() + "_log" + logCount;
|
|
|
|
|
|
|
|
|
|
logVariableNames.add(logVariableName);
|
|
|
|
|
|
|
|
|
|
logCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createSettingControlsVariableList(List<LogicalDevice> logicalDevices) {
|
|
|
|
|
for (LogicalDevice ld : logicalDevices) {
|
|
|
|
|
List<LogicalNode> lnodes = ld.getLogicalNodes();
|
|
|
|
@ -488,6 +567,10 @@ public class StaticModelGenerator {
|
|
|
|
|
printDataObjectDefinitions(lnName, logicalNode.getDataObjects(), null);
|
|
|
|
|
|
|
|
|
|
printReportControlBlocks(lnName, logicalNode);
|
|
|
|
|
|
|
|
|
|
printLogControlBlocks(lnName, logicalNode);
|
|
|
|
|
|
|
|
|
|
printLogs(lnName, logicalNode);
|
|
|
|
|
|
|
|
|
|
printGSEControlBlocks(ldName, lnName, logicalNode);
|
|
|
|
|
|
|
|
|
@ -994,6 +1077,34 @@ public class StaticModelGenerator {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printLogControlBlocks(String lnPrefix, LogicalNode logicalNode)
|
|
|
|
|
{
|
|
|
|
|
List<LogControl> logControlBlocks = logicalNode.getLogControlBlocks();
|
|
|
|
|
|
|
|
|
|
int lcbCount = logControlBlocks.size();
|
|
|
|
|
|
|
|
|
|
int lcbNumber = 0;
|
|
|
|
|
|
|
|
|
|
for (LogControl lcb : logControlBlocks) {
|
|
|
|
|
printLogControlBlock(lnPrefix, lcb, lcbNumber, lcbCount);
|
|
|
|
|
lcbNumber++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printLogs(String lnPrefix, LogicalNode logicalNode)
|
|
|
|
|
{
|
|
|
|
|
List<Log> logs = logicalNode.getLogs();
|
|
|
|
|
|
|
|
|
|
int logCount = logs.size();
|
|
|
|
|
|
|
|
|
|
int logNumber = 0;
|
|
|
|
|
|
|
|
|
|
for (Log log : logs) {
|
|
|
|
|
printLog(lnPrefix, log, logNumber, logCount);
|
|
|
|
|
logNumber++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printSettingControlBlock(String lnPrefix, LogicalNode logicalNode)
|
|
|
|
|
{
|
|
|
|
|
List<SettingControl> settingControls = logicalNode.getSettingGroupControlBlocks();
|
|
|
|
@ -1023,8 +1134,85 @@ public class StaticModelGenerator {
|
|
|
|
|
currentSGCBVariableNumber++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printLog(String lnPrefix, Log log, int logNumber, int logCount)
|
|
|
|
|
{
|
|
|
|
|
String logVariableName = lnPrefix + "_log" + logNumber;
|
|
|
|
|
|
|
|
|
|
String logString = "Log " + logVariableName + " = {";
|
|
|
|
|
|
|
|
|
|
logString += "&" + lnPrefix + ", ";
|
|
|
|
|
|
|
|
|
|
logString += "\"" + log.getName() + "\", ";
|
|
|
|
|
|
|
|
|
|
currentLogVariableNumber++;
|
|
|
|
|
|
|
|
|
|
if (currentLogVariableNumber < logVariableNames.size())
|
|
|
|
|
logString += "&" + logVariableNames.get(currentLogVariableNumber);
|
|
|
|
|
else
|
|
|
|
|
logString += "NULL";
|
|
|
|
|
|
|
|
|
|
logString += "};\n";
|
|
|
|
|
|
|
|
|
|
private void printReportControlBlockInstance(String lnPrefix, ReportControlBlock rcb, String index, int reportNumber, int reportsCount) {
|
|
|
|
|
this.logs.append(logString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printLogControlBlock(String lnPrefix, LogControl lcb, int lcbNumber, int lcbCount)
|
|
|
|
|
{
|
|
|
|
|
String lcbVariableName = lnPrefix + "_lcb" + lcbNumber;
|
|
|
|
|
|
|
|
|
|
String lcbString = "LogControlBlock " + lcbVariableName + " = {";
|
|
|
|
|
|
|
|
|
|
lcbString += "&" + lnPrefix + ", ";
|
|
|
|
|
|
|
|
|
|
lcbString += "\"" + lcb.getName() + "\", ";
|
|
|
|
|
|
|
|
|
|
if (lcb.getDataSet() != null)
|
|
|
|
|
lcbString += "\"" + lcb.getDataSet() + "\", ";
|
|
|
|
|
else
|
|
|
|
|
lcbString += "NULL, ";
|
|
|
|
|
|
|
|
|
|
if (lcb.getLogName() != null)
|
|
|
|
|
lcbString += "\"" + lcb.getLogName() + "\", ";
|
|
|
|
|
else
|
|
|
|
|
lcbString += "NULL, ";
|
|
|
|
|
|
|
|
|
|
int triggerOps = 16;
|
|
|
|
|
|
|
|
|
|
if (lcb.getTriggerOptions() != null)
|
|
|
|
|
triggerOps = lcb.getTriggerOptions().getIntValue();
|
|
|
|
|
|
|
|
|
|
lcbString += triggerOps + ", ";
|
|
|
|
|
|
|
|
|
|
if (lcb.getIntgPd() != 0)
|
|
|
|
|
lcbString += lcb.getIntgPd() + ", ";
|
|
|
|
|
else
|
|
|
|
|
lcbString += "0, ";
|
|
|
|
|
|
|
|
|
|
if (lcb.isLogEna())
|
|
|
|
|
lcbString += "true, ";
|
|
|
|
|
else
|
|
|
|
|
lcbString += "false, ";
|
|
|
|
|
|
|
|
|
|
if (lcb.isReasonCode())
|
|
|
|
|
lcbString += "true, ";
|
|
|
|
|
else
|
|
|
|
|
lcbString += "false, ";
|
|
|
|
|
|
|
|
|
|
currentLcbVariableNumber++;
|
|
|
|
|
|
|
|
|
|
if (currentLcbVariableNumber < lcbVariableNames.size())
|
|
|
|
|
lcbString += "&" + lcbVariableNames.get(currentLcbVariableNumber);
|
|
|
|
|
else
|
|
|
|
|
lcbString += "NULL";
|
|
|
|
|
|
|
|
|
|
lcbString += "};\n";
|
|
|
|
|
|
|
|
|
|
this.logControlBlocks.append(lcbString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printReportControlBlockInstance(String lnPrefix, ReportControlBlock rcb, String index, int reportNumber, int reportsCount)
|
|
|
|
|
{
|
|
|
|
|
String rcbVariableName = lnPrefix + "_report" + reportNumber;
|
|
|
|
|
|
|
|
|
|
String rcbString = "ReportControlBlock " + rcbVariableName + " = {";
|
|
|
|
|