use of org.apache.plc4x.java.api.messages.PlcSubscriptionResponse in project plc4x by apache.
the class OpcuaSubscriptionHandleTest method subscribeMultiple.
@Test
public void subscribeMultiple() throws Exception {
String field1 = "UInteger";
String identifier1 = UINTEGER_IDENTIFIER_READ_WRITE;
String field2 = "Integer";
String identifier2 = INTEGER_IDENTIFIER_READ_WRITE;
LOGGER.info("Starting subscription {} and {} test", field1, field2);
// Create Subscription
PlcSubscriptionRequest.Builder builder = opcuaConnection.subscriptionRequestBuilder();
builder.addChangeOfStateField(field1, identifier1);
builder.addChangeOfStateField(field2, identifier2);
PlcSubscriptionRequest request = builder.build();
// Get result of creating subscription
PlcSubscriptionResponse response = request.execute().get();
final OpcuaSubscriptionHandle subscriptionHandle = (OpcuaSubscriptionHandle) response.getSubscriptionHandle(field1);
// Create handler for returned value
subscriptionHandle.register(plcSubscriptionEvent -> {
assert plcSubscriptionEvent.getResponseCode(field1).equals(PlcResponseCode.OK);
assert plcSubscriptionEvent.getResponseCode(field2).equals(PlcResponseCode.OK);
});
// Wait for value to be returned from server
Thread.sleep(1200);
subscriptionHandle.stopSubscriber();
}
use of org.apache.plc4x.java.api.messages.PlcSubscriptionResponse in project plc4x by apache.
the class OpcuaSubscriptionHandleTest method subscribeInt32.
@Test
public void subscribeInt32() throws Exception {
String field = "Int32";
String identifier = INT32_IDENTIFIER_READ_WRITE;
LOGGER.info("Starting subscription {} test", field);
// Create Subscription
PlcSubscriptionRequest.Builder builder = opcuaConnection.subscriptionRequestBuilder();
builder.addChangeOfStateField(field, identifier);
PlcSubscriptionRequest request = builder.build();
// Get result of creating subscription
PlcSubscriptionResponse response = request.execute().get();
final OpcuaSubscriptionHandle subscriptionHandle = (OpcuaSubscriptionHandle) response.getSubscriptionHandle(field);
// Create handler for returned value
subscriptionHandle.register(plcSubscriptionEvent -> {
assert plcSubscriptionEvent.getResponseCode(field).equals(PlcResponseCode.OK);
LOGGER.info("Received a response from {} test {}", field, plcSubscriptionEvent.getPlcValue(field).toString());
});
// Wait for value to be returned from server
Thread.sleep(1200);
subscriptionHandle.stopSubscriber();
}
use of org.apache.plc4x.java.api.messages.PlcSubscriptionResponse in project plc4x by apache.
the class OpcuaSubscriptionHandleTest method subscribeSByte.
@Test
public void subscribeSByte() throws Exception {
String field = "SByte";
String identifier = SBYTE_IDENTIFIER_READ_WRITE;
LOGGER.info("Starting subscription {} test", field);
// Create Subscription
PlcSubscriptionRequest.Builder builder = opcuaConnection.subscriptionRequestBuilder();
builder.addChangeOfStateField(field, identifier);
PlcSubscriptionRequest request = builder.build();
// Get result of creating subscription
PlcSubscriptionResponse response = request.execute().get();
final OpcuaSubscriptionHandle subscriptionHandle = (OpcuaSubscriptionHandle) response.getSubscriptionHandle(field);
// Create handler for returned value
subscriptionHandle.register(plcSubscriptionEvent -> {
assert plcSubscriptionEvent.getResponseCode(field).equals(PlcResponseCode.OK);
LOGGER.info("Received a response from {} test {}", field, plcSubscriptionEvent.getPlcValue(field).toString());
});
// Wait for value to be returned from server
Thread.sleep(1200);
subscriptionHandle.stopSubscriber();
}
use of org.apache.plc4x.java.api.messages.PlcSubscriptionResponse in project plc4x by apache.
the class OpcuaSubscriptionHandleTest method subscribeInteger.
@Test
public void subscribeInteger() throws Exception {
String field = "Integer";
String identifier = INTEGER_IDENTIFIER_READ_WRITE;
LOGGER.info("Starting subscription {} test", field);
// Create Subscription
PlcSubscriptionRequest.Builder builder = opcuaConnection.subscriptionRequestBuilder();
builder.addChangeOfStateField(field, identifier);
PlcSubscriptionRequest request = builder.build();
// Get result of creating subscription
PlcSubscriptionResponse response = request.execute().get();
final OpcuaSubscriptionHandle subscriptionHandle = (OpcuaSubscriptionHandle) response.getSubscriptionHandle(field);
// Create handler for returned value
subscriptionHandle.register(plcSubscriptionEvent -> {
assert plcSubscriptionEvent.getResponseCode(field).equals(PlcResponseCode.OK);
LOGGER.info("Received a response from {} test {}", field, plcSubscriptionEvent.getPlcValue(field).toString());
});
// Wait for value to be returned from server
Thread.sleep(1200);
subscriptionHandle.stopSubscriber();
}
use of org.apache.plc4x.java.api.messages.PlcSubscriptionResponse in project plc4x by apache.
the class OpcuaSubscriptionHandleTest method subscribeByte.
@Test
public void subscribeByte() throws Exception {
String field = "Byte";
String identifier = BYTE_IDENTIFIER_READ_WRITE;
LOGGER.info("Starting subscription {} test", field);
// Create Subscription
PlcSubscriptionRequest.Builder builder = opcuaConnection.subscriptionRequestBuilder();
builder.addChangeOfStateField(field, identifier);
PlcSubscriptionRequest request = builder.build();
// Get result of creating subscription
PlcSubscriptionResponse response = request.execute().get();
final OpcuaSubscriptionHandle subscriptionHandle = (OpcuaSubscriptionHandle) response.getSubscriptionHandle(field);
// Create handler for returned value
subscriptionHandle.register(plcSubscriptionEvent -> {
assert plcSubscriptionEvent.getResponseCode(field).equals(PlcResponseCode.OK);
LOGGER.info("Received a response from {} test {}", field, plcSubscriptionEvent.getPlcValue(field).toString());
});
// Wait for value to be returned from server
Thread.sleep(1200);
subscriptionHandle.stopSubscriber();
}
Aggregations