Esempio n. 1
0
/*!This method can be used to log information. Only when the specified
   level of the message is an element in the set of logged levels the
   information is logged. This method receives a character string that may
   contain format specifiers that are also available to 'printf' (like %d, %f,
   etc.). The remaining arguments are the variables that have to be filled in
   at the location of the specifiers. Before the logged message the elapsed
   time since the timer has been restarted is printed.
   \param iLevel level corresponding to this message
   \param str character string with (possible) format specifiers
   \param ... variables that define the values of the specifiers.
   \return bool indicating whether the message was logged or not. */
bool Logger::logWithTime( int iLevel, const char *str, ... )
{
  if( isInLogLevel( iLevel ) )
  {
    logSignal(); // test whether there are no old strings left to log
    va_list ap;
#ifdef Solaris
    va_start( ap );
#else
    va_start( ap, str );
#endif
    if( vsnprintf( m_buf, MAX_LOG_LINE-1, str, ap ) == -1 )
      cerr << "Logger::log, buffer is too small!" << "\n";
    va_end(ap);

    string s = m_strHeader;
    s.append( m_buf );
    s.copy( m_buf, string::npos );
    m_buf[s.length()] = '\0';
    m_timing.printTimeDiffWithText( *m_os, m_buf );

    return true;
  }

  return false;
}
Esempio n. 2
0
void GuiInterface::run()
{

    //while consumer is not stopped, grab info and emit signal for eng screen to update display
    while(!stoppedConsumer)
    {

        //lock mutex
       mutex.lock();


       ////qDebug()<<"Gui thread running" <<endl;

       if(!msg.isEmpty())
       {
            //get data from queue
           dataGathered.x = msg.first().x;
           dataGathered.y = msg.first().y;
           dataGathered.z = msg.first().z;
           dataGathered.R0 = msg.first().R0;
           dataGathered.R1 = msg.first().R1;
           dataGathered.R2 = msg.first().R2;
           dataGathered.R3 = msg.first().R3;
           dataGathered.roll = msg.first().roll;
           dataGathered.pitch = msg.first().pitch;
           dataGathered.yaw = msg.first().yaw;
           dataGathered.reqNode = msg.first().reqNode;
           dataGathered.mError = msg.first().mError;
           dataGathered.status = msg.first().status;


           //emit signal for eng screen to update display
           //sleep(1000);
           emit display(dataGathered.x, dataGathered.y, dataGathered.z, dataGathered.R0, dataGathered.R1, dataGathered.R2,
                        dataGathered.R3,dataGathered.roll, dataGathered.pitch,dataGathered.yaw, dataGathered.mError,dataGathered.status);
            //will also emit a signal for logging data -- this allows for an easy way to get the data to the engineering screen
           emit logSignal(dataGathered.x, dataGathered.y, dataGathered.z, dataGathered.R0, dataGathered.R1, dataGathered.R2,
                          dataGathered.R3,dataGathered.roll, dataGathered.pitch,dataGathered.yaw, dataGathered.reqNode
                          , dataGathered.mError,dataGathered.status);

           emit emitPositionData(dataGathered.x, dataGathered.y, dataGathered.z);




          }


      mutex.unlock();
    }

    stoppedConsumer = false;
    //unlock the mutex, so the producer has another turn
}
Esempio n. 3
0
/*!This method can be used to log information. Only when the specified
   level of the message is part of the set of logged values the
   information is logged. This method receives a character string that may
   contain format specifiers that are also available to 'printf' (like %d, %f,
   etc.). The remaining arguments are the variables that have to be filled in
   at the location of the specifiers.
   \param iLevel level corresponding to this message
   \param str character string with (possible) format specifiers
   \param ... variables that define the values of the specifiers.
   \return bool indicating whether the message was logged or not. */
bool Logger::log( int iLevel, const char *str, ... )
{
  if( isInLogLevel( iLevel ) )
  {
    logSignal(); // test whether there are no old strings left to log
    va_list ap;
#ifdef Solaris
    va_start( ap );
#else
    va_start( ap, str );
#endif
    if( vsnprintf( m_buf, MAX_LOG_LINE-1, str, ap ) == -1 )
      cerr << "Logger::log, buffer is too small!\n" ;
    va_end(ap);
    *m_os << m_strHeader << m_buf << "\n";
    return true;
  }

  return false;
}