void sendLoadSceneRPC(Player* player, QString sceneName) // Loads a scene and send to the default spawn
{
    win.logMessage(QString("UDP: Loading scene \"") + sceneName + "\" on "+QString().setNum(player->pony.netviewId));
    Vortex vortex = findVortex(sceneName, 0);
    if (vortex.destName.isEmpty())
    {
        win.logMessage("UDP: Scene not in vortex DB. Aborting scene load.");
        return;
    }

    Scene* scene = findScene(sceneName);
    Scene* oldScene = findScene(player->pony.sceneName);
    if (scene->name.isEmpty() || oldScene->name.isEmpty())
    {
        win.logMessage("UDP: Can't find the scene, aborting");
        return;
    }

    // Update scene players
    //win.logMessage("sendLoadSceneRPC: locking");
    levelLoadMutex.lock();
    player->inGame=1;
    player->pony.pos = vortex.destPos;
    player->pony.sceneName = sceneName;
    player->lastValidReceivedAnimation.clear(); // Changing scenes resets animations
    Player::removePlayer(oldScene->players, player->IP, player->port);
    if (oldScene->name != sceneName)
    {
        // Send remove RPC to the other players of the old scene
        for (int i=0; i<oldScene->players.size(); i++)
            sendNetviewRemove(oldScene->players[i], player->pony.netviewId);

        // Send instantiate to the players of the new scene
        for (int i=0; i<scene->players.size(); i++)
            if (scene->players[i]->inGame>=2)
                sendNetviewInstantiate(player, scene->players[i]);
    }
    scene->players << player;

    QByteArray data(1,5);
    data += stringToData(sceneName);
    sendMessage(player,MsgUserReliableOrdered6,data); // Sends a 48
    //win.logMessage("sendLoadSceneRPC: unlocking");
    levelLoadMutex.unlock();
}
Beispiel #2
0
void
IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
{
    QueueItem* item = internalGet( artist, album_ptr(), trackdata_ptr(), autoCreate, ArtistType );
    artist->setIdFuture( item->promise.future() );

#if ID_THREAD_DEBUG
    tDebug() << "QUEUEING ARTIST:" << artist->name();
#endif

    s_mutex.lock();
    s_workQueue.enqueue( item );
    s_mutex.unlock();
    s_waitCond.wakeOne();
#if ID_THREAD_DEBUG
    tDebug() << "DONE WOKE UP THREAD:" << artist->name();
#endif
}
Beispiel #3
0
Data::Data(int typeId,
           equals_fn equals, lessThan_fn lessThan,
           castTo_fn castTo, convertTo_fn convertTo, convertFrom_fn convertFrom,
           canCastTo_fn canCastTo, canConvertTo_fn canConvertTo, canConvertFrom_fn canConvertFrom ) :
    typeId_( lh_lock_and_filter( typeId ) ),
    equals_( equals ),
    lessThan_( lessThan ),
    castTo_( castTo ),
    convertTo_( convertTo ),
    convertFrom_( convertFrom ),
    canCastTo_( canCastTo ),
    canConvertTo_( canConvertTo ),
    canConvertFrom_( canConvertFrom ),
    next_( typeId_ ? lh_first_info_ : 0 )
{
    if( typeId_ ) lh_first_info_ = this;
    lh_type_data_mutex_.unlock();
}
Beispiel #4
0
    void project(const Template &src, Template &dst) const
    {
        dst = src;

        if (Globals->parallelism) {
            qWarning("Edit::project() only works in single threaded mode.");
            return;
        }

        currentTemplateLock.lock();
        currentTemplate = src;
        OpenCVUtils::showImage(src, "Edit", false);
        setMouseCallback("Edit", mouseCallback, (void*)this);
        mouseEvent(0, 0, 0, 0);
        waitKey(-1);
        dst = currentTemplate;
        currentTemplateLock.unlock();
    }
