Package de.freaklamarsch.systarest
Class STouchRESTAPI
java.lang.Object
de.freaklamarsch.systarest.STouchRESTAPI
@Path("{stouchrest : (?i)stouchrest}")
public class STouchRESTAPI
extends java.lang.Object
A REST API for emulating the S-Touch app to interact with the Paradigma
SystaComfort system. This API provides endpoints for connecting to the
device, simulating touch events, retrieving the screen state, and automating
sequences of actions. This class is intended to be run by a
SystaRESTServer-
Field Summary
Fields Modifier and Type Field Description private static FakeSTouchfstThe instance of the FakeSTouch device used for emulation. -
Constructor Summary
Constructors Constructor Description STouchRESTAPI() -
Method Summary
Modifier and Type Method Description jakarta.ws.rs.core.Responseautomation(jakarta.ws.rs.core.UriInfo uriInfo)Executes a sequence of commands provided as query parameters.private booleanautomationCheckButtonCommand(java.lang.String command)private booleanautomationCheckTextCommand(java.lang.String command)private jakarta.ws.rs.core.ResponseautomationExecuteCommand(java.lang.String command)private jakarta.ws.rs.core.ResponseautomationWhileButtonCommand(java.lang.String[] commandArray, int i)private jakarta.ws.rs.core.ResponseautomationWhileTextCommand(java.lang.String[] commandArray, int i)jakarta.ws.rs.core.Responseconnect()Establishes a connection to the SystaComfort unit.jakarta.ws.rs.core.Responsedisconnect()Disconnects from the SystaComfort unit.private java.lang.ByteextractByteValue(java.lang.String command, java.lang.String prefix)private java.lang.StringextractComparisonValue(java.lang.String command, java.lang.String prefix)jakarta.ws.rs.core.ResponsegetDebugScreenWithHTML(java.util.List<java.lang.String> listOfTouches)Returns an interactive HTML page for debugging touch events on the screen.jakarta.ws.rs.core.ResponsegetObjectTree()jakarta.ws.rs.core.ResponsegetScreen()Retrieves the current screen as a PNG image.jakarta.ws.rs.core.ResponsehasButton(byte buttonId)jakarta.ws.rs.core.ResponsehasText(java.lang.String text)jakarta.ws.rs.core.Responsesearchsystacomfort()private voidshortSleep()jakarta.ws.rs.core.Responsetouch(int x, int y)Simulates a touch event at the specified coordinates on the screen.jakarta.ws.rs.core.ResponsetouchButton(byte buttonId)jakarta.ws.rs.core.ResponsetouchText(java.lang.String text)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
fst
The instance of the FakeSTouch device used for emulation.
-
-
Constructor Details
-
STouchRESTAPI
public STouchRESTAPI()
-
-
Method Details
-
connect
@POST @Path("{connect : (?i)connect}") public jakarta.ws.rs.core.Response connect()Establishes a connection to the SystaComfort unit.- Returns:
- a
Responseindicating the result of the connection attempt
-
searchsystacomfort
@POST @Path("{findsystacomfort : (?i)findsystacomfort}") @Produces("application/json") public jakarta.ws.rs.core.Response searchsystacomfort() -
disconnect
@POST @Path("{disconnect : (?i)disconnect}") public jakarta.ws.rs.core.Response disconnect()Disconnects from the SystaComfort unit.- Returns:
- a
Responseindicating the result of the disconnection attempt
-
touch
@POST @Path("{touch : (?i)touch}") public jakarta.ws.rs.core.Response touch(@QueryParam("x") int x, @QueryParam("y") int y)Simulates a touch event at the specified coordinates on the screen.- Parameters:
x- the x-coordinate of the touchy- the y-coordinate of the touch- Returns:
- a
Responseindicating the result of the touch event
-
getScreen
@GET @Path("{screen : (?i)screen}") @Produces("image/png") public jakarta.ws.rs.core.Response getScreen()Retrieves the current screen as a PNG image.- Returns:
- a
Responsecontaining the screen image
-
getDebugScreenWithHTML
@GET @Path("{debugscreen : (?i)debugscreen}") @Produces("text/html") public jakarta.ws.rs.core.Response getDebugScreenWithHTML(@QueryParam("touch") java.util.List<java.lang.String> listOfTouches)Returns an interactive HTML page for debugging touch events on the screen.- Returns:
- a
Responsecontaining the HTML page
-
getObjectTree
@GET @Path("{objecttree : (?i)objecttree}") @Produces("application/json") public jakarta.ws.rs.core.Response getObjectTree() -
hasButton
@GET @Path("{hasbutton : (?i)hasbutton}") @Produces("application/json") public jakarta.ws.rs.core.Response hasButton(@QueryParam("id") byte buttonId) -
touchButton
@POST @Path("{touchbutton : (?i)touchbutton}") public jakarta.ws.rs.core.Response touchButton(@QueryParam("id") byte buttonId) -
hasText
@GET @Path("{hastext : (?i)hastext}") @Produces("application/json") public jakarta.ws.rs.core.Response hasText(@QueryParam("text") java.lang.String text) -
touchText
@POST @Path("{touchtext : (?i)touchtext}") public jakarta.ws.rs.core.Response touchText(@QueryParam("text") java.lang.String text) -
automation
@GET @Path("{automation : (?i)automation}") public jakarta.ws.rs.core.Response automation(@Context jakarta.ws.rs.core.UriInfo uriInfo)Executes a sequence of commands provided as query parameters.- Parameters:
uriInfo- uriInfo is parsed to retrieve the query parameters, which are the commands that assemble the automation. Supported commands are: connect connect to the SystaComfort unit touch=x,y emulate a touch event on screen coordinates x and y touchText=text emulate a touch event on the given text, if it is in the object tree of the screen touchButton=id emulate a touch event on the button with the given id, if it is in the object tree of the screen whileText=text&doAction while the given text is in the object tree of the screen, do the given action whileButton=id&doAction while the button with the given id is in the object tree of the screen, do the given action checkText=text&theDoThisAction&elseDoThisAction if the given text is in the object tree of the screen, then do the first action, else do the second checkButton=id&theDoThisAction&elseDoThisAction if the button with the given id is in the object tree of the screen, then do the first action, else do the second disconnect disconnect from the SystaComfort unit- Returns:
- a
Responseindicating the result of the automation
-
automationWhileTextCommand
private jakarta.ws.rs.core.Response automationWhileTextCommand(java.lang.String[] commandArray, int i) -
automationCheckTextCommand
private boolean automationCheckTextCommand(java.lang.String command) -
automationWhileButtonCommand
private jakarta.ws.rs.core.Response automationWhileButtonCommand(java.lang.String[] commandArray, int i) -
automationCheckButtonCommand
private boolean automationCheckButtonCommand(java.lang.String command) -
extractComparisonValue
private java.lang.String extractComparisonValue(java.lang.String command, java.lang.String prefix) -
extractByteValue
private java.lang.Byte extractByteValue(java.lang.String command, java.lang.String prefix) -
shortSleep
private void shortSleep() -
automationExecuteCommand
private jakarta.ws.rs.core.Response automationExecuteCommand(java.lang.String command)
-