core
Class VSTaskManager

java.lang.Object
  extended by core.VSTaskManager
All Implemented Interfaces:
VSSerializable

public class VSTaskManager
extends java.lang.Object
implements VSSerializable

The class VSTaskManager, it is responsible that all tasks will get fullfilled in the correct order. Please also read the javadoc of the VSTask class. It describes the difference between local and global timed tasks.

Author:
Paul C. Buetow

Field Summary
static boolean ONLY_ONCE
          The Constant ONLY_ONCE.
static boolean PROGRAMMED
          The Constant PROGRAMMED.
 
Constructor Summary
VSTaskManager(VSPrefs prefs, VSSimulatorVisualization simulatorVisualization)
          Instantiates a new task manager object.
 
Method Summary
 void addTask(VSTask task)
          Adds a task.
 void addTask(VSTask task, boolean isProgrammed)
          Adds a task.
 void deserialize(VSSerialize serialize, java.io.ObjectInputStream objectInputStream)
          Deserializes
 java.util.ArrayList<VSTask> getGlobalTasks()
          Gets the global timed tasks.
 java.util.ArrayList<VSTask> getLocalTasks()
          Gets the local timed tasks.
 java.util.ArrayList<VSTask> getProcessGlobalTasks(VSInternalProcess process)
          Gets the global timed tasks of a specific process.
 java.util.ArrayList<VSTask> getProcessLocalTasks(VSInternalProcess process)
          Gets the local timed tasks of a specific process.
 void removeAllTasks(java.util.ArrayList<VSTask> tasks)
          Removes several tasks.
 boolean removeTask(VSTask task)
          Removes a task.
 void removeTasksOf(VSInternalProcess process)
          Removes the tasks of the specified process.
 void reset()
          Resets the task manager.
 void runTasks(long step, long offset, long lastGlobalTime)
          Run tasks.
 void serialize(VSSerialize serialize, java.io.ObjectOutputStream objectOutputStream)
          Serializes
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROGRAMMED

public static final boolean PROGRAMMED
The Constant PROGRAMMED.

See Also:
Constant Field Values

ONLY_ONCE

public static final boolean ONLY_ONCE
The Constant ONLY_ONCE.

See Also:
Constant Field Values
Constructor Detail

VSTaskManager

public VSTaskManager(VSPrefs prefs,
                     VSSimulatorVisualization simulatorVisualization)
Instantiates a new task manager object.

Parameters:
prefs - the simulator's default prefs
simulatorVisualization - the simulator canvas
Method Detail

runTasks

public void runTasks(long step,
                     long offset,
                     long lastGlobalTime)
Run tasks. This method gets called by the simulator canvas repeatedly. Almost all simulator actions take place in this method.

Parameters:
step - the step
offset - the offset
lastGlobalTime - the last global time

reset

public void reset()
Resets the task manager.


addTask

public void addTask(VSTask task)
Adds a task.

Parameters:
task - the task to add

addTask

public void addTask(VSTask task,
                    boolean isProgrammed)
Adds a task.

Parameters:
task - the task to add
isProgrammed - true, if the task is programmed

removeTask

public boolean removeTask(VSTask task)
Removes a task.

Parameters:
task - the task to remove
Returns:
true, if the task has been removed with success

removeAllTasks

public void removeAllTasks(java.util.ArrayList<VSTask> tasks)
Removes several tasks.

Parameters:
tasks - the tasks to remove

removeTasksOf

public void removeTasksOf(VSInternalProcess process)
Removes the tasks of the specified process.

Parameters:
process - the process to remove the tasks of

getLocalTasks

public java.util.ArrayList<VSTask> getLocalTasks()
Gets the local timed tasks.

Returns:
the local timed tasks

getGlobalTasks

public java.util.ArrayList<VSTask> getGlobalTasks()
Gets the global timed tasks.

Returns:
the global timed tasks

getProcessLocalTasks

public java.util.ArrayList<VSTask> getProcessLocalTasks(VSInternalProcess process)
Gets the local timed tasks of a specific process.

Parameters:
process - the process to get the local timed tasks of
Returns:
the local tasks of the specified process

getProcessGlobalTasks

public java.util.ArrayList<VSTask> getProcessGlobalTasks(VSInternalProcess process)
Gets the global timed tasks of a specific process.

Parameters:
process - the process to get the local timed tasks of
Returns:
the global timed tasks of the specified process

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

serialize

public void serialize(VSSerialize serialize,
                      java.io.ObjectOutputStream objectOutputStream)
               throws java.io.IOException
Description copied from interface: VSSerializable
Serializes

Specified by:
serialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectOutputStream - The object output stream
Throws:
java.io.IOException

deserialize

public void deserialize(VSSerialize serialize,
                        java.io.ObjectInputStream objectInputStream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Description copied from interface: VSSerializable
Deserializes

Specified by:
deserialize in interface VSSerializable
Parameters:
serialize - The serialize object
objectInputStream - The object input stream
Throws:
java.io.IOException
java.lang.ClassNotFoundException