/** displayes clique hash table */
static
void printCliquehash(
   CLIQUEHASH*      cliquehash          /**< clique hash table */
   )
{
   int i;

   assert(cliquehash != NULL);

   debugMessage("cliquehash (%d cliques):\n", cliquehash->ncliques);
   for( i = 0; i < cliquehash->ncliques; ++i )
   {
      int j;

      debugPrintf("%d:", i);
      for( j = 0; j < cliquehash->cliques[i]->nnodes; ++j )
         debugPrintf(" %d", cliquehash->cliques[i]->nodes[j]);
      debugPrintf("\n");
   }
}
Exemple #2
0
/**
 * @brief WebRequest::sendDataToServer
 * @param msg
 * @param serial
 */
void WebRequest::sendDataToServer(const QString msg, const QString serial)
{
    debugMessage();

    QNetworkRequest request;
    QByteArray  temp = msg.toUtf8();
    QString     webRequest = CBluuSettingsManager::Instance()->getWebRequestAddress();
    QString     siteId = CBluuSettingsManager::Instance()->getSiteId();
    QString     userId = CBluuSettingsManager::Instance()->getUserId();
    QString     userPassword = CBluuSettingsManager::Instance()->getUserPassword();
    QString     urlStr;
    QUrl        url;

    whoSend = sender();
    urlStr = QString("%1%2/devices/%3/statuses/").arg(webRequest).arg(siteId).arg(serial);
    url = QUrl(urlStr);
    request.setUrl(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
    request.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg(userId).arg(userPassword).toAscii()).toBase64());
    manager->post(request, temp);
}
Exemple #3
0
void Groupwise::get(const KURL &url)
{
    kdDebug(7000) << "Groupwise::get()" << endl;
    kdDebug(7000) << " URL: " << url.url() << endl;
#if 1
    kdDebug(7000) << " Path: " << url.path() << endl;
    kdDebug(7000) << " Query: " << url.query() << endl;
    kdDebug(7000) << " Protocol: " << url.protocol() << endl;
    kdDebug(7000) << " Filename: " << url.filename() << endl;
#endif

    mimeType("text/plain");

    QString path = url.path();
    debugMessage("Path: " + path);

    if(path.contains("/freebusy"))
    {
        getFreeBusy(url);
    }
    else if(path.contains("/calendar"))
    {
        getCalendar(url);
    }
    else if(path.contains("/addressbook"))
    {
        if(url.query().contains("update=true"))
            updateAddressbook(url);
        else
            getAddressbook(url);
    }
    else
    {
        QString error = i18n("Unknown path. Known paths are '/freebusy/', "
                             "'/calendar/' and '/addressbook/'.") + QString(" path was %1").arg(url.url());
        errorMessage(error);
    }

    kdDebug(7000) << "Groupwise::get() done" << endl;
}
/** Push new element on the parse stack.
 *
 *  TRUE if it worked, FAILURE otherwise.
 */
static
XML_Bool push_pstack(
   PPOS*                 ppos,
   XML_NODE*             node
   )
{
   PSTACK* p;

   assert(ppos != NULL);
   assert(node != NULL);

   debugMessage("Pushing %s\n", node->name);

   ALLOC_FALSE( BMSallocMemory(&p) );
   assert(p != NULL);

   p->node   = node;
   p->next   = ppos->top;
   ppos->top = p;

   return TRUE;
}
void RemoteGdbAdapter::startAdapter()
{
    QTC_ASSERT(state() == EngineStarting, qDebug() << state());
    setState(AdapterStarting);
    debugMessage(_("TRYING TO START ADAPTER"));

    // FIXME: make asynchroneous
    // Start the remote server
    if (startParameters().serverStartScript.isEmpty()) {
        m_engine->showStatusMessage(_("No server start script given. "
                                      "Assuming server runs already."));
    } else {
        m_uploadProc.start(_("/bin/sh ") + startParameters().serverStartScript);
        m_uploadProc.waitForStarted();
    }

    if (!m_engine->startGdb(QStringList(), startParameters().debuggerCommand))
        // FIXME: cleanup missing
        return;

    emit adapterStarted();
}
void FAccount::loginHandle()
{
	debugMessage("account->loginHandle()");
	loginReply->deleteLater();

	ticket = loginReply->ticket->ticket;
	delete loginReply->ticket;
	ticketvalid = true;

	defaultCharacter = loginReply->defaultCharacter;
	characterList = loginReply->characters;

	//todo: extract bookmarks
	//todo: extract friends list
	//todo: extract ignore list
	//todo: extract?

	//todo: get rid of this:
	charactersessions.append(new FSession(this, defaultCharacter, this));

	emit loginComplete(this);
	//emit ticketReady(this, ticket);
}
//______________________________________________________________________________
void scopeConfigReader::addToScopeTraceDataObjectsV1( const std::vector<std::string> &keyVal )
{
    if( keyVal[0] == UTL::NAME )
    {
        scopeStructs::scopeTraceData scotrob = scopeStructs::scopeTraceData();
        scotrob.name = keyVal[ 1 ];
        scopeTraceDataObjects.push_back( scotrob );
        debugMessage("Added ", scopeTraceDataObjects.back().name );
    }
    else if( keyVal[0] == UTL::PV_ROOT )
    {
        scopeTraceDataObjects.back().pvRoot = keyVal[ 1 ];
    }

    else if( keyVal[0] == UTL::TIMEBASE )
    {
        scopeTraceDataObjects.back().timebase = getNumD( keyVal[ 1 ] );
    }

    else if( keyVal[0] == UTL::DIAG_TYPE )
    {
        scopeTraceDataObjects.back().diagType = getDiagType( keyVal[ 1 ] );
    }
}
Exemple #8
0
	void write(LogMessageType type, const char* msg, ...)
	{
	#if XL_LOGGING_ENABLED || XL_DEBUG_OUT_ENABLED
		assert(type < LOG_COUNT);

		//first build up the string.
		va_list arg;
		va_start(arg, msg);
		int res = vsprintf(s_tmpBuffer, msg, arg);
		va_end(arg);
	#endif

	#if XL_LOGGING_ENABLED
		sprintf(s_printString, "%s%s\r\n", c_logMsgType[type], s_tmpBuffer);
		const size_t len = strlen(s_printString);

		s_logFile.write(s_printString, (u32)len);
	#endif

	#if XL_DEBUG_OUT_ENABLED
		sprintf(s_printString, "%s%s\n", c_logMsgType[type], s_tmpBuffer);
		debugMessage(s_printString);
	#endif
	}
Exemple #9
0
int routingHandler::backupValues(){
	debugMessage("Saving RoutingTables");
	int saveRTTReturnValue = saveRTTTables();
	switch(saveRTTReturnValue){
	case -1: debugMessage("Could not read "+fileRTTables); return RH_BACKUPVALUES_RT_NOREAD;
	case -2: debugMessage("Could not write BackupFile"); return RH_BACKUPVALUES_RT_NOWRITE;
	default: debugMessage("OK"); break;
	}

	debugMessage("Saving IP Tables");
	int saveIPTablesReturnValue = saveIPTables();
	if(saveIPTablesReturnValue != 0){
		return RH_BACKUPVALUES_IP_NOSAVE;
	}

	debugMessage("Saving RP Filter");
	int saveRPFilterReturnValue  = backupRpFilter();
	if(saveRPFilterReturnValue != 0){
		return RH_BACKUPVALUES_RPF_NOSAVE;
	}

	return 0;
}
Exemple #10
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(isAtHome(usedon))
  {
    systemMessage(user, "That belongs to someone else.");
    return(0x00);
  }
  int Q62A = getObjType(this);
  int Q66P = getObjType(usedon);
  loc Q66U = loc( getLocation(user) );
  loc Q61U = loc( getLocation(this) );
  loc Q66N = loc( getLocation(usedon) );
  obj Q4EZ;
  list args;
  if(testAndLearnSkill(user, 0x08, 0x00, 0x50) > 0x00)
  {
    switch(Q62A)
    {
    case 0x1BD1:
      switch(Q66P)
      {
      case 0x1BD4:
        attachScript(user, "makingarrows");
        args = list( this, usedon );
        message(user, "makearrows", args);
        break;
      default:
        systemMessage(user, "Can't use feathers on that.");
        return(0x00);
        break;
      }
      break;
    case 0x1BD4:
      switch(Q66P)
      {
      case 0x1BD1:
        attachScript(user, "makingarrows");
        args = list( usedon, this );
        message(user, "makearrows", args);
        break;
      default:
        systemMessage(user, "Can't use shafts on that.");
        return(0x00);
        break;
      }
      break;
    default:
      return(0x00);
      break;
    }
  }
  else
  {
    systemMessage(user, "Fletching failed.");
    int Q5MT;
    int Q4Q1;
    if(!random(0x00, 0x03))
    {
      debugMessage("!rand");
      debugMessage("thistype = " + Q62A);
      if(Q62A == 0x1BD1)
      {
        systemMessage(user, "A feather was destroyed.");
        returnResourcesToBank(this, 0x01, "feathers");
        Q4Q1 = getResource(Q5MT, this, "feathers", 0x03, 0x02);
      }
      if(Q62A == 0x1BD4)
      {
        systemMessage(user, "A shaft was destroyed.");
        returnResourcesToBank(this, 0x01, "wood");
        Q4Q1 = getResource(Q5MT, this, "wood", 0x03, 0x02);
      }
      if(Q5MT < 0x01)
      {
        deleteObject(this);
      }
    }
  }
  return(0x01);
}
Exemple #11
0
/*
 * This function loads all of the images into the program
 */
