QString GenericChatroomWidget::getTitle() const
{
    QString title = getName();

    if (!getStatusString().isNull())
        title += QStringLiteral(" (") + getStatusString() + QStringLiteral(")");

    return title;
}
// Storable Interface Methods
void FollowUpRecord::getAttributesAndValues(QMap<QString, QVariant> & attributesAndValues) const{
    Record::getAttributesAndValues(attributesAndValues);
    attributesAndValues.insert(QString("Status"), QVariant(getStatusString()));
    attributesAndValues.insert(QString("DueDateAndTime"), QVariant(QDateTime(getDueDateTime())));
    attributesAndValues.insert(QString("Details"), QVariant(QString(getDetails())));
    attributesAndValues.insert(QString("ConsultationRecordID"), QVariant(getConsultationRecordId()));
}
Exemple #3
0
void XDebugServer::addStatus(xdebug_xml_node& node) {
  // TODO(#4489053) Change this when xml api is changed
  char* status = const_cast<char*>(getStatusString(m_status));
  char* reason = const_cast<char*>(getReasonString(m_reason));
  xdebug_xml_add_attribute_ex(&node, "status", status, 0, 0);
  xdebug_xml_add_attribute_ex(&node, "reason", reason, 0, 0);
}
Exemple #4
0
static void
get_size_full( TorrentCellRenderer * cell,
               GtkWidget           * widget,
               gint                * width,
               gint                * height )
{
    int w, h;
    int xpad, ypad;
    GdkRectangle icon_area;
    GdkRectangle name_area;
    GdkRectangle stat_area;
    GdkRectangle prog_area;
    const char * name;
    GdkPixbuf * icon;

    struct TorrentCellRendererPrivate * p = cell->priv;
    const tr_torrent * tor = p->tor;
    const tr_stat * st = tr_torrentStatCached( (tr_torrent*)tor );
    const tr_info * inf = tr_torrentInfo( tor );
    GString * gstr_prog = p->gstr1;
    GString * gstr_stat = p->gstr2;

    icon = get_icon( tor, FULL_ICON_SIZE, widget );
    name = tr_torrentName( tor );
    g_string_truncate( gstr_stat, 0 );
    getStatusString( gstr_stat, tor, st, p->upload_speed_KBps, p->download_speed_KBps );
    g_string_truncate( gstr_prog, 0 );
    getProgressString( gstr_prog, tor, inf, st );
    gtr_cell_renderer_get_padding( GTK_CELL_RENDERER( cell ), &xpad, &ypad );

    /* get the idealized cell dimensions */
    g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
    gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &w, &h );
    icon_area.width = w;
    icon_area.height = h;
    g_object_set( p->text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL );
    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    name_area.width = w;
    name_area.height = h;
    g_object_set( p->text_renderer, "text", gstr_prog->str, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    prog_area.width = w;
    prog_area.height = h;
    g_object_set( p->text_renderer, "text", gstr_stat->str, NULL );
    gtk_cell_renderer_get_size( p->text_renderer, widget, NULL, NULL, NULL, &w, &h );
    stat_area.width = w;
    stat_area.height = h;

    /**
    *** LAYOUT
    **/

    if( width != NULL )
        *width = xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
    if( height != NULL )
        *height = ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;

    /* cleanup */
    g_object_unref( icon );
}
OSStatus CreateHTTPRespondMessageNoCopy( int status, const char *contentType, size_t inDataLen, uint8_t **outMessage, size_t *outMessageSize )
{
    OSStatus err = kParamErr;
     char *statusString = getStatusString(status);

    require( contentType, exit );
    require( inDataLen, exit );

    err = kNoMemoryErr;
    *outMessage = malloc( 200 );
    require( *outMessage, exit );

    // Create HTTP Response
    snprintf( (char*)*outMessage, 200, 
             "%s %d %s%s%s %s%s%s %d%s",
             "HTTP/1.1", status, statusString, kCRLFNewLine, 
             "Content-Type:", contentType, kCRLFNewLine,
             "Content-Length:", (int)inDataLen, kCRLFLineEnding );

    // outMessageSize will be the length of the HTTP Header plus the data length
    *outMessageSize = strlen( (char*)*outMessage );
    err = kNoErr;

exit:
    return err;
}
static void
get_size_full( TorrentCellRenderer * cell,
               GtkWidget           * widget,
               gint                * width,
               gint                * height )
{
    int w, h;
    GdkRectangle icon_area;
    GdkRectangle name_area;
    GdkRectangle stat_area;
    GdkRectangle prog_area;
    const char * name;
    char * status;
    char * progress;
    GdkPixbuf * icon;
    GtkCellRenderer * text_renderer;

    struct TorrentCellRendererPrivate * p = cell->priv;
    const tr_torrent * tor = p->tor;
    const tr_stat * st = tr_torrentStatCached( (tr_torrent*)tor );
    const tr_info * inf = tr_torrentInfo( tor );

    icon = get_icon( tor, FULL_ICON_SIZE, widget );
    name = inf->name;
    status = getStatusString( tor, st, p->upload_speed, p->download_speed );
    progress = getProgressString( tor, inf, st );

    /* get the idealized cell dimensions */
    g_object_set( p->icon_renderer, "pixbuf", icon, NULL );
    gtk_cell_renderer_get_size( p->icon_renderer, widget, NULL, NULL, NULL, &w, &h );
    icon_area.width = w;
    icon_area.height = h;
    text_renderer = get_text_renderer( st, cell );
    g_object_set( text_renderer, "text", name, "weight", PANGO_WEIGHT_BOLD, "scale", 1.0, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL );
    gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
    name_area.width = w;
    name_area.height = h;
    g_object_set( text_renderer, "text", progress, "weight", PANGO_WEIGHT_NORMAL, "scale", SMALL_SCALE, NULL );
    gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
    prog_area.width = w;
    prog_area.height = h;
    g_object_set( text_renderer, "text", status, NULL );
    gtk_cell_renderer_get_size( text_renderer, widget, NULL, NULL, NULL, &w, &h );
    stat_area.width = w;
    stat_area.height = h;

    /**
    *** LAYOUT
    **/

    if( width != NULL )
        *width = cell->parent.xpad * 2 + icon_area.width + GUI_PAD + MAX3( name_area.width, prog_area.width, stat_area.width );
    if( height != NULL )
        *height = cell->parent.ypad * 2 + name_area.height + prog_area.height + GUI_PAD_SMALL + p->bar_height + GUI_PAD_SMALL + stat_area.height;

    /* cleanup */
    g_free( status );
    g_free( progress );
    g_object_unref( icon );
}
Exemple #7
0
//---------------------------------------------------------------------------
bool TRig::checkOak(EOakStatus status)
{
   if(status != eOakStatusOK) {
       qDebug(getStatusString(status).c_str());
       closeOak();
   }

 return status == eOakStatusOK ? true:false;
}
Exemple #8
0
QuestDescriptor LocationQuest::getQuestDescriptor()
{
    QuestDescriptor qd =
    {
        id_, points_, name_, task_, getKindString() , getStatusString(), true, false, questLocation_, range_
    };
    return qd;

}
Exemple #9
0
void LocationQuest::checkVisibility()
{

    qDebug()<<"nono"<<getStatusString().toAscii()<<"id: "<<getId();

        //if(status_ == STATUS(UNBLOCKED) && nearLocation_)
        if(getStatusString().compare("UNBLOCKED")==0 && nearLocation_)
        {
            qDebug("sprawdzam widocznosc");


            qDebug("widzi mnie !");


            setStatus(STATUS(NOACTIVE));
            emit makeVisible(id_);//type, type2, geocoordinate, range, name ...
        }



}
Exemple #10
0
/*****************************************************************************
 * checkOakCall(..)
 *****************************************************************************/
