use of com.prosysopc.ua.server.nodes.PlainProperty in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addBlobValueNode.
/**
* Adds a Value Property to the given Blob Node.
*
* @param node The desired Blob Node
*/
private void addBlobValueNode(UaNode node) {
try {
NodeId myPropertyId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASBlobType.VALUE);
PlainProperty<ByteString> myProperty = new PlainProperty<>(this, myPropertyId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASBlobType.getNamespaceUri(), AASBlobType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASBlobType.VALUE));
myProperty.setDataTypeId(Identifiers.ByteString);
myProperty.setDescription(new LocalizedText("", ""));
node.addProperty(myProperty);
} catch (Exception ex) {
LOG.error("addBlobValueNode Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.server.nodes.PlainProperty 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.server.nodes.PlainProperty 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);
}
}
Aggregations