java.lang.AutoCloseable
public final class Master
extends java.lang.Object
implements java.lang.AutoCloseable
Is created using a Master.TcpBuilder
instance.
An association can be active or inactive. What it means for an association to be active depends on the physical layer protocol used. TCP based associations are active when a TCP connection exists between master and outstation. UDP based associations are active when the UDP socket was successfully bound. Serial based associations are active when the serial port was opened.
When inactive, the association attempts to automatically reactivate itself periodically.
Request methods throw a Dnp3TimeoutException if a timeout occurs while waiting for the response
Requests can be interrupted by issuing another request or by closing the association. The interrupted request method will throw an IOException in that case.
A request, when encoded, that exceeds the maximum message fragment size is transparently split and its responses are recombined and returned as a single response.
Modifier and Type | Class | Description |
---|---|---|
static interface |
Master.EventListener |
The listener is notified of event data.
|
static class |
Master.TcpBuilder |
A builder to create TCP based master associations.
|
Modifier and Type | Method | Description |
---|---|---|
java.util.Set<InternalIndication> |
assignClasses(AssignClassesRequest request) |
|
void |
awaitConnection(java.time.Duration timeout) |
Blocks until master has connected to the outstation.
|
void |
close() |
Closes this master.
|
java.util.Set<InternalIndication> |
disableUnsolicited(boolean class1,
boolean class2,
boolean class3) |
|
java.util.Set<InternalIndication> |
enableUnsolicited(boolean class1,
boolean class2,
boolean class3) |
|
boolean |
isClosed() |
|
static Master.TcpBuilder |
newTcpBuilder() |
|
java.util.Set<InternalIndication> |
operate(OperateRequest request,
OperateRequest.OperationMode operationMode) |
Send a select/operate or direct operate command.
|
ReadResponse |
read(ReadRequest request) |
Sends a read request and returns the response.
|
java.util.Set<InternalIndication> |
write(WriteRequest request) |
public static Master.TcpBuilder newTcpBuilder()
public void close()
close
in interface java.lang.AutoCloseable
public ReadResponse read(ReadRequest request) throws java.io.IOException, java.lang.InterruptedException
Master.EventListener
.
If the server responds with an internal indication (IIN) error, then this method will NOT throw an exception but instead return a response that contains the internal indications that the server responded with.
request
- the requestjava.io.IOException
- if an IO-error occurs while sending or receivingjava.lang.InterruptedException
- if the operation is interruptedpublic java.util.Set<InternalIndication> assignClasses(AssignClassesRequest request) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public java.util.Set<InternalIndication> write(WriteRequest request) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public java.util.Set<InternalIndication> operate(OperateRequest request, OperateRequest.OperationMode operationMode) throws java.io.IOException, java.lang.InterruptedException
If the server responds with an error, this method throws a Dnp3OperateException
(a
special IOException) which contains the error details.
request
- the responseoperationMode
- the operation modejava.io.IOException
- if any error occursjava.lang.InterruptedException
- if the operation is interruptedpublic java.util.Set<InternalIndication> enableUnsolicited(boolean class1, boolean class2, boolean class3) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public java.util.Set<InternalIndication> disableUnsolicited(boolean class1, boolean class2, boolean class3) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public boolean isClosed()
public void awaitConnection(java.time.Duration timeout) throws java.lang.InterruptedException, java.io.IOException
timeout
- the max duration to wait for a connection before throwing a Dnp3TimeoutException
java.lang.InterruptedException
- if the thread is interruptedDnp3TimeoutException
- if a timeout occurs while waiting for connectionjava.io.IOException
- if the master is closed while waiting for connection