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 classFakeSystaWeb.FakeSystaWebStatusInner class for representing the status of this @see FakeSystaWeb(package private) static classFakeSystaWeb.MessageTypeclassFakeSystaWeb.SystaComfortInfoInner class for representing the info about a SystaComfort unit -
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringcommitDateprivate static intCOUNTER_OFFSET_REPLYprivate static intCOUNTER_OFFSET_REPLY_2private longdataPacketsProcessedprivate longdataPacketsReceivedprivate static java.lang.StringDELIMITERprivate java.lang.StringinetAddressprivate java.lang.Integer[][]intDataprivate static java.lang.StringLOG_PATHprivate static java.io.FilenameFilterlogFileFilterprivate static java.lang.StringlogFileFilterStringprivate DataLogger<java.lang.Integer>logIntprivate DataLogger<java.lang.Byte>logRawprivate static intMAC_OFFSET_REPLYprivate static intMAX_DATA_LENGTHprivate static intMAX_NUMBER_DATA_PACKETSprivate static intMAX_NUMBER_ENTRIESprivate static intPORTprivate static java.lang.StringPREFIXprivate intreadIndexprivate byte[]receiveDataprivate java.net.DatagramPacketreceivePacketprivate java.net.InetAddressremoteAddressprivate intremotePortprivate byte[][]replyHeaderprivate intRING_BUFFER_SIZEprivate booleanrunningprivate java.net.DatagramSocketsocketprivate booleanstopRequestedprivate long[]timestampprivate java.time.format.DateTimeFormattertimestampFormatterprivate FakeSystaWeb.MessageTypetypeOfLastReceivedMessageprivate static java.lang.String[]WATER_HEATER_OPERATION_MODESprivate intwriteIndexprivate static intWRITER_MAX_DATA -
Constructor Summary
Constructors Constructor Description FakeSystaWeb() -
Method Summary
Modifier and Type Method Description intdeleteAllLogs()DeviceTouchSearch.DeviceTouchDeviceInfofindSystaComfort()java.io.FilegetAllLogs()java.lang.Integer[]getData()java.lang.StringgetFormattedTimeString(long timestamp)get the timestamp (epoch seconds) as formatted string for the local timezonejava.lang.StringgetInetAddress()SystaStatusgetParadigmaStatus()FakeSystaWeb.FakeSystaWebStatusgetStatus()Simulates retrieving the status of the SystaComfort unit.longgetTimestamp()get the timestamp for the current measurementjava.lang.StringgetTimestampString()get the timestamp for the current measurement as human readable stringSystaWaterHeaterStatusgetWaterHeaterStatus()voidlogRawData()voidlogRawData(int entriesPerFile)voidlogRawData(java.lang.String filePrefix)voidlogRawData(java.lang.String filePrefix, java.lang.String delimiter, int entriesPerFile)private voidprocessDatagram(java.nio.ByteBuffer data)private voidprocessDataPacket(java.nio.ByteBuffer data, int offset)private voidprocessDataType1(java.nio.ByteBuffer data)process UPD packets from Paradigma SystaComfort II with type field set to 0x01private voidprocessDataType2(java.nio.ByteBuffer data)process UDP packets from Paradigma SystaComfort II with type field set to 0x02private voidprocessDataType3(java.nio.ByteBuffer data)process UDP packets from Paradigma SystaComfort II with type field set to 0x03private voidprocessDataType4(java.nio.ByteBuffer data)process UDP packets from Paradigma SystaComfort II with type field set to 0x04private voidreceiveNextDatagram()voidrun()start the communication with a Paradigma SystaComfort II requires the globals inetAddress and PORT to be properly configuredprivate voidsend(byte[] reply)send a message to the SystaComfort II unitprivate voidsendDataReply(int index)function to reply the messages received from a Paradigma SystaComfort II, for keeping the communication alivevoidsetInetAddress(java.lang.String inetAddress)voidsetLogFileRootPath(java.lang.String path)voidstop()stop the communication with a Paradigma SystaComfort II if runningvoidstopLoggingRawData()private java.lang.Byte[]toByteArray(byte[] bytes)private helper function to convert frombytetoByteMethods 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
SystaStatusobject 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:
runin 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 frombytetoByte- 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()
-