Beispiel #1
0
void ImageViewer::connectWidgets(){
	connect(startBtn, SIGNAL(clicked()), model, SLOT(doRegistration()));
	connect(model, SIGNAL(processingDone()), this, SLOT(enableQuery()));
	connect(queryBtn, SIGNAL(clicked()), model, SLOT(doQuery()));
	connect(model, SIGNAL(queryDone()), this, SLOT(showCorrespondingPoints()));
	connect(matchingBtn, SIGNAL(clicked()), model, SLOT(doMatching()));
	connect(model, SIGNAL(matchingDone()), this, SLOT(showMatchingResult()));

}
TestFFTDisplay::TestFFTDisplay(QWidget *parent) :
    QWidget(parent)
{
    m_Controller = new libbeat::BeatController(0,4096,44100,192);
    //Setup two test frequencies: 600Hz and 12000Hz
    m_Controller->addCustomBeat(600);
    m_Controller->addCustomBeat(12000);
    //Draw when processed and analysed data is ready to be displayed
    connect(m_Controller,SIGNAL(processingDone()),this,SLOT(drawNewData()));
    //Connect some test slots to the Controller's signals
    connect(m_Controller,SIGNAL(beatDrum()),this,SLOT(processDrum()));
    connect(m_Controller,SIGNAL(beatSnare()),this,SLOT(processSnare()));
    connect(m_Controller,SIGNAL(beatCustom(QSet<uint16_t>)),this,SLOT(processCustom(QSet<uint16_t>)));
}
void BeatController::processNewData()
{

    m_FFT->processData();
    m_Analyser->processData();
    emit processingDone();
    if(m_Analyser->getDrumBeat())
        emit beatDrum();
    if(m_Analyser->getSnareBeat())
        emit beatSnare();
    //Check for a beat for every frequency in our list
    QSet<uint16_t> myBeats;
    QSetIterator<uint16_t> i(m_customBeats);
    while(i.hasNext())
    {
        if(m_Analyser->getBeatFrequency(i.peekNext()))
            myBeats.insert(i.peekNext());
        i.next();
    }
    if(!myBeats.empty())
        emit beatCustom(myBeats);
}
Beispiel #4
0
/**
 * @brief MainWindow::createWorkerThreads
 *
 * Creates the objects with the processing algorithms that are to be run i separate threads.
 * As of now they are one instance of Hasher and one instad of FileFinder.
 * Each instance is put in a QThread.
 *
 * To prevent race conditions, before doing any processing (calling a slot in the threads)
 * a call to processWorkStarted() must be made. When the threads are finished with the actions,
 * they will announce this with a signal to MainWindow::actionStopped.
 */