void LoadAllImages() {
    pageImages = LoadImages(IMAGE_LOCATION, pageFiles);
    viewImages = LoadImages(IMAGE_LOCATION, viewFiles);
    backProjectSample = LoadImages(IMAGE_LOCATION, backProjectFiles);
    debugMessage("Loaded all images successfully");
}
ChessPlayer* EngineBuilder::create(QObject* receiver,
				   const char* method,
				   QObject* parent,
				   QString* error) const
{
	QString workDir = m_config.workingDirectory();
	QString cmd = m_config.command().trimmed();
	QString stderrFile = m_config.stderrFile();

	if (cmd.isEmpty())
	{
		setError(error, tr("Empty engine command"));
		return nullptr;
	}

	if (!EngineFactory::protocols().contains(m_config.protocol()))
	{
		setError(error, tr("Unknown chess protocol: %1")
			 .arg(m_config.protocol()));
		return nullptr;
	}

	EngineProcess* process = new EngineProcess();

	if (workDir.isEmpty())
	{
		process->setWorkingDirectory(QDir::tempPath());

		QFileInfo cmdInfo(cmd);
		if (cmdInfo.isFile())
			cmd = cmdInfo.absoluteFilePath();
	}
	else
		process->setWorkingDirectory(workDir);

	if (!stderrFile.isEmpty())
		process->setStandardErrorFile(stderrFile, QIODevice::Append);

	if (!m_config.arguments().isEmpty())
		process->start(cmd, m_config.arguments());
	else
		process->start(cmd);

	bool ok = process->waitForStarted();
	if (!ok)
	{
		setError(error, tr("Cannot execute command: %1")
			 .arg(m_config.command()));
		delete process;
		return nullptr;
	}

	ChessEngine* engine = EngineFactory::create(m_config.protocol());
	Q_ASSERT(engine != nullptr);

	engine->setParent(parent);
	if (receiver != nullptr && method != nullptr)
		QObject::connect(engine, SIGNAL(debugMessage(QString)),
				 receiver, method);
	engine->setDevice(process);
	engine->applyConfiguration(m_config);

	engine->start();
	return engine;
}
Exemple #13
0
void Groupwise::getAddressbook(const KURL &url)
{
    QString u = soapUrl(url);

    QString user = url.user();
    QString pass = url.pass();

    debugMessage("URL: " + u);
    debugMessage("User: "******"Password: "******"?")
    {
        errorMessage(i18n("No addressbook IDs given."));
    }
    else
    {
        QStringList ids;

        query = query.mid(1);
        QStringList queryItems = QStringList::split("&", query);
        QStringList::ConstIterator it;
        for(it = queryItems.begin(); it != queryItems.end(); ++it)
        {
            QStringList item = QStringList::split("=", (*it));
            if(item.count() == 2 && item[ 0 ] == "addressbookid")
            {
                ids.append(item[ 1 ]);
            }
        }

        debugMessage("IDs: " + ids.join(","));

        GroupwiseServer server(u, user, pass, 0);

        connect(&server, SIGNAL(readAddressBookTotalSize(int)),
                SLOT(slotReadAddressBookTotalSize(int)));
        connect(&server, SIGNAL(readAddressBookProcessedSize(int)),
                SLOT(slotReadAddressBookProcessedSize(int)));
        connect(&server, SIGNAL(errorMessage(const QString &, bool)),
                SLOT(slotServerErrorMessage(const QString &, bool)));
        connect(&server, SIGNAL(gotAddressees(const KABC::Addressee::List)),
                SLOT(slotReadReceiveAddressees(const KABC::Addressee::List)));

        kdDebug() << "Login" << endl;
        if(!server.login())
        {
            errorMessage(i18n("Unable to login: "******"Read Addressbook" << endl;
            if(!server.readAddressBooksSynchronous(ids))
            {
                errorMessage(i18n("Unable to read addressbook data: ") + server.errorText());
            }
            kdDebug() << "Logout" << endl;
            server.logout();
            finished();
        }
    }
}
  ComplexFloatArrayTestPatch(){
    success=true;
    debugMessage("start");
    passed=0;
    failed=0;
    int size=100;
    ComplexFloat data[size];
    ComplexFloat backupData[size];
    for(int n=0; n<size; n++){ //initialize array
      float value= n<size/2 ? n : size-n; 
      data[n].re=backupData[n].re=value;
      data[n].im=backupData[n].im=-value;
    }
    ComplexFloatArray cfa(data,size);
    ComplexFloatArray backupcf(backupData,size);
    ComplexFloat tempcData[size]; 
    ComplexFloatArray tempc(tempcData,size);
    ComplexFloat tempc2Data[size]; 
    ComplexFloatArray tempc2(tempc2Data,size);
    float tempfData[size]; 
    FloatArray tempf(tempfData,size);
        
    assertr(cfa.getSize()==size,"ComplexFloatArray.getSize()");
    for(int n=0; n<size; n++){ 
      //checking cast and indexing operators
      assertr(cfa[n].re==data[n].re,"ComplexFloat& operator []");
      assertr(cfa[n].im==data[n].im,"ComplexFloat& operator []");
      assertr((ComplexFloat*)cfa==data,"(ComplexFloat*)cfa==data");
      assertr((float*)cfa==(float *)data,"(ComplexFloat*)cfa==data");
      assertr(&cfa[n]==&data[n],"cfa[n]==data[n]");
      
      //check that indexing works properly overlaying struct and float
      float *f=(float*)data;
      assertr(data[n].re==f[2*n],"data[n].re==f[2*n]");
      assertr(data[n].im==f[2*n+1],"data[n].im==f[2*n+1]");
      //checking scalar complex math functions
      assertr(cfa.mag(n)==sqrtf(f[2*n]*f[2*n]+f[2*n+1]*f[2*n+1]),"mag");
      assertr(cfa.mag2(n)==f[2*n]*f[2*n]+f[2*n+1]*f[2*n+1],"mag2");
    }
    
    //test equals(ComplexFloatArray) method
    {
      tempc.copyFrom(cfa);
      assertr(cfa.equals(tempc), ".equals()");
      
    }
    cfa.getMagnitudeValues(tempf);
    for(int n=0; n<size; n++){
      assertr(tempf[n]==sqrtf(cfa[n].re*cfa[n].re+cfa[n].im*cfa[n].im),"getMagnitudeValues", n);
    }
    cfa.getMagnitudeSquaredValues(tempf);
    for(int n=0; n<size; n++){
      assertr(tempf[n]==cfa[n].re*cfa[n].re+cfa[n].im*cfa[n].im,"getMagnitudeSquaredValues");
    }
    cfa.getComplexConjugateValues(tempc);
    for(int n=0; n<size; n++){
      assertr(tempc[n].re==cfa[n].re,"getComplexConjugateValues-real");
      assertr(tempc[n].im==-cfa[n].im,"getComplexConjugateValues-imag");
    }
    cfa.complexByComplexMultiplication(tempc, tempc2);
    for(int n=0; n<size; n++){
      assertr(tempc2[n].re==cfa[n].re*tempc[n].re - cfa[n].im*tempc[n].im,"complexByComplexMultiplication-real");
      assertr(tempc2[n].im==cfa[n].re*tempc[n].im + cfa[n].im*tempc[n].re,"complexByComplexMultiplication-imag");
    }
    cfa.complexByRealMultiplication(tempf, tempc2);
    for(int n=0; n<size; n++){
      assertr(tempc2[n].re==cfa[n].re*tempf[n],"complexByRealMultiplication-real");
      assertr(tempc2[n].im==cfa[n].im*tempf[n],"complexByRealMultiplication-imag");
    }
    
  //ComplexDotProduct
    ComplexFloat tempcf;
    for(int n=0; n<size; n++){
      tempcData[n].re=backupData[n].re=n*2;
      tempcData[n].im=backupData[n].im=-(n*2+1);
    }
    cfa.complexDotProduct(tempc, tempcf);
    float realResult=0;
    float imagResult=0;
    for(int n=0; n<size; n++) {    
      realResult += cfa[n].re*tempc[n].re - cfa[n].im*tempc[n].im;
      imagResult += cfa[n].re*tempc[n].im + cfa[n].im*tempc[n].re;
    }
    assertr(realResult==tempcf.re,"duct-re");
    assertr(imagResult==tempcf.im,"duct-im");

    float maxMagVal=-1;
    int maxMagInd=-1;
    for(int n=0; n<size; n++){
      if(cfa.mag(n)>maxMagVal){
        maxMagVal=cfa.mag(n);
        maxMagInd=n;
      }
    }
    assertr(maxMagVal==cfa.getMaxMagnitudeValue(),"getMaxMagnitudeValue()");
    assertr(maxMagInd==cfa.getMaxMagnitudeIndex(),"getMaxMagnitudeIndex()");
    
    cfa.getRealValues(tempf);
    for(int n=0; n<size; n++){
      assertr(tempf[n]==cfa[n].re,"getRealValues");
    }
    cfa.getImaginaryValues(tempf);
    for(int n=0; n<size; n++){
      assertr(tempf[n]==cfa[n].im,"getImaginaryValues");
    }
    
    //test setAll
    // test setAll(float)
    {
      for(int n=0; n<size; n++){
        tempc[n].re=1;
        tempc[n].im=1;
      }
      float allValue=0.1;
      tempc.setAll(allValue);
      for(int n=0; n<size; n++){
        assertr(tempc[n].re==allValue, "setAll(float) real");
        assertr(tempc[n].im==allValue, "setAll(float) imag");
      }
    }
      // test setAll(float, float)
    {
      float allValueRe=0.3;
      float allValueIm=-0.3;
      tempc.setAll(allValueRe, allValueIm);
      for(int n=0; n<size; n++){
        assertr(tempc[n].re==allValueRe, "setAll(float, float) real");
        assertr(tempc[n].im==allValueIm, "setAll(float, float) imag");
      }
    }
      // test setAll(ComplexFloat)
    {
      ComplexFloat allValue;
      allValue.re=0.4;
      allValue.im=-0.1;
      tempc.setAll(allValue);
      for(int n=0; n<size; n++){
        assertr(tempc[n].re==allValue.re, "setAll(ComplexFloat) real");
        assertr(tempc[n].im==allValue.im, "setAll(ComplexFloat) imag");
      }
    }
    
    //test copyFrom
    //test copyFrom(FloatArray)
    tempc.setAll(0);
    tempc.copyFrom(tempf);
    for(int n=0; n<size; n++){
      assertr(tempf[n]==tempc[n].re, "copyFrom(FloatArray)");
    }
    //test copyFrom(ComplexFloatArray)
    tempc.setAll(0);
    tempc.copyFrom(cfa);
    for(int n=0; n<size; n++){
      assertr(cfa[n].re==tempc[n].re, "copyFrom(ComplexFloatArray), real");
      assertr(cfa[n].im==tempc[n].im, "copyFrom(ComplexFloatArray), imag");
    }
    //test copyFrom(ComplexFloat *, int)
    tempc.setAll(0);
    tempc.copyFrom(cfa.getData(), cfa.getSize());
    for(int n=0; n<size; n++){
      assertr(cfa[n].re==tempc[n].re, "copyFrom(ComplexFloat*, int), real");
      assertr(cfa[n].im==tempc[n].im, "copyFrom(ComplexFloat*, int), imag");
    }
    
      //test ComplexFloat methods

    {
      ASSERT(tempc.getSize()==size,"tempc");
      //test ComplexFloat.setPolar()
      ComplexFloat i;
      i.re=0;
      i.im=0;
      float magnitude=rand()/(float)RAND_MAX*10;
      float phase=rand()/(float)RAND_MAX*2*M_PI - M_PI;
      i.setPolar(magnitude, phase);
      assertr(i.re=magnitude*cosf(phase),"ComplexFloat setPolar() real");
      assertr(i.im=magnitude*sinf(phase),"ComplexFloat setPolar() imag");
      //test ComplexFloat.getPhase()
      assertt(i.getPhase(),phase, "ComplexFloat getPhase()");
      //test ComplexFloat.getMagnitude()
      // debugMessage("magnitude",i.getMagnitude(),magnitude, phase);
      assertt(i.getMagnitude(),magnitude, "ComplexFloat getMagnitude()", 0.0001);
    }
    {
      //test ComplexFloat.setMagnitude()
      ComplexFloat i;
      float magnitude=rand()/(float)RAND_MAX*10;
      float phase=rand()/(float)RAND_MAX*2*M_PI - M_PI;
      i.setPolar(magnitude,phase);
      float newMagnitude=magnitude+1;
      i.setMagnitude(newMagnitude);
      assertt(i.getMagnitude(), newMagnitude, "ComplexFloat setMagnitude() magnitude", 0.0001);
      assertt(i.getPhase(), phase, "ComplexFloat setMagnitude() phase", 0.0001); //check that the phase has not changed
    }
    {
      //test ComplexFloat.setPhase()
      ComplexFloat i;
      float magnitude=rand()/(float)RAND_MAX*10;
      float phase=rand()/(float)RAND_MAX*2*M_PI - M_PI;
      i.setPolar(magnitude,phase);
      float newPhase=phase+1;
      i.setPhase(newPhase);
      assertt(i.getPhase(), newPhase, "ComplexFloat setPhase() phase", 0.0001);
      assertt(i.getMagnitude(), magnitude, "ComplexFloat setPhase() magnitude", 0.0001); //check that the magnitude has not changed
    }
    {
      // test ComplexFloatArray.setPhase()
      tempc.copyFrom(cfa);
      FloatArray phase=FloatArray::create(size);
      phase.noise(-M_PI, M_PI);
      // setPhase(FloatArray)
      tempc.setPhase(phase);
      for(int n=0; n<size; n++){
        if(cfa[n].getMagnitude()<0.001)
          continue; //skip small values of magnitude which would make the phase noisy
        assertt(tempc[n].getPhase(), phase[n], "setPhase() phase", 0.01);
        assertt(tempc[n].getMagnitude(), cfa[n].getMagnitude(), "setPhase() magnitude", 0.01);
      }
      // setPhase(FloatArray, int, int)
      int offset=size/3;
      int count= size/2;
      tempc.copyFrom(cfa);
      tempc.setPhase(phase, offset, count);
      for(int n=0; n<size; n++){
        if(n>=offset && n<offset+count){
          if(cfa[n].getMagnitude()<0.001)
            continue; //skip small values of magnitude which would make the phase noisy
          assertt(tempc[n].getPhase(), phase[n], "setPhase() phase wrong", 0.01);
          assertt(tempc[n].getMagnitude(), cfa[n].getMagnitude(), "setPhase() magnitude wrong", 0.01);
        } else { //check that values outside the range have not changed
          assertr(tempc[n].getPhase()==cfa[n].getPhase(), "setPhase() phase changed", 0);
          assertr(tempc[n].getMagnitude()==cfa[n].getMagnitude(), "setPhase() magnitude changed", 0);
        }
      }
      
      // test ComplexFloatArray.setMagnitude()
      tempc.copyFrom(cfa);
      FloatArray magnitude=FloatArray::create(size);
      magnitude.noise(0, 10);
      // setMagnitude(FloatArray)
      tempc.setMagnitude(magnitude);
      for(int n=0; n<size; n++){
        if(cfa[n].getMagnitude()<0.001 || tempc[n].getMagnitude()<0.001)
          continue; //skip small values of magnitude which would make the phase noisy
        assertt(tempc[n].getPhase(), cfa[n].getPhase(), "setMagnitude() phase", 0.01);
        assertt(tempc[n].getMagnitude(), magnitude[n], "setMagnitude() magnitude", 0.01);
      }
      // setMagnitude(FloatArray, int, int)
      offset=size/3.0f;
      count=size/2.0f;
      tempc.copyFrom(cfa);
      tempc.setMagnitude(magnitude, offset, count);
      for(int n=0; n<size; n++){
        if(n>=offset && n<offset+count){
          if(cfa[n].getMagnitude()<0.001 || tempc[n].getMagnitude()<0.001)
            continue; //skip small values of magnitude which would make the phase noisy
          assertt(tempc[n].getPhase(), cfa[n].getPhase(), "setMagnitude() phase", 0.01);
          assertt(tempc[n].getMagnitude(), magnitude[n], "setMagnitude() magnitude", 0.01);
        } else { //check that values outside the range have not changed
          if(abs(tempc[n].getPhase()-cfa[n].getPhase())>0){
            debugMessage("error", (float)n, tempc[n].getPhase(), cfa[n].getPhase());
            return;
          }
          assertr(tempc[n].getPhase()==cfa[n].getPhase(), "setMagnitude()t phase");
          assertr(tempc[n].getMagnitude()==cfa[n].getMagnitude(), "setMagnitude() magnitude");
        }
      }
      FloatArray::destroy(phase);
      FloatArray::destroy(magnitude);
    }
/*
    ComplexFloatArray subarray(int offset, int length);
*/
    if(success==true){
      debugMessage("Tests passed",passed);
    }
  };
Exemple #15
0
 /// set the path to the tootable
 void setToolTable(QString tbl_file) { 
     emit debugMessage( tr("g2m: setting tooltable %1").arg(tbl_file) ); 
     tooltable = tbl_file; 
 }
/** branches the searching tree, branching nodes are selected in decreasing order of their apriori bound,
 *  returns the level to which we should backtrack, or INT_MAX for continuing normally
 */
static
int branch(
   TCLIQUE_GETNNODES((*getnnodes)),     /**< user function to get the number of nodes */
   TCLIQUE_GETWEIGHTS((*getweights)),   /**< user function to get the node weights */
   TCLIQUE_ISEDGE   ((*isedge)),        /**< user function to check for existence of an edge */
   TCLIQUE_SELECTADJNODES((*selectadjnodes)), /**< user function to select adjacent edges */
   TCLIQUE_GRAPH*   tcliquegraph,       /**< pointer to graph data structure */
   TCLIQUE_NEWSOL   ((*newsol)),        /**< user function to call on every new solution */
   TCLIQUE_DATA*    tcliquedata,        /**< user data to pass to user callback function */
   BMS_CHKMEM*      mem,                /**< block memory */
   CLIQUEHASH*      cliquehash,         /**< clique hash table */
   int*             buffer,             /**< buffer of size nnodes */
   int              level,		/**< level of b&b tree */
   int*             V,                  /**< non-zero weighted nodes for branching */
   int              nV,                 /**< number of non-zero weighted nodes for branching */
   int*             Vzero,              /**< zero weighted nodes */
   int              nVzero,             /**< number of zero weighted nodes */
   NBC*             gsd,                /**< neighbour color information of all nodes */
   TCLIQUE_Bool*    iscolored,          /**< coloring status of all nodes */
   int*             K,                  /**< nodes from the b&b tree */
   TCLIQUE_WEIGHT   weightK,            /**< weight of the nodes from b&b tree */
   int*             maxcliquenodes,     /**< pointer to store nodes of the maximum weight clique */
   int*             nmaxcliquenodes,    /**< pointer to store number of nodes in the maximum weight clique */
   TCLIQUE_WEIGHT*  maxcliqueweight,    /**< pointer to store weight of the maximum weight clique */
   int*             curcliquenodes,     /**< pointer to store nodes of currenct clique */
   int*             ncurcliquenodes,    /**< pointer to store number of nodes in current clique */
   TCLIQUE_WEIGHT*  curcliqueweight,    /**< pointer to store weight of current clique */
   int*             tmpcliquenodes,     /**< buffer for storing the temporary clique */
   TCLIQUE_WEIGHT   maxfirstnodeweight, /**< maximum weight of branching nodes in level 0; 0 if not used
                                         **  (for cliques with at least one fractional node) */
   int*             ntreenodes,         /**< pointer to store number of nodes of b&b tree */
   int              maxntreenodes,	/**< maximal number of nodes of b&b tree */
   int              backtrackfreq,      /**< frequency to backtrack to first level of tree (0: no premature backtracking) */
   int              maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */
   int              fixednode,          /**< node that is forced to be in the clique, or -1; must have positive weight */
   TCLIQUE_STATUS*  status              /**< pointer to store the status of the solving call */
   )
{
   TCLIQUE_Bool isleaf;
   const TCLIQUE_WEIGHT* weights;
   TCLIQUE_WEIGHT* apbound;
   TCLIQUE_WEIGHT subgraphweight;
   TCLIQUE_WEIGHT weightKold;
   TCLIQUE_WEIGHT tmpcliqueweight;
   int backtracklevel;
   int ntmpcliquenodes;
   int i;

   assert(getnnodes != NULL);
   assert(getweights != NULL);
   assert(selectadjnodes != NULL);
   assert(mem != NULL);
   assert(V != NULL);
   assert(gsd != NULL);
   assert(iscolored != NULL);
   assert(K != NULL);
   assert(maxcliqueweight != NULL);
   assert(curcliquenodes != NULL);
   assert(ncurcliquenodes != NULL);
   assert(curcliqueweight != NULL);
   assert(ntreenodes != NULL);
   assert(maxfirstnodeweight >= 0);
   assert(*ntreenodes >= 0);
   assert(maxntreenodes >= 0);
   assert(status != NULL);

   /* increase the number of nodes, and stop solving, if the node limit is exceeded */
   (*ntreenodes)++;
#ifdef TCLIQUE_DEBUG
   debugMessage("(level %d, treenode %d) maxclique = %d, curclique = %d [mem=%lld (%lld), cliques=%d]\n",
      level, *ntreenodes, *maxcliqueweight, *curcliqueweight,
      BMSgetChunkMemoryUsed(mem), BMSgetMemoryUsed(), cliquehash == NULL ? 0 : cliquehash->ncliques);

   debugMessage(" -> current branching (weight %d):", weightK);
   for( i = 0; i < level; ++i )
      debugPrintf(" %d", K[i]);
   debugPrintf("\n");
   debugMessage(" -> branching candidates:");
   for( i = 0; i < nV; ++i )
      debugPrintf(" %d", V[i]);
   debugPrintf("\n");
#endif
   if( *ntreenodes > maxntreenodes )
   {
      *status = TCLIQUE_NODELIMIT;
      return TRUE;
   }

   weights = getweights(tcliquegraph);
   backtracklevel = INT_MAX;
   isleaf = TRUE;

   /* allocate temporary memory for a priori bounds */
   ALLOC_ABORT( BMSallocMemoryArray(&apbound, nV) );
   BMSclearMemoryArray(apbound, nV);

   /* use coloring relaxation to generate an upper bound for the current subtree and a heuristic solution */
   subgraphweight = boundSubgraph(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph,
      mem, buffer, V, nV, gsd, iscolored, apbound,
      tmpcliquenodes, &ntmpcliquenodes, &tmpcliqueweight);

#ifndef NDEBUG
   /* check correctness of V and apbound arrays */
   for( i = 0; i < nV; ++i )
   {
      assert(0 <= V[i] && V[i] < getnnodes(tcliquegraph));
      assert(i == 0 || V[i-1] < V[i]);
      assert(apbound[i] >= 0);
      assert((apbound[i] == 0) == (weights[V[i]] == 0));
   }
#endif

   /* check, whether the heuristic solution is better than the current subtree's solution;
    * if the user wanted to have a fixed variable inside the clique and we are in level 0, we first have to
    * fix this variable in this level (the current clique might not contain the fixed node)
    */
   if( weightK + tmpcliqueweight > *curcliqueweight && (level > 0 || fixednode == -1) )
   {
      /* install the newly generated clique as current clique */
      for( i = 0; i < level; ++i )
         curcliquenodes[i] = K[i];
      for( i = 0; i < ntmpcliquenodes; ++i )
         curcliquenodes[level+i] = tmpcliquenodes[i];
      *ncurcliquenodes = level + ntmpcliquenodes;
      *curcliqueweight = weightK + tmpcliqueweight;

#ifdef TCLIQUE_DEBUG
      debugMessage(" -> new current clique with weight %d at node %d in level %d:",
         *curcliqueweight, *ntreenodes, level);
      for( i = 0; i < *ncurcliquenodes; ++i )
         debugPrintf(" %d", curcliquenodes[i]);
      debugPrintf("\n");
#endif
   }

   /* discard subtree, if the upper bound is not better than the weight of the currently best clique;
    * if only 2 nodes are left, the maximal weighted clique was already calculated in boundSubgraph() and nothing
    * more has to be done;
    * however, if the user wanted to have a fixed node and we are in the first decision level, we have to continue
    */
   if( weightK + subgraphweight > *maxcliqueweight && (nV > 2 || (fixednode >= 0 && level == 0)) )
   {
      int* Vcurrent;
      int nVcurrent;
      int nValive;
      int branchingnode;

      assert(nV > 0);

      /* process current subtree */
      level++;

      /* set up data structures */
      ALLOC_ABORT( BMSallocMemoryArray(&Vcurrent, nV-1) );

      nValive = nV;
      weightKold = weightK;

      debugMessage("============================ branching level %d ===============================\n", level);

      /* branch on the nodes of V by decreasing order of their apriori bound */
      while( backtracklevel >= level && nValive > 0 )
      {
         int branchidx;

         /* check if we meet the backtracking frequency - in this case abort the search until we have reached first level */
         if( level > 1 && backtrackfreq > 0 && (*ntreenodes) % backtrackfreq == 0 )
         {
            backtracklevel = 1;
            break;
         }

         /* get next branching node */
	 if( level == 1 && fixednode >= 0 )
	 {
	    /* select the fixed node as first "branching" candidate */
	    for( branchidx = 0; branchidx < nValive && V[branchidx] != fixednode; branchidx++ )
	    {}
	    assert(branchidx < nValive);
	    assert(V[branchidx] == fixednode);
	 }
         else if( level == 1 && maxfirstnodeweight > 0 )
            branchidx = getMaxApBoundIndexNotMaxWeight(V, nValive, apbound, weights, maxfirstnodeweight);
         else
            branchidx = getMaxApBoundIndex(nValive, apbound);
         if( branchidx < 0 )
            break;
         assert(0 <= branchidx && branchidx < nValive && nValive <= nV);
         assert(apbound[branchidx] > 0);
         assert(weights[V[branchidx]] > 0);

         /* test a priori bound */
         if( (weightKold + apbound[branchidx]) <= *maxcliqueweight )
            break;

         debugMessage("%d. branching in level %d (treenode %d): bidx=%d, node %d, weight %d, upperbound: %d+%d = %d, maxclique=%d\n",
            nV-nValive+1, level, *ntreenodes, branchidx, V[branchidx], weights[V[branchidx]], weightKold,
            apbound[branchidx], weightKold + apbound[branchidx], *maxcliqueweight);

         /* because we branch on this node, the node is no leaf in the tree */
         isleaf = FALSE;

         /* update the set of nodes from the b&b tree
          *   K = K & {branchingnode}
          */
         branchingnode = V[branchidx];
         K[level-1] = branchingnode;
         weightK = weightKold + weights[branchingnode];

         /* update the set of nodes for branching
          *   V = V \ {branchingnode}
          */
         nValive--;
         for( i = branchidx; i < nValive; ++i )
         {
            V[i] = V[i+1];
            apbound[i] = apbound[i+1];
         }

         /* set the nodes for the next level of b&b tree
          *   Vcurrent = nodes of V, that are adjacent to branchingnode
          */
         nVcurrent = selectadjnodes(tcliquegraph, branchingnode, V, nValive, Vcurrent);

         /* process the selected subtree */
         backtracklevel = branch(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph, newsol, tcliquedata,
            mem, cliquehash, buffer,
            level, Vcurrent, nVcurrent, Vzero, nVzero, gsd, iscolored, K, weightK,
            maxcliquenodes, nmaxcliquenodes, maxcliqueweight,
            curcliquenodes, ncurcliquenodes, curcliqueweight, tmpcliquenodes,
            maxfirstnodeweight, ntreenodes, maxntreenodes, backtrackfreq, maxnzeroextensions, -1, status);

         /* if all other candidates stayed in the candidate list, the current branching was optimal and
          * there is no need to try the remaining ones
          */
         if( nVcurrent == nValive )
         {
            debugMessage("branching on node %d was optimal - ignoring remaining candidates\n", branchingnode);
            nValive = 0;
         }

	 /* if we had a fixed node, ignore all other nodes */
	 if( fixednode >= 0 )
            nValive = 0;
      }

      debugMessage("========================== branching level %d end =============================\n\n", level);

      /* free data structures */
      BMSfreeMemoryArray(&Vcurrent);
   }

   /* check, whether any branchings have been applied, or if this node is a leaf of the branching tree */
   if( isleaf )
   {
      /* the current clique is the best clique found on the path to this leaf
       * -> check, whether it is an improvement to the currently best clique
       */
      if( *curcliqueweight > *maxcliqueweight )
      {
         TCLIQUE_Bool stopsolving;

         debugMessage("found clique of weight %d at node %d in level %d\n", *curcliqueweight, *ntreenodes, level);
         newSolution(selectadjnodes, tcliquegraph, newsol, tcliquedata, cliquehash, buffer, Vzero, nVzero,
            maxnzeroextensions, curcliquenodes, *ncurcliquenodes, *curcliqueweight,
            maxcliquenodes, nmaxcliquenodes, maxcliqueweight, &stopsolving);

         if( stopsolving )
         {
            debugMessage(" -> solving terminated by callback method\n");
            backtracklevel = 0;
         }
      }

      /* discard the current clique */
      *ncurcliquenodes = 0;
      *curcliqueweight = 0;
   }

#ifdef TCLIQUE_DEBUG
   if( level > backtracklevel )
   {
      debugMessage("premature backtracking after %d nodes - level %d\n", *ntreenodes, level);
   }
#endif

   /* free data structures */
   BMSfreeMemoryArray(&apbound);

   return backtracklevel;
}
Exemple #17
0
void Groupwise::updateAddressbook(const KURL &url)
{
    kdDebug() << "Groupwise::updateAddressbook() " << url << endl;
    QString u = soapUrl(url);

    QString user = url.user();
    QString pass = url.pass();

    debugMessage("update AB URL: " + u);
    debugMessage("update AB User: "******"update AB Password: "******"?")
    {
        errorMessage(i18n("No addressbook IDs given."));
        return;
    }
    else
    {
        QStringList ids;

        query = query.mid(1);
        QStringList queryItems = QStringList::split("&", query);
        QStringList::ConstIterator it;
        for(it = queryItems.begin(); it != queryItems.end(); ++it)
        {
            QStringList item = QStringList::split("=", (*it));
            if(item.count() == 2 && item[ 0 ] == "addressbookid")
            {
                ids.append(item[ 1 ]);
            }
            if(item.count() == 2 && item[ 0 ] == "lastSeqNo")
                lastSequenceNumber = item[ 1 ].toULong();
            if(item.count() == 2 && item[ 0 ] == "PORebuildTime")
                lastPORebuildTime = item[ 1 ].toULong();
        }

        debugMessage("update IDs: " + ids.join(","));

        GroupwiseServer server(u, user, pass, 0);
        connect(&server, SIGNAL(errorMessage(const QString &, bool)),
                SLOT(slotServerErrorMessage(const QString &, bool)));
        connect(&server, SIGNAL(gotAddressees(const KABC::Addressee::List)),
                SLOT(slotReadReceiveAddressees(const KABC::Addressee::List)));

        kdDebug() << "  Login" << endl;
        if(!server.login())
        {
            errorMessage(i18n("Unable to login: "******"  Updating Addressbook" << endl;
            if(!server.updateAddressBooks(ids, lastSequenceNumber + 1, lastPORebuildTime))
            {
                error(KIO::ERR_NO_CONTENT, server.errorText());
                //errorMessage( i18n("Unable to update addressbook data: ") + server.errorText() );
            }
            kdDebug() << "  Logout" << endl;
            server.logout();
            finished();
        }
    }
}
Exemple #18
0
 /// pause program
 void pause() {
 	play_flag = false;
     emit debugMessage( tr("GPlayer: pause") );
 }
Exemple #19
0
void Bridge::attach(QString serialName, QString radioName, PortSettings serialSettings, int midiInPort, int midiOutPort, QThread *workerThread)
{
    this->moveToThread(workerThread);
    if(serialName.length() && serialName != TEXT_NOT_CONNECTED) {
        // Latency fixups
        latency = new PortLatency(serialName);
        connect(latency, SIGNAL(debugMessage(QString)), this, SIGNAL(debugMessage(QString)));
        connect(latency, SIGNAL(errorMessage(QString)), this, SIGNAL(displayMessage(QString)));
        latency->fixLatency();

        emit displayMessage(QString("Opening serial port '%1'...").arg(serialName));
        this->serial = new QextSerialPort(serialName, serialSettings);
        connect(this->serial, SIGNAL(readyRead()), this, SLOT(onSerialAvailable()));
        this->serial->open(QIODevice::ReadWrite|QIODevice::Unbuffered);
        attachTime = QTime::currentTime();
        this->serial->moveToThread(workerThread);
    }

    // MIDI out
    try
    {
        if(midiOutPort > -1)
        {
            emit displayMessage(QString("Opening MIDI Out port #%1").arg(midiOutPort));
            this->midiOutPort = midiOutPort;
            this->midiOut = new RtMidiOut(NAME_MIDI_OUT);
            this->midiOut->openPort(midiOutPort);
        }
    }
    catch(RtError e)
    {
        displayMessage(QString("Failed to open MIDI out port: %1").arg(QString::fromStdString(e.getMessage())));
    }

    // MIDI in
    try
    {
       if(midiInPort > -1) {
            emit displayMessage(QString("Opening MIDI In port #%1").arg(midiInPort));
            this->midiInPort = midiInPort;
            this->midiIn = new QRtMidiIn(NAME_MIDI_IN);
            this->midiIn->moveToThread(workerThread);
            this->midiIn->openPort(midiInPort);
            connect(this->midiIn, SIGNAL(messageReceived(double,QByteArray)), this, SLOT(onMidiIn(double,QByteArray)));
        }
     }
    catch(RtError e)
    {
        displayMessage(QString("Failed to open MIDI in port: %1").arg(QString::fromStdString(e.getMessage())));
    }

    try
    {
       if(radioName.length() && radioName != TEXT_NOT_CONNECTED) {
            emit displayMessage(QString("Opening Radio Mapping type %1").arg(radioName));
            emit displayMessage(QString("Pending Implementation of Radio-Port-Type on attach"));
        } else {
            emit displayMessage(QString("Radio Port Type not selected"));
       }
     }
    catch(RtError e)
    {
        displayMessage(QString("Failed to map Radio Port Type: %1").arg(QString::fromStdString(e.getMessage())));
    }

}
Exemple #20
0
/*
 * Magic happens here.
 */
int main() {
    cv::Mat detectedWhitePage, maskedImage, possibleBlueDotLocations, transformedImage;
    std::vector<cv::Point> approxCorners,detectedCorners, cornerPointDestinations, centresOfConnectedComponents;
    std::vector<std::vector<cv::Point>> connectedComponents, closestPoints;
    std::vector<cv::Vec4f> bestFitLines;
    int matchedImageIndex = 0;

    LoadAllImages();

    /*
     * Take a single book picture and find the top left, bottom left, bottom right, top right blue pixels
     * return a vector of those pixels and use them as destination points for transformations
     *
     * This should preserve the aspect ratio of the images
     */
    cornerPointDestinations = FindTemplateCorners(pageImages[0]);

    /*
     * Loop over every single image and perform some vision magic on each
     */
    for (size_t imageIndex = 0; imageIndex < groundTruth.size(); imageIndex++) {

        // Detect the white page, will tell the program to look for blue dots in that page
        PageDetector pageDetector(viewImages[imageIndex]);
        detectedWhitePage = pageDetector.DetectPage();

        // Apply the white page location as a mask to the original image.
        maskedImage = pageDetector.ApplyMask(viewImages[imageIndex], detectedWhitePage);
        Transformer transformer(maskedImage);

        // Search for blue spots in the masked image
        PointDetector pointDetector(maskedImage, MAGIC_THRESHOLD_VALUE, std::to_string(imageIndex));
        possibleBlueDotLocations = pointDetector.DetectPoints(backProjectSample[0]);
        connectedComponents = pointDetector.BlueDotsToContours(possibleBlueDotLocations);
        centresOfConnectedComponents = pointDetector.GetCentres(connectedComponents);
        approxCorners = transformer.FindApproximateCornersFromCentresOfComponents(centresOfConnectedComponents);
        closestPoints = transformer.FindClosestPoints(approxCorners, possibleBlueDotLocations);
        bestFitLines = transformer.LinesOfBestFit(closestPoints);

        // Find the approxCorners that were of the image
        detectedCorners = transformer.FindIntersections(maskedImage, bestFitLines);

        // Transform the image
        transformedImage = transformer.Transform(viewImages[imageIndex], detectedCorners, cornerPointDestinations);

        // Match the image with a template
        TemplateMatcher templateMatcher(transformedImage, pageImages, (int) pageFiles.size());
        matchedImageIndex = templateMatcher.Match();

        if(matchedImageIndex==-1){
            // No match found, since I only passed actual pages and it couldn't find it this is a Flase Negative
            FalseNegative++;
        }else {
            // Ground truth starts counting from 1 while program start counting from 0
            matchedImageIndex++;

            if (matchedImageIndex == groundTruth[imageIndex]) {
                TruePositive++;
            }else{
                FalsePositive++;
            }
        }
    }
    debugMessage("TP: " + std::to_string(TruePositive)+"/" + std::to_string(viewFiles.size()));
    debugMessage("FP: " + std::to_string(FalsePositive)+"/" + std::to_string(viewFiles.size()));
    debugMessage("TN: " + std::to_string(TrueNegative)+"/" + std::to_string(viewFiles.size()));
    debugMessage("FN: " + std::to_string(FalseNegative)+"/" + std::to_string(viewFiles.size()));
    return EXIT_SUCCESS;
}
/** calls user callback after a new solution was found, that is better than the current incumbent;
 *  the callback decides, whether this solution should be accepted as new incumbent, and whether the solution process
 *  should be stopped
 */
static
void newSolution(
   TCLIQUE_SELECTADJNODES((*selectadjnodes)), /**< user function to select adjacent edges */
   TCLIQUE_GRAPH*   tcliquegraph,       /**< pointer to graph data structure */
   TCLIQUE_NEWSOL   ((*newsol)),        /**< user function to call on every new solution */
   TCLIQUE_DATA*    tcliquedata,        /**< user data to pass to user callback function */
   CLIQUEHASH*      cliquehash,         /**< clique hash table */
   int*             buffer,             /**< buffer of size nnodes */
   int*             Vzero,              /**< zero weighted nodes */
   int              nVzero,             /**< number of zero weighted nodes */
   int              maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */
   int*             curcliquenodes,     /**< nodes of the new clique */
   int              ncurcliquenodes,    /**< number of nodes in the new clique */
   TCLIQUE_WEIGHT   curcliqueweight,    /**< weight of the new clique */
   int*             maxcliquenodes,     /**< pointer to store nodes of the maximum weight clique */
   int*             nmaxcliquenodes,    /**< pointer to store number of nodes in the maximum weight clique */
   TCLIQUE_WEIGHT*  maxcliqueweight,    /**< pointer to store weight of the maximum weight clique */
   TCLIQUE_Bool*    stopsolving         /**< pointer to store whether the solving should be stopped */
   )
{
   CLIQUE* clique;
   int insertpos;
   TCLIQUE_Bool acceptsol;

   assert(curcliquenodes != NULL);
   assert(maxcliquenodes != NULL);
   assert(nmaxcliquenodes != NULL);
   assert(maxcliqueweight != NULL);
   assert(curcliqueweight > *maxcliqueweight);
   assert(stopsolving != NULL);
   assert(newsol == NULL || cliquehash != NULL);

   acceptsol = TRUE;
   *stopsolving = FALSE;
   clique = NULL;
   insertpos = 0;

   if( newsol != NULL )
   {
      /* check whether the clique is already stored in the table */
      if( cliquehash->ncliques > 0 )
      {
         createClique(&clique, curcliquenodes, ncurcliquenodes);
         acceptsol = !inCliquehash(cliquehash, clique, &insertpos);
      }
   }

   /* check, if this is a new clique */
   if( acceptsol )
   {
      /* extend the clique with the zero-weighted nodes */
      extendCliqueZeroWeight(selectadjnodes, tcliquegraph, buffer, Vzero, nVzero, maxnzeroextensions,
         curcliquenodes, &ncurcliquenodes);

      if( newsol != NULL )
      {
         /* call user callback method */
         newsol(tcliquedata, curcliquenodes, ncurcliquenodes, curcliqueweight, maxcliqueweight, &acceptsol, stopsolving);

         /* if clique was accepted, clear the clique hash table; otherwise, insert it into the clique hash table, such that
          * the same or a weaker clique is not presented to the user again
          */
         if( acceptsol )
            clearCliquehash(cliquehash);
         else
         {
            /* if the clique was not yet created, do it now */
            if( clique == NULL )
            {
               assert(insertpos == 0);
               assert(cliquehash->ncliques == 0);
               createClique(&clique, curcliquenodes, ncurcliquenodes);
            }

            /* insert clique into clique hash table */
            insertClique(cliquehash, clique, insertpos);
            clique = NULL; /* the clique now belongs to the table */
         }
      }
   }

   /* free the clique, if it was created and not put into the clique hash table */
   if( clique != NULL )
      freeClique(&clique);

   if( acceptsol )
   {
      /* copy the solution to the incumbent */
      BMScopyMemoryArray(maxcliquenodes, curcliquenodes, ncurcliquenodes);
      *nmaxcliquenodes = ncurcliquenodes;
      if( curcliqueweight > *maxcliqueweight )
         *maxcliqueweight = curcliqueweight;
   }

#ifdef TCLIQUE_DEBUG
   debugMessage(" -> clique %s (weight %d):", acceptsol ? "accepted" : "rejected", curcliqueweight);
   {
      int i;
      for( i = 0; i < ncurcliquenodes; ++i )
         debugPrintf(" %d", curcliquenodes[i]);
      debugPrintf("\n");
   }
#endif
}
Exemple #22
0
/// called after "file" set in constructor
void g2m::interpret() {
    //success = false;
    QProcess toCanon;
    bool foundEOF; // checked at the end
    
    if (!startInterp(toCanon)) // finds rs274, reads tooltable, start interpreter
        return;
    
    if (!toCanon.waitForReadyRead(1000) ) {
        if ( toCanon.state() == QProcess::NotRunning ){
            infoMsg("Interpreter died.  Bad tool table?");
        } else  
            infoMsg("Interpreter timed out for an unknown reason.");
        std::cout << "stderr: " << (const char*)toCanon.readAllStandardError() << std::endl;
        std::cout << "stdout: " << (const char*)toCanon.readAllStandardOutput() << std::endl;
        toCanon.close();
        return;
    }
    
    // rs274  has now started correctly, and is ready to read ngc-file
    qint64 lineLength;
    char line[260];
    int fails = 0;
    do {
        if (toCanon.canReadLine()) {
            lineLength = toCanon.readLine(line, sizeof(line)); // read one output line from rs274
            if (lineLength != -1 ) {
                QString l(line);
                emit canonLineMessage( l.left(l.size()-1) );
                foundEOF = processCanonLine(line); // line is a canon-line
            } else {  //shouldn't get here!
                std::cout << " ERROR: lineLength= " << lineLength << "  fails="<< fails << "\n";
                fails++;
            }
        } else {
            std::cout << " ERROR: toCanon.canReadLine() fails="<< fails << "\n";
            fails++;
        }
        toCanon.waitForReadyRead();
    } while ( (fails < 100) &&
           ( (toCanon.canReadLine()) ||
            ( toCanon.state() != QProcess::NotRunning ) )  );
  
    if (fails > 1) {
        if (fails < 100) {
            infoMsg("Waited for interpreter over 100  times.");
        } else {
            infoMsg("Waited 100 seconds for interpreter. Giving up.");
            toCanon.close();
            return;
        }
    }
  
  std::string s = (const char *)toCanon.readAllStandardError();
  s.erase(0,s.find("executing"));
  if (s.size() > 10) {
    infoMsg("Interpreter exited with error:\n"+s.substr(10));
    return;
  }
  if (!foundEOF) {
    infoMsg("Warning: file data not terminated correctly. If the file is terminated correctly, this indicates a problem interpreting the file.");
  }

    emit debugMessage( tr("g2m: read %1 lines of g-code which produced %2 canon-lines.").arg(gcode_lines).arg(lineVector.size()) );
    return;
}
/** finds maximum weight clique */
void tcliqueMaxClique(
   TCLIQUE_GETNNODES((*getnnodes)),     /**< user function to get the number of nodes */
   TCLIQUE_GETWEIGHTS((*getweights)),   /**< user function to get the node weights */
   TCLIQUE_ISEDGE   ((*isedge)),        /**< user function to check for existence of an edge */
   TCLIQUE_SELECTADJNODES((*selectadjnodes)), /**< user function to select adjacent edges */
   TCLIQUE_GRAPH*   tcliquegraph,       /**< pointer to graph data structure that is passed to graph callbacks */
   TCLIQUE_NEWSOL   ((*newsol)),        /**< user function to call on every new solution */
   TCLIQUE_DATA*    tcliquedata,        /**< user data to pass to new solution callback function */
   int*             maxcliquenodes,     /**< pointer to store nodes of the maximum weight clique */
   int*             nmaxcliquenodes,    /**< pointer to store number of nodes in the maximum weight clique */
   TCLIQUE_WEIGHT*  maxcliqueweight,    /**< pointer to store weight of the maximum weight clique */
   TCLIQUE_WEIGHT   maxfirstnodeweight, /**< maximum weight of branching nodes in level 0; 0 if not used
                                         *   for cliques with at least one fractional node) */
   TCLIQUE_WEIGHT   minweight,          /**< lower bound for weight of generated cliques */
   int              maxntreenodes,	/**< maximal number of nodes of b&b tree */
   int              backtrackfreq,      /**< frequency to backtrack to first level of tree (0: no premature backtracking) */
   int              maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */
   int              fixednode,          /**< node that is forced to be in the clique, or -1; must have positive weight */
   TCLIQUE_STATUS*  status              /**< pointer to store the status of the solving call */
   )
{
   CLIQUEHASH* cliquehash;
   const TCLIQUE_WEIGHT* weights;
   int* buffer;
   int* K;
   int* V;
   int* Vzero;
   int nnodes;
   int nV;
   int nVzero;
   int i;
   BMS_CHKMEM* mem;
   NBC* gsd;
   TCLIQUE_Bool* iscolored;
   int* curcliquenodes;
   int ncurcliquenodes;
   TCLIQUE_WEIGHT curcliqueweight;
   int* tmpcliquenodes;
   int ntreenodes;
   int backtracklevel;

   assert(maxcliquenodes != NULL);
   assert(nmaxcliquenodes != NULL);
   assert(maxcliqueweight != NULL);
   assert(maxntreenodes >= 0);
   assert(backtrackfreq >= 0);
   assert(maxnzeroextensions >= 0);
   assert(status != NULL);

   *status = TCLIQUE_OPTIMAL;

   /* use default graph callbacks, if NULL pointers are given */
   if( getnnodes == NULL )
      getnnodes = tcliqueGetNNodes;
   if( getweights == NULL )
      getweights = tcliqueGetWeights;
   if( isedge == NULL )
      isedge = tcliqueIsEdge;
   if( selectadjnodes == NULL )
      selectadjnodes = tcliqueSelectAdjnodes;

   /* get number of nodes */
   nnodes = getnnodes(tcliquegraph);

   debugMessage("calculating maximal weighted clique in graph (%d nodes)\n", nnodes);

   /* set up data structures */
   if( newsol != NULL )
      createCliquehash(&cliquehash, CLIQUEHASH_INITSIZE);
   else
      cliquehash = NULL;
   ALLOC_ABORT( BMSallocMemoryArray(&buffer, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&K, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&V, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&Vzero, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&gsd, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&iscolored, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&curcliquenodes, nnodes) );
   ALLOC_ABORT( BMSallocMemoryArray(&tmpcliquenodes, nnodes) );

   /* set weight and number of nodes of maximum weighted clique */
   *nmaxcliquenodes = 0;
   *maxcliqueweight = minweight-1;
   ncurcliquenodes = 0;
   curcliqueweight = 0;
   ntreenodes = 0;

   /* set up V and Vzero */
   weights = getweights(tcliquegraph);
   assert(weights != NULL);
   nV = 0;
   nVzero = 0;
   for( i = 0 ; i <  nnodes; i++ )
   {
      if( weights[i] == 0 )
      {
         Vzero[nVzero] = i;
         nVzero++;
      }
      else
      {
         V[nV] = i;
         nV++;
      }
   }

   /* initialize own memory allocator for coloring */
   mem = BMScreateChunkMemory(sizeof(LIST_ITV), CHUNK_SIZE, -1);

   /* branch to find maximum weight clique */
   backtracklevel = branch(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph, newsol, tcliquedata, mem,
      cliquehash, buffer, 0, V, nV, Vzero, nVzero, gsd, iscolored, K, 0,
      maxcliquenodes, nmaxcliquenodes, maxcliqueweight,
      curcliquenodes, &ncurcliquenodes, &curcliqueweight, tmpcliquenodes,
      maxfirstnodeweight, &ntreenodes, maxntreenodes, backtrackfreq, maxnzeroextensions, fixednode, status);

   if( backtracklevel != INT_MAX && *status == TCLIQUE_OPTIMAL )
      *status = TCLIQUE_USERABORT;

   /* delete own memory allocator for coloring */
   BMSdestroyChunkMemory(&mem);

   /* free data structures */
   BMSfreeMemoryArray(&tmpcliquenodes);
   BMSfreeMemoryArray(&curcliquenodes);
   BMSfreeMemoryArray(&iscolored);
   BMSfreeMemoryArray(&gsd);
   BMSfreeMemoryArray(&Vzero);
   BMSfreeMemoryArray(&V);
   BMSfreeMemoryArray(&K);
   BMSfreeMemoryArray(&buffer);
   if( newsol != NULL )
      freeCliquehash(&cliquehash);
}
void authentificationThread()
{
	// initialisation de la structure sockaddr_in d'ecoute.

	AccountsList *list = loadAccountsFromFile(ACCOUNTS_FILE); // ajouter la détection de l'existence du fichier.
	if(list == NULL)
	{
		errorMessage("Accounts file is corrupted");
		return;
	}

	struct sockaddr_in server;
	initServerSocketAddress(&server);
	int listen_socket = createServerListenSocket(&server);


	ConnectionList connection_list;
	connection_list.nb_connections = 0;

	// initialisation de la fine d'attente des joueurs à charger sur la map et des joueurs déconnectés.
	PlayersQueue players_queues[2];
	initPlayersQueue(&players_queues[0]);
	initPlayersQueue(&players_queues[1]);

	PlayersQueue *new_players_queue = players_queues;
	PlayersQueue *disconnected_players_queue = &players_queues[1];

	// lancement du thread s'occupant de la gestion du déroulement du jeu.

#ifdef RUN_GAME_MANAGEMENT_THREAD
	runGameManagementThread(players_queues);
#endif
	int _continue, return_value;
	char *login, *password;
	Player *player;
	Connection * current_connection;
	int connection_index, account_index;
	GenericPacket packet;
	Buffer recv_buffer, send_buffer;
	initBuffer(&recv_buffer);
	initBuffer(&send_buffer);

	// utilise pour rendr le thread inactif pendant un certain temps.
	int no_activity = 0;
	struct timespec wait_time = {0, 150000}, sleep_return;

	long last_save_time = getTime();
	char save_needed = FALSE;

	while(1)
	{
		no_activity = TRUE;

		acceptNewConnections(listen_socket, &connection_list);
		/// il reste a traiter les packets éventuels de chaque connexion.
		for(connection_index = 0; connection_index < connection_list.nb_connections; connection_index++)
		{
			current_connection = & connection_list.connections[connection_index];
			_continue = TRUE;
			while(_continue)
			{
				return_value = recvPacket(current_connection, &packet, &recv_buffer);
				if(return_value == 1) // traitement du packet recu.
				{
					no_activity = FALSE;
					if(packet.type == AUTHENTIFICATION_REQUEST)
					{
						if(extractLoginAndPassword(&packet, &recv_buffer, &login, &password) < 0) // si la forme des donnees du paquet est incorrecte, on rejette la demande d'authentification.
							sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION);
						else if(!isCorrectLoginOrPassword(login)) // si le login est syntaxiquement incorrecte, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : login \"%s\" is syntactically false", login);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else if(!isCorrectLoginOrPassword(password)) // si le mot de passe est syntaxiquement incorrecte, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : password \"%s\" is syntactically false", password);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else if((account_index = getAccountPosition(list, login)) < 0) // Si le login ne correspond à aucun compte, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : none account matching with login \"%s\".", login);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else if(list->accounts[account_index].opened) // Si le compte correspondant au login est deja ouvert, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : account \"%s\" is already opened.", login);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else if(list->accounts[account_index].opened) // Si le compte correspondant est deja utilise, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : account \"%s\" is already opened.", password, login);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else if(strcmp(password, list->accounts[account_index].password)) // Si le compte correspondant au login a un mot de passe different de celui recu, on rejette la demande d'authentification.
						{
							debugMessage("Authentication has failed : password \"%s\" is incorrect for account \"%s\".", password, login);
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
							{
								warningMessage("Current connection is lost.");
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
							}
						}
						else // l'authentification a reussi, on supprime donc la connection du service de comptes.
						{
							if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, ACCEPT_AUTHENTIFICATION)) == -2)
								warningMessage("Current connection is lost.");

							if(addPlayerToQueue(new_players_queue, (player = createPlayerForAccount(& list->accounts[account_index], current_connection))) < 0) // Si la file d'attente des noueaux joueurs en attente de chargement sur la map est pleine, on rejette la demande d'authentification.
							{
								destroyPlayer(player);
								debugMessage("Authentication has failed : new players queue is full.");
								if((return_value = sendAuthentificationAnswer(current_connection, &send_buffer, REJECT_AUTHENTIFICATION)) == -2)
								{
									warningMessage("Current connection is lost.");
									removeConnectionFromList(& connection_list, connection_index);
									connection_index--;
									_continue = FALSE;
								}
							}
							else
							{
								removeConnectionFromList(& connection_list, connection_index);
								connection_index--;
								_continue = FALSE;
								list->accounts[account_index].opened = TRUE;
								debugMessage("player %s is authenticated", login);
							}
						}
					}
					else // le type du paquet ne concerne pas le service de comptes, donc on l'ignore.
						warningMessage("packet received is not for account management : type is %d", packet.type);
				}
				else if(return_value == 0) // aucun nouveau paquet recu, donc on traite l'eventuelle connexion suivante.
					_continue = FALSE;
				else if(return_value == -1)
					_continue = FALSE;
				else // la connexion est perdue, donc on la supprime de la liste des connexions et on traite l'eventuelle connexion suivante.
				{
					no_activity = FALSE;
					removeConnectionFromList(& connection_list, connection_index);
					connection_index--;
					_continue = FALSE;
				}
			}
		}

		// on traite l'ensemble des joueurs deconnectes.
		while((player = removePlayerFromQueue(disconnected_players_queue)) != NULL)
		{
			no_activity = FALSE;

			account_index = getAccountPosition(list, player->login); // on recupere l'indice du compte associe au joueur 'player'
			if(account_index >= 0) // si le compte est retrouve, on le met a jour.
			{
				list->accounts[account_index].opened = FALSE;
				list->accounts[account_index].pos_x = player->position.x;
				list->accounts[account_index].pos_y = player->position.y;
				save_needed = TRUE;
			}
			destroyPlayer(player);
		}

		if(save_needed && getTime() - last_save_time > 30000000) // sauvegarde des comptes toutes les 30 secondes.
		{
			saveAccountsFile(ACCOUNTS_FILE, list);
			save_needed = FALSE;
			last_save_time = getTime();
		}

		// si aucune activite (reception de paquet ou demande de connexion) n'a eu lieu, alors on rend le thread inactif pendant un certain temps afin de limiter la consommation des ressouces processeur.
		if(no_activity == TRUE)
			nanosleep(&wait_time, &sleep_return);
	}
}
Exemple #25
0
 /// set the path to the rs274 binary
 void setInterp(QString interp_binary) { 
     emit debugMessage( tr("g2m: setting rs274 path:  %1").arg(interp_binary) ); 
     interp = interp_binary; 
 }
