本文整理汇总了Java中com.digitalpetri.opcua.stack.core.types.structured.PublishRequest类的典型用法代码示例。如果您正苦于以下问题:Java PublishRequest类的具体用法?Java PublishRequest怎么用?Java PublishRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PublishRequest类属于com.digitalpetri.opcua.stack.core.types.structured包,在下文中一共展示了PublishRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: returnKeepAlive
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void returnKeepAlive(ServiceRequest<PublishRequest, PublishResponse> service) {
ResponseHeader header = service.createResponseHeader();
UInteger sequenceNumber = uint(currentSequenceNumber());
NotificationMessage notificationMessage = new NotificationMessage(
sequenceNumber, DateTime.now(), new ExtensionObject[0]);
UInteger[] available = getAvailableSequenceNumbers();
UInteger requestHandle = service.getRequest().getRequestHeader().getRequestHandle();
StatusCode[] acknowledgeResults = subscriptionManager.getAcknowledgeResults(requestHandle);
PublishResponse response = new PublishResponse(
header, subscriptionId, available,
moreNotifications, notificationMessage,
acknowledgeResults, new DiagnosticInfo[0]);
service.setResponse(response);
logger.debug("[id={}] returned keep-alive NotificationMessage sequenceNumber={}.",
subscriptionId, sequenceNumber);
}
示例2: returnStatusChangeNotification
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
void returnStatusChangeNotification(ServiceRequest<PublishRequest, PublishResponse> service) {
StatusChangeNotification statusChange = new StatusChangeNotification(
new StatusCode(StatusCodes.Bad_Timeout), null);
UInteger sequenceNumber = uint(nextSequenceNumber());
NotificationMessage notificationMessage = new NotificationMessage(
sequenceNumber,
new DateTime(),
new ExtensionObject[]{ExtensionObject.encode(statusChange)}
);
ResponseHeader header = service.createResponseHeader();
PublishResponse response = new PublishResponse(
header, subscriptionId,
new UInteger[0], false, notificationMessage,
new StatusCode[0], new DiagnosticInfo[0]);
service.setResponse(response);
logger.debug("[id={}] returned StatusChangeNotification sequenceNumber={}.", subscriptionId, sequenceNumber);
}
示例3: whenNormal
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void whenNormal(ServiceRequest<PublishRequest, PublishResponse> service) {
boolean publishingEnabled = Subscription.this.publishingEnabled;
/* Subscription State Table Row 4 */
if (!publishingEnabled || (publishingEnabled && !moreNotifications)) {
publishQueue().addRequest(service);
}
/* Subscription State Table Row 5 */
else if (publishingEnabled && moreNotifications) {
resetLifetimeCounter();
returnNotifications(service);
messageSent = true;
} else {
throw new IllegalStateException("unhandled subscription state");
}
}
示例4: whenLate
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void whenLate(ServiceRequest<PublishRequest, PublishResponse> service) {
boolean publishingEnabled = Subscription.this.publishingEnabled;
boolean notificationsAvailable = notificationsAvailable();
/* Subscription State Table Row 10 */
if (publishingEnabled && (notificationsAvailable || moreNotifications)) {
setState(State.Normal);
resetLifetimeCounter();
returnNotifications(service);
messageSent = true;
}
/* Subscription State Table Row 11 */
else if (!publishingEnabled ||
(publishingEnabled && !notificationsAvailable && !moreNotifications)) {
setState(State.KeepAlive);
resetLifetimeCounter();
returnKeepAlive(service);
messageSent = true;
} else {
throw new IllegalStateException("unhandled subscription state");
}
}
示例5: sendStatusChangeNotification
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
public void sendStatusChangeNotification(Subscription subscription) {
ServiceRequest<PublishRequest, PublishResponse> service = publishQueue.poll();
if (service != null) {
subscription.returnStatusChangeNotification(service);
} else {
transferred.add(subscription);
}
}
示例6: addRequest
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
/**
* Add a Publish {@link ServiceRequest} to the queue.
* <p>
* If there are wait-listed Subscriptions this request will be used immediately, otherwise it will be queued for
* later use by a Subscription whose publish timer has expired and has notifications to send.
*
* @param service the Publish {@link ServiceRequest}.
*/
public synchronized void addRequest(ServiceRequest<PublishRequest, PublishResponse> service) {
List<WaitingSubscription> waitingSubscriptions = Lists.newArrayList(waitList.values());
if (waitingSubscriptions.isEmpty()) {
serviceQueue.add(service);
logger.debug("Queued PublishRequest, size={}", serviceQueue.size());
} else {
WaitingSubscription subscription = null;
int maxPriority = 0;
long minWaitingSince = Long.MAX_VALUE;
for (WaitingSubscription waiting : waitingSubscriptions) {
int priority = waiting.getSubscription().getPriority();
long waitingSince = waiting.getWaitingSince().getTime();
if (priority > maxPriority) {
maxPriority = priority;
minWaitingSince = Long.MAX_VALUE;
}
if (priority >= maxPriority && waitingSince < minWaitingSince) {
minWaitingSince = waitingSince;
subscription = waiting;
}
}
if (subscription != null) {
waitList.remove(subscription.subscription.getId());
logger.debug("Delivering PublishRequest to Subscription [id={}]",
subscription.getSubscription().getId());
subscription.subscription.onPublish(service);
} else {
serviceQueue.add(service);
}
}
}
示例7: gatherAndSend
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
/**
* Gather {@link MonitoredItemNotification}s and send them using {@code service}, if present.
*
* @param iterator a {@link PeekingIterator} over the current {@link BaseMonitoredItem}s.
* @param service a {@link ServiceRequest}, if available.
*/
private void gatherAndSend(PeekingIterator<BaseMonitoredItem<?>> iterator,
Optional<ServiceRequest<PublishRequest, PublishResponse>> service) {
if (service.isPresent()) {
List<UaStructure> notifications = Lists.newArrayList();
while (notifications.size() < maxNotificationsPerPublish && iterator.hasNext()) {
BaseMonitoredItem<?> item = iterator.peek();
boolean gatheredAllForItem = gather(item, notifications, maxNotificationsPerPublish);
if (gatheredAllForItem && iterator.hasNext()) {
iterator.next();
}
}
moreNotifications = iterator.hasNext();
sendNotifications(service.get(), notifications);
if (moreNotifications) {
gatherAndSend(iterator, Optional.ofNullable(publishQueue().poll()));
}
} else {
if (moreNotifications) {
publishQueue().addSubscription(this);
}
}
}
示例8: onPublish
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
/**
* Handle an incoming {@link PublishRequest}.
*
* @param service The service request that contains the {@link PublishRequest}.
*/
synchronized void onPublish(ServiceRequest<PublishRequest, PublishResponse> service) {
State state = this.state.get();
logger.trace("[id={}] onPublish(), state={}, keep-alive={}, lifetime={}",
subscriptionId, state, keepAliveCounter, lifetimeCounter);
if (state == State.Normal) publishHandler.whenNormal(service);
else if (state == State.KeepAlive) publishHandler.whenKeepAlive(service);
else if (state == State.Late) publishHandler.whenLate(service);
else if (state == State.Closing) publishHandler.whenClosing(service);
else if (state == State.Closed) publishHandler.whenClosed(service);
else throw new RuntimeException("Unhandled subscription state: " + state);
}
示例9: addServiceSet
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
default void addServiceSet(SubscriptionServiceSet serviceSet) {
addRequestHandler(CreateSubscriptionRequest.class, serviceSet::onCreateSubscription);
addRequestHandler(ModifySubscriptionRequest.class, serviceSet::onModifySubscription);
addRequestHandler(DeleteSubscriptionsRequest.class, serviceSet::onDeleteSubscriptions);
addRequestHandler(TransferSubscriptionsRequest.class, serviceSet::onTransferSubscriptions);
addRequestHandler(SetPublishingModeRequest.class, serviceSet::onSetPublishingMode);
addRequestHandler(PublishRequest.class, serviceSet::onPublish);
addRequestHandler(RepublishRequest.class, serviceSet::onRepublish);
}
示例10: onPublish
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
@Override
public void onPublish(ServiceRequest<PublishRequest, PublishResponse> service) throws UaException {
Session session = session(service);
session.getSubscriptionServices().onPublish(service);
}
示例11: poll
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
public synchronized ServiceRequest<PublishRequest, PublishResponse> poll() {
return serviceQueue.poll();
}
示例12: sendNotifications
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void sendNotifications(ServiceRequest<PublishRequest, PublishResponse> service,
List<UaStructure> notifications) {
List<MonitoredItemNotification> dataNotifications = Lists.newArrayList();
List<EventFieldList> eventNotifications = Lists.newArrayList();
notifications.forEach(notification -> {
if (notification instanceof MonitoredItemNotification) {
dataNotifications.add((MonitoredItemNotification) notification);
} else if (notification instanceof EventFieldList) {
eventNotifications.add((EventFieldList) notification);
}
});
List<ExtensionObject> notificationData = Lists.newArrayList();
if (dataNotifications.size() > 0) {
DataChangeNotification dataChange = new DataChangeNotification(
dataNotifications.toArray(new MonitoredItemNotification[dataNotifications.size()]),
new DiagnosticInfo[0]);
notificationData.add(ExtensionObject.encode(dataChange));
}
if (eventNotifications.size() > 0) {
EventNotificationList eventChange = new EventNotificationList(
eventNotifications.toArray(new EventFieldList[eventNotifications.size()]));
notificationData.add(ExtensionObject.encode(eventChange));
}
UInteger sequenceNumber = uint(nextSequenceNumber());
NotificationMessage notificationMessage = new NotificationMessage(
sequenceNumber,
new DateTime(),
notificationData.toArray(new ExtensionObject[notificationData.size()])
);
availableMessages.put(notificationMessage.getSequenceNumber(), notificationMessage);
UInteger[] available = getAvailableSequenceNumbers();
UInteger requestHandle = service.getRequest().getRequestHeader().getRequestHandle();
StatusCode[] acknowledgeResults = subscriptionManager.getAcknowledgeResults(requestHandle);
ResponseHeader header = service.createResponseHeader();
PublishResponse response = new PublishResponse(
header, subscriptionId,
available, moreNotifications, notificationMessage,
acknowledgeResults, new DiagnosticInfo[0]);
service.setResponse(response);
logger.debug("[id={}] returning {} DataChangeNotification(s) and {} EventNotificationList(s) sequenceNumber={}.",
subscriptionId, dataNotifications.size(), eventNotifications.size(), sequenceNumber);
}
示例13: whenKeepAlive
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void whenKeepAlive(ServiceRequest<PublishRequest, PublishResponse> service) {
/* Subscription State Table Row 13 */
publishQueue().addRequest(service);
}
示例14: whenClosing
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void whenClosing(ServiceRequest<PublishRequest, PublishResponse> service) {
returnStatusChangeNotification(service);
setState(State.Closed);
}
示例15: whenClosed
import com.digitalpetri.opcua.stack.core.types.structured.PublishRequest; //导入依赖的package包/类
private void whenClosed(ServiceRequest<PublishRequest, PublishResponse> service) {
publishQueue().addRequest(service);
}