Search in sources :

Example 11 with UaNode

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.");
    }
}
Also used : UaMethodNode(org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode)

Example 12 with UaNode

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.");
    }
}
Also used : UaMethodNode(org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode)

Example 13 with UaNode

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);
}
Also used : EnumField(org.eclipse.milo.opcua.stack.core.types.structured.EnumField) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode) EnumDefinition(org.eclipse.milo.opcua.stack.core.types.structured.EnumDefinition) UaDataTypeNode(org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode) EnumDescription(org.eclipse.milo.opcua.stack.core.types.structured.EnumDescription)

Example 14 with UaNode

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();
    }
}
Also used : BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) ServerTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode)

Example 15 with UaNode

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();
    }
}
Also used : BaseEventTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode) ServerTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) UaNode(org.eclipse.milo.opcua.sdk.server.nodes.UaNode)

Aggregations

UaNode (org.eclipse.milo.opcua.sdk.server.nodes.UaNode)20 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)12 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)9 BaseEventTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode)8 ServerTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.objects.ServerTypeNode)7 AddressSpaceManager (org.eclipse.milo.opcua.sdk.server.api.AddressSpaceManager)6 UaMethodNode (org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode)6 NamespaceTable (org.eclipse.milo.opcua.stack.core.NamespaceTable)6 UaException (org.eclipse.milo.opcua.stack.core.UaException)6 Optional (java.util.Optional)5 Reference (org.eclipse.milo.opcua.sdk.core.Reference)5 VariableNode (org.eclipse.milo.opcua.sdk.core.nodes.VariableNode)5 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)5 Identifiers (org.eclipse.milo.opcua.stack.core.Identifiers)5 List (java.util.List)4 AttributeContext (org.eclipse.milo.opcua.sdk.server.nodes.AttributeContext)4 UaObjectNode (org.eclipse.milo.opcua.sdk.server.nodes.UaObjectNode)4 UaVariableNode (org.eclipse.milo.opcua.sdk.server.nodes.UaVariableNode)4 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)4 ExpandedNodeId (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId)4