/**
 * ajoute un compte a la liste.
 * retourne la position a laquelle le compte a ete insere, ou -1 en cas d'erreur ou si le login d'un compte de la liste est identique a celui du compte a ajouter.
 */
int addAccountToList(AccountsList *list, char *login, char *password, int x, int y)
{
	if(list == NULL || login == NULL || password == NULL) return-1;


	if(list->number_of_accounts == 0) // si la liste est vide, on étend sa taille et on ajoute le compte en premiere position.
	{
		expandAccountsList(list, 10);
		list->accounts[0].login = strCreateCopy(login);
		list->accounts[0].password = strCreateCopy(password);
		list->accounts[0].pos_x = x;
		list->accounts[0].pos_y = y;
		list->accounts[0].opened = FALSE;
		list->number_of_accounts++;

		debugMessage("account (%s : %s : %d : %d) added to list", login, password, x, y);
		return 0;
	}

	// on recherche la position à laquelle inserer le nouveau compte, si aucun compte de la liste à un login identique a celui du compte a creer.

	int min = 0, max = list->number_of_accounts - 1;
	int middle = (max + 1)/2;
	int result;

	while((result = strcmp(login, list->accounts[middle].login)) && min < max)
	{
		if(result < 0)
		{
			max = middle-1;
			middle = min + (max-min+1)/2;
		}
		else
		{
			min = max < middle+1 ? max : middle+1;
			middle = min + (max-min+1)/2;
		}
	}

	if(result == 0) // le login d'un compte de la liste est indentique a celui du compte a creer, on renvoie donc -1.
	{
		warningMessage("Account %s already exists", login);
		return -1;
	}
	else // le login est valide, on insere donc le compte dans la liste en respectant le critere de tri sur le login.
	{
		if(list->number_of_accounts == list->max_number_of_accounts)
			expandAccountsList(list, list->max_number_of_accounts + 10);

		int account_position = result < 0 ? middle : middle + 1;
		int i;
		for(i = (int) list->number_of_accounts; i > account_position; i--) // decalage des comptes dont le login est superieur au login du compte a ajouter.
			memcpy(& list->accounts[i], & list->accounts[i-1],sizeof(Account));

		list->accounts[account_position].login = strCreateCopy(login);
		list->accounts[account_position].password = strCreateCopy(password);
		list->accounts[account_position].pos_x = x;
		list->accounts[account_position].pos_y = y;
		list->accounts[0].opened = FALSE;

		list->number_of_accounts++;

		debugMessage("account (%s : %s : %d : %d) added to list", login, password, x, y);

		return account_position;
	}
}
Exemple #27
0
// Setup the EW Msg Manager
void K2UDPSock::setupEWMsgMgr(EWMessageMgr *EWmsgMgr)
{
    msgMgr = EWmsgMgr;
    msgsetup = true;
    emit debugMessage("Message Manager has been setup succesfully");
}
Exemple #28
0
FUNCTION void Q4Y8()
{
  if(hasObjVar(this, "debugSkillInfo"))
  {
    deleteArray(0x00);
  }
  if(isArrayInit(0x00))
  {
    return;
  }
  list Q4Y9 = list( 0x00, 0x01, "COL_NAME", 0x03, 0x04, 0x05 );
  initArray(0x00, 0x06, 0x3D, Q4Y9);
  int Q5NY = 0x00;
  Q4Y9 = list( 0x0FAF, 0x00, "Repair an Item", 0x00 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x13ED, 0x36, "Build Armor", 0x01 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x13EC, 0x36, "Build Ring Armor", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x13EB, 0x13EF, 0x13F0, 0x13EC );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x13BF, 0x36, "Build Chain Armor", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x13BB, 0x13BE, 0x13BF );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x1415, 0x36, "Build Plate Armor", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x1408, 0x36, "Build Helmets", 0x03 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x140A, 0x140C, 0x140E, 0x1408, 0x1412 );
  Q5NY = Q4Y7(Q5NY, 0x03, Q4Y9);
  Q4Y9 = list( 0x1413, 0x1414, 0x1410, 0x1411, 0x1415, 0x1C04 );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x1B74, 0x36, "Build Shields", 0x01 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x1B73, 0x1B72, 0x1B7B, 0x1B78, 0x1B74, 0x1B76 );
  Q5NY = Q4Y7(Q5NY, 0x01, Q4Y9);
  Q4Y9 = list( 0x0F45, 0x36, "Build Weapons", 0x01 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x0F61, 0x36, "Build Blades", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x0F51, 0x1441, 0x13FF, 0x1401, 0x13B6, 0x0F5E, 0x0F61, 0x13B9 );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x13FB, 0x36, "Build Axes", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x0F47, 0x0F49, 0x0F45, 0x1443, 0x0F4B, 0x13FB, 0x13B0 );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x0F4D, 0x36, "Build Pole Arms", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x1403, 0x0F62, 0x1405, 0x0F4D, 0x143F );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  Q4Y9 = list( 0x1407, 0x36, "Build Bludgeoning Weapons", 0x02 );
  setArrayElems(0x00, 0x00, Q5NY, Q4Y9);
  Q5NY ++;
  Q4Y9 = list( 0x0F5C, 0x143B, 0x1407, 0x1439, 0x143D );
  Q5NY = Q4Y7(Q5NY, 0x02, Q4Y9);
  debugMessage("BlackSmithing Loaded:  Allocated Rows= " + 0x3D + " Computed Rows:" + Q5NY);
  int Q576 = 0x000F4240;
  int Q55T = 0x00;
  int i;
  int val;
  int Q577;
  int Q567;
  for(i = 0x01; i < Q5NY; i ++)
  {
    if(getArrayIntElem(0x00, 0x01, i) != 0x36)
    {
      val = getArrayIntElem(0x00, 0x05, i);
      if(Q55T < val)
      {
        Q55T = val;
        Q567 = getArrayIntElem(0x00, 0x00, i);
      }
      if(Q576 > val)
      {
        Q576 = val;
        Q577 = getArrayIntElem(0x00, 0x00, i);
      }
    }
  }
  debugMessage("Min Value=" + Q576 + " (" + Q577 + ") Max Value=" + Q55T + " (" + Q567 + ")");
  int range = Q55T - Q576;
  for(i = 0x01; i < Q5NY; i ++)
  {
    if(getArrayIntElem(0x00, 0x01, i) != 0x36)
    {
      val = getArrayIntElem(0x00, 0x05, i);
      int Q4IA = (val - Q576) * 0x03E8 / range;
      setArrayIntElem(0x00, 0x05, i, Q4IA);
    }
  }
  return;
}
//______________________________________________________________________________
void shutterInterface::addChannel( const std::string & pvRoot, shutterStructs::pvStruct & pv )
{
    std::string s1 = pvRoot + pv.pvSuffix;
    ca_create_channel( s1.c_str(), 0, 0, 0, &pv.CHID );
    debugMessage( "Create channel to ", s1 );
}
 void setError(const QString &errorString)
 {
     this->errorString = errorString;
     debugMessage(errorString);
 }