当前位置: 首页>>代码示例>>Java>>正文


Java StatusCodes.Bad_NothingToDo方法代码示例

本文整理汇总了Java中com.digitalpetri.opcua.stack.core.StatusCodes.Bad_NothingToDo方法的典型用法代码示例。如果您正苦于以下问题:Java StatusCodes.Bad_NothingToDo方法的具体用法?Java StatusCodes.Bad_NothingToDo怎么用?Java StatusCodes.Bad_NothingToDo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.digitalpetri.opcua.stack.core.StatusCodes的用法示例。


在下文中一共展示了StatusCodes.Bad_NothingToDo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRegisterNodes

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void onRegisterNodes(ServiceRequest<RegisterNodesRequest, RegisterNodesResponse> service) throws UaException {
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();

    RegisterNodesRequest request = service.getRequest();

    NodeId[] nodeIds = request.getNodesToRegister();

    if (nodeIds.length == 0) {
        throw new UaException(StatusCodes.Bad_NothingToDo);
    }

    if (nodeIds.length > server.getConfig().getLimits().getMaxNodesPerRegisterNodes().intValue()) {
        throw new UaException(StatusCodes.Bad_TooManyOperations);
    }

    service.setResponse(new RegisterNodesResponse(
            service.createResponseHeader(StatusCode.GOOD),
            nodeIds
    ));
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:22,代码来源:ViewServices.java

示例2: onUnregisterNodes

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
@Override
public void onUnregisterNodes(ServiceRequest<UnregisterNodesRequest, UnregisterNodesResponse> service) throws UaException {
    OpcUaServer server = service.attr(ServiceAttributes.SERVER_KEY).get();

    UnregisterNodesRequest request = service.getRequest();

    NodeId[] nodeIds = request.getNodesToUnregister();

    if (nodeIds.length == 0) {
        throw new UaException(StatusCodes.Bad_NothingToDo);
    }

    if (nodeIds.length > server.getConfig().getLimits().getMaxNodesPerRegisterNodes().intValue()) {
        throw new UaException(StatusCodes.Bad_TooManyOperations);
    }

    service.setResponse(new UnregisterNodesResponse(service.createResponseHeader(StatusCode.GOOD)));
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:19,代码来源:ViewServices.java

示例3: setMonitoringMode

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
public void setMonitoringMode(ServiceRequest<SetMonitoringModeRequest, SetMonitoringModeResponse> service) {
    SetMonitoringModeRequest request = service.getRequest();
    UInteger subscriptionId = request.getSubscriptionId();

    try {
        Subscription subscription = subscriptions.get(subscriptionId);
        UInteger[] itemsToModify = request.getMonitoredItemIds();

        if (subscription == null) {
            throw new UaException(StatusCodes.Bad_SubscriptionIdInvalid);
        }
        if (itemsToModify.length == 0) {
            throw new UaException(StatusCodes.Bad_NothingToDo);
        }

        /*
         * Set MonitoringMode on each monitored item, if it exists.
         */

        MonitoringMode monitoringMode = request.getMonitoringMode();
        StatusCode[] results = new StatusCode[itemsToModify.length];
        List<BaseMonitoredItem<?>> modified = newArrayListWithCapacity(itemsToModify.length);

        for (int i = 0; i < itemsToModify.length; i++) {
            UInteger itemId = itemsToModify[i];
            BaseMonitoredItem<?> item = subscription.getMonitoredItems().get(itemId);

            if (item != null) {
                item.setMonitoringMode(monitoringMode);

                modified.add(item);

                results[i] = StatusCode.GOOD;
            } else {
                results[i] = new StatusCode(StatusCodes.Bad_MonitoredItemIdInvalid);
            }
        }

        /*
         * Notify namespaces of the items whose MonitoringMode has been modified.
         */

        Map<UShort, List<MonitoredItem>> byNamespace = modified.stream()
                .collect(Collectors.groupingBy(item -> item.getReadValueId().getNodeId().getNamespaceIndex()));

        byNamespace.keySet().forEach(namespaceIndex -> {
            List<MonitoredItem> items = byNamespace.get(namespaceIndex);
            server.getNamespaceManager().getNamespace(namespaceIndex).onMonitoringModeChanged(items);
        });

        /*
         * Build and return results.
         */

        ResponseHeader header = service.createResponseHeader();
        SetMonitoringModeResponse response = new SetMonitoringModeResponse(
                header, results, new DiagnosticInfo[0]);

        service.setResponse(response);
    } catch (UaException e) {
        service.setServiceFault(e);
    }
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:64,代码来源:SubscriptionManager.java


注:本文中的com.digitalpetri.opcua.stack.core.StatusCodes.Bad_NothingToDo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。