Class RemoteMenuController


  • public class RemoteMenuController
    extends java.lang.Object
    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.
    • Constructor Summary

      Constructors 
      Constructor Description
      RemoteMenuController​(RemoteConnector connector, MenuTree managedMenu, java.util.concurrent.ScheduledExecutorService executor, java.lang.String localName, java.time.Clock clock, int heartbeatFrequency)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(RemoteControllerListener listener)
      register for events when the tree becomes fully populated, a menu item changes or there's a change in connectivity.
      RemoteConnector getConnector()
      get the underlying connectivity, rarely needed
      RemoteInformation getRemotePartyInfo()
      get the name of the device that we've connected to.
      boolean isTreeFullyPopulated()
      Check if all the menu items from the remote device are available locally yet.
      void sendCommand​(MenuCommand command)
      send a command to the Arduino, normally use the CommandFactory to generate the command
      void start()
      starts the remote connection such that it will attempt to establish connectivity
      void stop()
      attempt to stop the underlying connector
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RemoteMenuController

        public RemoteMenuController​(RemoteConnector connector,
                                    MenuTree managedMenu,
                                    java.util.concurrent.ScheduledExecutorService executor,
                                    java.lang.String localName,
                                    java.time.Clock clock,
                                    int heartbeatFrequency)
    • 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

        public void sendCommand​(MenuCommand command)
        send a command to the Arduino, normally use the CommandFactory to generate the command
        Parameters:
        command - a command to send to the remote side.
      • getRemotePartyInfo

        public RemoteInformation getRemotePartyInfo()
        get the name of the device that we've connected to.
        Returns:
        the connected remote device
      • 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