tcMenuJavaAPI
Public Member Functions | Protected Member Functions | List of all members
com.thecoderscorner.menu.remote.RemoteMenuController Class Reference

Public Member Functions

 RemoteMenuController (RemoteConnector connector, MenuTree managedMenu)
 
void addCustomMessageProcessor (MessageField msgType, BiConsumer< RemoteMenuController, MenuCommand > processor)
 
void start ()
 
void stop ()
 
CorrelationId sendDialogAction (MenuButtonType buttonType)
 
CorrelationId sendDeltaUpdate (MenuItem item, int deltaChange)
 
CorrelationId sendAbsoluteUpdate (MenuItem item, Object newValue)
 
RemoteConnector getConnector ()
 
boolean isTreeFullyPopulated ()
 
void addListener (RemoteControllerListener listener)
 
void removeListener (RemoteControllerListener listener)
 
MenuTree getManagedMenu ()
 

Protected Member Functions

void sendCommand (MenuCommand command)
 

Detailed Description

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

Member Function Documentation

◆ addCustomMessageProcessor()

void com.thecoderscorner.menu.remote.RemoteMenuController.addCustomMessageProcessor ( MessageField  msgType,
BiConsumer< RemoteMenuController, MenuCommand processor 
)

Allows user level additional message processors for custom messages. Using this you can provide your own message type at the API protocol level, and then use this to apply the additional functionality to the manager. The provided consumer will be called each time this custom message is applied. Note that you cannot override the core security based message types, any attempt to do so results in an exception.

Parameters
msgTypethe message type for your custom message
processorthe processor to handle the message.

◆ addListener()

void com.thecoderscorner.menu.remote.RemoteMenuController.addListener ( RemoteControllerListener  listener)

register for events when the tree becomes fully populated, a menu item changes or there's a change in connectivity.

Parameters
listeneryour listener to register for events

◆ getConnector()

RemoteConnector com.thecoderscorner.menu.remote.RemoteMenuController.getConnector ( )

get the underlying connectivity, rarely needed

Returns
underlying connector

◆ isTreeFullyPopulated()

boolean com.thecoderscorner.menu.remote.RemoteMenuController.isTreeFullyPopulated ( )

Check if all the menu items from the remote device are available locally yet.

Returns
true if the populated, otherwise false.

◆ sendAbsoluteUpdate()

CorrelationId com.thecoderscorner.menu.remote.RemoteMenuController.sendAbsoluteUpdate ( MenuItem  item,
Object  newValue 
)

Send an asbolute change for the given item

Parameters
itemthe item
newValuethe absolute change

◆ sendCommand()

void com.thecoderscorner.menu.remote.RemoteMenuController.sendCommand ( MenuCommand  command)
protected

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
commanda command to send to the remote side.

◆ sendDeltaUpdate()

CorrelationId com.thecoderscorner.menu.remote.RemoteMenuController.sendDeltaUpdate ( MenuItem  item,
int  deltaChange 
)

Send a delta change for the given menuitem

Parameters
itemthe item to change
deltaChangethe amount to change by

◆ sendDialogAction()

CorrelationId com.thecoderscorner.menu.remote.RemoteMenuController.sendDialogAction ( MenuButtonType  buttonType)

Send a dialog update

Parameters
buttonTypethe type of button press to activate on the remote.

◆ start()

void com.thecoderscorner.menu.remote.RemoteMenuController.start ( )

starts the remote connection such that it will attempt to establish connectivity

◆ stop()

void com.thecoderscorner.menu.remote.RemoteMenuController.stop ( )

attempt to stop the underlying connector


The documentation for this class was generated from the following file: