Class UpdateTask
java.lang.Object
com.tccc.kos.core.service.firmware.UpdateTask
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 Summary
ConstructorsConstructorDescriptionUpdateTask
(FirmwareInfo firmware, int estimatedTimeMs) Create a update task to update a device using the specifiedFirmwareInfo
.UpdateTask
(FirmwareInfo firmware, int estimatedTimeMs, String exclusivityKey) Create a update task to update a device using the specifiedFirmwareInfo
.UpdateTask
(String firmwareVersion, int estimatedTimeMs, String exclusivityKey) Create a update task to update a device, not using standardFirmwareInfo
. -
Method Summary
Modifier and TypeMethodDescriptionReturn the associatedFirmwareUpdatableDevice
associated with this task.int
Return the estimated time for the update to be performed.Return the exclusivity key for this task.Return the associatedFirmwareInfo
if there is one.Return display string for the firmware version this task is trying to install.int
Get the retry count forupdate()
calls.int
Get the delay between retries ofupdate()
.void
setUpdateRetryCount
(int count) Set the retry count forupdate()
calls.void
setUpdateRetryDelayMs
(int delay) Set the delay between retries ofupdate()
.
-
Constructor Details
-
UpdateTask
Create a update task to update a device using the specifiedFirmwareInfo
. This update can run in parallel with any other update. If there are concurrency constraints, use the version withexclusivityKey
.- Parameters:
firmware
- firmware information fromFirmwareService
estimatedTimeMs
- estimated update time
-
UpdateTask
Create a update task to update a device using the specifiedFirmwareInfo
. If theexclusivityKey
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 fromFirmwareService
estimatedTimeMs
- estimated update timeexclusivityKey
- tasks with same key are serialized
-
UpdateTask
Create a update task to update a device, not using standardFirmwareInfo
.- Parameters:
firmwareVersion
- firmware version display stringestimatedTimeMs
- estimated update timeexclusivityKey
- tasks with same key are serialized
-
-
Method Details
-
getFirmware
Return the associatedFirmwareInfo
if there is one. This contains a reference to theKabFile
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 theFutureWork
returned byFirmwareUpdater.update()
with this value so it should be reasonably accurate. -
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
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 ofgetUpdater().getExclusivityKey()
. Override as needed.- Returns:
- the exclusivity key for this task
-
getUpdateRetryCount
public int getUpdateRetryCount()Get the retry count forupdate()
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 forupdate()
calls. -
getUpdateRetryDelayMs
public int getUpdateRetryDelayMs()Get the delay between retries ofupdate()
. 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 ofupdate()
. -
getDevice
Return the associatedFirmwareUpdatableDevice
associated with this task.
-