Class HardwareLink

java.lang.Object
com.tccc.kos.core.service.hardware.HardwareLink
All Implemented Interfaces:
BoardIdentifier
Direct Known Subclasses:
BoardIfaceLink, FirmwareUpdatableLink

public abstract class HardwareLink extends Object implements BoardIdentifier
Base class that implements the backend protocol for a particular board. The identity of the link identifies the board that this link should be attached to.
Since:
1.0
Version:
2022-12-01
  • Constructor Details

    • HardwareLink

      public HardwareLink()
  • Method Details

    • getLinkType

      public String getLinkType()
      Return the link type. Useful for UI code to know what data to expect.
    • getIdentity

      public String getIdentity()
      Returns the unique identifier of this board. This is used to remember that this board has been linked previously and used to determine when it has been replaced.

      This value must be unique among all other instances of this type of board. This defaults to the serial number, but can be overridden to use something like MAC address if the serial number isn't available. Unlike serial number, this will not be displayed so this can be overridden while serial number is left empty.

    • getMfgSerialNum

      public abstract String getMfgSerialNum()
      Returns the serial number of the board, if available. This serial number should match the manufacturing data of the board and should be used in analytic data. This should not be used for display purposes.
    • getSerialNum

      public String getSerialNum()
      Returns the display version of the serial number. By default, this returns the manufacturer's serial number, but in the event that the serial number printed on the board is in a different format from the manufacturer's serial number, then this can be overridden to return the serial number for display purposes.
    • getRevision

      public String getRevision()
      Return the revision of the hardware. By default this returns null as many boards don't internally track revisions. Override if your hardware has an internal revision value that can be displayed to the user in the admin screens.
    • getFirmwareVersions

      public String[] getFirmwareVersions()
      Return firmware information about the hardware. By default this returns null to indicate there is no firmware information. This should be overridden to return an array of strings, one for each firmware type applicable to the board. For example, if the board has both bootloader and application firmware, this can return two strings to capture the two versions. This is for display only so prefixes can be used to help the user understand the different versions if needed.
    • getBoard

      public Board getBoard()
      Returns the linked board.
    • isValid

      public boolean isValid()
      Return true if the link is currently valid for use. This is changed to false when the link is unregisterd from HardwareService . This generally occurs when the hardware disconnects and HardwareService is notified.
    • setInvalid

      public void setInvalid()
      Set the link invalid. This is called from HardwareService when a link is unregistered. If overridden, it must call super.setInvalid() .
    • close

      public void close() throws Exception
      Close the link. This is called when the board the link is associated with is uninstalled. This should close the underlying link if possible.
      Throws:
      Exception
    • getType

      public abstract String getType()
      Description copied from interface: BoardIdentifier
      Returns the type of the board.

      The hardware service uses the type to determine compatible firmware, as well as to link with adapters that are connected to the matching physical board.

      If a physical board is revised, it may keep the same type but have different variant information. The logical board is primarily concerned with the high-level feature set of the hardware, and leverages the link to the adapter to perform actual operations on the hardware. This means that a new version of a board can be spun with a different CPU and hardware changes, but so long as the protocol to the device is the same, it can still have the same board type.

      Specified by:
      getType in interface BoardIdentifier
    • getInstanceId

      public abstract String getInstanceId()
      Description copied from interface: BoardIdentifier
      Returns the instanceId of the board.

      If there is more than one instance of the board in the system, then the instanceId is used to determine which one is which. Typically, the hardware has a mechanism to identify which instance it is (via cable harness, jumper or some other mechanism), and that is the value that must be used here. For example, if a device can contain three instances of a board, and the cable harness allows the board to identify its position as "1", "2", or "3", then the logical board must use an instanceId of "1", "2", or "3" so that hardware service can match the incoming adapter link to the logical board.

      In general, there should never be more than one instance of a particular board type with the same identifierId, as there is no way to distinguish them from each other.

      If there is only one instance of the board, this will typically return null, as the hardware will not need to determine an instance ID in the adapter code.

      Specified by:
      getInstanceId in interface BoardIdentifier