Update ServerModel.java

pull/28/head
AbdelazizSaid250 4 years ago committed by GitHub
parent f9f34cde0c
commit f26d4a15e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,13 +17,8 @@ import com.beanit.iec61850bean.internal.mms.asn1.AlternateAccessSelection;
import com.beanit.iec61850bean.internal.mms.asn1.ObjectName; import com.beanit.iec61850bean.internal.mms.asn1.ObjectName;
import com.beanit.iec61850bean.internal.mms.asn1.ObjectName.DomainSpecific; import com.beanit.iec61850bean.internal.mms.asn1.ObjectName.DomainSpecific;
import com.beanit.iec61850bean.internal.mms.asn1.VariableDefs; import com.beanit.iec61850bean.internal.mms.asn1.VariableDefs;
import java.util.ArrayList;
import java.util.Collection; import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public final class ServerModel extends ModelNode { public final class ServerModel extends ModelNode {
@ -32,6 +27,8 @@ public final class ServerModel extends ModelNode {
private final Map<String, Urcb> urcbs = new HashMap<>(); private final Map<String, Urcb> urcbs = new HashMap<>();
private final Map<String, Brcb> brcbs = new HashMap<>(); private final Map<String, Brcb> brcbs = new HashMap<>();
private ConnectionParam connectionParam;
public ServerModel(List<LogicalDevice> logicalDevices, Collection<DataSet> dataSets) { public ServerModel(List<LogicalDevice> logicalDevices, Collection<DataSet> dataSets) {
children = new LinkedHashMap<>(); children = new LinkedHashMap<>();
objectReference = null; objectReference = null;
@ -136,7 +133,7 @@ public final class ServerModel extends ModelNode {
/** /**
* @param dataSetReference the data set reference * @param dataSetReference the data set reference
* @return returns the DataSet that was removed, null if no DataSet with the given reference was * @return returns the DataSet that was removed, null if no DataSet with the given reference was
* found or the data set is not deletable. * found or the data set is not deletable.
*/ */
DataSet removeDataSet(String dataSetReference) { DataSet removeDataSet(String dataSetReference) {
DataSet dataSet = dataSets.get(dataSetReference); DataSet dataSet = dataSets.get(dataSetReference);
@ -228,9 +225,9 @@ public final class ServerModel extends ModelNode {
* Logical Devices and Logical Nodes the given fc parameter may be <code>null</code>. * Logical Devices and Logical Nodes the given fc parameter may be <code>null</code>.
* *
* @param objectReference the object reference of the node that is being searched for. It has a * @param objectReference the object reference of the node that is being searched for. It has a
* syntax like "ldname/ln.do....". * syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device * @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references. * and Logical Node references.
* @return the model node if it was found or null otherwise * @return the model node if it was found or null otherwise
*/ */
public ModelNode findModelNode(ObjectReference objectReference, Fc fc) { public ModelNode findModelNode(ObjectReference objectReference, Fc fc) {
@ -252,9 +249,9 @@ public final class ServerModel extends ModelNode {
* Logical Devices and Logical Nodes the given fc parameter may be <code>null</code>. * Logical Devices and Logical Nodes the given fc parameter may be <code>null</code>.
* *
* @param objectReference the object reference of the node that is being searched for. It has a * @param objectReference the object reference of the node that is being searched for. It has a
* syntax like "ldname/ln.do....". * syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device * @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references. * and Logical Node references.
* @return the model node if it was found or null otherwise * @return the model node if it was found or null otherwise
*/ */
public ModelNode findModelNode(String objectReference, Fc fc) { public ModelNode findModelNode(String objectReference, Fc fc) {
@ -275,16 +272,16 @@ public final class ServerModel extends ModelNode {
if (objectName == null) { if (objectName == null) {
throw new ServiceError( throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"name in objectName is not selected"); "name in objectName is not selected");
} }
DomainSpecific domainSpecific = objectName.getDomainSpecific(); DomainSpecific domainSpecific = objectName.getDomainSpecific();
if (domainSpecific == null) { if (domainSpecific == null) {
throw new ServiceError( throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"domain_specific in name is not selected"); "domain_specific in name is not selected");
} }
ModelNode modelNode = getChild(domainSpecific.getDomainID().toString()); ModelNode modelNode = getChild(domainSpecific.getDomainID().toString());
@ -298,8 +295,8 @@ public final class ServerModel extends ModelNode {
if (index1 == -1) { if (index1 == -1) {
throw new ServiceError( throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"invalid mms item id: " + domainSpecific.getItemID()); "invalid mms item id: " + domainSpecific.getItemID());
} }
LogicalNode ln = (LogicalNode) modelNode.getChild(mmsItemId.substring(0, index1)); LogicalNode ln = (LogicalNode) modelNode.getChild(mmsItemId.substring(0, index1));
@ -312,15 +309,15 @@ public final class ServerModel extends ModelNode {
if (index2 == -1) { if (index2 == -1) {
throw new ServiceError( throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, "invalid mms item id"); ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, "invalid mms item id");
} }
Fc fc = Fc.fromString(mmsItemId.substring(index1 + 1, index2)); Fc fc = Fc.fromString(mmsItemId.substring(index1 + 1, index2));
if (fc == null) { if (fc == null) {
throw new ServiceError( throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"unknown functional constraint: " + mmsItemId.substring(index1 + 1, index2)); "unknown functional constraint: " + mmsItemId.substring(index1 + 1, index2));
} }
index1 = index2; index1 = index2;
@ -361,26 +358,26 @@ public final class ServerModel extends ModelNode {
} }
AlternateAccessSelection altAccIt = AlternateAccessSelection altAccIt =
variableDef.getAlternateAccess().getCHOICE().get(0).getUnnamed(); variableDef.getAlternateAccess().getCHOICE().get(0).getUnnamed();
if (altAccIt.getSelectAlternateAccess() != null) { if (altAccIt.getSelectAlternateAccess() != null) {
// path to node below an array element // path to node below an array element
modelNode = modelNode =
((Array) modelNode) ((Array) modelNode)
.getChild( .getChild(
altAccIt.getSelectAlternateAccess().getAccessSelection().getIndex().intValue()); altAccIt.getSelectAlternateAccess().getAccessSelection().getIndex().intValue());
String mmsSubArrayItemId = String mmsSubArrayItemId =
altAccIt altAccIt
.getSelectAlternateAccess() .getSelectAlternateAccess()
.getAlternateAccess() .getAlternateAccess()
.getCHOICE() .getCHOICE()
.get(0) .get(0)
.getUnnamed() .getUnnamed()
.getSelectAccess() .getSelectAccess()
.getComponent() .getComponent()
.getBasic() .getBasic()
.toString(); .toString();
index1 = -1; index1 = -1;
index2 = mmsSubArrayItemId.indexOf('$'); index2 = mmsSubArrayItemId.indexOf('$');
@ -394,7 +391,15 @@ public final class ServerModel extends ModelNode {
} else { } else {
// path to an array element // path to an array element
return (FcModelNode) return (FcModelNode)
((Array) modelNode).getChild(altAccIt.getSelectAccess().getIndex().intValue()); ((Array) modelNode).getChild(altAccIt.getSelectAccess().getIndex().intValue());
} }
} }
public ConnectionParam getConnectionParam() {
return connectionParam;
}
public void setConnectionParam(ConnectionParam connectionParam) {
this.connectionParam = connectionParam;
}
} }

Loading…
Cancel
Save