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.
  • 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

      private FakeSTouchDisplay 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

      public FakeSTouchDisplay getDisplay()
      Retrieves the simulated display associated with this S-Touch device.
      Returns:
      the FakeSTouchDisplay instance
    • getInfo

      Get the DeviceTouchSearch.DeviceTouchDeviceInfo currently set as communication target
      Returns:
      the DeviceTouchSearch.DeviceTouchDeviceInfo
    • setInfo

      public boolean setInfo​(DeviceTouchSearch.DeviceTouchDeviceInfo info)
      Set the DeviceTouchSearch.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.InterruptedException
      Connects the simulated S-Touch device to a Paradigma SystaComfort unit. If the info 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 messages
      java.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.IOException
      Disconnects the simulated S-Touch device from the SystaComfort unit.
      Throws:
      java.io.IOException - if an error occurs during disconnection
    • searchSTouchDevice

      public DeviceTouchSearch.DeviceTouchDeviceInfo 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 touch
      y - 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

      private boolean isCommandEnabled​(STouchProtocol.STouchCommand cmd)
    • processCommands

      public java.net.DatagramPacket processCommands​(java.net.DatagramPacket packet)
    • printByteArrayAsHex

      private void printByteArrayAsHex​(byte[] bytes, int len)
    • printByteArrayAsHex

      private void printByteArrayAsHex​(byte[] bytes)