Class FakeSystaWeb

java.lang.Object
de.freaklamarsch.systarest.FakeSystaWeb
All Implemented Interfaces:
java.lang.Runnable

public class FakeSystaWeb
extends java.lang.Object
implements java.lang.Runnable
See Also:
implementation to mock the Paradigma SystaWeb service. This class opens a @see DatagramSocket for the communication with a Paradigma SystaComfort I or II. This class provides access to the received data.
  • Field Details

    • commitDate

      private static final java.lang.String commitDate
      See Also:
      Constant Field Values
    • PORT

      private static final int PORT
      See Also:
      Constant Field Values
    • MAX_DATA_LENGTH

      private static final int MAX_DATA_LENGTH
      See Also:
      Constant Field Values
    • MAX_NUMBER_ENTRIES

      private static final int MAX_NUMBER_ENTRIES
      See Also:
      Constant Field Values
    • MAX_NUMBER_DATA_PACKETS

      private static final int MAX_NUMBER_DATA_PACKETS
      See Also:
      Constant Field Values
    • COUNTER_OFFSET_REPLY

      private static final int COUNTER_OFFSET_REPLY
      See Also:
      Constant Field Values
    • COUNTER_OFFSET_REPLY_2

      private static final int COUNTER_OFFSET_REPLY_2
      See Also:
      Constant Field Values
    • MAC_OFFSET_REPLY

      private static final int MAC_OFFSET_REPLY
      See Also:
      Constant Field Values
    • RING_BUFFER_SIZE

      private final int RING_BUFFER_SIZE
      See Also:
      Constant Field Values
    • WATER_HEATER_OPERATION_MODES

      private static final java.lang.String[] WATER_HEATER_OPERATION_MODES
    • WRITER_MAX_DATA

      private static final int WRITER_MAX_DATA
      See Also:
      Constant Field Values
    • DELIMITER

      private static final java.lang.String DELIMITER
      See Also:
      Constant Field Values
    • PREFIX

      private static final java.lang.String PREFIX
      See Also:
      Constant Field Values
    • LOG_PATH

      private static java.lang.String LOG_PATH
    • logFileFilterString

      private static final java.lang.String logFileFilterString
      See Also:
      Constant Field Values
    • logFileFilter

      private static final java.io.FilenameFilter logFileFilter
    • typeOfLastReceivedMessage

      private FakeSystaWeb.MessageType typeOfLastReceivedMessage
    • remoteAddress

      private java.net.InetAddress remoteAddress
    • remotePort

      private int remotePort
    • readIndex

      private int readIndex
    • writeIndex

      private int writeIndex
    • dataPacketsReceived

      private long dataPacketsReceived
    • dataPacketsProcessed

      private long dataPacketsProcessed
    • replyHeader

      private byte[][] replyHeader
    • intData

      private java.lang.Integer[][] intData
    • timestamp

      private long[] timestamp
    • inetAddress

      private java.lang.String inetAddress
    • socket

      private java.net.DatagramSocket socket
    • running

      private boolean running
    • stopRequested

      private boolean stopRequested
    • receiveData

      private byte[] receiveData
    • receivePacket

      private java.net.DatagramPacket receivePacket
    • timestampFormatter

      private java.time.format.DateTimeFormatter timestampFormatter
    • logInt

      private DataLogger<java.lang.Integer> logInt
    • logRaw

      private DataLogger<java.lang.Byte> logRaw
  • Constructor Details

    • FakeSystaWeb

      public FakeSystaWeb()
  • Method Details

    • setLogFileRootPath

      public void setLogFileRootPath​(java.lang.String path)
    • getStatus

      public FakeSystaWeb.FakeSystaWebStatus getStatus()
      Simulates retrieving the status of the SystaComfort unit.
      Returns:
      a SystaStatus object containing the current status
    • findSystaComfort

      public DeviceTouchSearch.DeviceTouchDeviceInfo findSystaComfort()
    • getInetAddress

      public java.lang.String getInetAddress()
      Returns:
      the inetAddress
    • setInetAddress

      public void setInetAddress​(java.lang.String inetAddress)
      Parameters:
      inetAddress - the inetAddress to set
    • getTimestamp

      public long getTimestamp()
      get the timestamp for the current measurement
      Returns:
      the timestamp in seconds from the epoch of 1970-01-01T00:00:00Z. Which is UTC.
    • getTimestampString

      public java.lang.String getTimestampString()
      get the timestamp for the current measurement as human readable string
      Returns:
      the timestamp as a LocalDateTime string, which is a date-time with a time-zone offset in the ISO-8601 calendar system e.g. 2021-12-24T14:49:27.123+01:00 or "never"
    • getFormattedTimeString

      public java.lang.String getFormattedTimeString​(long timestamp)
      get the timestamp (epoch seconds) as formatted string for the local timezone
      Returns:
      the timestamp as a LocalDateTime string, which is a date-time with a time-zone offset in the ISO-8601 calendar system e.g. 2021-12-24T14:49:27.123+01:00
    • getData

      public java.lang.Integer[] getData()
      Returns:
      the intData of the current measurement, or null if no measurement has been done so far
    • getWaterHeaterStatus

      public SystaWaterHeaterStatus getWaterHeaterStatus()
    • getParadigmaStatus

      public SystaStatus getParadigmaStatus()
    • stop

      public void stop()
      stop the communication with a Paradigma SystaComfort II if running
    • run

      public void run()
      start the communication with a Paradigma SystaComfort II requires the globals inetAddress and PORT to be properly configured
      Specified by:
      run in interface java.lang.Runnable
    • processDatagram

      private void processDatagram​(java.nio.ByteBuffer data)
      Parameters:
      data - ByteBuffer that holds the raw data of the Datagram
    • receiveNextDatagram

      private void receiveNextDatagram()
      receive the next UDP DatagramPacket from the configured socket into receivePacket
    • toByteArray

      private java.lang.Byte[] toByteArray​(byte[] bytes)
      private helper function to convert from byte to Byte
      Parameters:
      bytes -
      Returns:
    • sendDataReply

      private void sendDataReply​(int index)
      function to reply the messages received from a Paradigma SystaComfort II, for keeping the communication alive
      Parameters:
      index - index in replyHeader where the current message is stored
    • send

      private void send​(byte[] reply)
      send a message to the SystaComfort II unit
      Parameters:
      reply - byte[] holding the message to be sent
    • processDataPacket

      private void processDataPacket​(java.nio.ByteBuffer data, int offset)
    • processDataType1

      private void processDataType1​(java.nio.ByteBuffer data)
      process UPD packets from Paradigma SystaComfort II with type field set to 0x01
      Parameters:
      data - ByteBuffer that holds the received data
    • processDataType2

      private void processDataType2​(java.nio.ByteBuffer data)
      process UDP packets from Paradigma SystaComfort II with type field set to 0x02
      Parameters:
      data - ByteBuffer that holds the received data
    • processDataType3

      private void processDataType3​(java.nio.ByteBuffer data)
      process UDP packets from Paradigma SystaComfort II with type field set to 0x03
      Parameters:
      data - ByteBuffer that holds the received data
    • processDataType4

      private void processDataType4​(java.nio.ByteBuffer data)
      process UDP packets from Paradigma SystaComfort II with type field set to 0x04
      Parameters:
      data - ByteBuffer that holds the received data
    • logRawData

      public void logRawData()
    • logRawData

      public void logRawData​(int entriesPerFile)
    • logRawData

      public void logRawData​(java.lang.String filePrefix)
    • logRawData

      public void logRawData​(java.lang.String filePrefix, java.lang.String delimiter, int entriesPerFile)
    • stopLoggingRawData

      public void stopLoggingRawData()
    • getAllLogs

      public java.io.File getAllLogs()
    • deleteAllLogs

      public int deleteAllLogs()