use of opc.i4aas.AASValueTypeDataType in project FAAAST-Service by FraunhoferIOSB.
the class AASPropertyTypeNodeBase method getValueType.
@Mandatory
@Override
public AASValueTypeDataType getValueType() {
UaVariable node = getValueTypeNode();
if (node == null) {
throw new RuntimeException("Mandatory node ValueType does not exist");
}
Variant value = node.getValue().getValue();
return (AASValueTypeDataType) value.asEnum(AASValueTypeDataType.class);
}
use of opc.i4aas.AASValueTypeDataType in project FAAAST-Service by FraunhoferIOSB.
the class AASQualifierTypeImplBase method getValueType.
@Mandatory
@Override
public AASValueTypeDataType getValueType() {
UaVariable node = getValueTypeNode();
if (node == null) {
return null;
}
Variant value = node.getValue().getValue();
return (AASValueTypeDataType) value.asEnum(AASValueTypeDataType.class);
}
use of opc.i4aas.AASValueTypeDataType in project FAAAST-Service by FraunhoferIOSB.
the class AASRangeTypeImplBase method getValueType.
@Mandatory
@Override
public AASValueTypeDataType getValueType() {
UaVariable node = getValueTypeNode();
if (node == null) {
return null;
}
Variant value = node.getValue().getValue();
return (AASValueTypeDataType) value.asEnum(AASValueTypeDataType.class);
}
use of opc.i4aas.AASValueTypeDataType in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method setRangeValueAndType.
/**
* Adds the min and max properties to the UA range object and sets the values
*
* @param aasRange The AAS range object
* @param range The corresponding UA range object
* @param submodel The corresponding submodel
* @param rangeRef The AAS reference to the Range
*/
private void setRangeValueAndType(Range aasRange, AASRangeType range, Submodel submodel, Reference rangeRef) {
try {
String minValue = aasRange.getMin();
String maxValue = aasRange.getMax();
NodeId myPropertyIdMin = new NodeId(getNamespaceIndex(), range.getNodeId().getValue().toString() + "." + AASRangeType.MIN);
NodeId myPropertyIdMax = new NodeId(getNamespaceIndex(), range.getNodeId().getValue().toString() + "." + AASRangeType.MAX);
String valueType = aasRange.getValueType();
QualifiedName browseNameMin = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), AASRangeType.MIN).toQualifiedName(getNamespaceTable());
LocalizedText displayNameMin = LocalizedText.english(AASRangeType.MIN);
QualifiedName browseNameMax = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASRangeType.getNamespaceUri(), AASRangeType.MAX).toQualifiedName(getNamespaceTable());
LocalizedText displayNameMax = LocalizedText.english(AASRangeType.MAX);
submodelElementAasMap.put(myPropertyIdMin, new SubmodelElementData(aasRange, submodel, SubmodelElementData.Type.RANGE_MIN, rangeRef));
submodelElementAasMap.put(myPropertyIdMax, new SubmodelElementData(aasRange, submodel, SubmodelElementData.Type.RANGE_MAX, rangeRef));
submodelElementOpcUAMap.put(rangeRef, range);
TypedValue minTypedValue = TypedValueFactory.create(valueType, minValue);
TypedValue maxTypedValue = TypedValueFactory.create(valueType, maxValue);
AASValueTypeDataType valueDataType;
if (minTypedValue != null) {
valueDataType = ValueConverter.datatypeToValueType(minTypedValue.getDataType());
} else {
valueDataType = ValueConverter.stringToValueType(valueType);
}
range.setValueType(valueDataType);
switch(valueDataType) {
//
case Boolean:
if (minValue != null) {
PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myBoolProperty.setDataTypeId(Identifiers.Boolean);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myBoolProperty.setValue(minTypedValue.getValue());
}
myBoolProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myBoolProperty);
}
if (maxValue != null) {
PlainProperty<Boolean> myBoolProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myBoolProperty.setDataTypeId(Identifiers.Boolean);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myBoolProperty.setValue(maxTypedValue.getValue());
}
myBoolProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myBoolProperty);
}
break;
// break;
case Int32:
if (minValue != null) {
PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myIntProperty.setDataTypeId(Identifiers.Int32);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myIntProperty.setValue(minTypedValue.getValue());
}
myIntProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myIntProperty);
}
if (maxValue != null) {
PlainProperty<Integer> myIntProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myIntProperty.setDataTypeId(Identifiers.Int32);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myIntProperty.setValue(maxTypedValue.getValue());
}
myIntProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myIntProperty);
}
break;
case Int64:
if (minValue != null) {
PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myLongProperty.setDataTypeId(Identifiers.Int64);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
Object obj = minTypedValue.getValue();
if (!(obj instanceof Long)) {
obj = Long.parseLong(obj.toString());
}
myLongProperty.setValue(obj);
}
myLongProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myLongProperty);
}
if (maxValue != null) {
PlainProperty<Long> myLongProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myLongProperty.setDataTypeId(Identifiers.Int64);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
Object obj = maxTypedValue.getValue();
if (!(obj instanceof Long)) {
obj = Long.parseLong(obj.toString());
}
myLongProperty.setValue(obj);
}
myLongProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myLongProperty);
}
break;
case Int16:
if (minValue != null) {
PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myInt16Property.setDataTypeId(Identifiers.Int16);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myInt16Property.setValue(minTypedValue.getValue());
}
myInt16Property.setDescription(new LocalizedText("", ""));
range.addProperty(myInt16Property);
}
if (maxValue != null) {
PlainProperty<Short> myInt16Property = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myInt16Property.setDataTypeId(Identifiers.Int16);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myInt16Property.setValue(maxTypedValue.getValue());
}
myInt16Property.setDescription(new LocalizedText("", ""));
range.addProperty(myInt16Property);
}
break;
case SByte:
if (minValue != null) {
PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
mySByteProperty.setDataTypeId(Identifiers.SByte);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
mySByteProperty.setValue(minTypedValue.getValue());
}
mySByteProperty.setDescription(new LocalizedText("", ""));
range.addProperty(mySByteProperty);
}
if (maxValue != null) {
PlainProperty<Byte> mySByteProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
mySByteProperty.setDataTypeId(Identifiers.SByte);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
mySByteProperty.setValue(maxTypedValue.getValue());
}
mySByteProperty.setDescription(new LocalizedText("", ""));
range.addProperty(mySByteProperty);
}
break;
//
case Double:
if (minValue != null) {
PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myDoubleProperty.setDataTypeId(Identifiers.Double);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myDoubleProperty.setValue(minTypedValue.getValue());
}
myDoubleProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myDoubleProperty);
}
if (maxValue != null) {
PlainProperty<Double> myDoubleProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myDoubleProperty.setDataTypeId(Identifiers.Double);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myDoubleProperty.setValue(maxTypedValue.getValue());
}
myDoubleProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myDoubleProperty);
}
break;
case Float:
if (minValue != null) {
PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myFloatProperty.setDataTypeId(Identifiers.Float);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myFloatProperty.setValue(minTypedValue.getValue());
}
myFloatProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myFloatProperty);
}
if (maxValue != null) {
PlainProperty<Float> myFloatProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myFloatProperty.setDataTypeId(Identifiers.Float);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myFloatProperty.setValue(maxTypedValue.getValue());
}
myFloatProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myFloatProperty);
}
break;
//
case String:
if (minValue != null) {
PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myStringProperty.setDataTypeId(Identifiers.String);
if ((minTypedValue != null) && (minTypedValue.getValue() != null)) {
myStringProperty.setValue(minTypedValue.getValue());
}
myStringProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myStringProperty);
}
if (maxValue != null) {
PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myStringProperty.setDataTypeId(Identifiers.String);
if ((maxTypedValue != null) && (maxTypedValue.getValue() != null)) {
myStringProperty.setValue(maxTypedValue.getValue());
}
myStringProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myStringProperty);
}
break;
// break;
default:
logger.warn("setRangeValueAndType: Range " + range.getBrowseName().getName() + ": Unknown type: " + valueType + "; use string as default");
if (minValue != null) {
PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMin, browseNameMin, displayNameMin);
myStringProperty.setDataTypeId(Identifiers.String);
myStringProperty.setValue(minValue);
myStringProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myStringProperty);
}
if (maxValue != null) {
PlainProperty<String> myStringProperty = new PlainProperty<>(this, myPropertyIdMax, browseNameMax, displayNameMax);
myStringProperty.setDataTypeId(Identifiers.String);
myStringProperty.setValue(maxValue);
myStringProperty.setDescription(new LocalizedText("", ""));
range.addProperty(myStringProperty);
}
break;
}
} catch (Throwable ex) {
logger.error("setRangeValueAndType Exception", ex);
}
}
use of opc.i4aas.AASValueTypeDataType in project FAAAST-Service by FraunhoferIOSB.
the class ValueConverter method datatypeToValueType.
/**
* Converts the given datatype to the corresponding AASValueTypeDataType.
*
* @param type The desired datatype
* @return The corresponding AASValueTypeDataType
*/
public static AASValueTypeDataType datatypeToValueType(Datatype type) {
AASValueTypeDataType retval;
switch(type) {
case Double:
retval = AASValueTypeDataType.Double;
break;
case Int:
retval = AASValueTypeDataType.Int32;
break;
case String:
retval = AASValueTypeDataType.String;
break;
case Boolean:
retval = AASValueTypeDataType.Boolean;
break;
case Byte:
retval = AASValueTypeDataType.SByte;
break;
case Decimal:
logger.warn("datatypeToValueType: Decimal not supported!");
retval = AASValueTypeDataType.Int64;
break;
case Float:
retval = AASValueTypeDataType.Float;
break;
case Integer:
logger.warn("datatypeToValueType: Integer not supported - map to Long!");
retval = AASValueTypeDataType.Int64;
break;
case Long:
retval = AASValueTypeDataType.Int64;
break;
case Short:
retval = AASValueTypeDataType.Int16;
break;
default:
logger.warn("datatypeToValueType: unknown type: " + type);
throw new IllegalArgumentException("unknown type: " + type);
}
return retval;
}
Aggregations