Beispiel #5
0
void Person::onReset() {
    QMutex mutex;
    mutex.lock();
    this->stop = true;
    mutex.unlock();

    this->inCS = false;
    this->isWaiting = false;
    this->requests = new QVector<int>();
    this->awks = new QVector<int>();

    QPoint moveBy;
    moveBy.setX(this->initialPosition.x() - this->position.x());
    moveBy.setY(this->initialPosition.y() - this->position.y());
    emit this->ChangePosition(this->id, moveBy);

    this->position += moveBy;
}
void processsimthread::run()
{
    QMutex mutex;
    int counter = 0;
    this->Stop = false;
    while(!this->Stop)
    {
       mutex.lock();
       counter++;
       if (counter == 100) {
           counter = 0;
       }
       emit processValueChanged(counter);
       mutex.unlock();
       QThread::msleep(100);

    }
}
Beispiel #7
0
void QWaitConditionPrivate::post(QWaitConditionEvent *wce, bool ret)
{
    mtx.lock();

    // remove 'wce' from the queue
    queue.removeAll(wce);
    ResetEvent(wce->event);
    freeQueue.append(wce);

    // wakeups delivered after the timeout should be forwarded to the next waiter
    if (!ret && wce->wokenUp && !queue.isEmpty()) {
        QWaitConditionEvent *other = queue.first();
        SetEvent(other->event);
        other->wokenUp = true;
    }

    mtx.unlock();
}
Beispiel #8
0
void customMessageHandler(QtMsgType type, const char *msg)
{
    static QMutex mutex;
    mutex.lock();

    QString text;
    switch(type)
    {
    case QtDebugMsg:
        text = QString("Debug:");
        break;

    case QtWarningMsg:
        text = QString("Warning:");
        break;

    case QtCriticalMsg:
        text = QString("Critical:");
        break;

    case QtFatalMsg:
        text = QString("Fatal:");
    }

    QString current_date_time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
    QString current_date = QString("(%1)").arg(current_date_time);
    QString message = QString("%1 %2 %3").arg(text).arg(current_date).arg(msg);

    QFile file("log.txt");
    if (file.size() > 104857600)//size large than 100M split
    {
        QString filedate = QDateTime::currentDateTime().toString("yyyy-MM-dd--hh-mm-ss");
        file.rename(QString("log_%1.txt").arg(filedate));
        file.setFileName("log.txt");
    }
    file.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream text_stream(&file);
    text_stream.setCodec(QTextCodec::codecForName("System"));
    text_stream << message << "\r\n";
    file.flush();
    file.close();

    mutex.unlock();
}
Beispiel #9
0
void TimetableGenerateMultipleForm::stop()
{
	if(!simulation_running_multi){
		return;
	}

	simulation_running_multi=false;

	myMutex.lock();
	genMulti.abortOptimization=true;
	myMutex.unlock();

	QString s=TimetableGenerateMultipleForm::tr("Simulation interrupted!");
	s+="\n\n";

	QString s2=INPUT_FILENAME_XML.right(INPUT_FILENAME_XML.length()-INPUT_FILENAME_XML.lastIndexOf(FILE_SEP)-1);

	if(s2.right(4)==".fet")
		s2=s2.left(s2.length()-4);
	
	QString destDir=OUTPUT_DIR+FILE_SEP+"timetables"+FILE_SEP+s2+"-multi";

	time_t final_time;
	time(&final_time);
	int sec=int(final_time-initial_time);
	int h=sec/3600;
	sec%=3600;
	int m=sec/60;
	sec%=60;

	s+=TimetableGenerateMultipleForm::tr("The results were saved in the directory %1").arg(QDir::toNativeSeparators(destDir));
	s+="\n\n";
	s+=tr("Total searching time: %1h %2m %3s").arg(h).arg(m).arg(sec);
	
	TimetableExport::writeReportForMultiple(this, QString("\n")+s, false);

	QMessageBox::information(this, tr("FET information"), s);

	startPushButton->setEnabled(true);
	stopPushButton->setDisabled(true);
	minutesGroupBox->setEnabled(true);
	timetablesGroupBox->setEnabled(true);
	closePushButton->setEnabled(true);
}
Beispiel #10
0
void sendLoadSceneRPC(Player* player, QString sceneName, UVector pos) // Loads a scene and send to the given pos
{
    win.logMessage(QString(QString("UDP: Loading scene \"")+sceneName
                           +"\" to "+QString().setNum(player->pony.netviewId)
                           +" at "+QString().setNum(pos.x)+" "
                           +QString().setNum(pos.y)+" "
                           +QString().setNum(pos.z)));

    Scene* scene = findScene(sceneName);
    Scene* oldScene = findScene(player->pony.sceneName);
    if (scene->name.isEmpty() || oldScene->name.isEmpty())
    {
        win.logMessage("UDP: Can't find the scene, aborting");
        return;
    }

    // Update scene players
    //win.logMessage("sendLoadSceneRPC pos: locking");
    levelLoadMutex.lock();
    player->inGame=1;
    player->pony.pos = pos;
    player->pony.sceneName = sceneName.toLower();
    player->lastValidReceivedAnimation.clear(); // Changing scenes resets animations
    Player::removePlayer(oldScene->players, player->IP, player->port);
    if (oldScene->name.toLower() != sceneName.toLower())
    {
        // Send remove RPC to the other players of the old scene
        for (int i=0; i<oldScene->players.size(); i++)
            sendNetviewRemove(oldScene->players[i], player->pony.netviewId);

        // Send instantiate to the players of the new scene
        for (int i=0; i<scene->players.size(); i++)
            if (scene->players[i]->inGame>=2)
                sendNetviewInstantiate(&player->pony, scene->players[i]);
    }
    scene->players << player;

    QByteArray data(1,5);
    data += stringToData(sceneName.toLower());
    sendMessage(player,MsgUserReliableOrdered6,data); // Sends a 48
    //win.logMessage("sendLoadSceneRPC pos: unlocking");
    levelLoadMutex.unlock();
}
Beispiel #11
0
 bool GetDataFromQueuen(pComdata pData)
 {
     bool m_bbSuccess=false;
     if(pData == NULL)
     return m_bbSuccess;
     memset(pData,0,sizeof(Comdata));
     DataMutex.lock();
     if(m_outCount!=m_intoCount)
    {
     memcpy(pData,&mtQueuen[m_outCount++],sizeof(Comdata));
     if(m_outCount>=QueuenSize)
     m_outCount=0;
     m_bbSuccess=true;
     }


     DataMutex.unlock();
     return  m_bbSuccess;
 }