int checkOakCall(EOakStatus status, const char *file, int line, const char* function)
{
  if (status != eOakStatusOK) {
    if (debug > 0) {
      fprintf(stderr, "checkOakCall: Error: %s in function %s (file %s, line %d)\n",
	      getStatusString(status), function, file, line);
    }
    return status;
  } else {
    return 0;
  }
}
Exemple #11
0
QString Task::saveToDir()
{
    QString sleepAttr;
    if (getDaysSleep()>0)
	sleepAttr = attribut ("date_sleep",date_sleep.toString (Qt::ISODate) );
    return singleElement ("task",
	attribut ("status",getStatusString() ) +
	attribut ("awake",getAwakeString() ) +
	attribut ("date_creation",date_creation.toString (Qt::ISODate) ) +
	attribut ("date_modified",date_modified.toString (Qt::ISODate) ) +
	sleepAttr
     );
}
Exemple #12
0
//---------------------------------------------------------------------------
bool TRig::readAzEl(void)
{
 EOakStatus status;
 double prevEl, prevAz;

 std::vector<int> values;

   if(oakHandle < 0 || oak_flags&R_OAK_READING)
       return false;

   oak_flags |= R_OAK_READING;

   status = readInterruptReport(oakHandle, values);

   oak_flags &= ~R_OAK_READING;

   if(status != eOakStatusOK) {
       qDebug(getStatusString(status).c_str());
       return false;
   }
   else if(values.size() < 4)
       return false;

   prevEl = oakEl;
   prevAz = oakAz;


   oakEl = oakRadToDeg(values[2], oakChannelInfo[0]);
   oakAz = oakRadToDeg(values[3], oakChannelInfo[1]);

   if(oakEl < 0 || oakEl > 180 ||
      oakAz < 0 || oakAz > 360) {

      qDebug(" ");
      qDebug("* Error *");
      qDebug("El Degrees: %g", oakEl);
      qDebug("Az Degrees: %g", oakAz);

      return false;
   }


   if(oakEl > 90)
       oakEl = 180.0 - oakEl;

   qDebug(" ");
   qDebug("El Degrees: %f delta: %+f", oakEl, prevEl - oakEl);
   qDebug("Az Degrees: %f delta: %+f", oakAz, prevAz - oakAz);

 return true;
}
Exemple #13
0
std::ostream& HttpResponse::printHttpResponse(std::ostream& os) const {
  os << "HTTP/1.1 " << getStatusString(status) << "\r\n";

  for (auto pair: headers) {
    os << pair.first << ": " << pair.second << "\r\n";
  }
  os << "\r\n";

  if (!body.empty()) {
    os << body;
  }

  return os;
}
Exemple #14
0
QString Relation::toString() const
{
  stringstream ss(stringstream::out);
  ss << "relation(" << getId() << ")" << endl;
  ss << "type: " << getType() << endl;
  ss << "members: ";
  for (size_t i = 0; i < getMembers().size(); i++)
  {
    ss << "  " << getMembers()[i].toString().toUtf8().data() << endl;
  }
  ss << endl;
  ss << "tags: " << getTags().toString().toUtf8().data();
  ss << "status: " << getStatusString().toUtf8().data();
  return QString::fromUtf8(ss.str().data());
}
	char* Block::toString(void)
	{
		char tmp[4096];

		snprintf(tmp, sizeof(tmp),
			"BLOCK <%s>\n"
			" Info       : %s\n"
			" Input Pins : %d\n"
			" Output Pins: %d\n"
			" Status     : %s\n",
			getName(), getInfo(), _idp.getCount(), _odp.getCount(),
			getStatusString(getStatus()));

		_tostring.copy(tmp);
		return _tostring.toString();
	}
