Aimsun Next Scripting: GKTask Class Reference
Aimsun Next Scripting  22
Public Types | Signals | Public Member Functions | List of all members
GKTask Class Reference
Inheritance diagram for GKTask:

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
 

Detailed Description

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:

task = GKSystem.getSystem().createTask( model )
task.setName( "Doing 10 Steps" )
task.setTotalSteps( 10 )
task.start()
cancelled = False
for( i = 0; cancelled == false && i < 10; i++ ):
// do something that requires some time...
cancelled = task.stepTask( i )
task.end()
Class that keeps information about all data that is shared by the documents.
Definition: GKSystem.sip:35
static GKSystem & getSystem()
Singleton !
GKTask * createTask(GKModel *model, QString uid=QString())
void setName(const QString &aname)

Member Enumeration Documentation

◆ 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.
Enumerator
eModal 
eSemiInteractive 
eInteractive 

◆ Storable

Enumerator
eDoStore 
eDoNotStore 

Constructor & Destructor Documentation

◆ GKTask()

GKTask::GKTask ( QString  _modelUID,
QString  uid = QString() 
)

Creates a task that will perform work on the given model

Member Function Documentation

◆ cancel()

void GKTask::cancel ( )

Cancels the task if it can be canceled

◆ end()

void GKTask::end ( Storable  store = eDoStore)

Ends the task. The parameter controls if the task should be kept in the system for further reference or if it can be discarded

◆ getCancelable()

bool GKTask::getCancelable ( ) const

Gets if the task can be canceled or not

◆ getExecutionInfo()

const QString & GKTask::getExecutionInfo ( ) const

Gets the execution info of the task.

◆ getInterativeExtension()

QDialog * GKTask::getInterativeExtension ( ) const

The extension widget that will control the task.

◆ getMode()

Mode GKTask::getMode ( ) const

The task mode.

See also
GKTask::Mode

◆ getName()

const QString & GKTask::getName ( ) const

Gets the name of the task

◆ getState()

const QString & GKTask::getState ( ) const

Gets the state of the task.

◆ getStepsDone()

int GKTask::getStepsDone ( ) const

Steps done in this task

◆ getTotalSteps()

int GKTask::getTotalSteps ( ) const

Gets the number of steps the task is divided in

◆ secondToFinish()

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

◆ setCancelable()

void GKTask::setCancelable ( bool  cancelable)

Sets if the task can be canceled or not. Tasks are cancelable by default.

◆ setExecutionInfo()

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.

◆ setInteractiveWidget()

void GKTask::setInteractiveWidget ( QDialog *  extension)

Mark this task as interactive as set the widget that wil control it.

◆ setMode()

void GKTask::setMode ( Mode  mode)

The task mode.

See also
GKTask::Mode

◆ setName()

void GKTask::setName ( const QString &  aname)

Sets the name of the task

◆ setState()

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.

◆ setStepsUpdate()

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

◆ setTimeUpdate()

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.

◆ setTotalSteps()

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.

◆ start()

void GKTask::start ( )

Starts the task with the given extension and milliseconds to remain hidden

◆ stateChanged

void GKTask::stateChanged ( )
signal

◆ stepDone

void GKTask::stepDone ( bool  update)
signal

◆ stepTask()

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.

◆ taskCanceled

void GKTask::taskCanceled ( )
signal

◆ taskEnded

void GKTask::taskEnded ( )
signal

◆ taskTime()

double GKTask::taskTime ( ) const

Seconds needed to complete the task (when finished) or second that this task has been running.

◆ wasCancelled()

bool GKTask::wasCancelled ( ) const

Returns true if the task been canceled

© Aimsun SLU
Aimsun ®