use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAdminInformationProperties.
/**
* Adds the AdminInformation Properties to the given node (if they don't
* exist).
*
* @param adminInfNode The desired AdminInformation node
* @param info The corresponding AAS AdministrativeInformation object
*/
private void addAdminInformationProperties(AASAdministrativeInformationType adminInfNode, AdministrativeInformation info) {
try {
if ((adminInfNode != null) && (info != null)) {
if (info.getVersion() != null) {
if (adminInfNode.getVersionNode() == null) {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), adminInfNode.getNodeId().getValue().toString() + "." + AASAdministrativeInformationType.VERSION);
PlainProperty<String> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAdministrativeInformationType.VERSION).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASAdministrativeInformationType.VERSION));
myProperty.setDataTypeId(Identifiers.String);
if (VALUES_READ_ONLY) {
myProperty.setAccessLevel(AccessLevelType.CurrentRead);
}
myProperty.setDescription(new LocalizedText("", ""));
adminInfNode.addProperty(myProperty);
}
adminInfNode.setVersion(info.getVersion());
}
if (info.getRevision() != null) {
if (adminInfNode.getRevisionNode() == null) {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), adminInfNode.getNodeId().getValue().toString() + "." + AASAdministrativeInformationType.REVISION);
PlainProperty<String> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASAssetAdministrationShellType.getNamespaceUri(), AASAdministrativeInformationType.REVISION).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASAdministrativeInformationType.REVISION));
myProperty.setDataTypeId(Identifiers.String);
if (VALUES_READ_ONLY) {
myProperty.setAccessLevel(AccessLevelType.CurrentRead);
}
myProperty.setDescription(new LocalizedText("", ""));
adminInfNode.addProperty(myProperty);
}
adminInfNode.setRevision(info.getRevision());
}
}
} catch (Exception ex) {
LOG.error("addAdminInfProperties Exception", ex);
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addConceptDescriptions.
/**
* Adds the given list of AAS Concept Descriptions.
*
* @param descriptions The desired list of AAS Concept Descriptions
* @throws StatusException If the operation fails
*/
private void addConceptDescriptions(List<ConceptDescription> descriptions) throws StatusException {
try {
// create folder DictionaryEntries
final UaNode dictionariesFolder = getServer().getNodeManagerRoot().getNodeOrExternal(Identifiers.Dictionaries);
// Folder for my objects
final NodeId dictionarieEntriesFolderId = new NodeId(getNamespaceIndex(), "Dictionaries.DictionaryEntries");
FolderTypeNode dictEntriesFolder = createInstance(FolderTypeNode.class, "DictionaryEntries", dictionarieEntriesFolderId);
this.addNodeAndReference(dictionariesFolder, dictEntriesFolder, Identifiers.Organizes);
for (ConceptDescription c : descriptions) {
String name = c.getIdShort();
NodeId nid = createNodeId(dictionariesFolder, name);
DictionaryEntryType dictNode;
switch(c.getIdentification().getIdType()) {
case IRDI:
AASIrdiConceptDescriptionType irdiNode = createInstance(AASIrdiConceptDescriptionType.class, name, nid);
addIdentifiable(irdiNode, c.getIdentification(), c.getAdministration(), name);
addConceptDescriptionReference(irdiNode, getReference(c));
dictEntriesFolder.addComponent(irdiNode);
dictionaryMap.put(getReference(c), irdiNode);
dictNode = irdiNode;
break;
case IRI:
AASIriConceptDescriptionType iriNode = createInstance(AASIriConceptDescriptionType.class, name, nid);
addIdentifiable(iriNode, c.getIdentification(), c.getAdministration(), name);
addConceptDescriptionReference(iriNode, getReference(c));
dictEntriesFolder.addComponent(iriNode);
dictionaryMap.put(getReference(c), iriNode);
dictNode = iriNode;
break;
default:
AASCustomConceptDescriptionType customNode = createInstance(AASCustomConceptDescriptionType.class, name, nid);
addIdentifiable(customNode, c.getIdentification(), c.getAdministration(), name);
addConceptDescriptionReference(customNode, getReference(c));
dictEntriesFolder.addComponent(customNode);
dictionaryMap.put(getReference(c), customNode);
dictNode = customNode;
break;
}
referableMap.put(AasUtils.toReference(c), new ObjectData(c, dictNode));
}
} catch (Exception ex) {
LOG.error("addConceptDescriptions Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setPropertyValueAndType.
/**
* Adds the OPC UA property itself to the given Property object and sets the value.
*
* @param aasProperty The AAS property
* @param submodel The corresponding Submodel as parent object of the data element
* @param prop The UA Property object
* @param propRef The AAS reference to the property
*/
@SuppressWarnings("java:S125")
private void setPropertyValueAndType(Property aasProperty, Submodel submodel, AASPropertyType prop, Reference propRef) {
try {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), prop.getNodeId().getValue().toString() + "." + AASPropertyType.VALUE);
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASPropertyType.getNamespaceUri(), AASPropertyType.VALUE).toQualifiedName(getNamespaceTable());
LocalizedText displayName = LocalizedText.english(AASPropertyType.VALUE);
submodelElementAasMap.put(myPropertyId, new SubmodelElementData(aasProperty, submodel, SubmodelElementData.Type.PROPERTY_VALUE, propRef));
LOG.debug("setPropertyValueAndType: NodeId {}; Property: {}", myPropertyId, aasProperty);
if (submodel != null) {
submodelElementOpcUAMap.put(propRef, prop);
}
AASValueTypeDataType valueDataType;
PropertyValue typedValue = PropertyValue.of(aasProperty.getValueType(), aasProperty.getValue());
if ((typedValue != null) && (typedValue.getValue() != null)) {
valueDataType = ValueConverter.datatypeToValueType(typedValue.getValue().getDataType());
} else {
valueDataType = ValueConverter.stringToValueType(aasProperty.getValueType());
}
prop.setValueType(valueDataType);
switch(valueDataType) {
//
case Boolean:
PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myBoolProperty.setDataTypeId(Identifiers.Boolean);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myBoolProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myBoolProperty);
break;
//
case Int32:
PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myIntProperty.setDataTypeId(Identifiers.Int32);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myIntProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myIntProperty);
break;
//
case Int64:
PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myLongProperty.setDataTypeId(Identifiers.Int64);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
Object obj = typedValue.getValue().getValue();
if (!(obj instanceof Long)) {
obj = Long.parseLong(obj.toString());
}
myLongProperty.setValue(obj);
}
prop.addProperty(myLongProperty);
break;
//
case Int16:
PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myInt16Property.setDataTypeId(Identifiers.Int16);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myInt16Property.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myInt16Property);
break;
//
case SByte:
PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
mySByteProperty.setDataTypeId(Identifiers.SByte);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
mySByteProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(mySByteProperty);
break;
case Double:
PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myDoubleProperty.setDataTypeId(Identifiers.Double);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myDoubleProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myDoubleProperty);
break;
case Float:
PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myFloatProperty.setDataTypeId(Identifiers.Float);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myFloatProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myFloatProperty);
break;
//
case String:
PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myStringProperty.setDataTypeId(Identifiers.String);
if ((typedValue != null) && (typedValue.getValue() != null) && (typedValue.getValue().getValue() != null)) {
myStringProperty.setValue(typedValue.getValue().getValue());
}
prop.addProperty(myStringProperty);
break;
//
default:
LOG.warn("setValueAndType: Property {}: Unknown type: {}; use string as default", prop.getBrowseName().getName(), aasProperty.getValueType());
PlainProperty<String> myDefaultProperty = new PlainProperty<>(this, myPropertyId, browseName, displayName);
myDefaultProperty.setDataTypeId(Identifiers.String);
myDefaultProperty.setValue(aasProperty.getValue());
prop.addProperty(myDefaultProperty);
break;
}
if ((prop.getValueNode() != null) && (prop.getValueNode().getDescription() == null)) {
prop.getValueNode().setDescription(new LocalizedText("", ""));
}
} catch (Exception ex) {
LOG.error("setPropertyValueAndType Exception", ex);
}
}
use of com.prosysopc.ua.stack.builtintypes.NodeId in project FAAAST-Service by FraunhoferIOSB.
the class AASOperationTypeImplBase method operation.
@Override
public void operation() throws MethodCallStatusException, ServiceException {
NodeId methodId = getComponentId(getQualifiedName("http://opcfoundation.org/UA/I4AAS/V3/", "Operation"));
call(methodId);
}
Aggregations