Aimsun Next Scripting
22
|
Public Types | |
enum | Mode { eModal , eSemiInteractive , eInteractive } |
enum | Storable { eDoStore , eDoNotStore } |
Signals | |
void | taskCanceled () |
void | taskEnded () |
void | stepDone (bool update) |
void | stateChanged () |
Public Member Functions | |
GKTask (QString _modelUID, QString uid=QString()) | |
void | setTotalSteps (int atotal) |
int | getTotalSteps () const |
bool | stepTask (int progress, double seconds=-1.0) |
void | setName (const QString &aname) |
const QString & | getName () const |
void | setState (const QString &astate) |
const QString & | getState () const |
void | setExecutionInfo (const QString &info) |
const QString & | getExecutionInfo () const |
void | setCancelable (bool cancelable) |
bool | getCancelable () const |
void | cancel () |
bool | wasCancelled () const |
void | setTimeUpdate (double seconds) |
void | setStepsUpdate (int steps) |
void | start () |
void | setMode (Mode mode) |
Mode | getMode () const |
void | setInteractiveWidget (QDialog *extension) |
QDialog * | getInterativeExtension () const |
void | end (Storable store=eDoStore) |
double | taskTime () const |
int | secondToFinish () const |
int | getStepsDone () const |
This 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 GKSystem::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 GKTask::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 stepTask to 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:
enum GKTask::Mode |
The task mode:
Enumerator | |
---|---|
eModal | |
eSemiInteractive | |
eInteractive |
enum GKTask::Storable |
GKTask::GKTask | ( | QString | _modelUID, |
QString | uid = QString() |
||
) |
Creates a task that will perform work on the given model
void GKTask::cancel | ( | ) |
Cancels the task if it can be canceled
Ends the task. The parameter controls if the task should be kept in the system for further reference or if it can be discarded
bool GKTask::getCancelable | ( | ) | const |
Gets if the task can be canceled or not
const QString & GKTask::getExecutionInfo | ( | ) | const |
Gets the execution info of the task.
QDialog * GKTask::getInterativeExtension | ( | ) | const |
The extension widget that will control the task.
Mode GKTask::getMode | ( | ) | const |
The task mode.
const QString & GKTask::getName | ( | ) | const |
Gets the name of the task
const QString & GKTask::getState | ( | ) | const |
Gets the state of the task.
int GKTask::getStepsDone | ( | ) | const |
Steps done in this task
int GKTask::getTotalSteps | ( | ) | const |
Gets the number of steps the task is divided in
int GKTask::secondToFinish | ( | ) | const |
Seconds required to finish this task (a guess). Returns -1 if it cannot guess because no times have been given in stepTask or because too few steps have been done
void GKTask::setCancelable | ( | bool | cancelable | ) |
Sets if the task can be canceled or not. Tasks are cancelable by default.
void GKTask::setExecutionInfo | ( | const QString & | info | ) |
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.
void GKTask::setInteractiveWidget | ( | QDialog * | extension | ) |
Mark this task as interactive as set the widget that wil control it.
void GKTask::setMode | ( | Mode | mode | ) |
The task mode.
void GKTask::setName | ( | const QString & | aname | ) |
Sets the name of the task
void GKTask::setState | ( | const QString & | astate | ) |
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.
void GKTask::setStepsUpdate | ( | int | steps | ) |
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 setTimeUpdate nor setStepsUpdate are called. If steps is 0 the update will be every time the developer calls stepTask
void GKTask::setTimeUpdate | ( | double | seconds | ) |
Set the number of seconds (or fraction) that pass between task updates. If the developer uses this method he should not call setStepsUpdate.
void GKTask::setTotalSteps | ( | int | atotal | ) |
Set the number of steps (the simulation steps, the length of a file in kilobytes,...) in which this task can be divided.
void GKTask::start | ( | ) |
Starts the task with the given extension and milliseconds to remain hidden
|
signal |
|
signal |
bool GKTask::stepTask | ( | int | progress, |
double | seconds = -1.0 |
||
) |
Inform that step "progress" in the task have been done. This method will return true if the task has been cancelled.
The last parameters 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.
|
signal |
|
signal |
double GKTask::taskTime | ( | ) | const |
Seconds needed to complete the task (when finished) or second that this task has been running.
bool GKTask::wasCancelled | ( | ) | const |
Returns true if the task been canceled