PyANGKernel.GKTask¶
- class GKTask¶
A class for tasks
Details
These tasks are used by Aimsun operations to give the user feedback on the amount of time required to complete the task. It allows also the cancel of such task.
The user will create a new task using the
createTask. From this method the developer will set the label of the task (File Loading for example), the number of steps to complete the task (the simulation steps, the length of a file in kilobytes,…), the minimum step to refresh the task or the time between updates, if the task can be cancelled (if not the Cancel button will not appear) and if the dialog will process events (if it will refresh the GUI).To start a task the developer has to call
start().The current implementation refreshes the GUI each stepsToUpdate or timeToUpdate depending on what the user set.
After creating the dialog the developer must call
stepTaskto inform the dialog that the step N has been done. This method will return true if the task has been cancelled.When a task is complete the developer has to call GKTask::end().
Example:
GKModel *model; GTask *task; uint i; bool cancelled = false; task = GKSystem::getSystem().createTask(); task->setName( tr( "Doing 10 Steps" ) ); task->setTotalSteps( 10 ); task->start(); for( i = 0; cancelled == false && i < 10; i++ ){ // do something that requires some time... cancelled = task->stepTask( i ); } task->end();
Synopsis¶
Methods¶
def
__init__()def
addSubTask()def
allowUserInput()def
cancel()def
end()def
failed()def
getCancelable()def
getIsMultiTask()def
getMode()def
getModelUID()def
getName()def
getSingleDay()def
getStartTime()def
getState()def
getStepsDone()def
getSubTasks()def
getTargetId()def
getTimeUpdate()def
getTotalSteps()def
getUID()def
getUUID()def
isInternal()def
isQuick()def
multiTaskEnd()def
multiTaskStart()def
refresh()def
secondToFinish()def
setCancelable()def
setInternal()def
setIsMultiTask()def
setMode()def
setModelUID()def
setName()def
setParent()def
setQuick()def
setSingleDay()def
setStartTime()def
setState()def
setStepsUpdate()def
setSubTasks()def
setTargetId()def
setTimeUpdate()def
setTotalSteps()def
start()def
statsInterval()def
stepTask()def
stop()def
taskTime()def
wasCancelled()def
wasStopped()
Signals¶
def
percentageDone()def
stateChanged()def
stepDone()def
taskCanceled()def
taskEnded()def
taskFailed()def
taskStarted()def
taskStopped()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class Mode¶
The task mode: - eModal: No other task can be done. Update GUI (if available) from time to time. This is the default one. - eSemiInteractive: Other task can be started (if possible). Update GUI on every step - eInteractive: A task that can be controlled by the user. Update GUI on every step.
- class Storable¶
Creates a task that will perform work on the given model
Adds a
GKTypeexception to model editionAdd sub task
Returns true if user input should be processed during the ui update. true by default.
See also
- cancel()¶
Cancels the task if it can be canceled
- disableModelEdition()¶
Marks this task as one whose execution forbids modifications on existing objects
- failed(errorMsg)¶
- Parameters:
errorMsg – str
Mark this task as failed
Gets if the task can be canceled or not
If the task failed, the reason as set when calling
failedGets the execution info of the task.
In an interactive task, the time in where the task is. For example, for Aimsun Next Micro the simulation time.
- getInterativeExtension()¶
- Return type:
QDialog
The extension widget that will control the task.
The internal (cannot be translated) name of the task
The task mode.
See also
Returns the UID of the model that creates this task or a empty string for system tasks
Gets the name of the task
Returns the value set with
setShowExtensionOnClose.UnknownCommand
setSingleDayWhen this task was started.
Gets the state of the task.
Steps done in this task
- getSubTasks()¶
- Return type:
.list of QString
Get the sub task ids of this task
The target id. The target id the object in where we are doing the task.
Gets the number of steps the task is divided in
Returns the unique identifier of this task (generated using QUuid::createUuid())
Indicates if objects can be modified while this task is active
Don’t notify this task to external apps
Returns true if the task is quick. UnknownCommand
setQuick- multiTaskEnd()¶
- multiTaskStart()¶
- percentageDone(percentage)¶
- Parameters:
percentage – int
- refresh()¶
Emit a stepDone witg update = true to refresh the status (in the GUI)
Seconds required to finish this task (a guess). Returns -1 if it cannot guess because no times have been given in
stepTaskor because too few steps have been done- setAllowUserInput(allow)¶
- Parameters:
allow – bool
Configures if on the ui update the user inputs should be allowed or ignored.
See also
- setCancelable(cancelable)¶
- Parameters:
cancelable – bool
Sets if the task can be canceled or not. Tasks are cancelable by default.
- setExecutionInfo(info)¶
- Parameters:
info – str
Sets extra execution info for this task. It is task dependand but usually has information related a simulation (iterations info, vehs in/out…) in JSON format.
In an interactive task, the time in where the task is. For example, for Aimsun Next Micro the simulation time.
- setInteractiveWidget(extension)¶
- Parameters:
extension –
QDialog
Mark this task as interactive as set the widget that wil control it.
- setInternal()¶
Don’t notify this task to external apps
See also
- setInternalName(aname)¶
- Parameters:
aname – str
The internal (cannot be translated) name of the task
- setIsMultiTask(isMultiTask)¶
- Parameters:
isMultiTask – bool
The task mode.
See also
Set the model uid (if not set in the
GKTaskconstructor)- setName(aname)¶
- Parameters:
aname – str
Sets the name of the task.
- setParent(uuid)¶
- Parameters:
uuid – str
Parent task, if this is a subtask
See also
parent()- setQuick(isQuick)¶
- Parameters:
isQuick – bool
Sets the task as quick (needn’t a long-time process).
Note
Setting the task as quick won’t make it faster to process ! it will just let know other objects (f.ex, the UI) that this task is likely to be processed very fast, quick.
See also
- setShowExtensionOnClose(show)¶
- Parameters:
show – bool
Sets if the task should display its GKTaskExtensionWrapper informations on ending. *
Note
This value only has an effect when the task has a GKTaskExtensionWrapper. * * Default: true
- setSingleDay(value)¶
- Parameters:
value – bool
For interactive task, sim will run between days? If so, we will show the date.
Overwrites the start time. Usually not required as the start time is set automatically.
- setState(astate)¶
- Parameters:
astate – str
Sets the state of the task. This can be used to show a long task passing between one state and other, for example, first set the state to “Processing input” and then to “Generating the report”. State is not mandatory to be set.
- setStepsUpdate(steps)¶
- Parameters:
steps – int
Set the number of steps that pass between task updates. If the developer uses this method he should not call
setTimeUpdate.If steps is -1 then the dialog will be updated every 5% of the task. This is the default value if neither
setTimeUpdatenor setStepsUpdate are called. If steps is 0 the update will be every time the developer callsstepTask- setSubTasks(_subTasks)¶
- Parameters:
_subTasks – .list of QString
This task is a composition of tasks with ids in _subTasks
- setTargetId(id)¶
- Parameters:
id – int
The target id. The target id the object in where we are doing the task.
- setTimeUpdate(seconds)¶
- Parameters:
seconds – float
Set the number of seconds (or fraction) that pass between task updates. If the developer uses this method he should not call
setStepsUpdate.- setTotalSteps(atotal)¶
- Parameters:
atotal – int
Set the number of steps (the simulation steps, the length of a file in kilobytes,…) in which this task can be divided.
- start()¶
Starts the task with the given extension and milliseconds to remain hidden
- stateChanged()¶
- statsInterval(currentStatInterval, currentDetecInterval, aggregatedInterval)¶
- Parameters:
currentStatInterval – int
currentDetecInterval – int
aggregatedInterval – bool
The process in the task has calculated some statistical data. After this call this data can be read
- statsIntervalDone(currentStatInterval, currentDetecInterval, aggregatedInterval)¶
- Parameters:
currentStatInterval – int
currentDetecInterval – int
aggregatedInterval – bool
- stepDone(update)¶
- Parameters:
update – bool
Inform that one step in the task have been done. This method will return true if the task has been cancelled.
- stepTask(progress[, seconds=-1.0])
- Parameters:
progress – int
seconds – float
- Return type:
Inform that step “progress” in the task have been done. This method will return true if the task has been cancelled.
The last parameters (if non interactive) tells the task the amount of time used to perform these steps. If it is -1.0 means that no time has been calculated. If a time is provided (and then it must be provided for every call), then the task will calculated the aproximated duration of the operation.
If interactive this parameter will not be use
- stop()¶
prepares the task to be stopped
- taskCanceled()¶
- taskEnded()¶
- taskFailed(errorMessage)¶
- Parameters:
errorMessage – str
- taskStarted()¶
- taskStopped()¶
Seconds needed to complete the task (when finished) or second that this task has been running.
Returns true if the task been canceled
returns whether the task is stopped or not