void TextProducer::run()
{
    static int index = 0;
    static QMutex indexMutex;

    for( int i=0; i<m_text.length(); ++i )
    {
        freeSpace.acquire();
        indexMutex.lock();
        buffer[ index++ % bufferSize ] = m_text[i];
        indexMutex.unlock();

        if( i == m_text.length()-1 )
            //atEnd = true;
            atEnd.acquire();

        availableData.release();
    }
}
    void run()
    {
        test_mutex.lock();
        test_mutex.lock();
        test_mutex.lock();
        test_mutex.lock();

        mutex.lock();
        for (int i = 0; i < iterations; ++i) {
            cond.wakeOne();
            cond.wait(&mutex);
        }
        mutex.unlock();

        test_mutex.unlock();
        test_mutex.unlock();
        test_mutex.unlock();
        test_mutex.unlock();
    }
bool QSpotifySearch::event(QEvent *e)
{
    if (e->type() == QEvent::User) {
        auto ev = static_cast<SearchResultEvent*>(e);
        if (ev) {
            if (auto search = ev->getSearch()) {
                g_mutex.lock();
                bool is_current = (m_sp_search == search);
                g_mutex.unlock();
                if (sp_search_error(search) == SP_ERROR_OK && is_current) {
                    if(ev->getPtr()) {
                        switch(ev->getPtr()->mType) {
                        case Albums:
                            populateAlbums(search);
                            break;
                        case Artists:
                            populateArtists(search);
                            break;
                        case Playlists:
                            populatePlaylists(search);
                            break;
                        case Tracks:
                            populateTracks(search);
                            break;
                        default:
                            populateResults(search);
                            break;
                        }
                    } else
                        populateResults(search);
                }
                clearSearch(search);
            }
        }
        setBusy(false);

        emit resultsChanged();

        e->accept();
        return true;
    }
    return QObject::event(e);
}
Beispiel #15
0
MsvClientMessage* AuctionAction::getPlayerMessage(AuctionPlayerModel* resultPlayer) { // returns null if player didnt send anything
	qDebug() << "AuctionAction::doAuction# Waiting " << *(resultPlayer->getGamePlayer()->getPlayerModel()->getName())<< " action..." ;
	QMutex* mutex = new QMutex();
	QWaitCondition cond;
	mutex->lock();
	for (int i = 0;i<20;i++) { // waiting for action 20 seconds
		qDebug() << "...";
		cond.wait(mutex,1000);
		if (!(resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->isEmpty())) {
			qDebug() << endl << "AuctionAction::doAuction# i got action message from " << *(resultPlayer->getGamePlayer()->getPlayerModel()->getName()) << endl;
			MsvClientMessage* returnMessage = resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->last();
			resultPlayer->getGamePlayer()->getPlayerModel()->getMessagePool()->clear();
			return returnMessage;
		}
	}
	mutex->unlock();
	delete mutex;
	return NULL;
}
Beispiel #16
0
bool OpenConnection(in_addr_t ipReal, const QString & strClient)
{
	std::map<in_addr_t, Client *>::iterator iterClient, iterOldClient;
	std::map<QString, ClientCreator>::iterator iterCreator;
	bool bSuccess = false;
	Client * pClient;

	g_mutexClients.lock();

	g_pLogger->LogInfo(QString("Starting %1 to host %2...").arg(strClient).arg(IPAddressToString(ipReal)));

	iterCreator = g_mapClientCreators.find(strClient);
	iterClient = g_mapClients.find(ipReal);

	if (iterClient != g_mapClients.end())
	{
		if (iterClient->second != NULL)
		{
			iterClient->second->Stop();
			delete iterClient->second;
		}
		g_mapClients.erase(iterClient);
	}
	if (iterCreator != g_mapClientCreators.end())
		pClient = (*iterCreator->second)();
	else
		pClient = NULL;

	if (pClient != NULL && pClient->Start(ipReal))
		bSuccess = g_mapClients.insert(std::pair<in_addr_t, Client *>(ipReal, pClient)).second;
	else if (pClient != NULL)
		delete pClient;

	if (bSuccess)
		g_pLogger->LogInfo("Successful\n");
	else
		g_pLogger->LogInfo("Failed\n");

	g_mutexClients.unlock();

	return bSuccess;
}
void RadioSendThread::run()
{

    RadioServer Server;
    if (!Server.Open())
    {
        printf("Server Open failed!\r\n");
        return;
    }

    int size;
    while (true)
    {

        qDebug() << "Available: " << RadioSendRequest.available();
        RadioSendRequest.acquire();
        if (shutdownView)break;
        RadioSendMutex.lock();
        RadioCmds.set_time_stamp(0);
        size= RadioCmds.cmds_size();
        qDebug() << "size:" << size;
        qDebug() << "IsInitialized: " << RadioCmds.IsInitialized();

        if (RadioCmds.IsInitialized() && size>0 && size<10)
        {

            RadioCmds.set_time_stamp(0);
            Server.Send(RadioCmds);
            qDebug() << "sending";
        }
        else
        {
            printf("Radio Send Packet Error!\r\n");
        }

        Server.Send(RadioCmds);

        RadioCmds.clear_cmds();
        RadioSendMutex.unlock();
        RadioSendRequest.release();
    }
}
Beispiel #18
0
void evaluateWithWeighting(ScanMatchingConfiguration &conf) {
    const TruthMap &map = *conf.map;
    QList<MeasureError> errors[4];
    int correctCounts[4] = {0, 0, 0, 0};
    static QMutex mutex;

    Eigen::Matrix3d sqrtCov = conf.covariance.llt().matrixL();
    Eigen::Matrix3d newCov  = 4 * conf.covariance;

    QList<LineSegment *> segments = map.map();

    for(int i = 0; i < conf.sampleCount; i++) {
        int pickedIndex = Shared::Random::integer(0, map.nodeCount() - 1);
        const SegmentScan *scan = map.scan(pickedIndex);
        const Pose &pose = map.pose(pickedIndex);
        const UncertainRototranslation corruptedPose(
                Rototranslation(Shared::Random::multiNormalRoot(
                        pose.vectorForm(), sqrtCov)), newCov);

        SemiDeterministicRetriever sdr(segments, *scan, corruptedPose);

        doScanMatch<LiGriffithsICL<SemiDeterministicRetriever> >(sdr, pose, newCov, correctCounts[0], errors[0]);
        doScanMatch<ClassicICL<SemiDeterministicRetriever, AssociationType, W> >(sdr, pose, newCov, correctCounts[1], errors[1]);
        doScanMatch<FilteredICL<SemiDeterministicRetriever, AssociationType, W> >(sdr, pose, newCov, correctCounts[2], errors[2]);
        doScanMatch<RANSACMatcher<SemiDeterministicRetriever, AssociationType, W> >(sdr, pose, newCov, correctCounts[3], errors[3]);

    }

    mutex.lock();
    lprint << conf << endl;

    lprint << "ligriffithsAccuracy=" << correctCounts[0] / (double) conf.sampleCount << ";" << endl;
    lprint << "classiciclAccuracy=" << correctCounts[1] / (double) conf.sampleCount << ";" << endl;
    lprint << "filterediclAccuracy=" << correctCounts[2] / (double) conf.sampleCount << ";" << endl;
    lprint << "ransacmatcherAccuracy=" << correctCounts[3] / (double) conf.sampleCount << ";" << endl;
    lprint << "ligriffithsErrors=" << errors[0] << ";" << endl;
    lprint << "classiciclErrors=" << errors[1] << ";" << endl;
    lprint << "filterediclErrors=" << errors[2] << ";" << endl;
    lprint << "ransacmatcherErrors=" << errors[3] << ";" << endl;
    lprint << endl;
    mutex.unlock();
}
Beispiel #19
0
void CG27::run()  
{  
  
    HRESULT hr;  
    if (g_pJoystick == NULL)   
    {  
        return;  
    }  
  
  
    while(1)  
    {  
        hr = g_pJoystick->Poll();  
        g_pJoystick->Acquire();  
        g_mutexG27.lock();  
        hr = g_pJoystick->GetDeviceState( sizeof( DIJOYSTATE2 ), &g_G27State);  
        emit(GetG27Info());  
        
		qDebug() << g_G27State.lX;
	/*	qDebug() << g_G27State.lY;
		qDebug() << g_G27State.lZ;
		qDebug() << g_G27State.lRx;
		qDebug() << g_G27State.lRy;
		qDebug() << g_G27State.lRz;
		qDebug() << g_G27State.lVX;
		qDebug() << g_G27State.lVY;
		qDebug() << g_G27State.lVZ;
		qDebug() << g_G27State.lAX;
		qDebug() << g_G27State.lAY;
		qDebug() << g_G27State.lAZ;
		qDebug() << " ";
	*/
		qDebug() << " ";
		qDebug() << " ";
        
		g_mutexG27.unlock();  
		usleep(5000);  
    }  
  
    return;  
  
}
void TActionContext::releaseAll()
{
    if (contextCount() > 0) {
        setMutex.lock();
        for (QSetIterator<TActionContext *> i(actionContexts); i.hasNext(); ) {
            i.next()->stop();  // Stops application server
        }
        setMutex.unlock();

        for (;;) {
            Tf::msleep(1);
            qApp->processEvents();

            QMutexLocker locker(&setMutex);
            if (actionContexts.isEmpty()) {
                break;
            }
        }
    }
}
Beispiel #21
0
void printme()
{

    qDebug() << "printme " << QThread::currentThread()->objectName() << " begin running";

    g_mutex.lock();

    for(int i = 0; i < 60000;i++)
    {
        for(int j = 0; j < 40000; j++)
            int r = i+j;

        if(i%10000 == 0)
            qDebug() << "Producer " << QThread::currentThread()->objectName() << " is running" << i;
    }

    qDebug() << "printme " << QThread::currentThread()->objectName() << " begin running";

    g_mutex.unlock();
}
Beispiel #22
0
void CloseConnection(in_addr_t ipReal)
{
	std::map<in_addr_t, Client *>::iterator iterConnection;

	g_mutexClients.lock();
	g_pLogger->LogInfo(QString("Stopping client to host %1...").arg(IPAddressToString(ipReal)));
	iterConnection = g_mapClients.find(ipReal);
	if (iterConnection != g_mapClients.end())
	{
		if (iterConnection->second != NULL)
		{
			iterConnection->second->Stop();
			delete iterConnection->second;
			iterConnection->second = NULL;
		}
		g_mapClients.erase(iterConnection);
	}
	g_pLogger->LogInfo("Successful\n");
	g_mutexClients.unlock();
}
void cCustomTitleModelTable::PrepareTable(cModelList *Table) {
    if (InModifTable) return;
    InModifTable=true;
    CustomTitleModelTableLockPaint.lock();
    this->setUpdatesEnabled(false);
    ModelTable=Table;
    int CurIndex=0;
    int NbrItem =ModelTable->List.count();
    int NbrCol  =this->viewport()->width()/ModelTable->ThumbnailSize.width();   if (NbrCol==0) NbrCol=1;
    int NbrRow  =NbrItem/NbrCol;
    if (NbrRow*NbrCol<NbrItem) NbrRow++;
    setColumnCount(NbrCol);
    setRowCount(NbrRow);
    setCurrentCell(CurIndex/NbrCol,CurIndex-(CurIndex/NbrCol)*NbrCol);
    for (int i=0;i<columnCount();i++)  setColumnWidth(i,ModelTable->ThumbnailSize.width()+20);
    for (int i=0;i<rowCount();i++)     setRowHeight(i,ModelTable->ThumbnailSize.height()+20);
    this->setUpdatesEnabled(true);
    InModifTable=false;
    CustomTitleModelTableLockPaint.unlock();
}
Beispiel #24
0
void MixerWorkerThread::run()
{
// set denormal protection for this thread
#ifdef __SSE3__
/* DAZ flag */
	_MM_SET_DENORMALS_ZERO_MODE( _MM_DENORMALS_ZERO_ON );
#endif
#ifdef __SSE__
/* FTZ flag */
	_MM_SET_FLUSH_ZERO_MODE( _MM_FLUSH_ZERO_ON );
#endif	
	QMutex m;
	while( m_quit == false )
	{
		m.lock();
		queueReadyWaitCond->wait( &m );
		globalJobQueue.run();
		m.unlock();
	}
}
Beispiel #25
0
QWaitConditionEvent *QWaitConditionPrivate::pre()
{
    mtx.lock();
    QWaitConditionEvent *wce =
        freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
    wce->priority = GetThreadPriority(GetCurrentThread());
    wce->wokenUp = false;

    // insert 'wce' into the queue (sorted by priority)
    int index = 0;
    for (; index < queue.size(); ++index) {
        QWaitConditionEvent *current = queue.at(index);
        if (current->priority < wce->priority)
            break;
    }
    queue.insert(index, wce);
    mtx.unlock();

    return wce;
}
void mythread::disconnected()
{
	QLinkedList<threadFrame>::iterator fit;
	qDebug() << "Client " << socketDescriptor << "has disconnected from the server.";
	//remover the thread from the list of frames... because if the thread isn't removed, then the system cleanup will never be able to work right.
	lock->lock(); //I only want one person playing around with the shared variables.
	for(fit=sysFrameList->begin();fit!=sysFrameList->end();fit++)
	{
		//search for yourself in the list, remove yourself.
		if(fit->socketDescriptor == this->socketDescriptor)
		{
			//found myself, need to remove.
			sysFrameList->erase(fit);
			break; //memory accesss issues if you erase something then do not break.
		}
	}
	lock->unlock();
	socket->deleteLater();
	mythread::exit();
}
Beispiel #27
0
void OutputDataThread::run()
{
    _byteList->clear();

    QMutex mutex;
    while(!_exitThread)
    {
        mutex.lock();
        if(_sendData > 0 && !_byteList->isEmpty())
        {
            _sendData--;
            _connection->sendAudioData(_byteList->takeFirst());
        }
        mutex.unlock();
    }

    return;

    exec();
}
Beispiel #28
0
void ThreadLearning::run(){
    cOCR->iterasi = 0;
    do
    {
        for(unsigned n = 0; n < cOCR->input.size(); ++n){

            cOCR->ocrNet.feedForward(cOCR->input[n]);

            cOCR->ocrNet.backProp(cOCR->target[n]);
        }
        cOCR->iterasi++;
        cOCR->prosesPersen = cOCR->targetError / cOCR->ocrNet.getError() * 100;
        QMutex mutex;
        mutex.lock();
        if(this->Stop) break;
        mutex.unlock();

        emit LearningProses();
    }while (cOCR->ocrNet.getError() > cOCR->targetError && cOCR->iterasi < cOCR->maxInterasi);
}
Beispiel #29
0
/*!
 * \brief outputMessage
 * \param type
 * \param context
 * \param msg
 *
 */
