Class UpdateTask

java.lang.Object
com.tccc.kos.core.service.firmware.UpdateTask

public class UpdateTask extends Object
Base class for a for update tasks generated by a given FirmwareUpdater which contains all the state necessary for the updater to actually perform the update of the associated device. An instance will only be used to attempt a single update. If the update fails, another instance will be created to retry the update.

This class can be extended to add additional information to pass it to the updater when it's time to update the board.

Version:
2023-09-10
  • Constructor Details

    • UpdateTask

      public UpdateTask(FirmwareInfo firmware, int estimatedTimeMs)
      Create a update task to update a device using the specified FirmwareInfo . This update can run in parallel with any other update. If there are concurrency constraints, use the version with exclusivityKey .
      Parameters:
      firmware - firmware information from FirmwareService
      estimatedTimeMs - estimated update time
    • UpdateTask

      public UpdateTask(FirmwareInfo firmware, int estimatedTimeMs, String exclusivityKey)
      Create a update task to update a device using the specified FirmwareInfo . If the exclusivityKey is not null, any updates with this key will be serialized. This can be used for updating devices that use a shared bus that only allows one update to occur at a time.
      Parameters:
      firmware - firmware information from FirmwareService
      estimatedTimeMs - estimated update time
      exclusivityKey - tasks with same key are serialized
    • UpdateTask

      public UpdateTask(String firmwareVersion, int estimatedTimeMs, String exclusivityKey)
      Create a update task to update a device, not using standard FirmwareInfo .
      Parameters:
      firmwareVersion - firmware version display string
      estimatedTimeMs - estimated update time
      exclusivityKey - tasks with same key are serialized
  • Method Details

    • getFirmware

      public FirmwareInfo getFirmware()
      Return the associated FirmwareInfo if there is one. This contains a reference to the KabFile that contains the firmware file.
    • getEstimatedTimeMs

      public int getEstimatedTimeMs()
      Return the estimated time for the update to be performed. FirmwareService will override the estimated time of the FutureWork returned by FirmwareUpdater.update() with this value so it should be reasonably accurate.
    • getFirmwareVersion

      public String getFirmwareVersion()
      Return display string for the firmware version this task is trying to install. This is only used for display and reporting and may contain information specific to just this particular update (bootloader vs. application) as some hardware requires multiple update passes to fully update firmware.
    • getExclusivityKey

      public String getExclusivityKey()
      Return the exclusivity key for this task. Any tasks that return the same key will be run sequentially. This is useful for devices that share a common bus that only allows one update at a time. Tasks with different keys or no key (returns null) can be run concurrently. By default this will return the value of getUpdater().getExclusivityKey() . Override as needed.
      Returns:
      the exclusivity key for this task
    • getUpdateRetryCount

      public int getUpdateRetryCount()
      Get the retry count for update() calls. After this many attempts the board will be unusable as it cannot be updated. This is checked if the update fails and is used to determine if the update job should be queued again for another attempt. This task will be discarded and a new task will be created on the next attempt.

      Defaults to 3, update as needed.

    • setUpdateRetryCount

      public void setUpdateRetryCount(int count)
      Set the retry count for update() calls.
    • getUpdateRetryDelayMs

      public int getUpdateRetryDelayMs()
      Get the delay between retries of update() . This is checked if the update fails and is used to determine the delay before the next update is attempted. This task will be discarded and a new task will be created on the next attempt.

      Defaults to 2 seconds, update as needed.

    • setUpdateRetryDelayMs

      public void setUpdateRetryDelayMs(int delay)
      Set the delay between retries of update() .
    • getDevice

      public FirmwareUpdatableDevice getDevice()
      Return the associated FirmwareUpdatableDevice associated with this task.