Package de.freaklamarsch.systarest
Class FakeSTouch
java.lang.Object
de.freaklamarsch.systarest.FakeSTouch
public class FakeSTouch
extends java.lang.Object
A mock implementation of the S-Touch device for testing and simulation
purposes. This class provides methods to simulate interactions with the
S-Touch device, such as connecting, disconnecting, and sending touch events.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFakeSTouch.ConnectionStatus(package private) static classFakeSTouch.ReplyType -
Field Summary
Fields Modifier and Type Field Description private static intAPP_MINORprivate static intAPP_VERSIONprivate static intBASIS_VERSION(package private) intcnCmdprivate booleanconnectedprivate booleandebugprivate FakeSTouchDisplaydisplayThe display associated with this S-Touch device.private java.util.Map<STouchProtocol.STouchCommand,java.util.function.Function<java.lang.Object,java.lang.Boolean>>displayMethods(package private) java.net.InetAddressinetAddress(package private) DeviceTouchSearch.DeviceTouchDeviceInfoinfo(package private) intlastId(package private) intlastX(package private) intlastYprivate java.util.concurrent.Future<?>listenerFutureprivate java.util.concurrent.ExecutorServicelistenerService(package private) java.lang.Stringmacprivate static intMAX_DATA_LENGTHprivate static intMAX_RETRIES(package private) byte[]password(package private) longPktCmd(package private) intportprivate java.net.DatagramSocketsocketprivate static intTIMEOUT -
Constructor Summary
Constructors Constructor Description FakeSTouch() -
Method Summary
Modifier and Type Method Description FakeSTouch.ConnectionStatusconnect()Connects the simulated S-Touch device to a Paradigma SystaComfort unit.java.net.DatagramPacketcreateConnectionRequestMessage()Create a DatagramPacket to send a connection request to a Paradigma SystaComfort device.java.net.DatagramPacketcreateDisconnectRequestMessage()Create a DatagramPacket to inform a Paradigma SystaComfort device about the disconnection from this emulates S-Touch device.voiddisconnect()Disconnects the simulated S-Touch device from the SystaComfort unit.FakeSTouchDisplaygetDisplay()Retrieves the simulated display associated with this S-Touch device.DeviceTouchSearch.DeviceTouchDeviceInfogetInfo()Get theDeviceTouchSearch.DeviceTouchDeviceInfocurrently set as communication targetjava.lang.StringgetObjectTree()java.awt.image.BufferedImagegetScreenAsImage()private voidinitializeDisplayActions()private booleanisCommandEnabled(STouchProtocol.STouchCommand cmd)private voidprintByteArrayAsHex(byte[] bytes)private voidprintByteArrayAsHex(byte[] bytes, int len)private voidprintDebugInfo(java.lang.String string)voidprintScreen()java.net.DatagramPacketprocessCommands(java.net.DatagramPacket packet)private java.net.DatagramPacketreceive()Receive a message from the connected Paradigma SystaComfort unitDeviceTouchSearch.DeviceTouchDeviceInfosearchSTouchDevice()voidsetAddr(java.net.InetAddress addr)voidsetDebug(boolean debug)Enable/disable the writing of debug messagesbooleansetInfo(DeviceTouchSearch.DeviceTouchDeviceInfo info)Set theDeviceTouchSearch.DeviceTouchDeviceInfothat should be used as communication targetprivate voidstartListening()private booleansyncnow(int id)voidtouch(int x, int y)Simulates a touch event on the S-Touch display at the specified coordinates.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
socket
private java.net.DatagramSocket socket -
connected
private boolean connected -
listenerService
private java.util.concurrent.ExecutorService listenerService -
listenerFuture
private java.util.concurrent.Future<?> listenerFuture -
TIMEOUT
private static final int TIMEOUT- See Also:
- Constant Field Values
-
MAX_RETRIES
private static final int MAX_RETRIES- See Also:
- Constant Field Values
-
APP_MINOR
private static final int APP_MINOR- See Also:
- Constant Field Values
-
APP_VERSION
private static final int APP_VERSION- See Also:
- Constant Field Values
-
BASIS_VERSION
private static final int BASIS_VERSION- See Also:
- Constant Field Values
-
MAX_DATA_LENGTH
private static final int MAX_DATA_LENGTH- See Also:
- Constant Field Values
-
debug
private boolean debug -
lastId
int lastId -
lastX
int lastX -
lastY
int lastY -
display
The display associated with this S-Touch device. -
PktCmd
long PktCmd -
port
int port -
inetAddress
java.net.InetAddress inetAddress -
cnCmd
int cnCmd -
mac
java.lang.String mac -
password
byte[] password -
info
-
displayMethods
private final java.util.Map<STouchProtocol.STouchCommand,java.util.function.Function<java.lang.Object,java.lang.Boolean>> displayMethods
-
-
Constructor Details
-
FakeSTouch
public FakeSTouch()
-
-
Method Details
-
initializeDisplayActions
private void initializeDisplayActions() -
setDebug
public void setDebug(boolean debug)Enable/disable the writing of debug messages- Parameters:
debug-trueenables writing of debugging info,falsedisables it.
-
getDisplay
Retrieves the simulated display associated with this S-Touch device.- Returns:
- the
FakeSTouchDisplayinstance
-
getInfo
Get theDeviceTouchSearch.DeviceTouchDeviceInfocurrently set as communication target- Returns:
- the
DeviceTouchSearch.DeviceTouchDeviceInfo
-
setInfo
Set theDeviceTouchSearch.DeviceTouchDeviceInfothat should be used as communication target- Parameters:
info- the info to set
-
connect
public FakeSTouch.ConnectionStatus connect() throws java.io.IOException, java.lang.InterruptedExceptionConnects the simulated S-Touch device to a Paradigma SystaComfort unit. If theinfois set, this will be used as communication target, otherwise a compatible device is searched on the configured interface.- Returns:
trueif the connection was successful;falseotherwise- Throws:
java.io.IOException- if an error occurs during sending of connection messagesjava.lang.InterruptedException- if the thread gets interrupted during waiting for a reply for connection messages
-
createConnectionRequestMessage
public java.net.DatagramPacket createConnectionRequestMessage()Create a DatagramPacket to send a connection request to a Paradigma SystaComfort device.- Returns:
- the DatatgramPacket holding the created connection request
-
createDisconnectRequestMessage
public java.net.DatagramPacket createDisconnectRequestMessage()Create a DatagramPacket to inform a Paradigma SystaComfort device about the disconnection from this emulates S-Touch device.- Returns:
- the DatatgramPacket holding the created disconnect message
-
startListening
private void startListening() -
receive
private java.net.DatagramPacket receive()Receive a message from the connected Paradigma SystaComfort unit- Returns:
- the received DatagramPaket from the connected device, or null if no valid packet was received
-
disconnect
public void disconnect() throws java.io.IOExceptionDisconnects the simulated S-Touch device from the SystaComfort unit.- Throws:
java.io.IOException- if an error occurs during disconnection
-
searchSTouchDevice
-
printDebugInfo
private void printDebugInfo(java.lang.String string) -
syncnow
private boolean syncnow(int id) -
touch
public void touch(int x, int y)Simulates a touch event on the S-Touch display at the specified coordinates.- Parameters:
x- the x-coordinate of the touchy- the y-coordinate of the touch
-
printScreen
public void printScreen() -
getObjectTree
public java.lang.String getObjectTree() -
getScreenAsImage
public java.awt.image.BufferedImage getScreenAsImage() -
setAddr
public void setAddr(java.net.InetAddress addr)- Parameters:
addr- the InetAddress this instance should use for communication
-
isCommandEnabled
-
processCommands
public java.net.DatagramPacket processCommands(java.net.DatagramPacket packet) -
printByteArrayAsHex
private void printByteArrayAsHex(byte[] bytes, int len) -
printByteArrayAsHex
private void printByteArrayAsHex(byte[] bytes)
-