From 4982b9614516dde101c3e44c60a612b3bfd8d6fe Mon Sep 17 00:00:00 2001 From: DELL <DELL@WIN-3EOIPEE9ML1> Date: 星期三, 21 二月 2024 16:26:06 +0800 Subject: [PATCH] 新增IEDScout调试工具功能 --- iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/ObjectReference.java | 348 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 174 insertions(+), 174 deletions(-) diff --git a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/ObjectReference.java b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/ObjectReference.java index fa8fb2d..1592adb 100644 --- a/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/ObjectReference.java +++ b/iec61850_forFoShanAES_Model/src/org/openmuc/openiec61850/ObjectReference.java @@ -1,174 +1,174 @@ -/* - * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.openmuc.openiec61850; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -/** - * ObjectReference syntax: LDName/LNName.DOName[.Name[. ...]] - * - */ -public final class ObjectReference implements Iterable<String> { - - private final String objectReference; - private List<String> nodeNames = null; - - // if the ObjectReference contains an array index this variable will save - // its position in the nodeNames List - private int arrayIndexPosition = -1; - - public ObjectReference(String objectReference) { - if (objectReference == null || objectReference.isEmpty()) { - throw new IllegalArgumentException(); - } - this.objectReference = objectReference; - } - - /** - * @return Returns name part of the reference. - */ - public String getName() { - if (nodeNames == null) { - parseForNameList(); - } - return nodeNames.get(nodeNames.size() - 1); - } - - @Override - public String toString() { - return objectReference; - } - - public boolean isLogicalDeviceRef() { - if (nodeNames == null) { - parseForNameList(); - } - return (nodeNames.size() == 1); - } - - public boolean isLogicalNodeRef() { - if (nodeNames == null) { - parseForNameList(); - } - return (nodeNames.size() == 2); - } - - public boolean isDataRef() { - if (nodeNames == null) { - parseForNameList(); - } - return (nodeNames.size() > 2); - } - - int getArrayIndexPosition() { - if (nodeNames == null) { - parseForNameList(); - } - return arrayIndexPosition; - } - - @Override - public Iterator<String> iterator() { - if (nodeNames == null) { - parseForNameList(); - } - return nodeNames.iterator(); - } - - public String get(int i) { - if (nodeNames == null) { - parseForNameList(); - } - return nodeNames.get(i); - } - - public int size() { - if (nodeNames == null) { - parseForNameList(); - } - return nodeNames.size(); - } - - private void parseForNameList() { - - nodeNames = new LinkedList<>(); - - int lastDelim = -1; - int nextDelim = objectReference.indexOf('/'); - if (nextDelim == -1) { - nodeNames.add(objectReference.substring(lastDelim + 1, objectReference.length())); - return; - } - - nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim)); - - int dotIndex = -1; - int openingbracketIndex = -1; - int closingbracketIndex = -1; - while (true) { - lastDelim = nextDelim; - if (dotIndex == -1) { - dotIndex = objectReference.indexOf('.', lastDelim + 1); - if (dotIndex == -1) { - dotIndex = objectReference.length(); - } - } - if (openingbracketIndex == -1) { - openingbracketIndex = objectReference.indexOf('(', lastDelim + 1); - if (openingbracketIndex == -1) { - openingbracketIndex = objectReference.length(); - } - } - if (closingbracketIndex == -1) { - closingbracketIndex = objectReference.indexOf(')', lastDelim + 1); - if (closingbracketIndex == -1) { - closingbracketIndex = objectReference.length(); - } - } - - if (dotIndex == openingbracketIndex && dotIndex == closingbracketIndex) { - nodeNames.add(objectReference.substring(lastDelim + 1, objectReference.length())); - return; - } - - if (dotIndex < openingbracketIndex && dotIndex < closingbracketIndex) { - nextDelim = dotIndex; - dotIndex = -1; - } - else if (openingbracketIndex < dotIndex && openingbracketIndex < closingbracketIndex) { - nextDelim = openingbracketIndex; - openingbracketIndex = -1; - arrayIndexPosition = nodeNames.size() + 1; - } - else if (closingbracketIndex < dotIndex && closingbracketIndex < openingbracketIndex) { - if (closingbracketIndex == (objectReference.length() - 1)) { - nodeNames.add(objectReference.substring(lastDelim + 1, closingbracketIndex)); - return; - } - nextDelim = closingbracketIndex + 1; - closingbracketIndex = -1; - dotIndex = -1; - nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim - 1)); - continue; - - } - nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim)); - } - } -} +/* + * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.openmuc.openiec61850; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +/** + * ObjectReference syntax: LDName/LNName.DOName[.Name[. ...]] + * + */ +public final class ObjectReference implements Iterable<String> { + + private final String objectReference; + private List<String> nodeNames = null; + + // if the ObjectReference contains an array index this variable will save + // its position in the nodeNames List + private int arrayIndexPosition = -1; + + public ObjectReference(String objectReference) { + if (objectReference == null || objectReference.isEmpty()) { + throw new IllegalArgumentException(); + } + this.objectReference = objectReference; + } + + /** + * @return Returns name part of the reference. + */ + public String getName() { + if (nodeNames == null) { + parseForNameList(); + } + return nodeNames.get(nodeNames.size() - 1); + } + + @Override + public String toString() { + return objectReference; + } + + public boolean isLogicalDeviceRef() { + if (nodeNames == null) { + parseForNameList(); + } + return (nodeNames.size() == 1); + } + + public boolean isLogicalNodeRef() { + if (nodeNames == null) { + parseForNameList(); + } + return (nodeNames.size() == 2); + } + + public boolean isDataRef() { + if (nodeNames == null) { + parseForNameList(); + } + return (nodeNames.size() > 2); + } + + int getArrayIndexPosition() { + if (nodeNames == null) { + parseForNameList(); + } + return arrayIndexPosition; + } + + @Override + public Iterator<String> iterator() { + if (nodeNames == null) { + parseForNameList(); + } + return nodeNames.iterator(); + } + + public String get(int i) { + if (nodeNames == null) { + parseForNameList(); + } + return nodeNames.get(i); + } + + public int size() { + if (nodeNames == null) { + parseForNameList(); + } + return nodeNames.size(); + } + + private void parseForNameList() { + + nodeNames = new LinkedList<>(); + + int lastDelim = -1; + int nextDelim = objectReference.indexOf('/'); + if (nextDelim == -1) { + nodeNames.add(objectReference.substring(lastDelim + 1, objectReference.length())); + return; + } + + nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim)); + + int dotIndex = -1; + int openingbracketIndex = -1; + int closingbracketIndex = -1; + while (true) { + lastDelim = nextDelim; + if (dotIndex == -1) { + dotIndex = objectReference.indexOf('.', lastDelim + 1); + if (dotIndex == -1) { + dotIndex = objectReference.length(); + } + } + if (openingbracketIndex == -1) { + openingbracketIndex = objectReference.indexOf('(', lastDelim + 1); + if (openingbracketIndex == -1) { + openingbracketIndex = objectReference.length(); + } + } + if (closingbracketIndex == -1) { + closingbracketIndex = objectReference.indexOf(')', lastDelim + 1); + if (closingbracketIndex == -1) { + closingbracketIndex = objectReference.length(); + } + } + + if (dotIndex == openingbracketIndex && dotIndex == closingbracketIndex) { + nodeNames.add(objectReference.substring(lastDelim + 1, objectReference.length())); + return; + } + + if (dotIndex < openingbracketIndex && dotIndex < closingbracketIndex) { + nextDelim = dotIndex; + dotIndex = -1; + } + else if (openingbracketIndex < dotIndex && openingbracketIndex < closingbracketIndex) { + nextDelim = openingbracketIndex; + openingbracketIndex = -1; + arrayIndexPosition = nodeNames.size() + 1; + } + else if (closingbracketIndex < dotIndex && closingbracketIndex < openingbracketIndex) { + if (closingbracketIndex == (objectReference.length() - 1)) { + nodeNames.add(objectReference.substring(lastDelim + 1, closingbracketIndex)); + return; + } + nextDelim = closingbracketIndex + 1; + closingbracketIndex = -1; + dotIndex = -1; + nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim - 1)); + continue; + + } + nodeNames.add(objectReference.substring(lastDelim + 1, nextDelim)); + } + } +} -- Gitblit v1.9.1