use of org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class ExampleNamespace method addDataAccessNodes.
private void addDataAccessNodes(UaFolderNode rootNode) {
// DataAccess folder
UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
getNodeManager().addNode(dataAccessFolder);
rootNode.addOrganizes(dataAccessFolder);
try {
AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {
@Override
public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
return true;
}
});
node.setBrowseName(newQualifiedName("AnalogValue"));
node.setDisplayName(LocalizedText.english("AnalogValue"));
node.setDataType(Identifiers.Double);
node.setValue(new DataValue(new Variant(3.14d)));
node.setEURange(new Range(0.0, 100.0));
getNodeManager().addNode(node);
dataAccessFolder.addOrganizes(node);
} catch (UaException e) {
logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
}
}
use of org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName in project FAAAST-Service by FraunhoferIOSB.
the class ExampleNamespace method startBogusEventNotifier.
private void startBogusEventNotifier() {
// Set the EventNotifier bit on Server Node for Events.
UaNode serverNode = getServer().getAddressSpaceManager().getManagedNode(Identifiers.Server).orElse(null);
if (serverNode instanceof ServerTypeNode) {
((ServerTypeNode) serverNode).setEventNotifier(ubyte(1));
// Post a bogus Event every couple seconds
eventThread = new Thread(() -> {
while (keepPostingEvents) {
try {
BaseEventTypeNode eventNode = getServer().getEventFactory().createEvent(newNodeId(UUID.randomUUID()), Identifiers.BaseEventType);
eventNode.setBrowseName(new QualifiedName(1, "foo"));
eventNode.setDisplayName(LocalizedText.english("foo"));
eventNode.setEventId(ByteString.of(new byte[] { 0, 1, 2, 3 }));
eventNode.setEventType(Identifiers.BaseEventType);
eventNode.setSourceNode(serverNode.getNodeId());
eventNode.setSourceName(serverNode.getDisplayName().getText());
eventNode.setTime(DateTime.now());
eventNode.setReceiveTime(DateTime.NULL_VALUE);
eventNode.setMessage(LocalizedText.english("event message!"));
eventNode.setSeverity(ushort(2));
// noinspection UnstableApiUsage
getServer().getEventBus().post(eventNode);
eventNode.delete();
} catch (Throwable e) {
logger.error("Error creating EventNode: {}", e.getMessage(), e);
}
try {
// noinspection BusyWait
Thread.sleep(2_000);
} catch (InterruptedException ignored) {
// ignored
}
}
}, "bogus-event-poster");
eventThread.start();
}
}
use of org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName in project milo by eclipse.
the class DataTypeDictionaryManager method registerStructureDescription.
public void registerStructureDescription(StructureDescription description, NodeId binaryEncodingId) {
structureDescriptions.put(description.getDataTypeId(), description);
// Add a DataTypeDescriptionTypeNode with a ComponentOf reference to
// dictionaryNode.
DataTypeDescriptionTypeNode descriptionNode = new DataTypeDescriptionTypeNode(getNodeContext(), newNodeId(String.format("%s.Description", description.getName())), newQualifiedName(description.getName().getName()), LocalizedText.english(description.getName().getName()), LocalizedText.NULL_VALUE, uint(0), uint(0));
descriptionNode.setValue(new DataValue(new Variant(description.getName().getName())));
descriptionNode.setDataType(Identifiers.String);
descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeDescriptionType.expanded(), Direction.FORWARD));
descriptionNode.addReference(new Reference(descriptionNode.getNodeId(), Identifiers.HasComponent, dictionaryNode.getNodeId().expanded(), Direction.INVERSE));
addNode(descriptionNode);
// Add a DataTypeEncodingTypeNode with a HasDescription reference to
// descriptionNode and an EncodingOf reference to the DataTypeNode.
DataTypeEncodingTypeNode dataTypeEncodingNode = new DataTypeEncodingTypeNode(getNodeContext(), binaryEncodingId, new QualifiedName(0, "Default Binary"), LocalizedText.english("Default Binary"), LocalizedText.NULL_VALUE, uint(0), uint(0));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasTypeDefinition, Identifiers.DataTypeEncodingType.expanded(), Direction.FORWARD));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasDescription, descriptionNode.getNodeId().expanded(), Direction.FORWARD));
dataTypeEncodingNode.addReference(new Reference(dataTypeEncodingNode.getNodeId(), Identifiers.HasEncoding, description.getDataTypeId().expanded(), Direction.INVERSE));
addNode(dataTypeEncodingNode);
dictionaryFile.reset();
}
use of org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName in project milo by eclipse.
the class ExampleNamespace method addDataAccessNodes.
private void addDataAccessNodes(UaFolderNode rootNode) {
// DataAccess folder
UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
getNodeManager().addNode(dataAccessFolder);
rootNode.addOrganizes(dataAccessFolder);
try {
AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {
@Override
public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
return true;
}
});
node.setBrowseName(newQualifiedName("AnalogValue"));
node.setDisplayName(LocalizedText.english("AnalogValue"));
node.setDataType(Identifiers.Double);
node.setValue(new DataValue(new Variant(3.14d)));
node.setEURange(new Range(0.0, 100.0));
getNodeManager().addNode(node);
dataAccessFolder.addOrganizes(node);
} catch (UaException e) {
logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
}
}
use of org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName in project milo by eclipse.
the class ExampleNamespace method registerCustomEnumType.
private void registerCustomEnumType() throws Exception {
NodeId dataTypeId = CustomEnumType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable());
dictionaryManager.registerEnumCodec(new CustomEnumType.Codec().asBinaryCodec(), "CustomEnumType", dataTypeId);
UaNode node = getNodeManager().get(dataTypeId);
if (node instanceof UaDataTypeNode) {
UaDataTypeNode dataTypeNode = (UaDataTypeNode) node;
dataTypeNode.setEnumStrings(new LocalizedText[] { LocalizedText.english("Field0"), LocalizedText.english("Field1"), LocalizedText.english("Field2") });
}
EnumField[] fields = new EnumField[] { new EnumField(0L, LocalizedText.english("Field0"), LocalizedText.NULL_VALUE, "Field0"), new EnumField(1L, LocalizedText.english("Field1"), LocalizedText.NULL_VALUE, "Field1"), new EnumField(2L, LocalizedText.english("Field2"), LocalizedText.NULL_VALUE, "Field2") };
EnumDefinition definition = new EnumDefinition(fields);
EnumDescription description = new EnumDescription(dataTypeId, new QualifiedName(getNamespaceIndex(), "CustomEnumType"), definition, ubyte(BuiltinDataType.Int32.getTypeId()));
dictionaryManager.registerEnumDescription(description);
}
Aggregations