use of com.prosysopc.ua.stack.builtintypes.LocalizedText in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addDescriptions.
/**
* Adds the descriptions to the given argument.
*
* @param arg The desired UA argument
* @param descriptions The list of AAS descriptions
*/
private void addDescriptions(Argument arg, List<LangString> descriptions) {
try {
if ((arg != null) && (descriptions != null)) {
if (!descriptions.isEmpty()) {
LangString desc = descriptions.get(0);
arg.setDescription(new LocalizedText(desc.getValue(), desc.getLanguage()));
}
}
} catch (Throwable ex) {
logger.error("addDescriptions Exception", ex);
}
}
use of com.prosysopc.ua.stack.builtintypes.LocalizedText in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addAasOperation.
/**
* Adds an AAS Operation to the given node.
*
* @param node The desired UA node
* @param aasOperation The corresponding AAS operation to add
* @param submodel The corresponding Submodel as parent object of the data element
* @param parentRef The reference to the parent object
* @param ordered Specifies whether the operation should be added ordered
* (true) or unordered (false)
*/
private void addAasOperation(UaNode node, Operation aasOperation, Submodel submodel, Reference parentRef, boolean ordered) {
try {
String name = aasOperation.getIdShort();
QualifiedName browseName = UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASOperationType.getNamespaceUri(), name).toQualifiedName(getNamespaceTable());
NodeId nid = getDefaultNodeId();
AASOperationType oper = createInstance(AASOperationType.class, nid, browseName, LocalizedText.english(name));
addSubmodelElementBaseData(oper, aasOperation);
Reference operRef = AasUtils.toReference(parentRef, aasOperation);
// for operations we put the corresponding operation object into the map
submodelElementAasMap.put(nid, new SubmodelElementData(aasOperation, submodel, SubmodelElementData.Type.OPERATION, operRef));
logger.debug("addAasOperation: NodeId " + nid + "; Property: " + aasOperation);
// add method
NodeId myMethodId = new NodeId(getNamespaceIndex(), nid.getValue().toString() + "." + name);
PlainMethod method = new PlainMethod(this, myMethodId, name, Locale.ENGLISH);
Argument[] inputs = new Argument[aasOperation.getInputVariables().size()];
for (int i = 0; i < aasOperation.getInputVariables().size(); i++) {
OperationVariable v = aasOperation.getInputVariables().get(i);
inputs[i] = new Argument();
setOperationArgument(inputs[i], v);
}
method.setInputArguments(inputs);
Argument[] outputs = new Argument[1];
for (int i = 0; i < aasOperation.getOutputVariables().size(); i++) {
OperationVariable v = aasOperation.getOutputVariables().get(i);
outputs[i] = new Argument();
setOperationArgument(outputs[i], v);
}
method.setOutputArguments(outputs);
MethodManagerUaNode m = (MethodManagerUaNode) this.getMethodManager();
m.addCallListener(aasMethodManagerListener);
method.setDescription(new LocalizedText("", ""));
oper.addComponent(method);
if (ordered) {
node.addReference(oper, Identifiers.HasOrderedComponent, false);
} else {
node.addComponent(oper);
}
referableMap.put(operRef, new ObjectData(aasOperation, oper, submodel));
} catch (Throwable ex) {
logger.error("addAasOperation Exception", ex);
}
}
use of com.prosysopc.ua.stack.builtintypes.LocalizedText in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addDescriptions.
/**
* Adds the list of Descriptions to the given node.
*
* @param node The desired UA node in which the Descriptions should be created
* @param descriptions The list of AAS descriptions
*/
private void addDescriptions(UaNode node, List<LangString> descriptions) {
try {
if ((node != null) && (descriptions != null)) {
if (!descriptions.isEmpty()) {
LangString desc = descriptions.get(0);
node.setDescription(new LocalizedText(desc.getValue(), desc.getLanguage()));
}
}
} catch (Throwable ex) {
logger.error("addDescriptions Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.LocalizedText in project FAAAST-Service by FraunhoferIOSB.
the class AasServiceNodeManager method addMultiLanguageValueNode.
/**
* Adds the Value Node for the MultiLanguageProperty.
*
* @param node The desired MultiLanguageProperty Node
* @param arraySize The desired Array Size.
*/
private void addMultiLanguageValueNode(UaNode node, int arraySize) {
try {
NodeId propId = new NodeId(getNamespaceIndex(), node.getNodeId().getValue().toString() + "." + AASMultiLanguagePropertyType.VALUE);
PlainProperty<LocalizedText[]> myLTProperty = new PlainProperty<>(this, propId, UaQualifiedName.from(opc.i4aas.ObjectTypeIds.AASMultiLanguagePropertyType.getNamespaceUri(), AASMultiLanguagePropertyType.VALUE).toQualifiedName(getNamespaceTable()), LocalizedText.english(AASMultiLanguagePropertyType.VALUE));
myLTProperty.setDataTypeId(Identifiers.LocalizedText);
myLTProperty.setValueRank(ValueRanks.OneDimension);
myLTProperty.setArrayDimensions(new UnsignedInteger[] { UnsignedInteger.valueOf(arraySize) });
node.addProperty(myLTProperty);
myLTProperty.setDescription(new LocalizedText("", ""));
} catch (Throwable ex) {
logger.error("addMultiLanguageValueNode Exception", ex);
throw ex;
}
}
use of com.prosysopc.ua.stack.builtintypes.LocalizedText 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);
}
}
Aggregations