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

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

# Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi Class Reference

`#include <ME_rtapi.h>`

Collaboration diagram for Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi:

[legend]
List of all members.

## Public Member Functions
| ME_rtapi (Mers::Estimation::Discrete::ME_connection *syst, Mers::Executives::DeductiveController::Rtapi::RTAPICallback *liv_report)
virtual | ~ME_rtapi ()
virtual int | queue_command (unsigned int cmd_index, unsigned int cmd_value)
virtual int | queue_observation (unsigned int obs_index, unsigned int value_index)
virtual int | queue_initial_state (unsigned int state_index, unsigned int value_index)
int | queue_observations (int number, unsigned int obs[], unsigned int values[])
int | queue_find_mode_estimate ()
virtual int | queue_start_command_and_time (unsigned int cmd_index, unsigned int cmd_value)
virtual int | queue_observations_and_time (unsigned int obs_index, unsigned int value_index)
int | queue_abort_command ()
int | queue_report_full_state ()
int | registerCommandListener (unsigned int command, Mers::Executives::DeductiveController::Rtapi::CommandCallback *listener)
virtual int | observation_timeout ()
virtual int | command_timeout ()
void | decrementTimeouts ()
void | incrementTimeouts ()
unsigned int | getTimeouts ()
## Protected Attributes
pthread_attr_t | timer_attr
| The attributes that are used when creating timer threads.
Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue & | thequeue
Mers::Estimation::Discrete::ME_connection * | mec
ME_dispatcher * | dispatcher
bool | active
pthread_mutex_t | timersMutex
unsigned int | activeTimers
| The current number of active timers.
Mers::Utils::Containers::ObjectArray | listeners

## Detailed Description

A real-time queue that interfaces to a Mode Estimation object. This queue is thread-safe and will quickly record any messages for ME and then return. ME will then process the messages on its own thread as it processes the tasks it's been given.

Author:
  Andreas F. Wehowsky

  Paul H. Elliott

Definition at line 51 of file ME_rtapi.h.

## Constructor & Destructor Documentation

ME_rtapi::ME_rtapi | ( | Mers::Estimation::Discrete::ME_connection * | syst,
|  | Mers::Executives::DeductiveController::Rtapi::RTAPICallback * | liv_report |
| ) |  |  |

Creates a new ME RTAPI object.

Parameters:

  | syst | A handle to the Mode Estimation object with which this queue will communicate.
  | liv_report | The callback object that will receive updated when ME has finished processing a message from the queue.

Definition at line 96 of file ME_rtapi.cpp.

References active, activeTimers, Mers::Utils::Lang::ReferencedObject::addReference(), dispatcher, mec, thequeue, timer_attr, and timersMutex.

Here is the call graph for this function:

ME_rtapi::~ME_rtapi | ( |  | ) | `[virtual]`

Destroys this object.

Definition at line 124 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), listeners, Mers::Utils::Containers::DynamicArray::makeEmpty(), Mers::Utils::Lang::ReferencedObject::removeReference(), thequeue, timer_attr, timersMutex, and Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::waitForEmpty().

Here is the call graph for this function:

## Member Function Documentation

int ME_rtapi::queue_command | ( | unsigned int | cmd_index,
|  | unsigned int | cmd_value |
| ) |  |  | `[virtual]`

Adds command to the message queue. The command is (cmd_index = cmd_value). Also echos the command to the appropriate command listeners.

Parameters:

  | cmd_index | The unique index of the command variable being issued.
  | cmd_value | The unique index of the value being assigned to the command variable.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 161 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), Mers::Utils::Containers::DynamicArray::getLength(), listeners, and thequeue.

Here is the call graph for this function:

int ME_rtapi::queue_observation | ( | unsigned int | obs_index,
|  | unsigned int | value_index |
| ) |  |  | `[virtual]`

Queues a message indicating a new observation.

Parameters:

  | obs_index | The unique index of the variable that was measured.
  | value_index | The unique index of the value observed.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 186 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), and thequeue.

Referenced by queue_observations().

Here is the call graph for this function:

