Package offlineProcessing
Class OfflineTaskGroup
java.lang.Object
offlineProcessing.OfflineTaskGroup
- All Implemented Interfaces:
PamSettings
,SettingsNameProvider
- Direct Known Subclasses:
EventTaskGroup
,TethysTaskGroup
- Author:
- Doug Gillespie
Handles a series of offline tasks which all use a
common data block so that data can be loaded, a whole
series of tasks completed and the data then saved in
a single operation.
This will be the primary interface to OfflineTasks - even if there is only one task it will be in a group of one !
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Swing worker to do the actual work. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOfflineTaskGroup
(PamControlledUnit pamControlledUnit, String settingsName) PamControlledunit required in constructor since some bookkeeping will be going on in the background which will need the unit type and name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addTask
(OfflineTask task) int
addTasks
(List<OfflineTask> tasks) Add a list of offline tasks.void
Clear all task from the task group.void
void
int
int
long
getTask
(int iTask) boolean
haveTask
(OfflineTask task) See if a task already exists.boolean
haveTaskClass
(OfflineTask task) See if we already have a task of the same class.boolean
isInTimeChunk
(PamDataUnit dataUnit, ArrayList<long[]> timeChunks) Check whether a data unit is within a list of time chunks within params.boolean
Check whether the task has been cancelled.void
void
loadSecondaryData
(long procDataStart, long procDataEnd) void
logTaskStatus
(TaskMonitorData monitorData) void
newMonitorData
(TaskMonitorData monData) void
Called once at start of all processing.void
processAllData
(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, long startTime, long endTime) Process data between two timesvoid
processAllData
(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, ArrayList<long[]> timeChunks) Process all data for a list of time chunks.void
processData
(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, int globalProgress, OfflineDataMapPoint mapPoint, long processStartTime, long processEndTime) Called to process data currently in memory.void
processLoadedData
(OfflineTaskGroup.TaskGroupWorker taskGroupWorker) boolean
restoreSettings
(PamControlledUnitSettings pamControlledUnitSettings) void
runBackgroundTasks
(OfflineTaskGroup.TaskGroupWorker taskGroupWorker) Move all of the functions out of the TaskGroupWorker class so that they can be overridden / modified in specialist versions of OfflineTaskGroupboolean
runTasks()
Run all the tasks.void
setCompletionStatus
(TaskStatus completionStatus) void
setDataTimeLimits
(DataTimeLimits dataTimeLimits) void
setPrimaryDataBlock
(PamDataBlock primaryDataBlock) void
Setup summary lists of required and affected datablocks based on which tasks are actually going to run .void
setSuperDetectionFilter
(OfflineSuperDetFilter superDetectionFilter) Set a super detection filter (null if no super detection system available)void
setTaskMonitor
(TaskMonitor taskMonitor) boolean
shouldProcess
(OfflineDataMapPoint mapPoint) See if it's worth loading this map point.boolean
shouldProcess
(PamDataUnit dataUnit) void
some bookkeeping - write information about task completion to the database.
-
Field Details
-
Constructor Details
-
OfflineTaskGroup
PamControlledunit required in constructor since some bookkeeping will be going on in the background which will need the unit type and name.- Parameters:
pamControlledUnit
- host controlled unit.settingsName
- Name to be used in PamSettings for storing some basic information (which tasks are selected)
-
-
Method Details
-
setSummaryLists
public void setSummaryLists()Setup summary lists of required and affected datablocks based on which tasks are actually going to run . -
runTasks
public boolean runTasks()Run all the tasks.- Parameters:
offlineClassifierParams
-- Returns:
-
killTasks
public void killTasks() -
addTasks
Add a list of offline tasks. Checks that tasks are not already included in the task list and doesn't add them if they already exist.- Parameters:
tasks
- list of tasks.- Returns:
- number added.
-
haveTask
See if a task already exists.- Parameters:
task
- offline tasks.- Returns:
- true if it exists
-
haveTaskClass
See if we already have a task of the same class.- Parameters:
task
- task to check- Returns:
- true if a task of the same class already exists.
-
addTask
- Parameters:
task
- task to add to the group
-
getNTasks
public int getNTasks()- Returns:
- the number of tasks in the group
-
getTask
- Parameters:
iTask
- the task number- Returns:
- the task.
-
getProcessTime
public int getProcessTime()- Returns:
- the processTime
-
getPrimaryDataBlock
- Returns:
- the primaryDataBlock
-
setPrimaryDataBlock
- Parameters:
primaryDataBlock
- the primaryDataBlock to set
-
getTaskMonitor
- Returns:
- the taskMonitor
-
setTaskMonitor
- Parameters:
taskMonitor
- the taskMonitor to set
-
runBackgroundTasks
Move all of the functions out of the TaskGroupWorker class so that they can be overridden / modified in specialist versions of OfflineTaskGroup- Parameters:
taskGroupWorker
-
-
processAllData
public void processAllData(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, ArrayList<long[]> timeChunks) Process all data for a list of time chunks. This is robust to the list not being in chronological order.- Parameters:
taskGroupWorker
-timeChunks
- - the time chunks.
-
processAllData
public void processAllData(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, long startTime, long endTime) Process data between two times- Parameters:
taskGroupWorker
-startTime
- - the start time in millisendTime
- - the end time in millis.
-
shouldProcess
See if it's worth loading this map point. This will currently always return true unless there is a superDetectionFilter, in which case it will attempt to work out if there are any sub detections that might want processing.- Parameters:
mapPoint
-- Returns:
-
processLoadedData
-
prepareTasks
public void prepareTasks()Called once at start of all processing. -
processData
public void processData(OfflineTaskGroup.TaskGroupWorker taskGroupWorker, int globalProgress, OfflineDataMapPoint mapPoint, long processStartTime, long processEndTime) Called to process data currently in memory. i.e. get's called once when processing loaded data, multiple times when processing all data.- Parameters:
globalProgress
-mapPoint
-processStartTime
-processEndTime
-
-
shouldProcess
-
isInTimeChunk
Check whether a data unit is within a list of time chunks within params. Returns true if the PROCESS_TME_CHUNKS option is not the current data analysis choice.- Parameters:
dataUnit
- - the data unit to checktimeChunks
- - a list of time chunks with each long[] a start and end time in millis- Returns:
- true if the data unit is within any of the time chunks or data choice is not PROCESS_TME_CHUNKS.
-
commitDatabase
public void commitDatabase() -
loadSecondaryData
public void loadSecondaryData(long procDataStart, long procDataEnd) -
completeTasks
public void completeTasks() -
newMonitorData
-
logTaskStatus
-
tasksDone
public void tasksDone()some bookkeeping - write information about task completion to the database. -
getSettingsReference
- Specified by:
getSettingsReference
in interfacePamSettings
- Returns:
- The serialisable object that will be stored
-
getSettingsVersion
public long getSettingsVersion()- Specified by:
getSettingsVersion
in interfacePamSettings
- Returns:
- An integer version number for the settings
-
getUnitName
- Specified by:
getUnitName
in interfaceSettingsNameProvider
- Returns:
- A Name specific to this instance of the particular class, e.g. Sperm whale detector, Beaked whale detector, etc.
-
getUnitType
- Specified by:
getUnitType
in interfacePamSettings
- Returns:
- A Name specific to the type, e.g. Click detector
-
restoreSettings
- Specified by:
restoreSettings
in interfacePamSettings
- Parameters:
pamControlledUnitSettings
-- Returns:
- true if successful The object performs final checks (if needed) and then casts the settings data pamcontrolledunitSettings.settings into the correct type and uses as required
-
getTaskGroupParams
- Returns:
- the taskGroupParams
-
getDataTimeLimits
- Returns:
- the dataTimeLimits
-
setDataTimeLimits
- Parameters:
dataTimeLimits
- the dataTimeLimits to set
-
isTaskCancelled
public boolean isTaskCancelled()Check whether the task has been cancelled. Sometime used if processing a data unit takes a long time and should be cancelled- Returns:
- true if task has been cancelled.
-
setSuperDetectionFilter
Set a super detection filter (null if no super detection system available)- Parameters:
superDetectionFilter
- Super detection filter.
-
getSuperDetectionFilter
- Returns:
- the superDetectionFilter
-
clearTasks
public void clearTasks()Clear all task from the task group. This also clears affected and required datablocks. -
getCompletionStatus
- Returns:
- the completionStatus
-
setCompletionStatus
- Parameters:
completionStatus
- the completionStatus to set
-