Package org.openmuc.j62056
Class Iec21Port
- java.lang.Object
-
- org.openmuc.j62056.Iec21Port
-
public class Iec21Port extends java.lang.ObjectRepresents a serial communication port that can be used to read meters using IEC 62056-21 modes A, B, C or D. Create and open a port usingIec21Port.Builder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIec21Port.BuilderA builder for Iec21Ports.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this communication port.java.io.DataInputStreamgetInputStream()java.io.DataOutputStreamgetOutputStream()org.openmuc.jrxtx.SerialPortgetSerialPort()booleanisClosed()Returns true if this port has been closed.voidlisten(ModeDListener listener)Listen for mode D messages.DataMessageread()Requests meter data and returns the response.
-
-
-
Method Detail
-
getSerialPort
public final org.openmuc.jrxtx.SerialPort getSerialPort()
-
getOutputStream
public final java.io.DataOutputStream getOutputStream()
-
getInputStream
public final java.io.DataInputStream getInputStream()
-
close
public void close()
Closes this communication port. Also closes the associated serial port, input stream and output stream.The port cannot be opened again but has to be recreated.
-
read
public DataMessage read() throws java.io.IOException
Requests meter data and returns the response.Requests a data message from the remote device using IEC 62056-21 Mode A, B or C. The data message received is parsed and returned. The returned data message also contains some information fields from the identification message sent by the meter.
- Returns:
- The response data message.
- Throws:
java.io.IOException- if any kind of IO error occurs
-
isClosed
public boolean isClosed()
Returns true if this port has been closed.- Returns:
- true if this port has been closed
-
listen
public void listen(ModeDListener listener) throws java.io.IOException
Listen for mode D messages.- Parameters:
listener- A listener for mode D messages- Throws:
java.io.IOException- throws IOException
-
-