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
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tccc.kos.core.service.hardware.IfaceAware
IfaceAware.IfaceCallback<T>, IfaceAware.IfaceExceptionHandler -
Method Summary
Modifier and TypeMethodDescriptioncreateIface(BinaryMsgSession session) Return an instance of the custom iface for the board.default TgetIface()Return the associated iface.default voidCallsonIfaceConnect()to avoid name collisions when usingwithIface()methods.default voidonDisconnect(T iface) CallsonIfaceDisconnect()voidCalled once the associated iface is initialized and ready for use.voidCalled when the associated iface is shutdown.default voidSet the iface.Methods inherited from interface com.tccc.kos.core.service.hardware.IfaceAware
withIface, withIface, withIfaceCatch, withIfaceCatch, withIfaceCatch, withIfaceCatch, withIfaceOrThrow
-
Method Details
-
createIface
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 viagetIface(). 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
Description copied from interface:IfaceAwareReturn the associated iface. This may return null if no iface is available.- Specified by:
getIfacein interfaceIfaceAware<T extends BinaryMsgIface>
-
setIface
Description copied from interface:IfaceAwareSet the iface.- Specified by:
setIfacein interfaceIfaceAware<T extends BinaryMsgIface>
-
onIfaceConnect
Called once the associated iface is initialized and ready for use.- Throws:
Exception
-
onIfaceDisconnect
Called when the associated iface is shutdown.- Throws:
Exception
-
onConnect
CallsonIfaceConnect()to avoid name collisions when usingwithIface()methods.- Specified by:
onConnectin interfaceBinaryMsgIfaceListener<T extends BinaryMsgIface>- Throws:
Exception
-
onDisconnect
CallsonIfaceDisconnect()- Specified by:
onDisconnectin interfaceBinaryMsgIfaceListener<T extends BinaryMsgIface>- Throws:
Exception
-