short ExExeUtilTcb::executeQuery(char * task, 
				 char * object,
				 char * query,
				 NABoolean displayStartTime,
				 NABoolean displayEndTime,
				 short &rc,
				 short * warning,
				 Lng32 * ec,
				 NABoolean moveErrorRow,
				 NABoolean continueOnError,
				 NABoolean monitorThis)
{
  short retcode = 0;
  char buf[BUFFER_SIZE];

  while (1)
    {
      switch (pqStep_)
	{
	case PROLOGUE_:
	  {
	    warning_ = 0;
	    startTime_ = NA_JulianTimestamp();
	    elapsedTime_ = 0;
	    if (displayStartTime)
	      {
		getStatusString(task, "Started", object, buf);
		if (moveRowToUpQueue(buf, 0, &rc))
		  return 1;
	      }

	    pqStep_ = EXECUTE_;
	    rc = WORK_RESCHEDULE_AND_RETURN;
	    return 1;
	  }
	  break;
	
	case EXECUTE_:
	  {
	    retcode = cliInterface()->fetchRowsPrologue(query,FALSE,monitorThis);
	    if (retcode < 0)
	      {
		pqStep_ = ERROR_RETURN_;
		break;
	      }
	    
	    pqStep_ = FETCH_ROW_;
	  }
	  break;
	
	case FETCH_ROW_:
	  {
	    retcode = (short)cliInterface()->fetch();
	    if (retcode < 0)
	      {
		pqStep_ = ERROR_RETURN_;
		break;
	      }
	    
	    if ((retcode > 0) &&
		(retcode != 100))
	      warning_ = retcode;

	    if ((retcode != 100) &&
		(cliInterface()->outputBuf()))
	      pqStep_ = RETURN_ROW_;
	    else
	      pqStep_ = CLOSE_;
	  }
	  break;
	
	case RETURN_ROW_:
	  {
	    char * ptr;
	    Lng32   len;
	    
	    cliInterface()->getPtrAndLen(1, ptr, len);
	    retcode = moveRowToUpQueue(ptr, len, &rc);
	    if (retcode)
	      return 1;
	    
	    pqStep_ = FETCH_ROW_;
	  }
	  break;
	
	case CLOSE_:
	  {
	    retcode = cliInterface()->fetchRowsEpilogue("");
	    if (retcode < 0)
	      {
		pqStep_ = ERROR_RETURN_;
		break;
	      }

	    pqStep_ = EPILOGUE_;
	  }
	  break;
	
	case EPILOGUE_:
	  {
            endTime_ = NA_JulianTimestamp();
            elapsedTime_ = endTime_ - startTime_;

	    if (displayEndTime)
	      {
		char timeBuf[200];
		getTimeAsString(elapsedTime_, timeBuf);
		getStatusString(task, "Ended", object, buf, timeBuf);
		if (moveRowToUpQueue(buf, 0, &rc))
		  return 1;
	      }

	    pqStep_ = ALL_DONE_;
	    rc = WORK_RESCHEDULE_AND_RETURN;
	    return 1;
	  }
	  break;
	
	case ERROR_RETURN_:
	  {
	    Lng32 sqlcode = 0;
	    char * stringParam1 = NULL;
	    Lng32   intParam1 = ComDiags_UnInitialized_Int;

	    retcode = (short)cliInterface()->retrieveSQLDiagnostics(getDiagsArea());
	    if (moveErrorRow)
	      {
		if (retcode == 0)
		  {
		    ComDiagsArea * da = getDiagsArea();
		    
		    sqlcode = (short)da->mainSQLCODE();
		    
		    ComCondition * cc;
		    if (sqlcode < 0)
		      cc = da->getErrorEntry(1);
		    else
		      cc = da->getWarningEntry(1);
		    
		    if (sqlcode < 0 && ec != NULL)
		      *ec = sqlcode;
		    
		    if (cc->getOptionalStringCharSet(0) == CharInfo::ISO88591 || cc->getOptionalStringCharSet(0) == CharInfo::UTF8)
		      stringParam1 = (char*)cc->getOptionalString(0);
		    else
		      stringParam1 = NULL;
		    intParam1    = cc->getOptionalInteger(0);
		  }
		else
		  {
		    sqlcode = retcode;
		  }
		
	 Lng32 errorBufLen = 
		  200 + (stringParam1 ? strlen(stringParam1) : 0);
		
		char * errorBuf = new(getHeap()) char[errorBufLen];
		
		str_sprintf(errorBuf, "%d", sqlcode);
		if (stringParam1)
		  str_sprintf(&errorBuf[strlen(errorBuf)], ", %s", stringParam1);
		if (intParam1 != ComDiags_UnInitialized_Int)
		  str_sprintf(&errorBuf[strlen(errorBuf)], ", %d", intParam1);
		
		char * outBuf = new(getHeap()) char[errorBufLen+400];
		getStatusString(task, "Error", NULL, outBuf,
				NULL, NULL,
				errorBuf);
		
		NADELETEBASIC(errorBuf, getHeap());
		
		if ((moveErrorRow) &&
		    (moveRowToUpQueue(outBuf, 0, &rc)))
		  {
		    NADELETEBASIC(outBuf, getHeap());
		    
		    return 1;
		  }

		NADELETEBASIC(outBuf, getHeap());
	      }

	    // close cursor, etc. Ignore errors.
	    cliInterface()->fetchRowsEpilogue("");

	    if (continueOnError)
	      {
		pqStep_ = ALL_DONE_;

		rc = WORK_RESCHEDULE_AND_RETURN;
		return 1;
	      }
	    else
	      {
		pqStep_ = PROLOGUE_;
		return -1;
	      }
	  }
	  break;

	case ALL_DONE_:
	  {
	    pqStep_ = PROLOGUE_;

	    if (warning)
	      *warning = warning_;

	    return 0;
	  }
	  break;
	
	}
    }
}
  bool SOFM2D::train(const dmatrix& data) {

    // tracks the status of the training process.
    // if an error occurs set to false and use setStatusString()
    // however, training should continue, fixing the error as well as possible
    bool b=true;

    int i;

    const parameters& param=getParameters();

    // find the actual size of the grid
    if (param.calculateSize) {
      b = calcSize(data);
    } else {
      sizeX=param.sizeX;
      sizeY=param.sizeY;
    }

    // check whether one of the dimensions has negative or zero size
    // and try to fix by using alternate way of setting sizes.
    if (sizeX<=0 || sizeY<=0) {
      b=false;
      std::string err="Negative or zero size of one dimension";
      if (param.calculateSize) {
        if (param.area<=0) {
          err += "\narea is <= 0";
          if (param.sizeX>0 && param.sizeY>0) {
            sizeX=param.sizeX;
            sizeY=param.sizeY;
            err += "\nusing sizeX and sizeY instead";
          }
        }
      } else {
        if (param.sizeX<=0) {
          err += "\nsizeX <= 0";
        }
        if (param.sizeY<=0) {
          err += "\nsizeY <= 0";
        }
        if (param.area>0) {
          err += "\ncalculating size from area instead";
          calcSize(data);
          err += getStatusString();
        }
      }
      setStatusString(err.c_str());
    }

    // set grid to size
    grid.resize(sizeY*sizeX, data.columns());

    //set learn rates
    setLearnRates(data.rows());

    if (validProgressObject()) {
      getProgressObject().reset();
      std::string str("SOFM2D: Training using ");
      switch(param.metricType) {
        case parameters::L1:
          str += "L1 distance";
          break;
        case parameters::L2:
          str += "L2 distance";
          break;
        case parameters::Dot:
          str += "dot product";
          break;
        default:
          str += "unnamed method";
      }
      char buffer[256];
      sprintf(buffer," size of map %i x %i", sizeY, sizeX);
      str += std::string(buffer);
      getProgressObject().setTitle(str);
      getProgressObject().setMaxSteps(param.stepsOrdering+param.stepsConvergence+2);
    }



    //initialize grid
    if (validProgressObject()) {
      getProgressObject().step("initializing map");
    }
    b = initGrid(data);

    //training
    if (param.metricType == parameters::Dot) {
      trainDot(data);
    } else {
      trainDist(data);
    }

    if (validProgressObject()) {
      getProgressObject().step("training finished");
    }


    int nbOutputs = sizeX*sizeY;

    //Put the id information into the result object
    //Each output value has the id of its position in the matrix
    ivector tids(nbOutputs);
    for (i=0; i<nbOutputs; i++) {
      tids.at(i)=i;
    }
    outTemplate=outputTemplate(tids);

    return b;
  }
