|
|
@ -45,31 +45,36 @@ import org.w3c.dom.NamedNodeMap;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.Node;
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
import org.w3c.dom.NodeList;
|
|
|
|
|
|
|
|
|
|
|
|
final class SclParser {
|
|
|
|
public class SclParser {
|
|
|
|
|
|
|
|
|
|
|
|
private TypeDefinitions typeDefinitions;
|
|
|
|
private TypeDefinitions typeDefinitions;
|
|
|
|
private final Map<String, DataSet> dataSetsMap = new HashMap<>();
|
|
|
|
private final Map<String, DataSet> dataSetsMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
private Document doc;
|
|
|
|
private Document doc;
|
|
|
|
private String iedName;
|
|
|
|
private String iedName;
|
|
|
|
private List<ServerSap> serverSaps = null;
|
|
|
|
private List<ServerModel> serverModels = new ArrayList<>();
|
|
|
|
private boolean useResvTmsAttributes = false;
|
|
|
|
private boolean useResvTmsAttributes = false;
|
|
|
|
|
|
|
|
|
|
|
|
private final List<LnSubDef> dataSetDefs = new ArrayList<>();
|
|
|
|
private final List<LnSubDef> dataSetDefs = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
public List<ServerSap> getServerSaps() {
|
|
|
|
public static List<ServerModel> parse(InputStream is) throws SclParseException {
|
|
|
|
return serverSaps;
|
|
|
|
SclParser sclParser = new SclParser();
|
|
|
|
|
|
|
|
sclParser.parseStream(is);
|
|
|
|
|
|
|
|
return sclParser.serverModels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void parse(String icdFile) throws SclParseException {
|
|
|
|
public static List<ServerModel> parse(String sclFilePath) throws SclParseException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
parse(new FileInputStream(icdFile));
|
|
|
|
return parse(new FileInputStream(sclFilePath));
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
throw new SclParseException(e);
|
|
|
|
throw new SclParseException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void parse(InputStream icdFileStream) throws SclParseException {
|
|
|
|
private SclParser() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void parseStream(InputStream icdFileStream) throws SclParseException {
|
|
|
|
|
|
|
|
|
|
|
|
typeDefinitions = new TypeDefinitions();
|
|
|
|
typeDefinitions = new TypeDefinitions();
|
|
|
|
|
|
|
|
|
|
|
@ -95,29 +100,37 @@ final class SclParser {
|
|
|
|
throw new SclParseException("No IED section found!");
|
|
|
|
throw new SclParseException("No IED section found!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Node nameAttribute = iedList.item(0).getAttributes().getNamedItem("name");
|
|
|
|
for (int z = 0; z < iedList.getLength(); z++) {
|
|
|
|
|
|
|
|
Node iedNode = iedList.item(z);
|
|
|
|
|
|
|
|
|
|
|
|
iedName = nameAttribute.getNodeValue();
|
|
|
|
useResvTmsAttributes = false;
|
|
|
|
if ((iedName == null) || (iedName.length() == 0)) {
|
|
|
|
|
|
|
|
throw new SclParseException("IED must have a name!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NodeList iedElements = iedList.item(0).getChildNodes();
|
|
|
|
Node nameAttribute = iedNode.getAttributes().getNamedItem("name");
|
|
|
|
|
|
|
|
|
|
|
|
serverSaps = new ArrayList<>(iedElements.getLength());
|
|
|
|
iedName = nameAttribute.getNodeValue();
|
|
|
|
for (int i = 0; i < iedElements.getLength(); i++) {
|
|
|
|
if ((iedName == null) || (iedName.length() == 0)) {
|
|
|
|
Node element = iedElements.item(i);
|
|
|
|
throw new SclParseException("IED must have a name!");
|
|
|
|
String nodeName = element.getNodeName();
|
|
|
|
|
|
|
|
if ("AccessPoint".equals(nodeName)) {
|
|
|
|
|
|
|
|
serverSaps.add(createAccessPoint(element));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ("Services".equals(nodeName)) {
|
|
|
|
|
|
|
|
NodeList servicesElements = element.getChildNodes();
|
|
|
|
NodeList iedElements = iedNode.getChildNodes();
|
|
|
|
for (int j = 0; j < servicesElements.getLength(); j++) {
|
|
|
|
|
|
|
|
if ("ReportSettings".equals(servicesElements.item(j).getNodeName())) {
|
|
|
|
for (int i = 0; i < iedElements.getLength(); i++) {
|
|
|
|
Node resvTmsAttribute = servicesElements.item(j).getAttributes().getNamedItem("resvTms");
|
|
|
|
Node element = iedElements.item(i);
|
|
|
|
if (resvTmsAttribute != null) {
|
|
|
|
String nodeName = element.getNodeName();
|
|
|
|
useResvTmsAttributes = resvTmsAttribute.getNodeValue().equalsIgnoreCase("true");
|
|
|
|
if ("AccessPoint".equals(nodeName)) {
|
|
|
|
|
|
|
|
ServerSap serverSap = createAccessPoint(element);
|
|
|
|
|
|
|
|
if (serverSap != null) {
|
|
|
|
|
|
|
|
serverModels.add(serverSap.serverModel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ("Services".equals(nodeName)) {
|
|
|
|
|
|
|
|
NodeList servicesElements = element.getChildNodes();
|
|
|
|
|
|
|
|
for (int j = 0; j < servicesElements.getLength(); j++) {
|
|
|
|
|
|
|
|
if ("ReportSettings".equals(servicesElements.item(j).getNodeName())) {
|
|
|
|
|
|
|
|
Node resvTmsAttribute = servicesElements.item(j).getAttributes().getNamedItem("resvTms");
|
|
|
|
|
|
|
|
if (resvTmsAttribute != null) {
|
|
|
|
|
|
|
|
useResvTmsAttributes = resvTmsAttribute.getNodeValue().equalsIgnoreCase("true");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -174,16 +187,12 @@ final class SclParser {
|
|
|
|
throw new SclParseException("AccessPoint has no name attribute!");
|
|
|
|
throw new SclParseException("AccessPoint has no name attribute!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String name = namedItem.getNodeValue();
|
|
|
|
String name = namedItem.getNodeValue();
|
|
|
|
serverSap = new ServerSap(102, 0, null, server, name, null);
|
|
|
|
serverSap = new ServerSap(102, 0, null, server, null);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (serverSap == null) {
|
|
|
|
|
|
|
|
throw new SclParseException("AccessPoint has no server!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return serverSap;
|
|
|
|
return serverSap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|