Esempio n. 1
0
// Store objects with their propterties as QJsonObjects
// This way, every object can have custom properties, without creating special object classes
// The objects and its properties also may be saved to file in a human readable and modifiable format
bool ObjectContainer::add(ObjectType type, QJsonObject& data)
{
	if (!verifyData(data)) return false;

	ObjectItem* item = new ObjectItem(data["name"].toString());
	item->setData(data);
	m_model.appendRow(item);
	return true;
}
Esempio n. 2
0
void onBlock(int rank, ADIOS_FILE* f, ADIOS_VARINFO* v, int i, int j, int blockCounter, FastBitDataType ft)
{
      char bmsVarName[100];
      char keyVarName[100];
      char offsetName[100];

      int64_t       var_ids_bms[v->nblocks[i]];
      int64_t       var_ids_key[v->nblocks[i]];
      int64_t       var_ids_offset[v->nblocks[i]];
             
      sprintf(bmsVarName, "bms-%d-%d-%d", v->varid, i, j);
      sprintf(keyVarName, "key-%d-%d-%d", v->varid, i, j);
      sprintf(offsetName, "offset-%d-%d-%d", v->varid, i, j);
      

      uint64_t blockSize = fastbit_adios_util_getBlockSize(v, i, j); 
      uint64_t blockDataByteSize = adios_type_size (v->type, v->value) * blockSize; 
      
      char notes[100];
      logTime(NULL); logTimeMillis(NULL);
      
      sprintf(notes, "  reading data from adios  on varid=%d, time=%d, block: %d, size=%ld bytes=%ld", v->varid, i, j, blockSize, blockDataByteSize);
      
      logTime(notes); logTimeMillis(notes);
      localtime(&indexRefresh);
      
      //printf("   %d th block / (%d), size= %" PRIu64 " bytes=%" PRIu64, j, blockSize, blockCounter, blockDataByteSize);
      
      void* data = malloc (blockDataByteSize);
      ADIOS_SELECTION* blockSel = adios_selection_writeblock(j);
      
      //adios_selcton_writeblock(num),  0 <= num <  nblocks[timestep]
      //ADIOS_SELECTION* blockSel = adios_selection_writeblock(blockCounter);
      int err = adios_schedule_read_byid(f, blockSel, v->varid, i, 1, data);
      if (!err) {	
	err = adios_perform_reads(f, 1);
      } else {
	printf("Unable to read block %d at timestep: %d \n", j, i);
	return;
	//break;
      }
      //fastbit_adios_util_printData(data, v->type, blockSize);

      char selName[20];
      sprintf(selName, "block-%d", j);
      processData(data, blockSize, rank, i, selName, ft, v);

      //processData(void* data, uint64_t dataCount, int rank, int timestep, char* selName, FastBitDataType ft, ADIOS_VARINFO* v)


      adios_selection_delete(blockSel);
      verifyData(f, v, blockCounter, i);
} // onblock
Esempio n. 3
0
void FullRun::perform() {
    Run::perform(); // process common data

    verifyData();
    setup();
    loadPTable(pTableFile);


    Interface::instance() << Interface::SEPARATOR << endl;
    Interface::instance().showLog(true);

    progress();

    Interface::instance() << Interface::SEPARATOR << endl;
    Interface::instance().showLog(true);

    if (!cloAllBpCalculated && !cloNoBpCalculated && !cloNo3sRecFile) {
        /* We calculate breakpoints for the best triplets */
        for (unsigned long i = 0; i < childDataset->getSize(); i++) {
            Genome* child = childDataset->getGenome(i);
            Triplet* bestRecTriplet = child->getBestRecombinantTriplet();
            if (bestRecTriplet != NULL) {
                recordRecombinantTriplet(bestRecTriplet);
            }
        }
    }


    if (isRandomMode && randomLoopNum > 1) {
        Interface::instance() << "Recombination sensitivity: "
                << recombinationSensitivity << "/" << randomLoopNum << "\n";
        Interface::instance().showOutput(true);
        
    } else {
        displayResult();
        Interface::instance() << Interface::SEPARATOR << endl;
        Interface::instance().showLog(true);
        savePValHistogram();
    }


    /* Close all files */
    if (fileSkippedTriplets)
        fileSkippedTriplets->close();
    if (fileRecombinants)
        fileRecombinants->close();
    if (fileLongRecombinants != NULL)
        fileLongRecombinants->close();
}
Esempio n. 4
0
void AplusPopup::receiveEvent(MSEvent &event_)
{
  if (event_.type() == AplusEvent::symbol())
   {
     if (dbg_tmstk) cout << "Received UpdateEvent in AplusPopup"  << endl;
     redraw();
   }
  if (event_.type() == AplusVerifyEvent::symbol())
   {
     if (dbg_tmstk) cout << "Received VerifyEvent in AplusPopup"  << endl;

     AplusVerifyEvent *ave = (AplusVerifyEvent *) &event_;
     ave->result(verifyData(ave->aplusVar(), ave->a()));
   }
}
Esempio n. 5
0
bool ObjectContainer::modify(QJsonObject& data)
{
	if (!verifyData(data)) return false;

	ObjectItem * item = getItem(data["id"].toInt());
	if (!item)
	{
		StaticLogger::logit("WARNING: Object not modified! The object with id '" + QString::number(data["id"].toInt()) + "' does not exist.");
		return false;
	}
	item->setData(data["name"].toString(), Qt::DisplayRole); // Modify name in gui
	item->setData(data); // Modify object data ( UserRole + 1)

	return true;
}
Esempio n. 6
0
int ProcessSearchProductInfo(int new_sock) 
{
	int	ErrorCode;
	int	i;

	PRODUCTINFO_REQ_T Request;
	PRODUCTINFO_RES_T *Result;

	printLog(HEAD, "==[MSG_GET_PRODUCT_INFO_REQ]==\n");

	if((ErrorCode = ReadProductInfoReq(new_sock, &Request)) == FAIL) {
		if(Request.ReqCount > 0 && Request.RequestList != (PRODUCTID_USERID_T *) NULL)	{
			free(Request.RequestList);
		}
		return ErrorCode;
	}

	if((Result = (PRODUCTINFO_RES_T *) malloc(sizeof(PRODUCTINFO_RES_T)*Request.ReqCount)) == NULL) {
		printLog(HEAD, "ERR: Memory Allocation Error... size(%d)\n", sizeof(PRODUCTINFO_RES_T)*Request.ReqCount);
		if(Request.ReqCount > 0 && Request.RequestList != (PRODUCTID_USERID_T *) NULL)	{
			free(Request.RequestList);
		}
		return FAIL;
	}
	memset(Result, 0, sizeof(PRODUCTINFO_RES_T)*Request.ReqCount);

	if((ErrorCode = verifyData(Request)) == TRUE)	{
		ErrorCode = processProductInfoGet(Request, Result);
	}

	WriteProductInfoMulti("MSG_GET_PRODUCT_INFO_REQ", MSG_GET_PRODUCT_INFO_REQ, MSG_PDA_ERROR, Request.ReqCount, Result, ErrorCode, new_sock);

	if(Request.ReqCount > 0 && Request.RequestList != (PRODUCTID_USERID_T *) NULL)	{
		free(Request.RequestList);
	}
	for(i = 0; i < Request.ReqCount; i++)	{
		if(Result[i].ResCount > 0 && Result[i].ResultData != (PRODUCTINFO_DATA_T *) NULL)	{
			free(Result[i].ResultData);
		}
	}
	if(Request.ReqCount && Result != (PRODUCTINFO_RES_T *)NULL)	
		free(Result);

	return TRUE;
}
Esempio n. 7
0
void AplusScrolledWindow::receiveEvent(MSEvent &event_)
{
  if (event_.type()==MSIndexedEvent::symbol())
   {
     MSIndexedEvent &ev=(MSIndexedEvent&)event_;
     update(ev.index());
   }
  else if (event_.type()==MSNullEvent::symbol())
    update(MSIndexVector::nullVector());
  else if (event_.type() == AplusEvent::symbol())
   {
     if (dbg_tmstk) cout << "Received UpdateEvent in AplusScrolledWindow"  << endl;
     redraw();
   }
  if (event_.type() == AplusVerifyEvent::symbol())
   {
     if (dbg_tmstk) cout << "Received VerifyEvent in AplusScrolledWindow"  << endl;

     AplusVerifyEvent *ave = (AplusVerifyEvent *) &event_;
     ave->result(verifyData(ave->aplusVar(), ave->a()));
   }
}
Esempio n. 8
0
/*
** Main function.
*/
int main(void)
{
    volatile char originalData[260] = {0}; 
    volatile char readFlash[260] = {0};
    unsigned int retVal = 0;
    unsigned char choice;

    /* Initializes the UART Instance for serial communication. */
    UARTStdioInit(); 

    UARTPuts("Welcome to SPI EDMA application.\r\n", -1);
    UARTPuts("Here the SPI controller on the SoC communicates with", -1);
    UARTPuts(" the SPI Flash present on the SoM.\r\n\r\n", -1);

    /* Initializes the EDMA3 Instance. */
    EDMA3Initialize();

    /* Initializes the SPI1 Instance. */
    SPIInitialize();

    /* Request EDMA3CC for Tx and Rx channels for SPI1. */
    RequestEDMA3Channels();

    /* Enable SPI communication. */
    SPIEnable(SOC_SPI_1_REGS);

    /* Enable the SPI Flash for writing to it. */
    WriteEnable();

    UARTPuts("Do you want to erase a sector of the flash before writing to it ?.", -1);
    UARTPuts("\r\nInput y(Y)/n(N) to proceed.\r\n", -1);

    choice = UARTGetc();
    UARTPutc(choice); 

    if(('y' == choice) || ('Y' == choice))
    {
        /* Erasing the specified sector of SPI Flash. */
        FlashSectorErase();
    }
    
    WriteEnable(); 

    /* Program a specified Page of the SPI Flash. */
    FlashPageProgram(originalData); 

    /* Read the contents of the page that was previously written to. */
    ReadFromFlash(readFlash);

    /* Verify whether the written and the read contents are equal. */
    retVal = verifyData(&originalData[4], &readFlash[4], 256); 

    if(TRUE == retVal)
    {
        UARTPuts("\r\nThe data in the Flash and the one written ", -1); 
        UARTPuts("to it are equal.\r\n", -1);
    }
    else
    {
        UARTPuts("\r\n\r\nThe data in the Flash and the one written to it", -1);
        UARTPuts(" are not equal.\r\n", -1);
    } 
    
    while(1);
}
Esempio n. 9
0
void
KeyChain::onCertificateData(const ptr_lib::shared_ptr<const Interest> &interest, const ptr_lib::shared_ptr<Data> &data, ptr_lib::shared_ptr<ValidationRequest> nextStep)
{
  // Try to verify the certificate (data) according to the parameters in nextStep.
  verifyData(data, nextStep->onVerified_, nextStep->onVerifyFailed_, nextStep->stepCount_);
}
Esempio n. 10
0
void GuiInspectorField::setData( const char* data, bool callbacks )
{
   if( mField == NULL )
      return;

   if( verifyData( data ) )
   {
      String strData = data;
      const U32 numTargets = mInspector->getNumInspectObjects();
      
      if( callbacks && numTargets > 1 )
      { mInspector->onBeginCompoundEdit_callback(); }
            
      for( U32 i = 0; i < numTargets; ++ i )
      {
         SimObject* target = mInspector->getInspectObject( i );
         
         String oldValue = target->getDataField( mField->pFieldname, mFieldArrayIndex);
         
         // For numeric fields, allow input expressions.
         
         String newValue = strData;
         S32 type= mField->type;
         if( type == TypeS8 || type == TypeS32 || type == TypeF32 )
         {
            char buffer[ 2048 ];
            expandEscape( buffer, newValue );
            newValue = Con::evaluatef( "%%f = \"%s\"; return ( %s );", oldValue.c_str(), buffer );
         }
         else if(    type == TypeS32Vector
                  || type == TypeF32Vector
                  || type == TypeColorI
                  || type == TypeColorF
                  || type == TypePoint2I
                  || type == TypePoint2F
                  || type == TypePoint3F
                  || type == TypePoint4F
                  || type == TypeRectI
                  || type == TypeRectF
                  || type == TypeMatrixPosition
                  || type == TypeMatrixRotation
                  || type == TypeBox3F
                  || type == TypeRectUV )
         {
            //TODO: we should actually take strings into account and not chop things up between quotes

            U32 numNewUnits = StringUnit::getUnitCount( newValue, " \t\n\r" );
            
            StringBuilder strNew;
            bool isFirst = true;
            for( U32 n = 0; n < numNewUnits; ++ n )
            {
               char oldComponentVal[ 1024 ];
               StringUnit::getUnit( oldValue, n, " \t\n\r", oldComponentVal, sizeof( oldComponentVal ) );
               
               char newComponentExpr[ 1024 ];
               StringUnit::getUnit( newValue, n, " \t\n\r", newComponentExpr, sizeof( newComponentExpr ) );
               
               char buffer[ 2048 ];
               expandEscape( buffer, newComponentExpr );

               const char* newComponentVal = Con::evaluatef( "%%f = \"%s\"; %%v = \"%s\"; return ( %s );",
                  oldComponentVal, oldValue.c_str(), buffer );
               
               if( !isFirst )
                  strNew.append( ' ' );
               strNew.append( newComponentVal );
               
               isFirst = false;
            }
            
            newValue = strNew.end();
         }
            
         target->inspectPreApply();
         
         // Fire callback single-object undo.
         
         if( callbacks )
         {
           mInspector->onInspectorFieldModified_callback( 
                                          target->getIdString(), 
                                          mField->pFieldname, 
                                          mFieldArrayIndex ? mFieldArrayIndex : "(null)", 
                                          oldValue.c_str(), 
                                          newValue.c_str() );
         }
            

         target->setDataField( mField->pFieldname, mFieldArrayIndex, newValue );
         
         // Give the target a chance to validate.
         target->inspectPostApply();
      }
      
      if( callbacks && numTargets > 1 )
      { mInspector->onEndCompoundEdit_callback(); }
   }

   // Force our edit to update
   updateValue();
}
Esempio n. 11
0
int main (int argc, char** argv) 
{
  fastbit_init(0);
  fastbit_set_verbose_level(0);

  ADIOS_FILE * f;
  //MPI_Comm    comm_dummy = 0;  // MPI_Comm is defined through adios_read.h 
  MPI_Comm comm_dummy = MPI_COMM_WORLD;

  int         rank, size;
  MPI_Init (&argc, &argv);			   
  MPI_Comm_rank (comm_dummy, &rank);
  MPI_Comm_size (comm_dummy, &size);

  adios_init_noxml (comm_dummy);
  
  if (argc < 2) {
    printf("Usage: index_fastbit fileName (attrName)");
    return 0;
  }

  f = adios_read_open_file (argv[1], ADIOS_READ_METHOD_BP, comm_dummy);
  if (f == NULL) {
    printf ("::%s\n", adios_errmsg());
    return -1;
  }
  
  /*
  adios_allocate_buffer (ADIOS_BUFFER_ALLOC_NOW, (f->file_size)*2/1048576 + 5); // +5MB for extra room in buffer
  adios_declare_group (&gAdios_group, gGroupNameFastbitIdx, "", adios_flag_yes);
  adios_select_method (gAdios_group, "MPI", "", "");
  */
  gIdxFileName = fastbit_adios_util_getFastbitIndexFileName(argv[1]);
  unlink(gIdxFileName);

      adios_allocate_buffer (ADIOS_BUFFER_ALLOC_NOW, 500); // +5MB for extra room in buffer
      adios_declare_group (&gAdios_group, gGroupNameFastbitIdx, "", adios_flag_yes);
      adios_select_method (gAdios_group, "MPI", "", "");

      adios_open (&gAdios_write_file, gGroupNameFastbitIdx, gIdxFileName, "w", MPI_COMM_WORLD);

#ifdef MULTI_BLOCK
      int testid = adios_define_var (gAdios_group, "pack", "", adios_integer , 0, 0, 0);
#endif
#ifdef BOX
      int testid = adios_define_var (gAdios_group, "elements", "", adios_integer , 0, 0, 0);
#endif
      //uint64_t estimatedbytes = (nb+nk+no)*adios_type_size(adios_double, NULL);
      int jobCounter = getJobCounter(f);
      uint64_t estimatedbytes =  getByteEstimationOnFile(f, rank);
      if (size > 1) {
	int maxJobsPP = jobCounter/size + 1;
        estimatedbytes = estimatedbytes * maxJobsPP /jobCounter +1048576;
      }

      estimatedbytes += 1048576;

      uint64_t adios_totalsize;      // adios_group_size needs to be call before any write_byid, Otherwise write_byid does nothing 
      adios_group_size (gAdios_write_file, estimatedbytes , &adios_totalsize);     

      printf("=> .. adios open output file: %s, rank %d allocated %" PRIu64 " bytes... \n", gIdxFileName, rank, adios_totalsize);
      // IMPORTANT: 
      // can only call open/close once in a process
      // otherwise data is tangled or only the data in the last open/close call is recorded

#ifdef MULTI_BLOCK
      adios_write_byid(gAdios_write_file, testid, &pack);
#endif
#ifdef BOX
      adios_write_byid(gAdios_write_file, testid, &recommended_index_ele);
#endif


  sumLogTime(-1);
  sumLogTimeMillis(-1);

  
  if (argc >= 3) {
     int i=2;
     while (i<argc) {
        const char* varName = argv[i];
	if(strstr(varName, "<binning prec") != NULL) {
	  if (gBinningOption == NULL) {
	    gBinningOption = argv[i];
	  }
	  if (argc == 3) {
	    buildIndexOnAllVar(f, rank, size);
	    break;
	  }
	  i++;
	  continue;
	} else {
	  ADIOS_VARINFO * v = adios_inq_var(f, varName);
	  if (v == NULL) {
	     printf("No such variable: %s\n", varName);
	     return 0;
	   }	
	  printf("building fastbit index on  variable: %s\n", varName);
	  buildIndex_mpi(f, v, rank, size);
	  adios_free_varinfo(v);
	  i++;
	}
     }
  } else {
    buildIndexOnAllVar(f, rank, size);
  }


  sumLogTime(0);
  sumLogTimeMillis(0);

  adios_close(gAdios_write_file);
  adios_read_close(f);

  //
  // writing file clean up
  //


  // read back:
  f = adios_read_open_file (gIdxFileName, ADIOS_READ_METHOD_BP, comm_dummy);
  if (f == NULL) {
    printf("No such file: %s \n", gIdxFileName);
    return 0;
  }

  int numVars = f->nvars;
  
  int i=0;
  int k=0;
  int j=0;
  for (i=0; i<numVars; i++) {
      char* varName = f->var_namelist[i];
      ADIOS_VARINFO* v = adios_inq_var(f, varName);

       adios_inq_var_blockinfo(f,v);      
      int timestep = 0;
      for (k=0; k<v->sum_nblocks; k++) {
	  verifyData(f, v, k, timestep);
      }

      adios_free_varinfo(v);
  }

  adios_read_close(f);

  if (rank == 0) {
    printf(" ==>  index file is at: %s\n", gIdxFileName);
  }

  // clean up
  MPI_Barrier (comm_dummy);
  adios_finalize (rank);
  MPI_Finalize ();
  free (gIdxFileName);

  fastbit_cleanup();
  return 0;
}