Example #1
0
void SmsReader::onCpmsCommand()
{
    QString defaultStorage("SM");
    QString preferedStorage = "MT";
    AtCommand *cmd = qobject_cast<AtCommand*>(sender());
    if (cmd) {
        AtResult res = cmd->getCommandResult();
        if (res.resultCode() == AtResult::OK) {
            // expected responce like "+CPMS: "MT",6,100,"ME",6,100,"SM",0,20"
            QRegExp cpmsParser("^\\+CPMS:\\s*\\\"(\\w{2})\\\"\\s*,\\s*\\d+\\s*,\\s*\\d+,\\s*\\\"(\\w{2})\\\"\\s*,\\s*\\d+,\\s*\\d+\\s*,\\\"(\\w{2})\\\"\\s*,\\s*\\d+\\s*,\\s*\\d+");
            if (cpmsParser.indexIn(res.content()) >= 0) {
                for (int i = 1; i <= 3; ++i) {{
                        if (cpmsParser.cap(i).toUpper() == preferedStorage) {
                            defaultStorage = preferedStorage;
                            break;
                        }
                    }
                }
            }
        }
        cmd->deleteLater();
    }
    m_storage = defaultStorage;
    logMsg(QString("trying set default sms storage to \"%0\"...").arg(m_storage));

    cmd = new SimpleAtCommand(QString("AT+CPMS=\"%0\"").arg(m_storage));
    connect(cmd, SIGNAL(isProcessed()), this, SLOT(onSetDefaultStorageCommand()));
    m_atChat->addCommand(cmd);

}
Example #2
0
static void gff3ToPsl(char *mapFile, char *inGff3File, char *outPSL)
/* gff3ToPsl - convert a GFF3 file to a genePred file. */
{
    struct hash *chromHash = readSizes(mapFile);
    struct hash *processed = hashNew(12);
    struct gff3File *gff3File = loadGff3(inGff3File);
    FILE *pslF = mustOpen(outPSL, "w");
    struct gff3AnnRef *root;
    for (root = gff3File->roots; root != NULL; root = root->next)
    {
        if (!isProcessed(processed, root->ann))
        {
            processRoot(pslF, root->ann, processed, chromHash);
            if (convertErrCnt >= maxConvertErrs)
                break;
        }
    }
    carefulClose(&pslF);
    if (convertErrCnt > 0)
        errAbort("%d errors converting GFF3 file: %s", convertErrCnt, inGff3File);

#if 0  // free memory for leak debugging if 1
    gff3FileFree(&gff3File);
    hashFree(&processed);
#endif
}
Example #3
0
void SmsReader::getStorage()
{
    if (m_atChat->isOpen()){
        SimpleAtCommand *cmd = new SimpleAtCommand("AT+CPMS?");
        connect(cmd, SIGNAL(isProcessed()), this, SLOT(onCpmsCommand()));
        m_atChat->addCommand(cmd);
    }
}
Example #4
0
/// LOAD
void FileData::loadFile( const bool FORCE_RELOAD ) {
    if( isProcessed() && FORCE_RELOAD ) {
        std::string filename = getFileName();
        reset();
        setFileName( filename );
    }

    if( !isInitialized() ) {
        return;
    }

    // File extension check
    // - If we decide to deal with user-defined file, here we should check if we are dealing with one of them or not

    Assimp::Importer importer;
    const aiScene* scene = importer.ReadFile( getFileName(),
                                              aiProcess_Triangulate           | // This could/should be taken away if we want to deal with mesh types other than trimehses
                                              aiProcess_JoinIdenticalVertices |
                                              aiProcess_GenSmoothNormals      |
                                              aiProcess_SortByPType           |
                                              aiProcess_FixInfacingNormals    |
                                              aiProcess_CalcTangentSpace      |
                                              aiProcess_GenUVCoords );

    // File was not loaded
    if( scene == nullptr ) {
        LOG( logERROR ) << "Error while loading file \"" << getFileName() << "\" : " << importer.GetErrorString() << ".";
        return;
    }

    if( m_verbose ) {
        LOG(logINFO) << "File Loading begin...";
    }

    std::clock_t startTime;
    startTime = std::clock();

    AssimpGeometryDataLoader geometryLoader( Core::StringUtils::getDirName( getFileName() ), m_verbose );
    geometryLoader.loadData( scene, m_geometryData );

    AssimpHandleDataLoader handleLoader( m_verbose );
    handleLoader.loadData( scene, m_handleData );

    AssimpAnimationDataLoader animationLoader( m_verbose );
    animationLoader.loadData( scene, m_animationData );

    m_loadingTime = ( std::clock() - startTime ) / Scalar( CLOCKS_PER_SEC );

    if( m_verbose ) {
        LOG(logINFO) << "File Loading end.";
        displayInfo();
    }

    m_processed = true;
}
void postOrder(node * head)
{//LRD
    node * p;
    node * processed[SIZE];
    int indx = 0;
    
    if(head == NULL)
    {
        printf("\n Tree is not created ");
        return;
    }
    
    p = head->left; //root
    
    do//to visit all the node
    {
        while(p->lThread == 'n' && ! isProcessed(processed, indx, p->left))
        {//p has left child that is not processed
            p = p->left; //L
        }
        
        if(p->rThread == 'y' || isProcessed(processed, indx, p->right))
        {//p has not right child or processed right child
        
            //data
            printf(" %d ", p->data);
            processed[indx] =p;
            indx++;
            
            //follow a thread or a child
            do
            {
               p = p->right;
            }while(isProcessed(processed, indx, p));
        }
        else
        {// p has a right child
            p = p->right;
        }
    }while( ! isProcessed(processed, indx, head->left) );//loop
}
Example #6
0
void SmsReader::deleteSms(const int number)
{
    if (number >= count()) {
        return;
    }
    QSMSMessage msg = getSmsMessage(number);
    for (const int numSmsInMemory : msg.messageIds()) {
        SimpleAtCommand *cmd = new SimpleAtCommand(QString("AT+CMGD=%0").arg(numSmsInMemory));
        connect(cmd, SIGNAL(isProcessed()), this, SLOT(onDeleteCommand()));
        m_atChat->addCommand(cmd);
    }
    m_incomingMessages.removeAt(number);
}
Example #7
0
void SmsReader::check()
{
    if (!m_atChat->isOpen()) {
        return;
    }
    if (m_storage.isEmpty()) {
        getStorage();
        return;
    }
    SimpleAtCommand *cmd = new SimpleAtCommand("AT+CMGL=4");
    cmd->setWaitDataTimeout(2000);
    connect(cmd, SIGNAL(isProcessed()), this, SLOT(onRequestSmsCommand()));
    m_atChat->addCommand(cmd);
}
Example #8
0
bool ResolverRequest::checkAndhandleSlot(int index)
{
    bool done = getaddrinfoHasFinished(index);  // check if the request is done
    
    if(!done) {
        return false;
    }

    if(!isProcessed(index)) {                   // if it's done, check if it's processed
        processSlot(index);                     // not processed, process it
    }
     
    return true;
}
Example #9
0
int main(int argc, char* argv[])
{
  //reset random
  srand (time(NULL));
  //create 2D array of nodes
  xyNode* disk[TRACKS][SECTORS];
  int i, j, counter;
  int seek = 0;
  
  counter = 1;
  //initialize values into 2D array sequentially
  for(i = 0; i < TRACKS; i++)
  {
    for(j = 0; j < SECTORS; j++)
    {
      disk[i][j] = (xyNode*)malloc(sizeof(xyNode));
      disk[i][j]-> x = j;
      disk[i][j]-> y = i;
      disk[i][j]->value = counter;
      counter++;
    }
  } 

  //Fill request list a value from each track
  int k;
  xyNode* requestList[TRACKS];
  for(k = 0; k < TRACKS; k++){
    //choose 1 random processs on every track
    requestList[k] = disk[k][(int) rand() % (SECTORS)];
  }
 
  //Set head to point random disk location
  int xHead = rand() % (SECTORS);
  int yHead = rand() % (TRACKS);
  xyNode* head = disk[yHead][xHead];
  xyNode* tracker;
  printf("%s%d\n", "Head Originally set at ", head->value);  
  printf("\n");

 
  
  while(!isProcessed(requestList))  
  {
    tracker = head;
    //move head to closest
    head = getClosest(head, requestList);

    //seek time between head and next closest node
    seek = distance(head,tracker) + seek;
    printf("\nseek distance: %d\n", seek);
    
      printf("%s%d\n", "HEAD is now on ", head->value);

    //process request
    head = processRequest(head);  
   
    printRequestList(requestList);
  }
 
  printf("\n average seek time for sstf: %d" , (seek/TRACKS));  
  printf("\nOUTPUT OF THE DISK\n");
 for(i = 0; i <TRACKS; i++)
    {

      for(j = 0; j < SECTORS; j++)
	{
	  printf(" %d ", disk[i][j]->value);
	} 
      printf("\n");
    } 
  return 0;
}