- Add ConnectionParam.java to extract the connection parameters under ConnectedAP tag in the CID/SCD file while parsing it.

- Add the ConnectionParam to the ServerModel.java to be retrieved after parsing the CID/SCD file.
- Enhance the SclParser.java to parse the ConnectionParam under the ConnectedAP tag.
- Optimize imports in the SclParser.java
- Remove the unnecessary .toStrings in the SclParser.java
- Replace the If-else with switch case in the SclParser.java
pull/30/head
Abdelaziz Said 4 years ago
parent f9f34cde0c
commit c8f49bdc47

@ -0,0 +1,148 @@
package com.beanit.iec61850bean;
import java.util.Objects;
public class ConnectionParam {
private String iedName;
private String IP;
private String IP_SUBNET;
private String OSI_AP_Title;
private String OSI_AE_Qualifier;
private String OSI_PSEL;
private String OSI_SSEL;
private String OSI_TSEL;
private String IP_GATEWAY;
private String S_Profile;
private String MAC_Address;
public String getIedName() {
return iedName;
}
public void setIedName(String iedName) {
this.iedName = iedName;
}
public String getIP() {
return IP;
}
public void setIP(String IP) {
this.IP = IP;
}
public String getIP_SUBNET() {
return IP_SUBNET;
}
public void setIP_SUBNET(String IP_SUBNET) {
this.IP_SUBNET = IP_SUBNET;
}
public String getOSI_AP_Title() {
return OSI_AP_Title;
}
public void setOSI_AP_Title(String OSI_AP_Title) {
this.OSI_AP_Title = OSI_AP_Title;
}
public String getOSI_AE_Qualifier() {
return OSI_AE_Qualifier;
}
public void setOSI_AE_Qualifier(String OSI_AE_Qualifier) {
this.OSI_AE_Qualifier = OSI_AE_Qualifier;
}
public String getOSI_PSEL() {
return OSI_PSEL;
}
public void setOSI_PSEL(String OSI_PSEL) {
this.OSI_PSEL = OSI_PSEL;
}
public String getOSI_SSEL() {
return OSI_SSEL;
}
public void setOSI_SSEL(String OSI_SSEL) {
this.OSI_SSEL = OSI_SSEL;
}
public String getOSI_TSEL() {
return OSI_TSEL;
}
public void setOSI_TSEL(String OSI_TSEL) {
this.OSI_TSEL = OSI_TSEL;
}
public String getIP_GATEWAY() {
return IP_GATEWAY;
}
public void setIP_GATEWAY(String IP_GATEWAY) {
this.IP_GATEWAY = IP_GATEWAY;
}
public String getS_Profile() {
return S_Profile;
}
public void setS_Profile(String s_Profile) {
S_Profile = s_Profile;
}
public String getMAC_Address() {
return MAC_Address;
}
public void setMAC_Address(String MAC_Address) {
this.MAC_Address = MAC_Address;
}
@Override
public String toString() {
return "iedName = " + iedName + '\n' +
"IP = " + IP + '\n' +
"IP_SUBNET = " + IP_SUBNET + '\n' +
"OSI_AP_Title = " + OSI_AP_Title + '\n' +
"OSI_AE_Qualifier = " + OSI_AE_Qualifier + '\n' +
"OSI_PSEL = " + OSI_PSEL + '\n' +
"OSI_SSEL = " + OSI_SSEL + '\n' +
"OSI_TSEL = " + OSI_TSEL + '\n' +
"IP_GATEWAY = " + IP_GATEWAY + '\n' +
"S_Profile = " + S_Profile + '\n' +
"MAC-Address = " + MAC_Address
;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ConnectionParam that = (ConnectionParam) o;
return iedName.equals(that.iedName) &&
IP.equals(that.IP) &&
Objects.equals(IP_SUBNET, that.IP_SUBNET) &&
Objects.equals(OSI_AP_Title, that.OSI_AP_Title) &&
Objects.equals(OSI_AE_Qualifier, that.OSI_AE_Qualifier) &&
Objects.equals(OSI_PSEL, that.OSI_PSEL) &&
Objects.equals(OSI_SSEL, that.OSI_SSEL) &&
Objects.equals(OSI_TSEL, that.OSI_TSEL) &&
Objects.equals(IP_GATEWAY, that.IP_GATEWAY) &&
Objects.equals(S_Profile, that.S_Profile) &&
Objects.equals(MAC_Address, that.MAC_Address);
}
@Override
public int hashCode() {
return Objects.hash(iedName, IP, IP_SUBNET, OSI_AP_Title, OSI_AE_Qualifier, OSI_PSEL, OSI_SSEL,
OSI_TSEL, IP_GATEWAY, S_Profile, MAC_Address);
}
}