void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    static QMutex mutex;
    mutex.lock();

    QString text;
    switch(type)
    {
    case QtDebugMsg:
        text = QString("Debug:");
        break;

    case QtWarningMsg:
        text = QString("Warning:");
        break;

    case QtCriticalMsg:
        text = QString("Critical:");
        break;

    case QtFatalMsg:
        text = QString("Fatal:");
        break;
    default:
        text = QString("undefine: ");
    }

    QString context_info = QString("File:(%1) Line:(%2)").arg(QString(context.file)).arg(context.line);
    QString current_date_time = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss ddd");
    QString current_date = QString("(%1)").arg(current_date_time);
    QString message = QString("%1 %2 %3 %4").arg(text).arg(context_info).arg(msg).arg(current_date);

    QFile file("rocherlog.txt");
    file.open(QIODevice::WriteOnly | QIODevice::Append);
    QTextStream text_stream(&file);
    text_stream << message << "\r\n";
    file.flush();
    file.close();

    mutex.unlock();
}
Beispiel #30
0
void CmdTestProgress1::activated(int iMsg)
{
    try
    {
        QMutex mutex;
        mutex.lock();
        unsigned long steps = 1000;
        Base::SequencerLauncher seq("Starting progress bar", steps);

        for (unsigned long i=0; i<steps;i++)
        {
            seq.next(true);
            QWaitCondition().wait(&mutex, 30);
        }

        mutex.unlock();
    }
    catch (...)
    {
    }
}