int ME_rtapi::queue_initial_state | ( | unsigned int | state_index,
|  | unsigned int | value_index |
| ) |  |  | `[virtual]`

Queues a message that will change the current state of ME. This function is used to initialize ME to a particular initial state.

Parameters:

  | state_index | The unique index of the state variable being initialized.
  | value_index | The unique index of the value being assigned to the variable.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 198 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), and thequeue.

Referenced by Mers::Executives::DeductiveController::DCInterface::setInitialState().

Here is the call graph for this function:

int ME_rtapi::queue_observations | ( | int | number,
|  | unsigned int | obs[],
|  | unsigned int | values[] |
| ) |  |  |

Queues a set of messages indicating a set of new observations.

Parameters:

  | number | The number of observations.
  | obs | A list of number unique observation variables that will be updated.
  | values | A list of number unique values that will be paired with their corresponding variables.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 212 of file ME_rtapi.cpp.

References active, and queue_observation().

Here is the call graph for this function:

int ME_rtapi::queue_find_mode_estimate | ( |  | ) |

Requests that ME determine the current Mode Estimate given the past set of observations and the past command. The update will be posted to the current RTAPICallback listener.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 230 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), and thequeue.

Referenced by command_timeout(), observation_timeout(), and Mers::Executives::DeductiveController::DCInterface::process_next_control_cmd().

Here is the call graph for this function:

int ME_rtapi::queue_start_command_and_time | ( | unsigned int | cmd_index,
|  | unsigned int | cmd_value |
| ) |  |  | `[virtual]`

queues a command and starts a timer which will automatically enqueue a find_mode_estimate request after the timer has expired

Parameters:

  | cmd_index | the UID of the command variable being issued
  | cmd_value | the UID of the command value being issued

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 241 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), Mers::Utils::Containers::DynamicArray::getLength(), incrementTimeouts(), listeners, RTITimerPacket::msg, RTITimerPacket::rtapi, thequeue, and timer_attr.

Referenced by Mers::Executives::DeductiveController::DCInterface::process_next_control_cmd().

Here is the call graph for this function:

int ME_rtapi::queue_observations_and_time | ( | unsigned int | obs_index,
|  | unsigned int | value_index |
| ) |  |  | `[virtual]`

queues an observation and starts a timer which will automatically enqueue a find_mode_estimate request after the timer has expired, unless a command is already running, in which case it will just add an observation message.

Parameters:

  | obs_index | the UID of the observable variable being issued
  | value_index | the UID of the observable value being issued

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 292 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), getTimeouts(), incrementTimeouts(), RTITimerPacket::msg, RTITimerPacket::rtapi, thequeue, and timer_attr.

Here is the call graph for this function:

int ME_rtapi::queue_abort_command | ( |  | ) |

This function clears the queue.

Todo:
  This function currently does nothing.

Definition at line 331 of file ME_rtapi.cpp.

References active.

Referenced by Mers::Executives::DeductiveController::DCInterface::requestAbort().

int ME_rtapi::queue_report_full_state | ( |  | ) |

Requests that ME determine the current Mode Estimate given the past set of observations and the past command. The update will be posted to the current RTAPICallback listener and will include all the states, not just those that have changed.

Returns:
  0 on success or a positive value if the queue was full. this function returns a negative value if the rtapi is currently being destroyed.

Definition at line 339 of file ME_rtapi.cpp.

References active, Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue::enqueue(), and thequeue.

Referenced by Mers::Executives::DeductiveController::DCInterface::requestFullState().

Here is the call graph for this function:

int ME_rtapi::registerCommandListener | ( | unsigned int | command,
|  | Mers::Executives::DeductiveController::Rtapi::CommandCallback * | listener |
| ) |  |  |

adds the specified listener for for the specified command. Everytime the command (variable) is issued, the listener will be called Note that this object will not delete the listener.

Parameters:

  | command | the UID of the command variable that this listener is listening for.
  | listener | the listener that will be called each time the command is issued.

Returns:
  0 on success or a positive value if the listener could not be added

Definition at line 350 of file ME_rtapi.cpp.

