Package com.thecoderscorner.menu.remote
Class RemoteMenuController
- java.lang.Object
-
- com.thecoderscorner.menu.remote.RemoteMenuController
-
public class RemoteMenuController extends java.lang.ObjectThis class manages a single remote connection to an Arduino. It is responsible for check if the connection is still alive, and sending heartbeat messages to keep the connection alive too. This class abstracts the connectivity part away from the business logic. The remote connection is then handled by the RemoteConnector. Normally, one creates a whole remote stack using one the builders, such as Rs232ControllerBuilder.
-
-
Constructor Summary
Constructors Constructor Description RemoteMenuController(RemoteConnector connector, MenuTree managedMenu)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(RemoteControllerListener listener)register for events when the tree becomes fully populated, a menu item changes or there's a change in connectivity.RemoteConnectorgetConnector()get the underlying connectivity, rarely neededMenuTreegetManagedMenu()booleanisTreeFullyPopulated()Check if all the menu items from the remote device are available locally yet.CorrelationIdsendAbsoluteUpdate(MenuItem item, java.lang.Object newValue)Send an asbolute change for the given itemprotected voidsendCommand(MenuCommand command)Use to send commands directly.CorrelationIdsendDeltaUpdate(MenuItem item, int deltaChange)Send a delta change for the given menuitemCorrelationIdsendDialogAction(MenuButtonType buttonType)Send a dialog updatevoidstart()starts the remote connection such that it will attempt to establish connectivityvoidstop()attempt to stop the underlying connector
-
-
-
Constructor Detail
-
RemoteMenuController
public RemoteMenuController(RemoteConnector connector, MenuTree managedMenu)
-
-
Method Detail
-
start
public void start()
starts the remote connection such that it will attempt to establish connectivity
-
stop
public void stop()
attempt to stop the underlying connector
-
sendCommand
protected void sendCommand(MenuCommand command)
Use to send commands directly. Should not be used outside of this class, instead prefer the helper methods to send each type of item.- Parameters:
command- a command to send to the remote side.
-
sendDialogAction
public CorrelationId sendDialogAction(MenuButtonType buttonType)
Send a dialog update- Parameters:
buttonType- the type of button press to activate on the remote.
-
sendDeltaUpdate
public CorrelationId sendDeltaUpdate(MenuItem item, int deltaChange)
Send a delta change for the given menuitem- Parameters:
item- the item to changedeltaChange- the amount to change by
-
sendAbsoluteUpdate
public CorrelationId sendAbsoluteUpdate(MenuItem item, java.lang.Object newValue)
Send an asbolute change for the given item- Parameters:
item- the itemnewValue- the absolute change
-
getConnector
public RemoteConnector getConnector()
get the underlying connectivity, rarely needed- Returns:
- underlying connector
-
isTreeFullyPopulated
public boolean isTreeFullyPopulated()
Check if all the menu items from the remote device are available locally yet.- Returns:
- true if the populated, otherwise false.
-
addListener
public void addListener(RemoteControllerListener listener)
register for events when the tree becomes fully populated, a menu item changes or there's a change in connectivity.- Parameters:
listener- your listener to register for events
-
getManagedMenu
public MenuTree getManagedMenu()
-
-