28 #ifndef HMI_CONSOLE_OUTPUT_HPP    29 #define HMI_CONSOLE_OUTPUT_HPP    31 #include <rtt/TaskContext.hpp>    32 #include <rtt/Activity.hpp>    33 #include <rtt/Logger.hpp>    34 #include <rtt/os/MutexLock.hpp>    38 #include <ocl/OCL.hpp>    51         : 
public RTT::TaskContext
    56         std::ostringstream messages;
    57         std::ostringstream backup;
    58         std::ostringstream logmessages;
    59         std::ostringstream logbackup;
    61         RTT::os::Mutex msg_lock;
    62         RTT::os::Mutex log_lock;
    66             : RTT::TaskContext( name ),
    67               coloron(
"\033[1;34m"), coloroff(
"\033[0m"),
    68               _prompt(
"HMIConsoleOutput :\n")
    70             this->addOperation(
"display", &
HMIConsoleOutput::display, 
this, RTT::ClientThread).doc(
"Display a message on the console").arg(
"message", 
"The message to be displayed");
    71             this->addOperation(
"displayBool", &
HMIConsoleOutput::displayBool, 
this, RTT::ClientThread).doc(
"Display a boolean on the console").arg(
"boolean", 
"The Boolean to be displayed");
    72             this->addOperation(
"displayInt", &
HMIConsoleOutput::displayInt, 
this, RTT::ClientThread).doc(
"Display a integer on the console").arg(
"integer", 
"The Integer to be displayed");
    73             this->addOperation(
"displayDouble", &
HMIConsoleOutput::displayDouble, 
this, RTT::ClientThread).doc(
"Display a double on the console").arg(
"double", 
"The Double to be displayed");
    74             this->addOperation(
"log", &HMIConsoleOutput::log, 
this, RTT::ClientThread).doc(
"Log a message on the console").arg(
"message", 
"The message to be logged");
    75             this->addOperation(
"logBool", &
HMIConsoleOutput::logBool, 
this, RTT::ClientThread).doc(
"Log a boolean on the console").arg(
"boolean", 
"The Boolean to be logged");
    76             this->addOperation(
"logInt", &
HMIConsoleOutput::logInt, 
this, RTT::ClientThread).doc(
"Log a integer on the console").arg(
"integer", 
"The Integer to be logged");
    77             this->addOperation(
"logDouble", &
HMIConsoleOutput::logDouble, 
this, RTT::ClientThread).doc(
"Log a double on the console").arg(
"double", 
"The Double to be logged");
    89                 RTT::os::MutexLock lock1( msg_lock );
    90                 if ( ! messages.str().empty() ) {
    91                     std::cout << coloron << _prompt<< coloroff <<
    92                         messages.str() << std::endl;
    93                     messages.rdbuf()->str(
"");
    97                 RTT::os::MutexLock lock1( log_lock );
    98                 if ( ! logmessages.str().empty() ) {
    99                     RTT::log(RTT::Info) << logmessages.str() << RTT::endlog();
   100                     logmessages.rdbuf()->str(
"");
   111                 coloron = 
"\033[1;34m";
   112                 coloroff = 
"\033[0m";
   133             this->enqueue( what );
   145                 RTT::os::MutexTryLock try_lock( msg_lock );
   146                 if ( try_lock.isSuccessful() ) {
   148                     messages << backup.str();
   149                     messages << what << std::endl;
   150                     backup.rdbuf()->str(
"");
   153                     backup << what << std::endl;
   156             if ( this->engine()->getActivity() )
   157                 this->engine()->getActivity()->trigger();
   165             this->enqueue( what );
   173             this->enqueue( what );
   181             this->enqueue( what );
   185         void dolog( 
const T& what )
   188                 RTT::os::MutexTryLock try_lock( log_lock );
   189                 if ( try_lock.isSuccessful() ) {
   191                     logmessages << logbackup.str();
   193                     logbackup.rdbuf()->str(
"");
   198             if ( this->engine()->getActivity() )
   199                 this->engine()->getActivity()->trigger();
   203         void log(
const std::string & what)
 void enableColor(bool yesno=true)
Enable or disable using a colored prompt. 
void display(const std::string &what)
Display a message on standard output. 
void logBool(bool what)
Log a boolean on standard output. 
void displayDouble(double what)
Display a double on standard output. 
The Orocos Component Library. 
void logDouble(double what)
Log a double on standard output. 
void displayBool(bool what)
Display a boolean on standard output. 
This component can be used to display messages on the standard output. 
void setPrompt(const std::string &prompt)
Set the prompt text. 
void displayInt(int what)
Display an integer on standard output. 
void logInt(int what)
Log an integer on standard output. 
void enqueue(const T &what)
Put a message in the queue.