本文整理汇总了Java中com.digitalpetri.opcua.stack.core.types.builtin.StatusCode类的典型用法代码示例。如果您正苦于以下问题:Java StatusCode类的具体用法?Java StatusCode怎么用?Java StatusCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatusCode类属于com.digitalpetri.opcua.stack.core.types.builtin包,在下文中一共展示了StatusCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onError
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
private void onError(ChannelHandlerContext ctx, ByteBuf buffer) {
try {
ErrorMessage errorMessage = TcpMessageDecoder.decodeError(buffer);
StatusCode statusCode = errorMessage.getError();
long errorCode = statusCode.getValue();
boolean secureChannelError =
errorCode == StatusCodes.Bad_SecurityChecksFailed ||
errorCode == StatusCodes.Bad_TcpSecureChannelUnknown ||
errorCode == StatusCodes.Bad_SecureChannelIdInvalid;
if (secureChannelError) {
secureChannel.setChannelId(0);
}
logger.error("Received error message: " + errorMessage);
handshakeFuture.completeExceptionally(new UaException(statusCode, errorMessage.getReason()));
} catch (UaException e) {
logger.error("An exception occurred while decoding an error message: {}", e.getMessage(), e);
handshakeFuture.completeExceptionally(e);
} finally {
ctx.close();
}
}
示例2: invoke
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@UaMethod
public void invoke(
InvocationContext context,
@UaInputArgument(name = "subscriptionId")
UInteger subscriptionId) throws UaException {
Subscription subscription = server.getSubscriptions().get(subscriptionId);
if (subscription == null) {
context.setFailure(new UaException(new StatusCode(StatusCodes.Bad_SubscriptionIdInvalid)));
} else {
// TODO
// subscription.resendData();
}
}
示例3: setPublishingMode
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的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);
}
示例4: returnKeepAlive
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的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);
}
示例5: returnStatusChangeNotification
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的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);
}
示例6: browseResult
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
private BrowseResult browseResult(List<ReferenceDescription> references, int max) {
if (references.size() > max) {
if (server.getBrowseContinuationPoints().size() >
server.getConfig().getLimits().getMaxBrowseContinuationPoints().intValue()) {
return new BrowseResult(BAD_NO_CONTINUATION_POINTS, null, new ReferenceDescription[0]);
} else {
List<ReferenceDescription> subList = references.subList(0, max);
List<ReferenceDescription> current = Lists.newArrayList(subList);
subList.clear();
BrowseContinuationPoint c = new BrowseContinuationPoint(references, max);
server.getBrowseContinuationPoints().put(c.identifier, c);
return new BrowseResult(StatusCode.GOOD, c.identifier, current.toArray(new ReferenceDescription[current.size()]));
}
} else {
return new BrowseResult(StatusCode.GOOD, null, references.toArray(new ReferenceDescription[references.size()]));
}
}
示例7: decodeStatusCode
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@Override
public StatusCode decodeStatusCode(String field) {
if (nextStartElement(field)) {
UInteger value = Unsigned.uint(0);
if (nextStartElement("Code")) {
value = decodeUInt32(null);
requireNextEndElement("Code");
}
requireNextEndElement(field);
return new StatusCode(value);
} else {
return new StatusCode(0);
}
}
示例8: decodeDiagnosticInfo
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@Override
public DiagnosticInfo decodeDiagnosticInfo(String field) throws UaSerializationException {
int mask = buffer.readByte();
if (mask == 0) {
return null;
} else {
int symbolicId = ((mask & 0x01) == 0x01) ? decodeInt32(null) : -1;
int namespaceUri = ((mask & 0x02) == 0x02) ? decodeInt32(null) : -1;
int localizedText = ((mask & 0x04) == 0x04) ? decodeInt32(null) : -1;
int locale = ((mask & 0x08) == 0x08) ? decodeInt32(null) : -1;
String additionalInfo = ((mask & 0x10) == 0x10) ? decodeString(null) : null;
StatusCode innerStatusCode = ((mask & 0x20) == 0x20) ? decodeStatusCode(null) : null;
DiagnosticInfo innerDiagnosticInfo = ((mask & 0x40) == 0x40) ? decodeDiagnosticInfo(null) : null;
return new DiagnosticInfo(namespaceUri, symbolicId, locale, localizedText, additionalInfo, innerStatusCode, innerDiagnosticInfo);
}
}
示例9: encodeDataValue
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@Override
public void encodeDataValue(String field, DataValue value) throws UaSerializationException {
if (value == null) {
buffer.writeByte(0);
} else {
int mask = 0x00;
if (value.getValue() != null && value.getValue().isNotNull()) mask |= 0x01;
if (!StatusCode.GOOD.equals(value.getStatusCode())) mask |= 0x02;
if (!DateTime.MIN_VALUE.equals(value.getSourceTime())) mask |= 0x04;
if (!DateTime.MIN_VALUE.equals(value.getServerTime())) mask |= 0x08;
buffer.writeByte(mask);
if ((mask & 0x01) == 0x01) encodeVariant(null, value.getValue());
if ((mask & 0x02) == 0x02) encodeStatusCode(null, value.getStatusCode());
if ((mask & 0x04) == 0x04) encodeDateTime(null, value.getSourceTime());
if ((mask & 0x08) == 0x08) encodeDateTime(null, value.getServerTime());
}
}
示例10: invoke
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@Override
public void invoke(CallMethodRequest request, CompletableFuture<CallMethodResult> future) {
CallMethodResult nodeIdUnknown = new CallMethodResult(
new StatusCode(StatusCodes.Bad_NodeIdUnknown),
new StatusCode[0],
new DiagnosticInfo[0],
new Variant[0]);
future.complete(nodeIdUnknown);
}
示例11: WriteContext
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
public WriteContext(OpcUaServer server,
@Nullable Session session,
CompletableFuture<List<StatusCode>> future,
DiagnosticsContext<WriteValue> diagnosticsContext) {
super(server, session, future, diagnosticsContext);
}
示例12: decode
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
public static ActivateSessionResponse decode(UaDecoder decoder) {
ResponseHeader _responseHeader = decoder.decodeSerializable("ResponseHeader", ResponseHeader.class);
ByteString _serverNonce = decoder.decodeByteString("ServerNonce");
StatusCode[] _results = decoder.decodeArray("Results", decoder::decodeStatusCode, StatusCode.class);
DiagnosticInfo[] _diagnosticInfos = decoder.decodeArray("DiagnosticInfos", decoder::decodeDiagnosticInfo, DiagnosticInfo.class);
return new ActivateSessionResponse(_responseHeader, _serverNonce, _results, _diagnosticInfos);
}
示例13: getVariants
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@DataProvider
public Object[][] getVariants() {
return new Object[][]{
{new Variant(true)},
{new Variant((byte) 1)},
{new Variant(ubyte(1))},
{new Variant((short) 1)},
{new Variant(ushort(1))},
{new Variant(1)},
{new Variant(uint(1))},
{new Variant(1L)},
{new Variant(ulong(1L))},
{new Variant(3.14f)},
{new Variant(6.12d)},
{new Variant("hello, world")},
{new Variant(DateTime.now())},
{new Variant(UUID.randomUUID())},
{new Variant(ByteString.of(new byte[]{1, 2, 3, 4}))},
{new Variant(new XmlElement("<tag>hello</tag>"))},
{new Variant(new NodeId(0, 42))},
{new Variant(new ExpandedNodeId(1, 42, "uri", 1))},
{new Variant(StatusCode.GOOD)},
{new Variant(new QualifiedName(0, "QualifiedName"))},
{new Variant(LocalizedText.english("LocalizedText"))},
{new Variant(ExtensionObject.encode(new ReadValueId(NodeId.NULL_VALUE, uint(1), null, new QualifiedName(0, "DataEncoding"))))},
};
}
示例14: invoke
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
@UaMethod
public void invoke(
InvocationContext context,
@UaInputArgument(name = "subscriptionId")
UInteger subscriptionId,
@UaOutputArgument(name = "serverHandles")
Out<UInteger[]> serverHandles,
@UaOutputArgument(name = "clientHandles")
Out<UInteger[]> clientHandles) throws UaException {
Subscription subscription = server.getSubscriptions().get(subscriptionId);
if (subscription == null) {
context.setFailure(new UaException(new StatusCode(StatusCodes.Bad_SubscriptionIdInvalid)));
} else {
List<UInteger> serverHandleList = Lists.newArrayList();
List<UInteger> clientHandleList = Lists.newArrayList();
for (BaseMonitoredItem<?> item : subscription.getMonitoredItems().values()) {
serverHandleList.add(item.getId());
clientHandleList.add(uint(item.getClientHandle()));
}
serverHandles.set(serverHandleList.toArray(new UInteger[serverHandleList.size()]));
clientHandles.set(clientHandleList.toArray(new UInteger[clientHandleList.size()]));
}
}
示例15: release
import com.digitalpetri.opcua.stack.core.types.builtin.StatusCode; //导入依赖的package包/类
private BrowseResult release(ByteString bs) {
BrowseContinuationPoint c = server.getBrowseContinuationPoints().remove(bs);
return c != null ?
new BrowseResult(StatusCode.GOOD, null, null) :
new BrowseResult(BAD_CONTINUATION_POINT_INVALID, null, null);
}