Exemple #18
0
	HTTP_RESPONSE*
	resp_t::toHttpResponse(void)
	{
		//	std::lock_guard< std::mutex >	lck(m_mutex);
		HTTP_RESPONSE*					resp(new HTTP_RESPONSE);
		HTTP_RESPONSE_HEADERS*			hdrs(m_headers.getResponseHeaders());
		std::string						sc(getStatusString().toStdString());
		//QString							sc(getStatusString());
		BYTE*							buf(nullptr);
		HTTP_DATA_CHUNK*				chunk(new HTTP_DATA_CHUNK);
		std::size_t						len(m_body.size());

		::memset(resp, 0, sizeof(HTTP_RESPONSE));

		resp->StatusCode = m_status;
		resp->pReason = new CHAR[sc.length() + 1];
		::memset((void*)resp->pReason, 0, sc.length() + 1);
		::memcpy_s((void*)resp->pReason, sc.length() + 1, sc.c_str(), sc.length());

		resp->ReasonLength = ::strlen(resp->pReason);

		if (INT_MAX <= len)
			throw std::runtime_error("http::resp_t::toHttpResponse(): Overly large HTTP response encountered");

		buf = new BYTE[len + 1];

		::memset(buf, 0, len + 1);
		::memcpy_s(buf, len + 1, m_body.constData(), len);

		chunk->DataChunkType = HTTP_DATA_CHUNK_TYPE::HttpDataChunkFromMemory;
		chunk->FromMemory.pBuffer = buf;
		chunk->FromMemory.BufferLength = len;

		resp->pEntityChunks = chunk;
		resp->EntityChunkCount = 1;

		if (nullptr != hdrs) {
			::memcpy_s(resp->Headers.KnownHeaders, sizeof(resp->Headers.KnownHeaders), hdrs->KnownHeaders, sizeof(hdrs->KnownHeaders));

			resp->Headers.pTrailers = hdrs->pTrailers;
			resp->Headers.TrailerCount = hdrs->TrailerCount;
			resp->Headers.UnknownHeaderCount = hdrs->UnknownHeaderCount;

			if (0 != hdrs->UnknownHeaderCount) {
				//USHORT l = hdrs->UnknownHeaderCount;

				//if (USHRT_MAX-1 < l)
				//	throw std::runtime_error("http::resp_t::toHttpResponse(): Unusually large volume of unknown HTTP headers, aborting response.");


				//resp->Headers.pUnknownHeaders = new HTTP_UNKNOWN_HEADER[l+1];

				/*for (auto idx = 0; idx < l; idx++) {
					resp->Headers.pUnknownHeaders[idx].NameLength		= hdrs->pUnknownHeaders[idx].NameLength;
					resp->Headers.pUnknownHeaders[idx].RawValueLength	= hdrs->pUnknownHeaders[idx].RawValueLength;
					resp->Headers.pUnknownHeaders[idx].pName			= hdrs->pUnknownHeaders[idx].pName;
					*/

				resp->Headers.pUnknownHeaders = hdrs->pUnknownHeaders;

				//::memcpy_s(resp->Headers.pUnknownHeaders, (l+1)*sizeof(HTTP_UNKNOWN_HEADER), hdrs->pUnknownHeaders, l*sizeof(HTTP_UNKNOWN_HEADER));
			}

			//m_headers.destroyResponseHeaders(hdrs);

		}

		//m_log.info("unknown headers count: " + QString::number(resp->Headers.UnknownHeaderCount) + " name: " + QString(resp->Headers.pUnknownHeaders[0].pName) + " value: " + QString(resp->Headers.pUnknownHeaders[0].pRawValue));
		return resp;
	}
