Class Board
- All Implemented Interfaces:
HandleAware
,AssemblyAware
,BoardIdentifier
- Direct Known Subclasses:
UpdatableBoard
The logical representation is created at startup, and is used to access the physical hardware when it comes online. This allows control logic to wire up all the boards even when they're offline, so that when they become available they can be used.
Board objects are created as part of Assembly
creation so that the
boards are available to be wired up in the application code even if the
hardware doesn't exist or hasn't been discovered yet. In general a Board
object is used to access the underlying hardware but these accesses won't work
until the actual hardware becomes available. This process is known as linking.
Hardware integration starts with a HardwareLink
passed to
HardwareService
. The service will match the link with an existing board
and the board can then pass hardware operations through that link to the actual
hardware. The board will experience the following events as part of this process:
-
onLink()
: Called whenHardwareService
matches aHardwareLink
with a board. The board can use this event to establish additional communication channels to the board. For example, if the board is connected with an adapter, in theonLink()
callback it can connected to additional ifaces provided by the hardware. - firmware update : If the board has a
FirmwareUpdater
then the hardware firmware versions will be checked and updated as needed. -
onStart()
: After firmware update,onOnline()
will be called to indicate that the board is ready for normal use.
-
onStop()
: IfonStart()
was called, a matching call toonOffline()
will be made to indicate that the board is going offline. -
onUnlink()
: The hardware link has been disconnected from the board and the board is back into pending state, waiting for a newHardwareLink
to be established to the board.
- Since:
- 1.0
- Version:
- 2022-12-01
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLinkListener
(BoardLinkListener listener) Add a listener to the board.void
addReadyListener
(BoardReadyListener listener) Add a listener to the board.void
Called to indicate the board is ready for use.Returns the associated assembly.Returns the handle for this bean.getLink()
Return theHardwareLink
for the board or throw exception if not currently linked.int
Return the number of times the board has been linked.boolean
isLinked()
Return true if the board is linked to hardware.boolean
isReady()
Return true if the board is ready.boolean
Called after the board is linked to see if the board is ready for use.void
onLink
(HardwareLink link) Called when the board is linked to hardware.void
onUnlink
(HardwareLink link) Called when the board is unlinked from hardware.void
removeListener
(HardwareListener listener) Remove a listener from the board.void
Returns if board is linked, throws exception if not.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.core.service.assembly.AssemblyAware
getAssemblyName
Methods inherited from interface com.tccc.kos.core.service.hardware.BoardIdentifier
getInstanceId, getType
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
-
Constructor Details
-
Board
-
-
Method Details
-
isLinked
public boolean isLinked()Return true if the board is linked to hardware. -
getLinkCount
public int getLinkCount()Return the number of times the board has been linked. This indicates how many times the hardware has disconnected and reconnected. -
addLinkListener
Add a listener to the board. -
addReadyListener
Add a listener to the board. -
removeListener
Remove a listener from the board. -
getLink
Return theHardwareLink
for the board or throw exception if not currently linked.- Throws:
NotLinkedException
- if not linked
-
onLink
Called when the board is linked to hardware. Override as needed.- Parameters:
link
- the link to the hardware
-
onUnlink
Called when the board is unlinked from hardware. Override as needed.- Parameters:
link
- the link to the hardware
-
onBoardReady
public boolean onBoardReady()Called after the board is linked to see if the board is ready for use. If this returns true, anyBoardReadyListener
will be called for this board. If this returns false, it is the responsibility of the board to eventually callboardReady()
to fire the associated listeners. -
boardReady
public void boardReady()Called to indicate the board is ready for use. This notifies all associatedBoardReadyListener
that the board is ready for use.onBoardReady()
is called afteronLink
is called and link callbacks are complete. IfonBoardReady()
returns true (which it does by default) thenboardReady()
will be called. If the board requires additional setup after linking before it is ready for use, overrideonBoardReady()
to return false. It is then up the board to callboardReady()
when the board is actually ready for use.This can only be called once per link. If it is called more than once, only the first call will generate an event.
Listeners can be attached to just this board to be notified of this particular board being ready, or to
HardwareService
to be notified when any board becomes ready. -
isReady
public boolean isReady()Return true if the board is ready. This is true if the board is linked andboardReady()
has been called. If the board unlinks then this will become false again. -
verifyLinked
public void verifyLinked()Returns if board is linked, throws exception if not. -
getHandle
Description copied from interface:HandleAware
Returns the handle for this bean. This is used by the context to compute the opaque handle for the object.- Specified by:
getHandle
in interfaceHandleAware
- Returns:
- the handle node for the bean
-
getAssembly
Description copied from interface:AssemblyAware
Returns the associated assembly.- Specified by:
getAssembly
in interfaceAssemblyAware
-