Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rovsoft::main::CommandTranslator Class Reference

This class forwards the numbered command messages (and translates them to normal command messages). More...

#include <CommandTranslator.hh>

Inheritance diagram for rovsoft::main::CommandTranslator:

Inheritance graph
[legend]
Collaboration diagram for rovsoft::main::CommandTranslator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CommandTranslator (messages::MotionCommandMessageReceiver *motionReceiver=0, messages::BoolCommandMessageReceiver *boolReceiver=0, messages::NConfirmationMessageReceiver *confirmationReceiver=0)
 Construct a CommandTranslator object, with the specified receivers of the filtered messages.
virtual void putNMotionCommandMessage (messages::NMotionCommandMessagePtr message)
 Just calls sendMotionCommand().
virtual void putNBoolCommandMessage (messages::NBoolCommandMessagePtr message)
 Just calls sendBoolCommand().
virtual void newMotionCommandReceiver (messages::MotionCommandMessageReceiver &receiver)
 Just calls sendAllMotionCommands().
virtual void newBoolCommandReceiver (messages::BoolCommandMessageReceiver &receiver)
 Just calls sendAllBoolCommands().
virtual void setMotionCommandReceiver (messages::MotionCommandMessageReceiver &listener)
 Tries to send motion command messages in motionCommands if motionReceiverWasNull is 1, then sets it to 0.
virtual void setBoolCommandReceiver (messages::BoolCommandMessageReceiver &listener)
 Tries to send bool command messages in boolCommands if boolReceiverWasNull is 1, then sets it to 0.

Protected Member Functions

void sendAllMotionCommands ()
 Tries to send all motion commands in the motionCommands list.
void sendAllBoolCommands ()
 Tries to send all bool commands in the boolCommands list.
void sendMotionCommand (messages::NMotionCommandMessagePtr message)
 Tries to send the translated message to motionCommandReceiver, if it fails it puts it into the motionCommands list.
void sendBoolCommand (messages::NBoolCommandMessagePtr message)
 Tries to send the translated message to boolCommandReceiver, if it fails it puts it into the boolCommands list.

Protected Attributes

std::list< messages::NMotionCommandMessagePtrmotionCommands
 A list of motion command messages not yet send because the device didn't exist already or the motion command receiver was not yet set.
std::list< messages::NBoolCommandMessagePtrboolCommands
 A list of bool command messages not yet send because the device didn't exist already or the bool command receiver was not yet set.
unsigned char motionReceiverWasNull:1
 Was a motion command message not send, because the motion command receiver was 0:.
unsigned char boolReceiverWasNull:1
 Was a bool command message not send, because the bool command receiver was 0:.
ost::Semaphore motionLock
 Synchronize the access to the lists.
ost::Semaphore boolLock
 Synchronize the access to the lists.

Detailed Description

This class forwards the numbered command messages (and translates them to normal command messages).

Then it sends a confirmation message.


Constructor & Destructor Documentation

rovsoft::main::CommandTranslator::CommandTranslator messages::MotionCommandMessageReceiver motionReceiver = 0,
messages::BoolCommandMessageReceiver boolReceiver = 0,
messages::NConfirmationMessageReceiver confirmationReceiver = 0
[inline]
 

Construct a CommandTranslator object, with the specified receivers of the filtered messages.

Parameters:
motionReceiver The receiver of translated motion command messages.
boolReceiver The receiver of translated bool command messages.
confirmationReceiver The receiver of confirmation messages. If this is not set, then no confirmation messages are sent!!
Todo:
If the XXXSender interfaces are left, having references as parameter in their setXXXReceiver() methods, (Maybe not too bad, because setting to a 0 Pointer is currently not needed any way), then this constructor could also take references and the sendCommand methods could be simpler, because the receivers can't be 0!

Maybe implement a synced version of all senders (or the ones where they are needed), using a common virtual base class, implementing the basic features.


Member Function Documentation

void rovsoft::main::CommandTranslator::newBoolCommandReceiver messages::BoolCommandMessageReceiver receiver  )  [virtual]
 