//////////////////////////////////////////////////////////////////////////
// Prints out an application
void Application::print() const {
  cout << "APPLICATION #: " << appNum << " for " << course->getName() 
       << " " << getStatusString(status) << endl;
}
Exemple #20
0
int main(int argc, char* argv[])
{
   uint8_t data_pin  = 0;
   uint8_t power_pin  = 0;
   DHT_MODEL_t model = AUTO_DETECT;
   int retry = MAX_RETRIES;
 
   
   /* Parse command line */
   switch (argc)
   {   
      case 2:  /* 1 paramters provided */
      case 3:  /* 2 paramters provided */
      case 4:  /* 3 paramters provided */
         /* Get first parameter: sensor type */ 
         if (strcmp(argv[1], "DHT11")==0) model = DHT11;
         else if (strcmp(argv[1], "DHT22")==0) model = DHT22;
         else
         {
            printf("Unknown sensor model %s\n", argv[1]);
            return -1;
         }

         /* Get second parameter: data pin */ 
         if (argc==3)
         {
            /* Get Kernel Id of data pin */
            data_pin = atoi(argv[2]);
         }
         
         /* Get third parameter: power pin */ 
         if (argc==4)
         {
            /* Get Kernel Id of power pin */
            power_pin = atoi(argv[3]);
         }
      break;
      
      default: /* print help message */
         printf("dhtsensor - read temperature and humidity data from DHT11 and DHT22 sensors\n\n");
         printf("Usage: dhtsensor <sensor type> [<data pin>] [<power pin>]\n");
         printf("       sensor type: DHT11|DHT22 \n");
         printf("       data pin:    Kernel Id of GPIO data pin (not needed for SPI communication mode)\n");
         printf("       power pin:   Kernel Id of GPIO power pin (optional)\n");
         return -1;
   }

   /* Power on the sensor */
   if (power_pin) dhtPoweron(power_pin);
   
   /* Init sensor communication */
   dhtSetup(data_pin, model);
   if (getStatus() != ERROR_NONE)
   {
      printf("Error during setup: %s\n", getStatusString());
      return -1;
   }

   /* Read sensor with retry */
   do    
   {
      readSensor();
   
      if (getStatus() == ERROR_NONE)
      {
         printf("Rel. Humidity: %3.1f %%\n", getHumidity());
         printf("Temperature:   %3.1f °C\n", getTemperature());
      }
      else
      {
         sleep(2);
      }
   }
   while ((getStatus() != ERROR_NONE) && retry--);
   
   if (getStatus() != ERROR_NONE)
   {
      printf("Error reading sensor: %s\n", getStatusString());
   }
   
   /* Cleanup */
   dhtCleanup();

   /* Power off the sensor */
   if (power_pin) dhtPoweroff(power_pin);
   
   return 0;
}
void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    painter->save();
    bool isHideState = true;
    if (Preferences::instance()->getHideZeroComboValues() == 1) {  // paused torrents only
        QModelIndex stateIndex = index.sibling(index.row(), TransferListModel::TR_STATUS);
        if (stateIndex.data().value<BitTorrent::TorrentState>() != BitTorrent::TorrentState::PausedDownloading)
            isHideState = false;
    }
    const bool hideValues = Preferences::instance()->getHideZeroValues() & isHideState;

    QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option);
    QItemDelegate::drawBackground(painter, opt, index);
    switch (index.column()) {
    case TransferListModel::TR_AMOUNT_DOWNLOADED:
    case TransferListModel::TR_AMOUNT_UPLOADED:
    case TransferListModel::TR_AMOUNT_DOWNLOADED_SESSION:
    case TransferListModel::TR_AMOUNT_UPLOADED_SESSION:
    case TransferListModel::TR_AMOUNT_LEFT:
    case TransferListModel::TR_COMPLETED:
    case TransferListModel::TR_SIZE:
    case TransferListModel::TR_TOTAL_SIZE: {
            qlonglong size = index.data().toLongLong();
            if (hideValues && !size)
                break;
            opt.displayAlignment = (Qt::AlignRight | Qt::AlignVCenter);
            QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size));
        }
        break;
    case TransferListModel::TR_ETA: {
        opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
        QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::userFriendlyDuration(index.data().toLongLong()));
        break;
    }
    case TransferListModel::TR_SEEDS:
    case TransferListModel::TR_PEERS: {
            qlonglong value = index.data().toLongLong();
            qlonglong total = index.data(Qt::UserRole).toLongLong();
            if (hideValues && (!value && !total))
                break;
            QString display = QString::number(value) + " (" + QString::number(total) + ')';
            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
        }
        break;
    case TransferListModel::TR_STATUS: {
            const auto state = index.data().value<BitTorrent::TorrentState>();
            QString display = getStatusString(state);
            QItemDelegate::drawDisplay(painter, opt, opt.rect, display);
        }
        break;
    case TransferListModel::TR_UPSPEED:
    case TransferListModel::TR_DLSPEED: {
            const int speed = index.data().toInt();
            if (hideValues && !speed)
                break;
            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true));
        }
        break;
    case TransferListModel::TR_UPLIMIT:
    case TransferListModel::TR_DLLIMIT: {
            const qlonglong limit = index.data().toLongLong();
            if (hideValues && !limit)
                break;
            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            QItemDelegate::drawDisplay(painter, opt, opt.rect, limit > 0 ? Utils::Misc::friendlyUnit(limit, true) : QString::fromUtf8(C_INFINITY));
        }
        break;
    case TransferListModel::TR_TIME_ELAPSED: {
            const int elapsedTime = index.data().toInt();
            const int seedingTime = index.data(Qt::UserRole).toInt();
            const QString txt = (seedingTime > 0)
                ? tr("%1 (seeded for %2)", "e.g. 4m39s (seeded for 3m10s)")
                    .arg(Utils::Misc::userFriendlyDuration(elapsedTime)
                        , Utils::Misc::userFriendlyDuration(seedingTime))
                : Utils::Misc::userFriendlyDuration(elapsedTime);
            QItemDelegate::drawDisplay(painter, opt, opt.rect, txt);
        }
        break;
    case TransferListModel::TR_ADD_DATE:
    case TransferListModel::TR_SEED_DATE:
        QItemDelegate::drawDisplay(painter, opt, opt.rect, index.data().toDateTime().toLocalTime().toString(Qt::DefaultLocaleShortDate));
        break;
    case TransferListModel::TR_RATIO_LIMIT:
    case TransferListModel::TR_RATIO: {
            const qreal ratio = index.data().toDouble();
            if (hideValues && (ratio <= 0))
                break;
            QString str = ((ratio == -1) || (ratio > BitTorrent::TorrentHandle::MAX_RATIO)) ? QString::fromUtf8(C_INFINITY) : Utils::String::fromDouble(ratio, 2);
            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            QItemDelegate::drawDisplay(painter, opt, opt.rect, str);
        }
        break;
    case TransferListModel::TR_PRIORITY: {
            const int priority = index.data().toInt();
            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            if (priority > 0) {
                QItemDelegate::paint(painter, opt, index);
            }
            else {
                QItemDelegate::drawDisplay(painter, opt, opt.rect, "*");
            }
        }
        break;
    case TransferListModel::TR_PROGRESS: {
            QStyleOptionProgressBar newopt;
            qreal progress = index.data().toDouble() * 100.;
            newopt.rect = opt.rect;
            newopt.text = ((progress == 100.0) ? QString("100%") : Utils::String::fromDouble(progress, 1) + '%');
            newopt.progress = static_cast<int>(progress);
            newopt.maximum = 100;
            newopt.minimum = 0;
            newopt.state |= QStyle::State_Enabled;
            newopt.textVisible = true;
#ifndef Q_OS_WIN
            QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
            // XXX: To avoid having the progress text on the right of the bar
            QProxyStyle st("fusion");
            st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
        }
        break;
    case TransferListModel::TR_LAST_ACTIVITY: {
            qlonglong elapsed = index.data().toLongLong();
            if (hideValues && ((elapsed < 0) || (elapsed >= MAX_ETA)))
                break;

            // Show '< 1m ago' when elapsed time is 0
            if (elapsed == 0)
                elapsed = 1;

            QString elapsedString = (elapsed >= 0)
                ? tr("%1 ago", "e.g.: 1h 20m ago").arg(Utils::Misc::userFriendlyDuration(elapsed))
                : Utils::Misc::userFriendlyDuration(elapsed);

            opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter;
            QItemDelegate::drawDisplay(painter, opt, option.rect, elapsedString);
        }
        break;
    default:
        QItemDelegate::paint(painter, option, index);
    }
    painter->restore();
}
static void
torrent_cell_renderer_get_size( GtkCellRenderer * cell,
                                GtkWidget *       widget,
                                GdkRectangle *    cell_area,
                                gint *            x_offset,
                                gint *            y_offset,
                                gint *            width,
                                gint *            height )
{
    TorrentCellRenderer * self = TORRENT_CELL_RENDERER( cell );

    if( self && self->priv->tor )
    {
        const tr_torrent *                  tor = self->priv->tor;
        const tr_info *                     info = tr_torrentInfo( tor );
        const char *                        name = info->name;
        const tr_stat *                     torStat =
            tr_torrentStatCached( (tr_torrent*)tor );
        char *                              str;
        int                                 w = 0, h = 0;
        struct TorrentCellRendererPrivate * p = self->priv;
        GtkCellRenderer *                   text_renderer =
            torStat->error != 0
            ? p->
            text_renderer_err
            : p->
            text_renderer;

        g_object_set( text_renderer, "ellipsize", PANGO_ELLIPSIZE_NONE,
                      NULL );

        /* above the progressbar */
        if( p->minimal )
        {
            int    w1, w2, h1, h2;
            char * shortStatus = getShortStatusString( torStat );
            g_object_set( text_renderer, "text", name, NULL );
            gtk_cell_renderer_get_size( text_renderer,
                                        widget, NULL, NULL, NULL, &w1, &h1 );
            str = g_markup_printf_escaped( "<small>%s</small>", shortStatus );
            g_object_set( text_renderer, "markup", str, NULL );
            gtk_cell_renderer_get_size( text_renderer,
                                        widget, NULL, NULL, NULL, &w2, &h2 );
            h += MAX( h1, h2 );
            w = MAX( w, w1 + GUI_PAD_BIG + w2 );
            g_free( str );
            g_free( shortStatus );
        }
        else
        {
            int    w1, h1;
            char * progressString = getProgressString( info, torStat );
            str = g_markup_printf_escaped( "<b>%s</b>\n<small>%s</small>",
                                           name, progressString );
            g_object_set( text_renderer, "markup", str, NULL );
            gtk_cell_renderer_get_size( text_renderer,
                                        widget, NULL, NULL, NULL, &w1, &h1 );
            h += h1;
            w = MAX( w, w1 );
            g_free( str );
            g_free( progressString );
        }

        /* below the progressbar */
        if( !p->minimal )
        {
            int    w1, h1;
            char * statusString = getStatusString( torStat );
            str = g_markup_printf_escaped( "<small>%s</small>",
                                           statusString );
            g_object_set( text_renderer, "markup", str, NULL );
            gtk_cell_renderer_get_size( text_renderer,
                                        widget, NULL, NULL, NULL, &w1, &h1 );
            h += h1;
            w = MAX( w, w1 );
            g_free( str );
            g_free( statusString );
        }

        h += p->bar_height;

        if( cell_area )
        {
            if( x_offset ) *x_offset = 0;
            if( y_offset )
            {
                *y_offset = 0.5 *
                            ( cell_area->height - ( h + ( 2 * cell->ypad ) ) );
                *y_offset = MAX( *y_offset, 0 );
            }
        }

        *width = w + cell->xpad * 2;
        *height = h + cell->ypad * 2;
    }
}
Exemple #23
0
VALUE set_internet_password_for(VALUE self, VALUE data) {
    VALUE ret = Qfalse;

    CHECK_FETCH_HASH_KEY(account)
    CHECK_FETCH_HASH_KEY(protocol)
    CHECK_FETCH_HASH_KEY(server)
    CHECK_FETCH_HASH_KEY(password)

    VALUE sym_auth = rb_eval_string(":auth");
    VALUE auth;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_auth)) {
        auth = kSecAuthenticationTypeDefault;
    } else {
        auth = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_auth), rb_intern("to_s"), 0);
        auth = String2FourChar(StringValuePtr(auth));
    }

    VALUE sym_port = rb_eval_string(":port");
    VALUE port;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_port)) {
        port = 0;
    } else {
        port = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_port), rb_intern("to_i"), 0);
        port = NUM2INT(port);
    }

    VALUE sym_path = rb_eval_string(":path");
    VALUE path;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_path)) {
        path = rb_str_new2("");
    } else {
        path = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_path), rb_intern("to_s"), 0);
    }

    OSStatus status = SecKeychainAddInternetPassword (
                          NULL,                                       // default keychain
                          strlen(StringValuePtr(server)),             // length of serverName
                          StringValuePtr(server),                     // serverName
                          0,                                          // length of domain
                          NULL,                                       // no domain
                          strlen(StringValuePtr(account)),            // length of account name
                          StringValuePtr(account),                    // account name
                          strlen(StringValuePtr(path)),               // length of path
                          StringValuePtr(path),                       // path
                          port,                                       // ignore port
                          String2FourChar(StringValuePtr(protocol)),  // protocol
                          auth,                                       // auth type
                          strlen(StringValuePtr(password)),
                          StringValuePtr(password),
                          NULL
                      );

    if (status == noErr) {
        ret = Qtrue;
    } else if (status == errSecDuplicateItem) {
        // Try updating instead
        SecKeychainItemRef itemRef = nil;

        status = SecKeychainFindInternetPassword (
                     NULL,                                       // default keychain
                     strlen(StringValuePtr(server)),             // length of serverName
                     StringValuePtr(server),                     // serverName
                     0,                                          // length of domain
                     NULL,                                       // no domain
                     strlen(StringValuePtr(account)),            // length of account name
                     StringValuePtr(account),                    // account name
                     strlen(StringValuePtr(path)),               // length of path
                     StringValuePtr(path),                       // path
                     port,                                       // ignore port
                     String2FourChar(StringValuePtr(protocol)),  // protocol
                     auth,
                     nil,
                     nil,
                     &itemRef
                 );

        if (status != noErr)
            rb_raise(rb_eStandardError, getStatusString(status));

        status = SecKeychainItemModifyAttributesAndData (
                     itemRef,                             // the item reference
                     NULL,                                // no change to attributes
                     strlen(StringValuePtr(password)),    // length of password
                     StringValuePtr(password)             // pointer to password data
                 );
        if (status != noErr)
            rb_raise(rb_eStandardError, getStatusString(status));

        ret = Qtrue;
    } else {
        rb_raise(rb_eStandardError, getStatusString(status));
    }

    return ret;
}
Exemple #24
0
VALUE internet_password_for(VALUE self, VALUE data) {
    VALUE ret = Qnil;

    CHECK_FETCH_HASH_KEY(account)
    CHECK_FETCH_HASH_KEY(protocol)
    CHECK_FETCH_HASH_KEY(server)

    VALUE sym_auth = rb_eval_string(":auth");
    VALUE auth;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_auth)) {
        auth = 0;
    } else {
        auth = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_auth), rb_intern("to_s"), 0);
        auth = String2FourChar(StringValuePtr(auth));
    }

    VALUE sym_port = rb_eval_string(":port");
    VALUE port;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_port)) {
        port = 0;
    } else {
        port = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_port), rb_intern("to_i"), 0);
        port = NUM2INT(port);
    }

    VALUE sym_path = rb_eval_string(":path");
    VALUE path;

    if (!rb_funcall(data, rb_intern("has_key?"), 1, sym_path)) {
        path = rb_str_new2("");
    } else {
        path = rb_funcall(rb_funcall(data, rb_intern("fetch"), 1, sym_path), rb_intern("to_s"), 0);
    }

    char *passwordData    = nil; // will be allocated and filled in by SecKeychainFindGenericPassword
    UInt32 passwordLength = nil;

    OSStatus status = SecKeychainFindInternetPassword (
                          NULL,                                       // default keychain
                          strlen(StringValuePtr(server)),             // length of serverName
                          StringValuePtr(server),                     // serverName
                          0,                                          // length of domain
                          NULL,                                       // no domain
                          strlen(StringValuePtr(account)),            // length of account name
                          StringValuePtr(account),                    // account name
                          strlen(StringValuePtr(path)),               // length of path
                          StringValuePtr(path),                       // path
                          port,                                       // ignore port
                          String2FourChar(StringValuePtr(protocol)),  // protocol
                          auth,
                          &passwordLength,
                          &passwordData,
                          NULL
                      );
    if (status == noErr) {
        ((char*)passwordData)[passwordLength] = '\0'; // Should this be necessary?
        ret = rb_str_new2(passwordData);
        SecKeychainItemFreeContent(NULL, passwordData);
    } else if (status == errSecItemNotFound) {
        ret = Qnil;
    } else if (status == errSecAuthFailed) {
        rb_raise(rb_eSecurityError, "Authorisation failed");
    } else {
        rb_raise(rb_eStandardError, getStatusString(status));
    }
    return ret;
}
EngineStatus IpoptEngine::solve()
{
  Ipopt::ApplicationReturnStatus status = Ipopt::Internal_Error; 
  bool should_stop;

  stats_->calls += 1;
  if (!(bndChanged_ || consChanged_)) {
    return status_;
  }
  // Check if warm start is enabled. If so, load the information and
  // resolve. Otherwise solve from scratch.
  if (useWs_ && ws_ && ws_->hasInfo()) {
    myapp_->Options()->SetStringValue("warm_start_init_point", "yes");
    if (true == strBr_) {
      mynlp_->copySolution(ws_->getPoint());
    } else {
      mynlp_->setSolution(ws_->getPoint());
    }
  } else {
    myapp_->Options()->SetStringValue("warm_start_init_point", "no");
  }

  if (consChanged_) {
    problem_->prepareForSolve(); // reset hessian and jacobian structures.
    setOptionsForProb_();
  }
  // Ask Ipopt to solve the problem. In order to do that, one should convert
  // mynlp_ from the derived class IpoptFunInterface (that we define) to
  // Ipopt::TNLP
  status_ = EngineUnknownStatus;
  //Ipopt::SmartPtr<Ipopt::TNLP> base = Ipopt::SmartPtr<Ipopt::TNLP>
  //(&(*mynlp_));
  timer_->start();
  should_stop = presolve_();
  stats_->ptime += timer_->query();
  if (should_stop) {
    if (status_== ProvenLocalOptimal) {
      status = Ipopt::Solve_Succeeded;
    } else if (status_ == ProvenLocalInfeasible) {
      status = Ipopt::Infeasible_Problem_Detected;
    }
  } else if (ws_ && ws_->hasInfo() && stats_->calls > 1) {
    status = myapp_->ReOptimizeTNLP(mynlp_);
  } else {
    status = myapp_->OptimizeTNLP(mynlp_);
  }

#if SPEW
  logger_->msgStream(LogDebug) << me_ << "time taken = " << timer_->query() 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "Ipopt's status = " << status 
    << std::endl;
#endif
  //exit(0);

  // See IpReturnCodes_inc.h for the list
  switch (status) {
   case Ipopt::Solve_Succeeded : 
     status_ = ProvenLocalOptimal;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Solved_To_Acceptable_Level :
     status_ = ProvenLocalOptimal;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Infeasible_Problem_Detected :
     status_ = ProvenLocalInfeasible;
     break;
   case Ipopt::Maximum_Iterations_Exceeded :
     status_ = EngineIterationLimit;
     break;
   case Ipopt::Maximum_CpuTime_Exceeded :
     status_ = EngineIterationLimit;
     break;
   case Ipopt::Restoration_Failed :  // don't know what else to do.
     logger_->msgStream(LogInfo) << me_ << "restoration failed, "
       << "assuming local infeasible." << std::endl;
     status_ = ProvenLocalInfeasible;
     sol_ = mynlp_->getSolution();
     break;
   case Ipopt::Diverging_Iterates :
     status_ = ProvenUnbounded;
     break;
   case Ipopt::Search_Direction_Becomes_Too_Small :
     assert(!"Ipopt: search direction becomes too small.");
     break;
   case Ipopt::User_Requested_Stop:
     assert(!"Ipopt: user requested stop.");
     break;
   case Ipopt::Feasible_Point_Found:
     assert(!"Ipopt: feasible point found.");
     break;
   case Ipopt::Error_In_Step_Computation:
   case Ipopt::Not_Enough_Degrees_Of_Freedom:
   case Ipopt::Invalid_Problem_Definition:
   case Ipopt::Invalid_Option:
   case Ipopt::Invalid_Number_Detected:
   case Ipopt::Unrecoverable_Exception:
   case Ipopt::NonIpopt_Exception_Thrown:
   case Ipopt::Insufficient_Memory:
   case Ipopt::Internal_Error:
   default:
     logger_->msgStream(LogNone) << me_ << "error reported." << std::endl;
     status_ = EngineError;
  }
  if (prepareWs_) {
    // save warm start information
    ws_->setPoint(sol_);
  }

  Ipopt::SmartPtr<Ipopt::SolveStatistics> stats = myapp_->Statistics();
  // sometimes, (e.g. when all variables are fixed) ipopt does not solve
  // anything returns an empty Statistics object.
  UInt iters = (Ipopt::IsValid(stats)) ? stats->IterationCount() : 0;
#if SPEW
  logger_->msgStream(LogDebug) << me_ << "solve number = " << stats_->calls
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "number of iterations = " << iters 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "status = " << getStatusString() 
    << std::endl;
  logger_->msgStream(LogDebug) << me_ << "obj = ";
  if (sol_) {
    logger_->msgStream(LogDebug) << mynlp_->getSolutionValue() << std::endl;
  } else {
    logger_->msgStream(LogDebug) << 1e40 << std::endl;
  }
#endif 
  if (true == strBr_) {
    stats_->strCalls += 1;
    stats_->strTime  += timer_->query();
    stats_->strIters += iters;
  } 
  stats_->time  += timer_->query();
  stats_->iters += iters;
  timer_->stop();

  bndChanged_ = false;
  consChanged_ = false;
  return status_;
}
Exemple #26
0
void ofxSickGrabber::connect() {
	ofLogVerbose("ofxSickGrabber") << "Connecting @ " << ip;
	laser.connect(ip);
	if(!laser.isConnected()) {
		ofLogError("ofxSickGrabber") << "Connection failed @ " << ip;
		return;
	}
	
	ofLogVerbose("ofxSickGrabber") << "Logging in.";
	laser.login();
	
	laser.stopMeas(); // unnecessary?
	
	scanCfg targetCfg;
	targetCfg.angleResolution = angularResolution * 1000;
	targetCfg.scaningFrequency = scanningFrequency * 100;
	targetCfg.startAngle = startAngle * 10000; // 0 defaults to -45 * 10000.
	targetCfg.stopAngle = stopAngle * 10000; // 0 defaults to 225 * 10000.
	
	ofLogVerbose("ofxSickGrabber") << "Setting new scan configuration.";
	laser.setScanCfg(targetCfg);
	
	ofLogVerbose("ofxSickGrabber") << "Updating current scan configuration.";
	scanCfg curCfg = laser.getScanCfg();
	
	scanningFrequency = curCfg.scaningFrequency / 100.;
	angularResolution = curCfg.angleResolution / 10000.;
	startAngle = curCfg.startAngle / 10000.;
	stopAngle = curCfg.stopAngle / 10000.;	
	ofLogVerbose("ofxSickGrabber") << scanningFrequency << "Hz at " << angularResolution << "deg, from " << startAngle << "deg to " << stopAngle << "deg";
	
	confirmCfg(curCfg.angleResolution, targetCfg.angleResolution, "angular resolution");
	confirmCfg(curCfg.scaningFrequency, targetCfg.scaningFrequency, "scanning frequency");
	confirmCfg(curCfg.startAngle, targetCfg.startAngle, "start angle");
	confirmCfg(curCfg.stopAngle, targetCfg.stopAngle, "stop angle");
	
	bool enableSecondReturn = false;
	scanDataCfg targetDataCfg;
	targetDataCfg.deviceName = false;
	targetDataCfg.encoder = 0;
	targetDataCfg.outputChannel = enableSecondReturn ? 3 : 1;
	targetDataCfg.remission = false;
	targetDataCfg.resolution = 0; // 8-bit remission values
	targetDataCfg.position = false;
	targetDataCfg.outputInterval = 1; // don't skip any frames
	
	ofLogVerbose("ofxSickGrabber") << "Setting scan data configuration.";
	laser.setScanDataCfg(targetDataCfg);
	
	ofLogVerbose("ofxSickGrabber") << "Start measurments.";
	laser.startMeas();
	
	ofLogVerbose("ofxSickGrabber") << "Wait for ready status.";
	int ret = 0, prevRet = 0;
	while (ret != 7) {
		ret = laser.queryStatus();
		if(ret != prevRet) {
			ofLogVerbose("ofxSickGrabber") << "Status: " << getStatusString(ret);
		}
		prevRet = ret;
		ofSleepMillis(10);
	}
	ofLogVerbose("ofxSickGrabber") << "Ready, starting continuous data transmission.";
	laser.scanContinous(1);
}
Exemple #27
0
void PackerJob::createToolTip()
{
	mir_snwprintf(uDlg->m_tszToolTipText, TranslateT("Status: %s\r\nFile: %s\r\nServer: %S"),
		getStatusString(), m_tszFileName, m_ftp->m_szServer);
}