Class Iec21Port


  • public class Iec21Port
    extends java.lang.Object
    Represents 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 using Iec21Port.Builder.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Iec21Port.Builder
      A builder for Iec21Ports.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this communication port.
      java.io.DataInputStream getInputStream()  
      java.io.DataOutputStream getOutputStream()  
      org.openmuc.jrxtx.SerialPort getSerialPort()  
      boolean isClosed()
      Returns true if this port has been closed.
      void listen​(ModeDListener listener)
      Listen for mode D messages.
      DataMessage read()
      Requests meter data and returns the response.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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