Just calls sendAllBoolCommands().

Because now the device previously not existing could exist now.

Implements rovsoft::messages::NewBoolCommandReceiverListener.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::newMotionCommandReceiver messages::MotionCommandMessageReceiver receiver  )  [virtual]
 

Just calls sendAllMotionCommands().

Because now the device previously not existing could exist now.

Implements rovsoft::messages::NewMotionCommandReceiverListener.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::putNBoolCommandMessage messages::NBoolCommandMessagePtr  message  )  [virtual]
 

Just calls sendBoolCommand().

Implements rovsoft::messages::NBoolCommandMessageReceiver.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::putNMotionCommandMessage messages::NMotionCommandMessagePtr  message  )  [virtual]
 

Just calls sendMotionCommand().

Todo:
Implement device switch off state:
  • New Exception Type (PoweredDownException, or something like that)
  • Devices have know their power state!
  • Switch off commands must be checked and the state of devices has to be changed.
  • Currently a switched off device should result in an IOException.

Implements rovsoft::messages::NMotionCommandMessageReceiver.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::sendAllBoolCommands  )  [protected]
 

Tries to send all bool commands in the boolCommands list.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::sendAllMotionCommands  )  [protected]
 

Tries to send all motion commands in the motionCommands list.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::sendBoolCommand messages::NBoolCommandMessagePtr  message  )  [protected]
 

Tries to send the translated message to boolCommandReceiver, if it fails it puts it into the boolCommands list.

If it fails because the boolCommandReceiver was 0, then it also sets boolReceiverWasNull. It sends also a confirmation message if confirmationReceiver is not null.

Parameters:
message a translated bool command message.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::sendMotionCommand messages::NMotionCommandMessagePtr  message  )  [protected]
 

Tries to send the translated message to motionCommandReceiver, if it fails it puts it into the motionCommands list.

If it fails because the motionCommandReceiver was 0, then it also sets motionReceiverWasNull. It sends also a confirmation message if confirmationReceiver is not null.

Parameters:
message a translated motion command message.
Todo:
Currently there are no errors reported to the server.
(Maybe change the implementation later and just report an error to the server, instead of buffering the messages, when the device doesn't exist)

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::setBoolCommandReceiver messages::BoolCommandMessageReceiver listener  )  [virtual]
 

Tries to send bool command messages in boolCommands if boolReceiverWasNull is 1, then sets it to 0.

Implements rovsoft::messages::BoolCommandMessageSender.

Here is the call graph for this function:

void rovsoft::main::CommandTranslator::setMotionCommandReceiver messages::MotionCommandMessageReceiver listener  )  [virtual]
 

Tries to send motion command messages in motionCommands if motionReceiverWasNull is 1, then sets it to 0.

Reimplemented from rovsoft::messages::MotionCommandMessageSender.

Here is the call graph for this function:


Member Data Documentation

std::list<messages::NBoolCommandMessagePtr> rovsoft::main::CommandTranslator::boolCommands [protected]
 

A list of bool command messages not yet send because the device didn't exist already or the bool command receiver was not yet set.

ost::Semaphore rovsoft::main::CommandTranslator::boolLock [protected]
 

Synchronize the access to the lists.

unsigned char rovsoft::main::CommandTranslator::boolReceiverWasNull [protected]
 

Was a bool command message not send, because the bool command receiver was 0:.

std::list<messages::NMotionCommandMessagePtr> rovsoft::main::CommandTranslator::motionCommands [protected]
 

A list of motion command messages not yet send because the device didn't exist already or the motion command receiver was not yet set.

ost::Semaphore rovsoft::main::CommandTranslator::motionLock [protected]
 

Synchronize the access to the lists.

unsigned char rovsoft::main::CommandTranslator::motionReceiverWasNull [protected]
 

Was a motion command message not send, because the motion command receiver was 0:.


The documentation for this class was generated from the following files:
Generated on Tue May 31 14:19:55 2005 for Rovsoft by  doxygen 1.4.3