void MainWindow::createWorkerThreads()
{
   hasher = new Hasher;
   filefinder = new FileFinder;
   hasherthread = new QThread;
   filefinderthread = new QThread;
   filefinder->moveToThread(filefinderthread);
   hasher->moveToThread(hasherthread);
   filefinderthread->start();
   hasherthread->start();

   connect(this, SIGNAL(findFiles(HashProject*)), filefinder, SLOT(scanProject(HashProject*)));
   connect(this, SIGNAL(hashFiles(HashProject*, bool, QString)), hasher, SLOT(hashProject(HashProject*, bool, QString)));

   connect(filefinder, SIGNAL(fileFound(HashProject::File, bool)), filelist, SLOT(addFile(HashProject::File, bool)));

   connect(filelist, SIGNAL(hashFile(int, QString, HashProject::File, QString)), hasher, SLOT(hashFile(int, QString, HashProject::File, QString)));
   connect(hasher, SIGNAL(fileHashCalculated(int, QString, QString, bool)), filelist, SLOT(fileHashCalculated(int, QString, QString, bool)));

   /**
    * Signal path between the three threads when announcing that they are finished:
    *  Example, scanning for files using filefinder:
    *   filefinder.scanFinished -> filelist.fileAdditionFinished -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped
    * Example, hashing files after dropping them:
    *   filelist.fileAdditionFinished -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped
    * Example, hashing a project:
    *   hasher.hashproject -> hasher.scanFinished -> filelist.processingDone -> mainwindow.actionStopped
    */
   connect(this, SIGNAL(processWorkStarted()), hasher, SLOT(startProcessWork()));
   connect(filefinder, SIGNAL(scanFinished()), filelist, SLOT(fileAdditionFinished()));
   connect(filelist, SIGNAL(noMoreFileJobs()), hasher, SLOT(noMoreFiles()));
   connect(hasher, SIGNAL(scanFinished()), filelist, SLOT(hashingFinished()));
   connect(filelist, SIGNAL(processingDone()), this, SLOT(actionStopped()));

   connect(hasher, SIGNAL(progressstatus(int)), progressbar, SLOT(setValue(int)));
}
void processing(conn_t *r){

	char libArtc[BUFLEN],newCon[CHUNKLEN];
	char *finish_transmission,*answerFile,*response;
    int	c, fileCounter;
    int complete = 0, notDone = 0;
    time_t	new_time;
	struct tm *time_information;
	char buffer[80];

	
	answerFile = malloc(1024 * sizeof(char));
	response = malloc(1024*sizeof(char));
	snprintf(libArtc, sizeof(libArtc), "%s/%s", r->s->document_dir, r->buffer);
	sprintf(answerFile, "%s %d %s %s", inet_ntoa(r->client.sin_addr),
			ntohs(r->client.sin_port), r->buffer, r->rec_time);
	memset(buffer, 0, 81);
	strcat(response,"file found\n");
	int checksum=1,jumpFile=1;
	FILE* article=fopen(libArtc, "r");
	if(article == NULL) {
		fprintf(stderr, NOTFOUND );
		sendto(r->s->ss, NOTCOMPLETE, strlen(NOTCOMPLETE), 0,
				(struct sockaddr*)&r->client, sizeof(r->client));
		strcat(answerFile, " file not found\n");
	}else{
	//not null
	    if(article!=NULL && jumpFile==1){
	        fprintf(stderr, "Can Access.\n");
	    }
		if(access( r->s->document_dir, R_OK) != -1){
		
			while(!feof(article)){
                bzero(&newCon, sizeof(newCon));
				for(fileCounter=0; fileCounter < 1024; fileCounter++){
					c=fgetc(article);
					if(c!=EOF){
						strcat(newCon, (const char*)&c);
					}
					if(feof(article)){
						if(fileCounter == 0)
							strcat(newCon, "$");
						break;
					}
				}
				notDone = sendto(r->s->ss, newCon, sizeof(newCon), 0,
							(struct sockaddr*)&r->client,sizeof(r->client));
			    jumpFile=0;			
				if(notDone < 0){
					fprintf(stderr, NOTCOMPLETE);
					break;
				}
			}
			if(notDone >= 0&&checksum==1){
			    time( &new_time );
	            time_information = localtime( &new_time );
	            strftime(buffer,80,"%a %d %b %Y %X %Z", time_information);
				fprintf(stdout, "Successfilly\n");
				finish_transmission = strdup(buffer);
				complete = 1;
				
			}
		} else {
			fprintf(stderr, "CAN NOT READ.\n");
		}
		//done with file
		if (complete ==1){
		    jumpFile = 1;
		}
	}
		
	FILE* fileJustRead = fopen(r->s->logFile_dir, "a");
	flock(fileno(fileJustRead), LOCK_EX);
	processingDone(fileJustRead);
	if(complete == 1)
		fprintf(fileJustRead,"%s %s\n", answerFile, finish_transmission);
	else
		fprintf(fileJustRead,"%s  Transmission Fail\n", answerFile);
	flock(fileno(fileJustRead), LOCK_UN);
	fclose(fileJustRead);
	free(response); 
	free(answerFile);
}