File diff suppressed because it is too large Load Diff

@ -17,384 +17,389 @@ import com.beanit.iec61850bean.internal.mms.asn1.AlternateAccessSelection;
import com.beanit.iec61850bean.internal.mms.asn1.ObjectName;
import com.beanit.iec61850bean.internal.mms.asn1.ObjectName.DomainSpecific;
import com.beanit.iec61850bean.internal.mms.asn1.VariableDefs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public final class ServerModel extends ModelNode {
private final Map<String, DataSet> dataSets = new LinkedHashMap<>();
private final Map<String, DataSet> dataSets = new LinkedHashMap<>();
private final Map<String, Urcb> urcbs = new HashMap<>();
private final Map<String, Brcb> brcbs = new HashMap<>();
private final Map<String, Urcb> urcbs = new HashMap<>();
private final Map<String, Brcb> brcbs = new HashMap<>();
public ServerModel(List<LogicalDevice> logicalDevices, Collection<DataSet> dataSets) {
children = new LinkedHashMap<>();
objectReference = null;
for (LogicalDevice logicalDevice : logicalDevices) {
children.put(logicalDevice.getReference().getName(), logicalDevice);
logicalDevice.setParent(this);
}
private ConnectionParam connectionParam;
if (dataSets != null) {
addDataSets(dataSets);
}
public ServerModel(List<LogicalDevice> logicalDevices, Collection<DataSet> dataSets) {
children = new LinkedHashMap<>();
objectReference = null;
for (LogicalDevice logicalDevice : logicalDevices) {
children.put(logicalDevice.getReference().getName(), logicalDevice);
logicalDevice.setParent(this);
}
for (LogicalDevice ld : logicalDevices) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcbs.put(urcb.getReference().toString(), urcb);
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
if (dataSets != null) {
addDataSets(dataSets);
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcbs.put(brcb.getReference().toString(), brcb);
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
for (LogicalDevice ld : logicalDevices) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcbs.put(urcb.getReference().toString(), urcb);
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcbs.put(brcb.getReference().toString(), brcb);
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
}
}
}
}
}
}
@Override
public ServerModel copy() {
List<LogicalDevice> childCopies = new ArrayList<>(children.size());
for (ModelNode childNode : children.values()) {
childCopies.add((LogicalDevice) childNode.copy());
@Override
public ServerModel copy() {
List<LogicalDevice> childCopies = new ArrayList<>(children.size());
for (ModelNode childNode : children.values()) {
childCopies.add((LogicalDevice) childNode.copy());
}
List<DataSet> dataSetCopies = new ArrayList<>(dataSets.size());
for (DataSet dataSet : dataSets.values()) {
dataSetCopies.add(dataSet);
}
return new ServerModel(childCopies, dataSetCopies);
}
List<DataSet> dataSetCopies = new ArrayList<>(dataSets.size());
for (DataSet dataSet : dataSets.values()) {
dataSetCopies.add(dataSet);
/**
* Get the data set with the given reference. Return null if none is found.
*
* @param reference the reference of the requested data set.
* @return the data set with the given reference.
*/
public DataSet getDataSet(String reference) {
return dataSets.get(reference);
}
return new ServerModel(childCopies, dataSetCopies);
}
/**
* Get the data set with the given reference. Return null if none is found.
*
* @param reference the reference of the requested data set.
* @return the data set with the given reference.
*/
public DataSet getDataSet(String reference) {
return dataSets.get(reference);
}
void addDataSet(DataSet dataSet) {
dataSets.put(dataSet.getReferenceStr().replace('$', '.'), dataSet);
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
void addDataSet(DataSet dataSet) {
dataSets.put(dataSet.getReferenceStr().replace('$', '.'), dataSet);
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
}
}
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
}
}
}
}
void addDataSets(Collection<DataSet> dataSets) {
for (DataSet dataSet : dataSets) {
addDataSet(dataSet);
}
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
void addDataSets(Collection<DataSet> dataSets) {
for (DataSet dataSet : dataSets) {
addDataSet(dataSet);
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
}
}
}
}
}
}
List<String> getDataSetNames(String ldName) {
// TODO make thread save
List<String> dataSetNames = new ArrayList<>();
for (String dataSetRef : dataSets.keySet()) {
if (dataSetRef.startsWith(ldName)) {
dataSetNames.add(dataSetRef.substring(dataSetRef.indexOf('/') + 1).replace('.', '$'));
}
List<String> getDataSetNames(String ldName) {
// TODO make thread save
List<String> dataSetNames = new ArrayList<>();
for (String dataSetRef : dataSets.keySet()) {
if (dataSetRef.startsWith(ldName)) {
dataSetNames.add(dataSetRef.substring(dataSetRef.indexOf('/') + 1).replace('.', '$'));
}
}
return dataSetNames;
}
return dataSetNames;
}
/**
* Get a collection of all data sets that exist in this model.
*
* @return a collection of all data sets
*/
public Collection<DataSet> getDataSets() {
return dataSets.values();
}
/**
* @param dataSetReference the data set reference
* @return returns the DataSet that was removed, null if no DataSet with the given reference was
* found or the data set is not deletable.
*/
DataSet removeDataSet(String dataSetReference) {
DataSet dataSet = dataSets.get(dataSetReference);
if (dataSet == null || !dataSet.isDeletable()) {
return null;
/**
* Get a collection of all data sets that exist in this model.
*
* @return a collection of all data sets
*/
public Collection<DataSet> getDataSets() {
return dataSets.values();
}
DataSet removedDataSet = dataSets.remove(dataSetReference);
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
/**
* @param dataSetReference the data set reference
* @return returns the DataSet that was removed, null if no DataSet with the given reference was
* found or the data set is not deletable.
*/
DataSet removeDataSet(String dataSetReference) {
DataSet dataSet = dataSets.get(dataSetReference);
if (dataSet == null || !dataSet.isDeletable()) {
return null;
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
DataSet removedDataSet = dataSets.remove(dataSetReference);
for (ModelNode ld : children.values()) {
for (ModelNode ln : ld.getChildren()) {
for (Urcb urcb : ((LogicalNode) ln).getUrcbs()) {
urcb.dataSet = getDataSet(urcb.getDatSet().getStringValue().replace('$', '.'));
}
for (Brcb brcb : ((LogicalNode) ln).getBrcbs()) {
brcb.dataSet = getDataSet(brcb.getDatSet().getStringValue().replace('$', '.'));
}
}
}
}
}
return removedDataSet;
}
void addUrcb(Urcb urcb) {
urcbs.put(urcb.getReference().getName(), urcb);
}
/**
* Get the unbuffered report control block (URCB) with the given reference.
*
* @param reference the reference of the requested URCB.
* @return the reference to the requested URCB or null if none with the given reference is found.
*/
public Urcb getUrcb(String reference) {
return urcbs.get(reference);
}
/**
* Get a collection of all unbuffered report control blocks (URCB) that exist in this model.
*
* @return a collection of all unbuffered report control blocks (URCB)
*/
public Collection<Urcb> getUrcbs() {
return urcbs.values();
}
/**
* Get the buffered report control block (BRCB) with the given reference.
*
* @param reference the reference of the requested BRCB.
* @return the reference to the requested BRCB or null if none with the given reference is found.
*/
public Brcb getBrcb(String reference) {
return brcbs.get(reference);
}
/**
* Get a collection of all buffered report control blocks (BRCB) that exist in this model.
*
* @return a collection of all buffered report control blocks (BRCB)
*/
public Collection<Brcb> getBrcbs() {
return brcbs.values();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (ModelNode logicalDevice : children.values()) {
sb.append(logicalDevice.toString());
return removedDataSet;
}
sb.append("\n\n\n---------------------\nURCBs:");
for (Urcb urcb : getUrcbs()) {
sb.append("\n\n").append(urcb);
void addUrcb(Urcb urcb) {
urcbs.put(urcb.getReference().getName(), urcb);
}
sb.append("\n\n\n---------------------\nBRCBs:");
for (Brcb brcb : getBrcbs()) {
sb.append("\n\n").append(brcb);
/**
* Get the unbuffered report control block (URCB) with the given reference.
*
* @param reference the reference of the requested URCB.
* @return the reference to the requested URCB or null if none with the given reference is found.
*/
public Urcb getUrcb(String reference) {
return urcbs.get(reference);
}
sb.append("\n\n\n---------------------\nData sets:");
for (DataSet dataSet : getDataSets()) {
sb.append("\n\n").append(dataSet);
/**
* Get a collection of all unbuffered report control blocks (URCB) that exist in this model.
*
* @return a collection of all unbuffered report control blocks (URCB)
*/
public Collection<Urcb> getUrcbs() {
return urcbs.values();
}
return sb.toString();
}
/**
* Searches and returns the model node with the given object reference and FC. If searching for
* 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
* syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references.
* @return the model node if it was found or null otherwise
*/
public ModelNode findModelNode(ObjectReference objectReference, Fc fc) {
ModelNode currentNode = this;
Iterator<String> searchedNodeReferenceIterator = objectReference.iterator();
while (searchedNodeReferenceIterator.hasNext()) {
currentNode = currentNode.getChild(searchedNodeReferenceIterator.next(), fc);
if (currentNode == null) {
return null;
}
/**
* Get the buffered report control block (BRCB) with the given reference.
*
* @param reference the reference of the requested BRCB.
* @return the reference to the requested BRCB or null if none with the given reference is found.
*/
public Brcb getBrcb(String reference) {
return brcbs.get(reference);
}
return currentNode;
}
/**
* Searches and returns the model node with the given object reference and FC. If searching for
* 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
* syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references.
* @return the model node if it was found or null otherwise
*/
public ModelNode findModelNode(String objectReference, Fc fc) {
return findModelNode(new ObjectReference(objectReference), fc);
}
/**
* Returns the subModelNode that is referenced by the given VariableDef. Return null in case the
* referenced ModelNode is not found.
*
* @param variableDef the variableDef
* @return the subModelNode that is referenced by the given VariableDef
* @throws ServiceError if an error occurs
*/
FcModelNode getNodeFromVariableDef(VariableDefs.SEQUENCE variableDef) throws ServiceError {
ObjectName objectName = variableDef.getVariableSpecification().getName();
if (objectName == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"name in objectName is not selected");
/**
* Get a collection of all buffered report control blocks (BRCB) that exist in this model.
*
* @return a collection of all buffered report control blocks (BRCB)
*/
public Collection<Brcb> getBrcbs() {
return brcbs.values();
}
DomainSpecific domainSpecific = objectName.getDomainSpecific();
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for (ModelNode logicalDevice : children.values()) {
sb.append(logicalDevice.toString());
}
sb.append("\n\n\n---------------------\nURCBs:");
for (Urcb urcb : getUrcbs()) {
sb.append("\n\n").append(urcb);
}
if (domainSpecific == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"domain_specific in name is not selected");
}
sb.append("\n\n\n---------------------\nBRCBs:");
for (Brcb brcb : getBrcbs()) {
sb.append("\n\n").append(brcb);
}
ModelNode modelNode = getChild(domainSpecific.getDomainID().toString());
sb.append("\n\n\n---------------------\nData sets:");
for (DataSet dataSet : getDataSets()) {
sb.append("\n\n").append(dataSet);
}
if (modelNode == null) {
return null;
return sb.toString();
}
String mmsItemId = domainSpecific.getItemID().toString();
int index1 = mmsItemId.indexOf('$');
/**
* Searches and returns the model node with the given object reference and FC. If searching for
* 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
* syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references.
* @return the model node if it was found or null otherwise
*/
public ModelNode findModelNode(ObjectReference objectReference, Fc fc) {
ModelNode currentNode = this;
Iterator<String> searchedNodeReferenceIterator = objectReference.iterator();
while (searchedNodeReferenceIterator.hasNext()) {
currentNode = currentNode.getChild(searchedNodeReferenceIterator.next(), fc);
if (currentNode == null) {
return null;
}
}
return currentNode;
}
if (index1 == -1) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"invalid mms item id: " + domainSpecific.getItemID());
/**
* Searches and returns the model node with the given object reference and FC. If searching for
* 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
* syntax like "ldname/ln.do....".
* @param fc the functional constraint of the requested model node. May be null for Logical Device
* and Logical Node references.
* @return the model node if it was found or null otherwise
*/
public ModelNode findModelNode(String objectReference, Fc fc) {
return findModelNode(new ObjectReference(objectReference), fc);
}
LogicalNode ln = (LogicalNode) modelNode.getChild(mmsItemId.substring(0, index1));
/**
* Returns the subModelNode that is referenced by the given VariableDef. Return null in case the
* referenced ModelNode is not found.
*
* @param variableDef the variableDef
* @return the subModelNode that is referenced by the given VariableDef
* @throws ServiceError if an error occurs
*/
FcModelNode getNodeFromVariableDef(VariableDefs.SEQUENCE variableDef) throws ServiceError {
ObjectName objectName = variableDef.getVariableSpecification().getName();
if (objectName == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"name in objectName is not selected");
}
if (ln == null) {
return null;
}
DomainSpecific domainSpecific = objectName.getDomainSpecific();
if (domainSpecific == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"domain_specific in name is not selected");
}
int index2 = mmsItemId.indexOf('$', index1 + 1);
ModelNode modelNode = getChild(domainSpecific.getDomainID().toString());
if (index2 == -1) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, "invalid mms item id");
}
if (modelNode == null) {
return null;
}
Fc fc = Fc.fromString(mmsItemId.substring(index1 + 1, index2));
String mmsItemId = domainSpecific.getItemID().toString();
int index1 = mmsItemId.indexOf('$');
if (fc == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"unknown functional constraint: " + mmsItemId.substring(index1 + 1, index2));
}
if (index1 == -1) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"invalid mms item id: " + domainSpecific.getItemID());
}
index1 = index2;
LogicalNode ln = (LogicalNode) modelNode.getChild(mmsItemId.substring(0, index1));
index2 = mmsItemId.indexOf('$', index1 + 1);
if (ln == null) {
return null;
}
if (index2 == -1) {
if (fc == Fc.RP) {
return ln.getUrcb(mmsItemId.substring(index1 + 1));
}
if (fc == Fc.BR) {
return ln.getBrcb(mmsItemId.substring(index1 + 1));
}
return (FcModelNode) ln.getChild(mmsItemId.substring(index1 + 1), fc);
}
int index2 = mmsItemId.indexOf('$', index1 + 1);
if (fc == Fc.RP) {
modelNode = ln.getUrcb(mmsItemId.substring(index1 + 1, index2));
} else if (fc == Fc.BR) {
modelNode = ln.getBrcb(mmsItemId.substring(index1 + 1, index2));
} else {
modelNode = ln.getChild(mmsItemId.substring(index1 + 1, index2), fc);
}
if (index2 == -1) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT, "invalid mms item id");
}
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
while (index2 != -1) {
modelNode = modelNode.getChild(mmsItemId.substring(index1 + 1, index2));
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
}
Fc fc = Fc.fromString(mmsItemId.substring(index1 + 1, index2));
modelNode = modelNode.getChild(mmsItemId.substring(index1 + 1));
if (fc == null) {
throw new ServiceError(
ServiceError.FAILED_DUE_TO_COMMUNICATIONS_CONSTRAINT,
"unknown functional constraint: " + mmsItemId.substring(index1 + 1, index2));
}
if (variableDef.getAlternateAccess() == null) {
// no array is in this node path
return (FcModelNode) modelNode;
}
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
if (index2 == -1) {
if (fc == Fc.RP) {
return ln.getUrcb(mmsItemId.substring(index1 + 1));
}
if (fc == Fc.BR) {
return ln.getBrcb(mmsItemId.substring(index1 + 1));
}
return (FcModelNode) ln.getChild(mmsItemId.substring(index1 + 1), fc);
}
if (fc == Fc.RP) {
modelNode = ln.getUrcb(mmsItemId.substring(index1 + 1, index2));
} else if (fc == Fc.BR) {
modelNode = ln.getBrcb(mmsItemId.substring(index1 + 1, index2));
} else {
modelNode = ln.getChild(mmsItemId.substring(index1 + 1, index2), fc);
}
AlternateAccessSelection altAccIt =
variableDef.getAlternateAccess().getCHOICE().get(0).getUnnamed();
if (altAccIt.getSelectAlternateAccess() != null) {
// path to node below an array element
modelNode =
((Array) modelNode)
.getChild(
altAccIt.getSelectAlternateAccess().getAccessSelection().getIndex().intValue());
String mmsSubArrayItemId =
altAccIt
.getSelectAlternateAccess()
.getAlternateAccess()
.getCHOICE()
.get(0)
.getUnnamed()
.getSelectAccess()
.getComponent()
.getBasic()
.toString();
index1 = -1;
index2 = mmsSubArrayItemId.indexOf('$');
while (index2 != -1) {
modelNode = modelNode.getChild(mmsSubArrayItemId.substring(index1 + 1, index2));
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
}
while (index2 != -1) {
modelNode = modelNode.getChild(mmsItemId.substring(index1 + 1, index2));
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
}
modelNode = modelNode.getChild(mmsItemId.substring(index1 + 1));
if (variableDef.getAlternateAccess() == null) {
// no array is in this node path
return (FcModelNode) modelNode;
}
AlternateAccessSelection altAccIt =
variableDef.getAlternateAccess().getCHOICE().get(0).getUnnamed();
if (altAccIt.getSelectAlternateAccess() != null) {
// path to node below an array element
modelNode =
((Array) modelNode)
.getChild(
altAccIt.getSelectAlternateAccess().getAccessSelection().getIndex().intValue());
String mmsSubArrayItemId =
altAccIt
.getSelectAlternateAccess()
.getAlternateAccess()
.getCHOICE()
.get(0)
.getUnnamed()
.getSelectAccess()
.getComponent()
.getBasic()
.toString();
index1 = -1;
index2 = mmsSubArrayItemId.indexOf('$');
while (index2 != -1) {
modelNode = modelNode.getChild(mmsSubArrayItemId.substring(index1 + 1, index2));
index1 = index2;
index2 = mmsItemId.indexOf('$', index1 + 1);
}
return (FcModelNode) modelNode.getChild(mmsSubArrayItemId.substring(index1 + 1));
} else {
// path to an array element
return (FcModelNode)
((Array) modelNode).getChild(altAccIt.getSelectAccess().getIndex().intValue());
}
}
public ConnectionParam getConnectionParam() {
return connectionParam;
}
return (FcModelNode) modelNode.getChild(mmsSubArrayItemId.substring(index1 + 1));
} else {
// path to an array element
return (FcModelNode)
((Array) modelNode).getChild(altAccIt.getSelectAccess().getIndex().intValue());
public void setConnectionParam(ConnectionParam connectionParam) {
this.connectionParam = connectionParam;
}
}
}
}
Loading…
Cancel
Save