use of org.eclipse.milo.opcua.sdk.server.nodes.UaNode in project milo by eclipse.
the class OpcUaNamespace method configureGetMonitoredItems.
private void configureGetMonitoredItems() {
UaNode node = getNodeManager().get(Identifiers.Server_GetMonitoredItems);
if (node instanceof UaMethodNode) {
UaMethodNode methodNode = (UaMethodNode) node;
configureMethodNode(methodNode, GetMonitoredItemsMethodImpl::new);
} else {
logger.warn("GetMonitoredItems UaMethodNode not found.");
}
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaNode in project milo by eclipse.
the class OpcUaNamespace method configureConditionRefresh.
private void configureConditionRefresh() {
UaNode node = getNodeManager().get(Identifiers.ConditionType_ConditionRefresh);
if (node instanceof UaMethodNode) {
UaMethodNode conditionRefreshNode = (UaMethodNode) node;
configureMethodNode(conditionRefreshNode, ConditionRefreshMethodImpl::new);
} else {
logger.warn("ConditionRefresh UaMethodNode not found.");
}
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaNode 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);
}
use of org.eclipse.milo.opcua.sdk.server.nodes.UaNode in project iot-tree by bambooww.
the class DrvNamespace 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.sdk.server.nodes.UaNode in project milo by eclipse.
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();
}
}
Aggregations