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 class
FakeSTouch.ConnectionStatus
(package private) static class
FakeSTouch.ReplyType
-
Field Summary
Fields Modifier and Type Field Description private static int
APP_MINOR
private static int
APP_VERSION
private static int
BASIS_VERSION
(package private) int
cnCmd
private boolean
connected
private boolean
debug
private FakeSTouchDisplay
display
The 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.InetAddress
inetAddress
(package private) DeviceTouchSearch.DeviceTouchDeviceInfo
info
(package private) int
lastId
(package private) int
lastX
(package private) int
lastY
private java.util.concurrent.Future<?>
listenerFuture
private java.util.concurrent.ExecutorService
listenerService
(package private) java.lang.String
mac
private static int
MAX_DATA_LENGTH
private static int
MAX_RETRIES
(package private) byte[]
password
(package private) long
PktCmd
(package private) int
port
private java.net.DatagramSocket
socket
private static int
TIMEOUT
-
Constructor Summary
Constructors Constructor Description FakeSTouch()
-
Method Summary
Modifier and Type Method Description FakeSTouch.ConnectionStatus
connect()
Connects the simulated S-Touch device to a Paradigma SystaComfort unit.java.net.DatagramPacket
createConnectionRequestMessage()
Create a DatagramPacket to send a connection request to a Paradigma SystaComfort device.java.net.DatagramPacket
createDisconnectRequestMessage()
Create a DatagramPacket to inform a Paradigma SystaComfort device about the disconnection from this emulates S-Touch device.void
disconnect()
Disconnects the simulated S-Touch device from the SystaComfort unit.FakeSTouchDisplay
getDisplay()
Retrieves the simulated display associated with this S-Touch device.DeviceTouchSearch.DeviceTouchDeviceInfo
getInfo()
Get theDeviceTouchSearch.DeviceTouchDeviceInfo
currently set as communication targetjava.lang.String
getObjectTree()
java.awt.image.BufferedImage
getScreenAsImage()
private void
initializeDisplayActions()
private boolean
isCommandEnabled(STouchProtocol.STouchCommand cmd)
private void
printByteArrayAsHex(byte[] bytes)
private void
printByteArrayAsHex(byte[] bytes, int len)
private void
printDebugInfo(java.lang.String string)
void
printScreen()
java.net.DatagramPacket
processCommands(java.net.DatagramPacket packet)
private java.net.DatagramPacket
receive()
Receive a message from the connected Paradigma SystaComfort unitDeviceTouchSearch.DeviceTouchDeviceInfo
searchSTouchDevice()
void
setAddr(java.net.InetAddress addr)
void
setDebug(boolean debug)
Enable/disable the writing of debug messagesboolean
setInfo(DeviceTouchSearch.DeviceTouchDeviceInfo info)
Set theDeviceTouchSearch.DeviceTouchDeviceInfo
that should be used as communication targetprivate void
startListening()
private boolean
syncnow(int id)
void
touch(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
-true
enables writing of debugging info,false
disables it.
-
getDisplay
Retrieves the simulated display associated with this S-Touch device.- Returns:
- the
FakeSTouchDisplay
instance
-
getInfo
Get theDeviceTouchSearch.DeviceTouchDeviceInfo
currently set as communication target- Returns:
- the
DeviceTouchSearch.DeviceTouchDeviceInfo
-
setInfo
Set theDeviceTouchSearch.DeviceTouchDeviceInfo
that 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 theinfo
is set, this will be used as communication target, otherwise a compatible device is searched on the configured interface.- Returns:
true
if the connection was successful;false
otherwise- 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)
-