References Mers::Utils::Containers::DynamicArray::getLength(), listeners, and Mers::Utils::Containers::DynamicArray::resize().

Here is the call graph for this function:

int ME_rtapi::observation_timeout | ( |  | ) | `[virtual]`

Called when a timer created by queue_observations_and_time has expired.

Returns:
  0 on success or a positive value if the function could not complete properly.

Definition at line 374 of file ME_rtapi.cpp.

References activeTimers, queue_find_mode_estimate(), and timersMutex.

Here is the call graph for this function:

int ME_rtapi::command_timeout | ( |  | ) | `[virtual]`

Called when a timer created by queue_observations_and_time has expired.

Returns:
  0 on success or a positive value if the function could not complete properly.

Definition at line 395 of file ME_rtapi.cpp.

References activeTimers, queue_find_mode_estimate(), and timersMutex.

Here is the call graph for this function:

void ME_rtapi::decrementTimeouts | ( |  | ) |

This function decrements the number of timeouts currently active. This function is thread-safe.

Definition at line 426 of file ME_rtapi.cpp.

References activeTimers, and timersMutex.

void ME_rtapi::incrementTimeouts | ( |  | ) |

This function increments the number of timeouts currently active. This function is thread-safe.

Definition at line 414 of file ME_rtapi.cpp.

References activeTimers, and timersMutex.

Referenced by queue_observations_and_time(), and queue_start_command_and_time().

unsigned int ME_rtapi::getTimeouts | ( |  | ) |

This function returns the number of timeouts currently active. This function is thread-safe.

Returns:
  The total number of active timers running.

Definition at line 433 of file ME_rtapi.cpp.

References activeTimers, and timersMutex.

Referenced by queue_observations_and_time().

## Member Data Documentation

Mers::Executives::DeductiveController::Rtapi::ThreadSafeObjectQueue& Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::thequeue`[protected]`

The thread-safe queue used to send messages between the outside world and the Mode Estimation object.

Definition at line 269 of file ME_rtapi.h.

Referenced by ME_rtapi(), queue_command(), queue_find_mode_estimate(), queue_initial_state(), queue_observation(), queue_observations_and_time(), queue_report_full_state(), queue_start_command_and_time(), and ~ME_rtapi().

Mers::Estimation::Discrete::ME_connection* Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::mec`[protected]`

The Mode Estimation Object that receives messages from the queue.

Definition at line 273 of file ME_rtapi.h.

Referenced by ME_rtapi().

ME_dispatcher* Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::dispatcher`[protected]`

The object that is actively removing messages from the queue and handing them off to the mec object.

Definition at line 276 of file ME_rtapi.h.

Referenced by ME_rtapi().

bool Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::active`[protected]`

This flag indicates whether the queue is still active or not. The queue becomes inactive when this object is destroyed. At this point, the queue becomes inactive in preparation for deleting the queue. Any additional messages posted will be ignored until this object is deleted.

Definition at line 284 of file ME_rtapi.h.

Referenced by ME_rtapi(), queue_abort_command(), queue_command(), queue_find_mode_estimate(), queue_initial_state(), queue_observation(), queue_observations(), queue_observations_and_time(), queue_report_full_state(), queue_start_command_and_time(), and ~ME_rtapi().

pthread_mutex_t Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::timersMutex`[protected]`

The mutex used to insure that only one timer accesses the activeTimers value at the same time.

Definition at line 288 of file ME_rtapi.h.

Referenced by command_timeout(), decrementTimeouts(), getTimeouts(), incrementTimeouts(), ME_rtapi(), observation_timeout(), and ~ME_rtapi().

Mers::Utils::Containers::ObjectArray Mers::Executives::DeductiveController::Rtapi::ME::ME_rtapi::listeners`[protected]`

An array of ObjectArrays, which in turn contain a list of CommandCallback listeners that are relevant for the specified command UID. The listeners is indexed by the command UID.

Definition at line 296 of file ME_rtapi.h.

Referenced by queue_command(), queue_start_command_and_time(), registerCommandListener(), and ~ME_rtapi().

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

- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/ME/ME_rtapi.h
- /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Rtapi/ME/ME_rtapi.cpp