Пример #1
0
void BatchSyncMetadata::parsePicture()
{
    ImageInfo info = d->imageInfoList[d->imageInfoIndex];

    if (d->direction == WriteFromDatabaseToFile)
    {
        MetadataHub fileHub;
        // read in from database
        fileHub.load(info);
        // write out to file DMetadata
        fileHub.write(info.filePath());
    }
    else
    {
        d->scanner.scanFile(info, CollectionScanner::Rescan);
    }

    emit signalProgressValue((int)((d->count++/(float)d->imageInfoList.count())*100.0));

    d->imageInfoIndex++;
}
Пример #2
0
/*Write paskage to TOO*/
void ftdiChip::on_Machine()
{
static QQueue<QByteArray> templistCMD;
static quint16 retAnswer;
static int CurrentValue,ValueMax;
switch(stat)
    {
    case stOpen:
        if(!listCMD.isEmpty()){
            if(Open()==retOk){
                stat=stCounter;
                disconnect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()));
                setParametersUSB(parameter.retSpeed(),parameter.retDataBit(),parameter.retStopBit(),parameter.retParity());
                timerRead->setInterval(parameter.retTimeDelay());
                templistCMD = listCMD;
                CurrentValue = 0;
                ValueMax = 3*templistCMD.count();
                emit signalProgressRange(0,ValueMax);
                emit signalStep();
                }else {
                emit signalMessageError(tr("<CENTER><b>Not found KIT USN_RS485!</CENTER></b>"));
                emit signalStop();
                }
            }
        listCMD.clear();
        return;
    case stCounter:
        if(!templistCMD.isEmpty()){
            emit signalProgressValue(++CurrentValue,true);
            stat=stWrite;
            }else{
            stat=stClose;
            }
        emit signalStep();
        return;
    case stWrite:
        {
        QByteArray cmd(templistCMD.dequeue());//long Time;
        quint16 result = Bit8Write(cmd,1);
        emit signalSendMessage(false,cmd,Qt::green);
        if(result!=retOk){
            templistCMD.clear();stat=stCounter;emit signalStep();}
        stat=stRead;
        timerRead->start();
        emit signalProgressValue(++CurrentValue,true);
        }
        return;
    case stRead:
        {
        QByteArray resBuff;
        quint16 retRead =Read(resBuff);
        emit signalSendMessage(true,resBuff,Qt::darkBlue);
        retAnswer = CheckingReceivedPacket(resBuff);
        if(retAnswer&ANWR_PROTOCOL::retGet){
          return; // next package
          }
        if((retAnswer&(~(ANWR_PROTOCOL::retOK)))
             &&
           (retRead&(ftdiChip::retErr|ftdiChip::retBusyDevice))){// stop sending
          templistCMD.clear();
          }
        stat=stCounter;
        timerRead->stop();
        emit signalProgressValue(++CurrentValue,true);
        emit signalStep();
        }
        return;
    case stClose:
        Close();
        connect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()),Qt::DirectConnection);
    default:
        emit signalEnd(true);
        stat = stOpen;
        timerRead->stop();
        emit signalProgressValue(0,false);
        if(retAnswer&(ANWR_PROTOCOL::retOK)) // it is not error
          emit signalStatusOk(tr("Data is written successfully!"));
        if(retAnswer&ANWR_PROTOCOL::retError) // it is error
          emit signalStatusError(tr("Error response!"),false);
        if(retAnswer&ANWR_PROTOCOL::retNoAnsError) // it is error
          emit signalStatusError(tr("Device does not answer!"),false);
        if(retAnswer&ANWR_PROTOCOL::retIncorData)
          emit signalStatusError(tr("Data is incorrect!"),false);
        emit signalStep();
        return;        
  }
}