- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Executives::DeductiveController::Command::CommandDispatcher Class Reference

`#include <CommandDispatcher.h>`

Inheritance diagram for Mers::Executives::DeductiveController::Command::CommandDispatcher:

[legend]
Collaboration diagram for Mers::Executives::DeductiveController::Command::CommandDispatcher:

[legend]
List of all members.

## Public Member Functions
| CommandDispatcher ()
| ~CommandDispatcher ()
void | setModel (Mers::Models::Base::BaseModel const *model)
int | addConnection (Mers::Interfaces::ExecutionInterfaceBase *connection, char const *fileName)
virtual void | issueCommand (unsigned int commandVariable, unsigned int commandValue)
virtual bool | start (TaskIdentifier task)=0
virtual bool | stop ()=0
virtual bool | stop (TaskIdentifier task)=0
virtual int | step (bool block=true)=0
virtual bool | isDone ()=0
virtual bool | isDone (TaskIdentifier task)=0
virtual Mers::Utils::Lang::String | getActiveTasksString () const
virtual TaskIdentifier | createTask (const std::string &taskName)
virtual TaskIdentifier | createTask (const std::string &taskName, std::vector< std::string * > const &parameters)
virtual bool | isValid (TaskIdentifier task)
virtual void | deleteTask (TaskIdentifier task)
virtual TaskFactory * | getTaskFactory ()
virtual Task * | getTask (TaskIdentifier task) const
virtual void | print (std::ostream &out) const
## Protected Attributes
Mers::Utils::Containers::DynamicArrayTemplate< const CommandDispatcherEntry > | m_DispatchLists
| An array of all of our execution interfaces.
Mers::Models::Base::BaseModelVariableArray const * | mModelVariables
| The list of variables used to map from variables to values.

## Detailed Description

Takes commands issued by titan and a configuration file and issues a corresponding set of commands to the hardware.

Definition at line 39 of file CommandDispatcher.h.

## Constructor & Destructor Documentation

CommandDispatcher::CommandDispatcher | ( |  | ) |

Creates a new command dispatcher.

Definition at line 100 of file CommandDispatcher.cpp.

CommandDispatcher::~CommandDispatcher | ( |  | ) |

Destroys this object.

Definition at line 107 of file CommandDispatcher.cpp.

## Member Function Documentation

void CommandDispatcher::setModel | ( | Mers::Models::Base::BaseModel const * | model | ) |

Sets the model with which translation from command strings in the configuration files to UIDs in the execution is performed.

Parameters:

  | model | The model used to translate strings into UIDs.

Definition at line 115 of file CommandDispatcher.cpp.

References Mers::Utils::Containers::DynamicArray::getLength(), Mers::Models::Base::BaseModel::getVariables(), mModelVariables, and Mers::Utils::Containers::DynamicArray::resize().

Here is the call graph for this function:

int CommandDispatcher::addConnection | ( | Mers::Interfaces::ExecutionInterfaceBase * | connection,
|  | char const * | fileName |
| ) |  |  |

Adds a new connection that this process will issue commands to. The commands issued will be based on the file specified. Note that a model for mapping the string values of commands to UIDs must have been specified before this function.

Parameters:

  | connection | the new object that will have commands issued to it.
  | fileName | the name of the file that contains the mapping between commands from titan and this particular connection.

Returns:
  0 on success or a positive value if there was a problem with the file or a problem with creating a mapping.

Definition at line 148 of file CommandDispatcher.cpp.

References Mers::Interfaces::ExecutionInterfaceBase::createTask(), Mers::Models::Base::BaseModelVariableArray::find(), Mers::Models::Base::BaseModelVariable::getDomain(), Mers::Utils::Containers::DynamicArray::getDynamicArrayType(), Mers::Utils::Containers::DynamicArray::getLength(), Mers::Models::Base::BaseModelValue::getUID(), Mers::Models::Base::BaseModelVariable::getUID(), mModelVariables, and Mers::Utils::Containers::ObjectArray::pushBack().

Here is the call graph for this function:

void CommandDispatcher::issueCommand | ( | unsigned int | commandVariable,
|  | unsigned int | commandValue |
| ) |  |  | `[virtual]`

This function is called each time a registered command is issued. This function should not spend much time processing. Issues the command to the hardware.

Parameters:

  | commandVariable | the variable of the command that was issued.
  | commandValue | the value of the command that was issued.

Definition at line 224 of file CommandDispatcher.cpp.

References Mers::Executives::DeductiveController::Command::DispatcherPair::dispatch(), Mers::Utils::Containers::DynamicArray::getDynamicArrayType(), and Mers::Utils::Containers::DynamicArray::getLength().

Here is the call graph for this function:

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::start | ( | TaskIdentifier | task | ) | `[pure virtual]`

Starts an additional task. The task will continue until it has either completed or is told to stop. The execution status of tasks can generally be queried, so the termination of the task can be determined. This routine should generally do as little work as possible.

Parameters:

  | task | The name of the task that should be started.

