Package de.freaklamarsch.systarest
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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FakeSystaWeb.FakeSystaWebStatus
Inner class for representing the status of this @see FakeSystaWeb(package private) static class
FakeSystaWeb.MessageType
class
FakeSystaWeb.SystaComfortInfo
Inner class for representing the info about a SystaComfort unit -
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
commitDate
private static int
COUNTER_OFFSET_REPLY
private static int
COUNTER_OFFSET_REPLY_2
private long
dataPacketsProcessed
private long
dataPacketsReceived
private static java.lang.String
DELIMITER
private java.lang.String
inetAddress
private java.lang.Integer[][]
intData
private static java.lang.String
LOG_PATH
private static java.io.FilenameFilter
logFileFilter
private static java.lang.String
logFileFilterString
private DataLogger<java.lang.Integer>
logInt
private DataLogger<java.lang.Byte>
logRaw
private static int
MAC_OFFSET_REPLY
private static int
MAX_DATA_LENGTH
private static int
MAX_NUMBER_DATA_PACKETS
private static int
MAX_NUMBER_ENTRIES
private static int
PORT
private static java.lang.String
PREFIX
private int
readIndex
private byte[]
receiveData
private java.net.DatagramPacket
receivePacket
private java.net.InetAddress
remoteAddress
private int
remotePort
private byte[][]
replyHeader
private int
RING_BUFFER_SIZE
private boolean
running
private java.net.DatagramSocket
socket
private boolean
stopRequested
private long[]
timestamp
private java.time.format.DateTimeFormatter
timestampFormatter
private FakeSystaWeb.MessageType
typeOfLastReceivedMessage
private static java.lang.String[]
WATER_HEATER_OPERATION_MODES
private int
writeIndex
private static int
WRITER_MAX_DATA
-
Constructor Summary
Constructors Constructor Description FakeSystaWeb()
-
Method Summary
Modifier and Type Method Description int
deleteAllLogs()
DeviceTouchSearch.DeviceTouchDeviceInfo
findSystaComfort()
java.io.File
getAllLogs()
java.lang.Integer[]
getData()
java.lang.String
getFormattedTimeString(long timestamp)
get the timestamp (epoch seconds) as formatted string for the local timezonejava.lang.String
getInetAddress()
SystaStatus
getParadigmaStatus()
FakeSystaWeb.FakeSystaWebStatus
getStatus()
Simulates retrieving the status of the SystaComfort unit.long
getTimestamp()
get the timestamp for the current measurementjava.lang.String
getTimestampString()
get the timestamp for the current measurement as human readable stringSystaWaterHeaterStatus
getWaterHeaterStatus()
void
logRawData()
void
logRawData(int entriesPerFile)
void
logRawData(java.lang.String filePrefix)
void
logRawData(java.lang.String filePrefix, java.lang.String delimiter, int entriesPerFile)
private void
processDatagram(java.nio.ByteBuffer data)
private void
processDataPacket(java.nio.ByteBuffer data, int offset)
private void
processDataType1(java.nio.ByteBuffer data)
process UPD packets from Paradigma SystaComfort II with type field set to 0x01private void
processDataType2(java.nio.ByteBuffer data)
process UDP packets from Paradigma SystaComfort II with type field set to 0x02private void
processDataType3(java.nio.ByteBuffer data)
process UDP packets from Paradigma SystaComfort II with type field set to 0x03private void
processDataType4(java.nio.ByteBuffer data)
process UDP packets from Paradigma SystaComfort II with type field set to 0x04private void
receiveNextDatagram()
void
run()
start the communication with a Paradigma SystaComfort II requires the globals inetAddress and PORT to be properly configuredprivate void
send(byte[] reply)
send a message to the SystaComfort II unitprivate void
sendDataReply(int index)
function to reply the messages received from a Paradigma SystaComfort II, for keeping the communication alivevoid
setInetAddress(java.lang.String inetAddress)
void
setLogFileRootPath(java.lang.String path)
void
stop()
stop the communication with a Paradigma SystaComfort II if runningvoid
stopLoggingRawData()
private java.lang.Byte[]
toByteArray(byte[] bytes)
private helper function to convert frombyte
toByte
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
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
-
logRaw
-
-
Constructor Details
-
FakeSystaWeb
public FakeSystaWeb()
-
-
Method Details
-
setLogFileRootPath
public void setLogFileRootPath(java.lang.String path) -
getStatus
Simulates retrieving the status of the SystaComfort unit.- Returns:
- a
SystaStatus
object containing the current status
-
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
-
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 interfacejava.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() -
toByteArray
private java.lang.Byte[] toByteArray(byte[] bytes)private helper function to convert frombyte
toByte
- 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()
-