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


Java StatusCodes.Bad_SubscriptionIdInvalid方法代码示例

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


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

示例1: setPublishingMode

import com.digitalpetri.opcua.stack.core.StatusCodes; //导入方法依赖的package包/类
public void setPublishingMode(ServiceRequest<SetPublishingModeRequest, SetPublishingModeResponse> service) {
    SetPublishingModeRequest request = service.getRequest();
    UInteger[] subscriptionIds = request.getSubscriptionIds();
    StatusCode[] results = new StatusCode[subscriptionIds.length];

    for (int i = 0; i < subscriptionIds.length; i++) {
        Subscription subscription = subscriptions.get(subscriptionIds[i]);
        if (subscription == null) {
            results[i] = new StatusCode(StatusCodes.Bad_SubscriptionIdInvalid);
        } else {
            subscription.setPublishingMode(request);
            results[i] = StatusCode.GOOD;
        }
    }

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

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

示例2: modifySubscription

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

    try {
        Subscription subscription = subscriptions.get(subscriptionId);

        if (subscription == null) {
            throw new UaException(StatusCodes.Bad_SubscriptionIdInvalid);
        }

        subscription.modifySubscription(request);

        ResponseHeader header = service.createResponseHeader();

        ModifySubscriptionResponse response = new ModifySubscriptionResponse(
                header,
                subscription.getPublishingInterval(),
                uint(subscription.getLifetimeCount()),
                uint(subscription.getMaxKeepAliveCount())
        );

        service.setResponse(response);
    } catch (UaException e) {
        service.setServiceFault(e);
    }
}
 
开发者ID:digitalpetri,项目名称:ua-server-sdk,代码行数:28,代码来源:SubscriptionManager.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_SubscriptionIdInvalid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。