Returns:
  True if the task was found and started, otherwise false. False may be returned for many reasons, including the inability of finding the task, the inability of starting the task (due to limitations in the conditions on the task, the number of times it can be run, the total number of tasks that can be run, etc), etc.

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::stop | ( |  | ) | `[pure virtual]`

Stops all current activities. Every command that was started will be stopped, if possible.

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::stop | ( | TaskIdentifier | task | ) | `[pure virtual]`

Stops the task, if currently active. Has no effect if the task was already stopped or already complete.

Parameters:

  | task | The task that should be stopped. A task will be stopped if it is still running and the task can be stopped.

Returns:
  true If the task was successfully stopped or was already stopped, false if it could not be stopped.

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual int Mers::Executives::DeductiveController::Command::CommandDispatcher::step | ( | bool | block = `true` | ) | `[pure virtual]`

Takes a single processing step. If block is false, then this executive will only progress if it is ready to progress. If block is true, then this executive will wait until progress can be made before returning. Generally, block should be false for reactive systems, and should be true when running this task-step process on a seperate thread.

Parameters:

  | block | If true, this procedure will always progress before returning. If false, this procedure will not block but will return an error if blocking is required to make progress.

Returns:
  the following values:
  * -1: no progress could be made w/o blocking
  * 0: successfully progressed
  * 1: execution failure
  * 2: exception (designers intent)

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::isDone | ( |  | ) | `[pure virtual]`

Returns true if all procedures have completed.

Returns:
  true if all procedures have completed.

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::isDone | ( | TaskIdentifier | task | ) | `[pure virtual]`

Returns true if a specific task has completed.

Parameters:

  | task | The task whos status is desired

Returns:
  True if a specific procedure is done, false otherwise.

Implements Mers::Interfaces::ExecutionInterfaceBase.

virtual Mers::Utils::Lang::String Mers::Executives::DeductiveController::Command::CommandDispatcher::getActiveTasksString | ( |  | ) | const`[virtual]`

Returns a string representing all of the active tasks, where each task is seperated by a return character.

Returns:
  a printable list of all active tasks, one per line.

Note that this function does nothing by default.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

virtual TaskIdentifier Mers::Executives::DeductiveController::Command::CommandDispatcher::createTask | ( | const std::string & | taskName | ) | `[virtual]`

Creates a new Task that can be later referenced.

Parameters:

  | taskName | The name of the task that should be created.

Returns:
  a new TaskIdentifier of the created task, or an invalid identifier if the task could not be created. Use isValid() to verify the validity of this task.

virtual TaskIdentifier Mers::Executives::DeductiveController::Command::CommandDispatcher::createTask | ( | const std::string & | taskName,
|  | std::vector< std::string * > const & | parameters |
| ) |  |  | `[virtual]`

Creates a new Task that can be later referenced.

Parameters:

  | taskName | The name of the task that should be created.
  | parameters | The parameters of this task.

Returns:
  a new TaskIdentifier of the created task, or an invalid identifier if the task could not be created. Use isValid() to verify the validity of this task.

virtual bool Mers::Executives::DeductiveController::Command::CommandDispatcher::isValid | ( | TaskIdentifier | task | ) | `[virtual]`

Returns true if this is a valid task.

Parameters:

  | task | The task identifier that is being verified.

Returns:
  True if the TaskIdentifier reflects a valid task.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

virtual void Mers::Executives::DeductiveController::Command::CommandDispatcher::deleteTask | ( | TaskIdentifier | task | ) | `[virtual]`

Frees a task that was previously created. Note that this function just dereferences the object, so other classes that have also taken a reference to the class will still have a valid object.

Parameters:

  | task | The task that should be freed.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

virtual TaskFactory* Mers::Executives::DeductiveController::Command::CommandDispatcher::getTaskFactory | ( |  | ) | `[virtual]`

Returns the current factory.

Returns:
  The factory currently being used to create tasks.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

virtual Task* Mers::Executives::DeductiveController::Command::CommandDispatcher::getTask | ( | TaskIdentifier | task | ) | const`[virtual]`

Returns a Task object from an identifier, if the identifier is valid. Otherwise, returns NULL.

Parameters:

  | task | The identifier of the task being sought.

Returns:
  A handle to the task that corresponds to the task identifier.

Reimplemented from Mers::Interfaces::ExecutionInterfaceBase.

void CommandDispatcher::print | ( | std::ostream & | out | ) | const`[virtual]`

Called to print this object to the specified ostream. Derived classes must define this.

Parameters:

  | out | the ostream to print this object information to.

Definition at line 271 of file CommandDispatcher.cpp.

## Member Data Documentation

Mers::Utils::Containers::DynamicArrayTemplate< const CommandDispatcherEntry > Mers::Executives::DeductiveController::Command::CommandDispatcher::m_DispatchLists`[protected]`

An array of all of our execution interfaces.

An array of dispatch lists. Each list contains a set of dispatcher objects and the commands that should be sent to them in response to the current command issued.

Definition at line 261 of file CommandDispatcher.h.

The documentation for this class was generated from the following files:

- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Command/CommandDispatcher.h
- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Command/CommandDispatcher.cpp