Interface IfaceAwareBoard<T extends BinaryMsgIface>

All Superinterfaces:
BinaryMsgIfaceListener<T>, IfaceAware<T>

public interface IfaceAwareBoard<T extends BinaryMsgIface> extends IfaceAware<T>, BinaryMsgIfaceListener<T>
It is common that a Board class in KOS is linked to physical hardware using an adapter. The Board class then needs to get access to the BinaryMsgSession to the adapter in order to create an instance of the iface used to communicate to the board.

To simplify this process, an adapter can implement the board iface. This allows HardwareService to automatically detect when the adapter is started, fetch the board details, and link the physical board to the logical board without any additional code. However, this doesn't solve the problem of creating the custom iface instance to interact with the board.

A board that implements IfaceAware that leverages the board detection logic mentioned above, will automatically call createIface() when the board is linked and make the iface available via getIface(). This eliminates the need to override the link callbacks just to add / remove a custom iface instance.

Version:
2025-04-09
  • Method Details

    • createIface

      T createIface(BinaryMsgSession session)
      Return an instance of the custom iface for the board. This is called when the adapter for the board connects to java. The iface returned by this method can be accessed via getIface() . This will be called every time the adapter connects to the board. For removable hardware, this generally corresponds to every time the physical hardware is detected and the linking process is initiated.
    • getIface

      default T getIface()
      Description copied from interface: IfaceAware
      Return the associated iface. This may return null if no iface is available.
      Specified by:
      getIface in interface IfaceAware<T extends BinaryMsgIface>
    • setIface

      default void setIface(T iface)
      Description copied from interface: IfaceAware
      Set the iface.
      Specified by:
      setIface in interface IfaceAware<T extends BinaryMsgIface>
    • onIfaceConnect

      void onIfaceConnect() throws Exception
      Called once the associated iface is initialized and ready for use.
      Throws:
      Exception
    • onIfaceDisconnect

      void onIfaceDisconnect() throws Exception
      Called when the associated iface is shutdown.
      Throws:
      Exception
    • onConnect

      default void onConnect(T iface) throws Exception
      Calls onIfaceConnect() to avoid name collisions when using withIface() methods.
      Specified by:
      onConnect in interface BinaryMsgIfaceListener<T extends BinaryMsgIface>
      Throws:
      Exception
    • onDisconnect

      default void onDisconnect(T iface) throws Exception
      Calls onIfaceDisconnect()
      Specified by:
      onDisconnect in interface BinaryMsgIfaceListener<T extends BinaryMsgIface>
      Throws:
      Exception