예제 #1
0
int main(int argc, char *argv[]) {
   QCoreApplication app(argc, argv);
   if (app.arguments().size() > 1) return writeOutput();
   AppendTest test;
   QTEST_SET_MAIN_SOURCE_PATH
   return QTest::qExec(&test, argc, argv);
}
예제 #2
0
void faToGcStats(char *inFaFile, char *noGapBedFile, unsigned int windowSize, char *outFile)
{
	struct dnaSeq *seqList = NULL;
	struct hash *noGapHash = NULL;
	double totalWindows = 0;
	double *gcBins = NULL;
	AllocArray(gcBins, windowSize+1);

	verbose(2, "reading in fa file\n");
	seqList = faReadAllDna(inFaFile);

	verbose(2, "reading in no gap file\n");
	noGapHash = bedLoadNInHash(noGapBedFile, 3);

	verbose(2, "finding the kmers that appear more than once\n");
	totalWindows = gatherGcStats(seqList, noGapHash, windowSize, gcBins);
	
	verbose(2, "writing uniqueness of each position\n");
	writeOutput(gcBins, windowSize, totalWindows, outFile);

	if(optWiggle != NULL)
	{
		verbose(2, "writing wiggle output\n");
		outputGcStatsWiggle(seqList, noGapHash, windowSize, optWiggle);
	}

	verbose(2, "done\n");
}
예제 #3
0
//arg1: number of nodes to add; arg2: 9 digit seed for RNG
int main(int argc, char **argv)
{
	nodes = atoi(argv[1]);
	seed = atof(argv[2]);
	eligible = (int *)malloc(nodes*sizeof(int));
	memset(eligible, 0, nodes*sizeof(int));

	init();

	//determine how many additional connections each node needs
	for(int i = 0; i < nodes; i++)
		eligible[i] = (int) round(power_rng(&seed, alpha, min, max));

	//add those connections as necessary
	for(int i = 0; i < nodes; i++)
	{
		if(eligible[i] > 0)
			addConnections(i, eligible[i]);
	}

	writeOutput();

	cleanup();

	return EXIT_SUCCESS;
}
예제 #4
0
//function for rotating an image
void rotate(double angle,long int height,long int width,HIPL_IMAGE *it,HIPL_IMAGE *ot,char *argv){
long int x;
long int y;
printf("total rows %ld \n",height);
printf("total columns %ld \n",width);
int tr;
scanf("%d",&tr);
for(x = 0; x < 263; x++) {
for(y = 0; y < width; y++) {
long int hwidth = width / 2;
long int hheight = height / 2;
		
long int xt = x - hwidth;
long int yt = y - hheight;
		

printf("currnent row %ld \n",x);
printf("currnent column %ld \n",y);
double sinma = sin(-angle);
double cosma = cos(-angle);
		
long int xs = (int)round((cosma * xt - sinma * yt) + hwidth);
long int ys = (int)round((sinma * xt + cosma * yt) + hheight);
//ot->iarr[x][y] = 100;
if(xs >= 0 && xs < width && ys >= 0 && ys < height) {
ot->iarr[x][y] = it->iarr[x][y];
} else {
ot->iarr[x][y] = it->iarr[x][y];

}
//HIPL_StoreResult(argv,ot);
}
}
writeOutput(ot,argv);
}
예제 #5
0
파일: io.c 프로젝트: AndTH/GCA
void doTimedOff(int i) {
    if (Ports[i].timedoff) {
        if (Ports[i].timer == 0) {
            Ports[i].timedoff = 0;
            if (Ports[i].cfg & PORTCFG_IN) {
                CANMsg canmsg;
                // Send an OPC.
                if (NV1 & CFG_SHORTEVENTS) {
                  canmsg.b[d0] = Ports[i].cfg & PORTCFG_INV ? OPC_ASON : OPC_ASOF;
                } else {
                  canmsg.b[d0] = Ports[i].cfg & PORTCFG_INV ? OPC_ARON : OPC_AROF;
                }
                canmsg.b[d1] = (NN_temp / 256) & 0xFF;
                canmsg.b[d2] = (NN_temp % 256) & 0xFF;
                canmsg.b[d3] = (Ports[i].addr / 256) & 0xFF;
                canmsg.b[d4] = (Ports[i].addr % 256) & 0xFF;
                canmsg.b[dlc] = 5;
                canbusSend(&canmsg);
                // check if an output is consumer of this event
                setOutput(NN_temp, Ports[i].addr, Ports[i].cfg & PORTCFG_INV ? 1 : 0);
            } else {
                writeOutput(i, 0);
            }
            //LED2 = 0;
        }
    }
}
예제 #6
0
bool AndroidDeployStep::init()
{
    m_packageName = AndroidManager::packageName(target());
    const QString targetSDK = AndroidManager::targetSDK(target());

    writeOutput(tr("Please wait, searching for a suitable device for target:%1.").arg(targetSDK));
    m_deviceAPILevel = targetSDK.mid(targetSDK.indexOf(QLatin1Char('-')) + 1).toInt();
    m_deviceSerialNumber = AndroidConfigurations::instance().getDeployDeviceSerialNumber(&m_deviceAPILevel);
    if (!m_deviceSerialNumber.length()) {
        m_deviceSerialNumber.clear();
        raiseError(tr("Cannot deploy: no devices or emulators found for your package."));
        return false;
    }

    QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(target()->profile());
    if (!version)
        return false;

    const Qt4BuildConfiguration *bc = static_cast<Qt4BuildConfiguration *>(target()->activeBuildConfiguration());
    if (!bc)
        return false;

    m_qtVersionSourcePath = version->sourcePath().toString();
    m_qtVersionQMakeBuildConfig = bc->qmakeBuildConfiguration();
    m_androidDirPath = AndroidManager::dirPath(target());
    m_apkPathDebug = AndroidManager::apkPath(target(), AndroidManager::DebugBuild).toString();
    m_apkPathRelease = AndroidManager::apkPath(target(), AndroidManager::ReleaseBuildSigned).toString();
    m_buildDirectory = static_cast<Qt4Project *>(target()->project())->rootQt4ProjectNode()->buildDir();
    m_runQASIPackagePath = m_QASIPackagePath;
    m_runDeployAction = m_deployAction;
    return true;
}
void
MSDetectorControl::close(SUMOTime step) {
    // flush the last values
    writeOutput(step, true);
    // [...] files are closed on another place [...]
    myIntervals.clear();
}
예제 #8
0
/**
* When the process shuts down, the event list is analyzed and the profiling results are written
* to the output file.
**/
void handleExitProcess(UserData* userData)
{
	IdaFile file = IdaFile();

	std::list<Event>& list = userData->getEventList().getList();

	std::map<Offset, TimedBlock*> timedBlocks = initBlockMap();
	std::map<Offset, TimedBlock*> timedFunctions = initFunctionMap();

	analyzeEventList(list, timedBlocks, timedFunctions);

	std::list<TimedBlock*> blockResults = projectSecond(timedBlocks);
	std::list<TimedBlock*> functionResults = projectSecond(timedFunctions);

	writeOutput(list, blockResults, functionResults);

	for (std::map<Offset, TimedBlock*>::iterator Iter = timedBlocks.begin(); Iter != timedBlocks.end(); ++Iter)
	{
		delete Iter->second;
	}

	removeBreakpoints();

	// Remove the debugger notification callback and get rid of the old userData
	file.getDebugger().removeEventCallback(debuggerCallback, userData);

	delete userData;
}
예제 #9
0
static bool childToMultiString(HWND output, BinStorage::STORAGE **ph, Config0::VAR *parent, LPSTR entryName, DWORD cfgID, BYTE valuesCount)
{
  Config0::VAR *pcvc;
  if((pcvc = Config0::_GetVar(parent, NULL, NULL, entryName)) && pcvc->dwChildsCount > 0)
  {
    DWORD count = 0;
    DWORD size = 0;
    LPSTR list = NULL;
    bool error = false;
    DWORD strSize;

    for(DWORD i = 0; i < pcvc->dwChildsCount; i++)
    {
      if(pcvc->pChilds[i].bValuesCount == valuesCount)
      {
        for(BYTE k = 0; k < valuesCount; k++)
        {
          if((strSize = Str::_LengthA(pcvc->pChilds[i].pValues[k])) == 0)
          {
            Mem::free(list);
            return false;
          }

          Str::UTF8STRING u8s;
          if(!Str::_utf8FromAnsi(pcvc->pChilds[i].pValues[k], strSize, &u8s))
          {
            error = true;
            break;
          }

          if(!Mem::reallocEx(&list, size + u8s.size + 2))
          {
            Str::_utf8Free(&u8s);
            error = true;
            break;
          }

          Mem::_copy(list + size, u8s.data, u8s.size + 1);
          size += u8s.size + 1;
          Str::_utf8Free(&u8s);
        }
        writeOutput(output, L"%S[%u]=%S", entryName, count++, pcvc->pChilds[i].pValues[0]);
      }
      else
      {
        Mem::free(list);
        return false;
      }
    }

    if(count > 0 && !error)
    {
      list[++size] = 0;
      error = !BinStorage::_addItem(ph, cfgID, BinStorage::ITEMF_COMBINE_OVERWRITE | BinStorage::ITEMF_IS_OPTION | BinStorage::ITEMF_COMPRESSED, list, size);
    }
    Mem::free(list);
    if(error)return false;
  }
  return true;
}
예제 #10
0
파일: idList.cpp 프로젝트: mmananth/CSE-655
void idList::writeOutput()
{
  cout<<" = ";
  idValue=id.getIDVal();
  cout<<idValue;
  writeOutput();
}
예제 #11
0
int Application::main(int argc,char *argv[])
  {
    // Process command line
    BOOM::CommandLine cmd(argc,argv,"");
    if(cmd.numArgs()!=6) 
      throw BOOM::String(
"\n\n\
train-tata-cap-model <tata.model> <cap.model> <intergenic.model> \n\
                      <min-submodel-separation> <max-submodel-separation>\n\
                      <outfile>\n\n");
    BOOM::String tataFile=cmd.arg(0);
    BOOM::String capFile=cmd.arg(1);
    BOOM::String intergenicFile=cmd.arg(2);
    minSeparation=cmd.arg(3).asInt();
    maxSeparation=cmd.arg(4).asInt();
    BOOM::String outfile=cmd.arg(5);

    // Load the intergenic model and reduce to zeroth order
    loadIntergenic(intergenicFile);

    // Load the cap site model and produce a likelihood ratio version of it
    loadCapModel(capFile);

    // Write out the submodels into a single model file
    writeOutput(tataFile,outfile);
    
    return 0;
  }
예제 #12
0
파일: io.c 프로젝트: AndTH/GCA
void resetOutputs(void) {
    int idx = 0;
    for (idx = 0; idx < 16; idx++) {
        if ((Ports[idx].cfg & 0x01) == 0) {
            writeOutput(idx, 0);
        }
    }
}
예제 #13
0
int main(int argc, char** argv)
{
    int grid_rows = 0, grid_cols = 0, iterations = 0;
    float *MatrixTemp = NULL, *MatrixPower = NULL;
    char tfile[] = "temp.dat";
    char pfile[] = "power.dat";
    char ofile[] = "output.dat";

    if (argc >= 3) {
        grid_rows = atoi(argv[1]);
        grid_cols = atoi(argv[1]);
        iterations = atoi(argv[2]);
        if (argc >= 4)  setenv("BLOCKSIZE", argv[3], 1);
        if (argc >= 5) {
          setenv("HEIGHT", argv[4], 1);
          pyramid_height = atoi(argv[4]);
        }
    } else {
        printf("Usage: hotspot grid_rows_and_cols iterations [blocksize]\n");
        return 0;
    }

    // Read the power grid, which is read-only.
    int num_elements = grid_rows * grid_cols;
    MatrixPower = new float[num_elements];
    readInput(MatrixPower, grid_rows, grid_cols, pfile);

    // Read the temperature grid, which will change over time.
    MatrixTemp = new float[num_elements];
    readInput(MatrixTemp, grid_rows, grid_cols, tfile);

    float grid_width = chip_width / grid_cols;
    float grid_height = chip_height / grid_rows;
    float Cap = FACTOR_CHIP * SPEC_HEAT_SI * t_chip * grid_width * grid_height;
    // TODO: Invert Rx, Ry, Rz?
    float Rx = grid_width / (2.0 * K_SI * t_chip * grid_height);
    float Ry = grid_height / (2.0 * K_SI * t_chip * grid_width);
    float Rz = t_chip / (K_SI * grid_height * grid_width);
    float max_slope = MAX_PD / (FACTOR_CHIP * t_chip * SPEC_HEAT_SI);
    float step = PRECISION / max_slope;
    float step_div_Cap = step / Cap;

    struct timeval starttime, endtime;
    long usec;
    runOMPHotspotSetData(MatrixPower, num_elements);
    gettimeofday(&starttime, NULL);
    runOMPHotspot(MatrixTemp, grid_cols, grid_rows, iterations, pyramid_height,
            step_div_Cap, Rx, Ry, Rz);
    gettimeofday(&endtime, NULL);
    usec = ((endtime.tv_sec - starttime.tv_sec) * 1000000 +
            (endtime.tv_usec - starttime.tv_usec));
    printf("Total time=%ld\n", usec);
    writeOutput(MatrixTemp, grid_rows, grid_cols, ofile);

    delete [] MatrixTemp;
    delete [] MatrixPower;
    return 0;
}
예제 #14
0
int main(){

	int i;
	int page_count=5;
	char wr_buffer[(page_count*PAGE_SIZE)];
	char rd_buffer[page_count*PAGE_SIZE];
	int res=0;

	/*	OPEN the file	*/
	if ((FILE_DESC = open("/dev/i2c-flash",O_RDWR)) < 0) {
		fprintf(stderr,"APP: Error: Failed to open the bus: %s\n",strerror(errno));
		exit(1);
	}
	printf("APP: File opened successfully\n");

	/* Populate the buffer to write	*/
	for(i=0; i<(page_count*PAGE_SIZE); i++){
		wr_buffer[i]='*';
	}

	/*	SEEK to page number	*/
	if(seek_EEPROM(510) ==-1)											//
		return -1;

	/*	write until it returns with 0	*/
	while((res=write(FILE_DESC, wr_buffer, page_count)) !=0){
		writeOutput(res);
		usleep(300000);
	}
	writeOutput(res);

	/*	SEEK to page number	*/
	if(seek_EEPROM(510) ==-1)											//
		return -1;

	while( (res=read(FILE_DESC,rd_buffer, page_count)) != 0)
	{
		readOutput(res, rd_buffer, page_count);
		usleep(300000);
	}
	readOutput(res, rd_buffer, page_count);

	return 0;
}
예제 #15
0
파일: io.c 프로젝트: AndTH/GCA
void restoreOutputStates(void) {
    int idx = 0;
    byte o1 = eeRead(EE_PORTSTAT + 0);
    byte o2 = eeRead(EE_PORTSTAT + 1);

    for (idx = 0; idx < 8; idx++) {
        if ((Ports[idx].cfg & 0x01) == 0) {
            byte o = (o1 >> idx) & 0x01;
            writeOutput(idx, o);
        }
    }
예제 #16
0
int main (int argc, char *argv[])
{
    if (argc < 2)
    {
        std::cout << "Error: Not enough arguments.\nUsage: ./streetname_fixer INPUT.pbf" << std::endl;
        return 1;
    }

    char* input_file_path = argv[1];
    boost::filesystem::path input_path(input_file_path);
    if (!boost::filesystem::exists(input_path))
    {
        std::cout << "Error: Input file " << input_file_path << " does not exists." << std::endl;
    }

    boost::filesystem::path output_path = input_path.filename().replace_extension(".csv");

    std::unique_ptr<EndpointWayMapT> endpoint_way_map;
    std::unique_ptr<ParsedWayVectorT> parsed_ways;
    std::unique_ptr<StringTableT> string_table;
    parseInput(input_file_path, endpoint_way_map, parsed_ways, string_table);

    auto name_getter = [](const ParsedWay& w) { return w.name_id; };
    auto ref_getter  = [](const ParsedWay& w) { return w.ref_id; };

    // Yes, just using inheritence would be possible, but we don't want virtual functions.
    // the lambdas will get inline.
    MissingValueDetector<decltype(name_getter)> name_detector(*endpoint_way_map, *parsed_ways, name_getter);
    MissingValueDetector<decltype(ref_getter)>  ref_detector(*endpoint_way_map, *parsed_ways, ref_getter);

    std::vector<ConsistencyError> name_errors = name_detector();
    std::cout << "Number of name errors: " << name_errors.size() << std::endl;
    writeOutput(name_errors, *string_table, "name", output_path.string());

    std::vector<ConsistencyError> ref_errors = ref_detector();
    std::cout << "Number of refs errors: " << ref_errors.size() << std::endl;
    writeOutput(ref_errors, *string_table, "ref", output_path.string());


    return 0;
}
예제 #17
0
void AbstractMaemoUploadAndInstallStep::handleUploadFinished(const QString &errorMsg)
{
    ASSERT_BASE_STATE(QList<BaseState>() << Deploying << StopRequested);
    ASSERT_STATE(QList<ExtendedState>() << Uploading << Inactive);

    if (m_extendedState == Inactive)
        return;

    if (!errorMsg.isEmpty()) {
        raiseError(errorMsg);
        setFinished();
    } else {
        writeOutput(tr("Successfully uploaded package file."));
        const QString remoteFilePath = uploadDir() + QLatin1Char('/')
            + QFileInfo(packagingStep()->packageFilePath()).fileName();
        m_extendedState = Installing;
        writeOutput(tr("Installing package to device..."));
        m_installer->installPackage(connection(), helper().cachedDeviceConfig(),
            remoteFilePath, true);
    }
}
예제 #18
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool CorrectInitializerList( AbstractFilter::Pointer filter, const QString& hFile, const QString& cppFile)
{
  QString contents;
  {
    // Read the Source File
    QFileInfo fi(cppFile);
    //
    if (fi.baseName().compare("RegisterPointSets") != 0)
    {
      return false;
    }
    QFile source(cppFile);
    source.open(QFile::ReadOnly);
    contents = source.readAll();
    source.close();
  }


  QStringList names;
  bool didReplace = false;

  QString searchString = filter->getNameOfClass() + "::" + filter->getNameOfClass();
  QStringList outLines;
  QStringList list = contents.split(QRegExp("\\n"));
  QStringListIterator sourceLines(list);

  int index = 0;
  while (sourceLines.hasNext())
  {
    QString line = sourceLines.next();
    if(line.contains(searchString) )
    {
      outLines.push_back(line);
      line = sourceLines.next();
      outLines.push_back(line); // get the call to the superclass

      fixInitializerList(sourceLines, outLines, hFile, cppFile);
      didReplace = true;
    }
    else
    {
      outLines.push_back(line);
    }
  }


  writeOutput(didReplace, outLines, cppFile);
  index++;

  return didReplace;
}
예제 #19
0
int
main(int argc, char *argv[]) {

    FILE *ifp;
    FILE *alpha_file, *imageout_file;
    pixel *colormap;
    int cols, rows;
    int transparent;  /* value of 'data' that means transparent */
    int *data;
        /* The image as an array of width * height integers, each one
           being an index int colormap[].
        */

    struct cmdline_info cmdline;

    ppm_init(&argc, argv);

    parse_command_line(argc, argv, &cmdline);

    verbose = cmdline.verbose;

    if ( cmdline.input_filespec != NULL ) 
        ifp = pm_openr( cmdline.input_filespec);
    else
        ifp = stdin;

    if (cmdline.alpha_stdout)
        alpha_file = stdout;
    else if (cmdline.alpha_filename == NULL) 
        alpha_file = NULL;
    else {
        alpha_file = pm_openw(cmdline.alpha_filename);
    }

    if (cmdline.alpha_stdout) 
        imageout_file = NULL;
    else
        imageout_file = stdout;

    ReadXPMFile(ifp, &cols, &rows, &colormap, &data, &transparent);
    
    pm_close(ifp);

    writeOutput(imageout_file, alpha_file, cols, rows, colormap, data,
                transparent);

    free(colormap);
    
    return 0;
}
예제 #20
0
/**
* Creates the output HTML file.
**/
void writeOutput(const std::list<Event>& list, std::list<TimedBlock*>& blockResults, std::list<TimedBlock*>& functionResults)
{
	msg("Generating the output file...\n");

	std::string pluginDir = ::idadir("plugins");
	std::string hotchDir = pluginDir + "/hotch";

	char filename[40] = {0};

	sprintf(filename, "results.html");
//	sprintf(filename, "results-%d.html", currentTime);

	std::string templateString;
	
	if (!readTextFile(hotchDir + "/template.htm", templateString))
	{
		msg("Could not read template file\n");
		return;
	}

	IdaFile file;

	unsigned int functions = file.getNumberOfFunctions();
	unsigned int hitFunctions = countHitBlocks(functionResults);
	unsigned int unhitFunctions = functions - hitFunctions;

	unsigned int blocks = file.getDebugger().getNumberOfBreakpoints();
	unsigned int hitBlocks = countHitBlocks(blockResults);
	unsigned int unhitBlocks = blocks - hitBlocks;	

	replaceString(templateString, "%FILENAME%", file.getInputfilePath());
	replaceString(templateString, "%NUMBER_OF_FUNCTIONS%", toString(functions));
	replaceString(templateString, "%NUMBER_OF_HIT_FUNCTIONS%", toString(hitFunctions));
	replaceString(templateString, "%NUMBER_OF_HIT_FUNCTIONS_PERCENTAGE%", floatToString(100.0 * hitFunctions / functions));
	replaceString(templateString, "%NUMBER_OF_NOT_HIT_FUNCTIONS%", toString(unhitFunctions));
	replaceString(templateString, "%NUMBER_OF_NOT_HIT_FUNCTIONS_PERCENTAGE%", floatToString(100.0 * unhitFunctions / functions));
	replaceString(templateString, "%NUMBER_OF_BLOCKS%", toString(blocks));
	replaceString(templateString, "%NUMBER_OF_HIT_BLOCKS%", toString(hitBlocks));
	replaceString(templateString, "%NUMBER_OF_HIT_BLOCKS_PERCENTAGE%", floatToString(100.0 * hitBlocks / blocks));
	replaceString(templateString, "%NUMBER_OF_NOT_HIT_BLOCKS%", toString(unhitBlocks));
	replaceString(templateString, "%NUMBER_OF_NOT_HIT_BLOCKS_PERCENTAGE%", floatToString(100.0 * unhitBlocks / blocks));
	replaceString(templateString, "%FUNCTIONS_BY_HITS%", generateFunctionTable(functionResults, sortByHits));
	replaceString(templateString, "%FUNCTIONS_BY_TIME%", generateFunctionTable(functionResults, sortByTime));
	replaceString(templateString, "%FUNCTIONS_BY_AVERAGE_TIME%", generateFunctionTable(functionResults, sortByAverageTime));
	replaceString(templateString, "%BLOCKS_BY_HITS%", generateBlocksTable(blockResults, sortByHits));
	replaceString(templateString, "%BLOCKS_BY_TIME%", generateBlocksTable(blockResults, sortByTime));
	replaceString(templateString, "%ALL_EVENTS%", generateEventsTable(list));

	writeOutput(hotchDir + "/" + filename, templateString);
}
예제 #21
0
void mitk::pa::SpectralUnmixingSO2::GenerateData()
{
  MITK_INFO(m_Verbose) << "GENERATING DATA..";

  // Get input image
  mitk::Image::Pointer inputHbO2 = GetInput(0);
  mitk::Image::Pointer inputHb = GetInput(1);

  CheckPreConditions(inputHbO2, inputHb);

  unsigned int xDim = inputHbO2->GetDimensions()[0];
  unsigned int yDim = inputHbO2->GetDimensions()[1];
  unsigned int zDim = inputHbO2->GetDimensions()[2];

  InitializeOutputs();

  mitk::ImageReadAccessor readAccessHbO2(inputHbO2);
  mitk::ImageReadAccessor readAccessHb(inputHb);

  const float* inputDataArrayHbO2 = ((const float*)readAccessHbO2.GetData());
  const float* inputDataArrayHb = ((const float*)readAccessHb.GetData());

  auto output = GetOutput(0);
  auto output1 = GetOutput(1);

  mitk::ImageWriteAccessor writeOutput(output);
  float* writeBuffer = (float *)writeOutput.GetData();

  mitk::ImageWriteAccessor writeOutput1(output1);
  float* writeBuffer1 = (float *)writeOutput1.GetData();

  for (unsigned int x = 0; x < xDim; x++)
  {
    for (unsigned int y = 0; y < yDim; y++)
    {
      for (unsigned int z = 0;z < zDim; z++)
      {
        unsigned int pixelNumber = (xDim*yDim * z) + x * yDim + y;
        float pixelHb = inputDataArrayHb[pixelNumber];
        float pixelHbO2 = inputDataArrayHbO2[pixelNumber];
        float resultSO2 = CalculateSO2(pixelHb, pixelHbO2);
        writeBuffer[(xDim*yDim * z) + x * yDim + y] = resultSO2;
        float resultTHb = CalculateTHb(pixelHb, pixelHbO2);
        writeBuffer1[(xDim*yDim * z) + x * yDim + y] = resultTHb;
      }
    }
  }
  MITK_INFO(m_Verbose) << "GENERATING DATA...[DONE]";
}
예제 #22
0
bool AndroidDeployStep::runCommand(QProcess *buildProc,
    const QString &program, const QStringList &arguments)
{
    writeOutput(tr("Package deploy: Running command '%1 %2'.").arg(program).arg(arguments.join(QLatin1String(" "))), BuildStep::MessageOutput);
    buildProc->start(program, arguments);
    if (!buildProc->waitForStarted()) {
        writeOutput(tr("Packaging error: Could not start command '%1 %2'. Reason: %3")
            .arg(program).arg(arguments.join(QLatin1String(" "))).arg(buildProc->errorString()), BuildStep::ErrorMessageOutput);
        return false;
    }
    buildProc->waitForFinished(-1);
    if (buildProc->error() != QProcess::UnknownError
            || buildProc->exitCode() != 0) {
        QString mainMessage = tr("Packaging Error: Command '%1 %2' failed.")
                .arg(program).arg(arguments.join(QLatin1String(" ")));
        if (buildProc->error() != QProcess::UnknownError)
            mainMessage += tr(" Reason: %1").arg(buildProc->errorString());
        else
            mainMessage += tr("Exit code: %1").arg(buildProc->exitCode());
        writeOutput(mainMessage, BuildStep::ErrorMessageOutput);
        return false;
    }
    return true;
}
예제 #23
0
bool DimBuilder::execute()
{
    Json::Reader reader;

    std::ifstream in(m_input);

    if (!in)
        return false;

    Json::Value root;
    if (!reader.parse(in, root))
    {
        std::cerr << reader.getFormattedErrorMessages();
        return false;
    }
    Json::Value dims = root.get("dimensions", Json::Value());
    if (root.size() != 1 || !dims.isArray())
    {
        std::ostringstream oss;

        oss << "Root node must contain a single 'dimensions' array.";
        throw dimbuilder_error(oss.str());
    }
    for (size_t i = 0; i < dims.size(); ++i)
    {
        Json::Value& dim = dims[(int)i];
        if (!dim.isObject())
        {
            std::ostringstream oss;

            oss << "Found a dimension that is not an object: " <<
                dim.asString();
            throw dimbuilder_error(oss.str());
        }
        extractDim(dim);
    }

    std::ofstream out(m_output);
    if (!out)
    {
        std::ostringstream oss;

        oss << "Unable to open output file '" << m_output << "'.";
        throw dimbuilder_error(oss.str());
    }
    writeOutput(out);
    return true;
}
예제 #24
0
void processFiles(WCHAR* outname)
{
	int tally;
	// parse def info into vector
	printf("parsing def...");
	parseDef();
	printf("done! %d items found.\nparsing txt...", g_items.size());
	parseTxt();
	printf("done! %d items found.\n", g_txt.size());
	// iterate vector to find and mark disabled instances in infile.txt
	printf("tidying things up...\n");
	checkTxt();
	printf("writing result to %S...", outname);
	tally = writeOutput(outname);
	printf("Done!\n%d of %d items were commented out\n", tally, g_items.size());
}
예제 #25
0
void AbstractMaemoUploadAndInstallStep::handleInstallationFinished(const QString &errorMsg)
{
    ASSERT_BASE_STATE(QList<BaseState>() << Deploying << StopRequested);
    ASSERT_STATE(QList<ExtendedState>() << Installing << Inactive);

    if (m_extendedState == Inactive)
        return;

    if (errorMsg.isEmpty()) {
        setDeployed(connection()->connectionParameters().host,
            MaemoDeployable(packagingStep()->packageFilePath(), QString()));
        writeOutput(tr("Package installed."));
    } else {
        raiseError(errorMsg);
    }
    setFinished();
}
예제 #26
0
// Codifica uma entrada num arquivo binario utilizando a codificação de Shannon-Fano
string encode(string *input, int *sizeB, int *sizeA)
{
    std::vector<Symbol> symbols;
    unsigned short num_bit = 1;
    bool flag = false;
    string file = "";

    if ((input != NULL) && (!input->empty()))
    {
        file = *input;
        flag = readFile(input);
    }
    
    if (flag)
    {
        *sizeB = input->size();
        
        makeVector(*input,symbols); // Constroi o vector com os simbolos

        while (symbols.size() > pow(2,num_bit)) // Conta quantos bits serao necessarios para representar os simbolos
            num_bit++;

        makeCodes(symbols); // Cria os codigos em Shannon-Fano de cada simbolo
        
        string encoded = charToSF(*input,symbols); // String com a mensagem na codificação de Shannon-Fano

        input->clear();
        
        string output = outArvore(symbols, encoded, input); // Saida do algoritmo de Shannon-Fano

        *sizeA = output.size();
        
        writeOutput(output, &file); // Escreve a(s) saida(s) no arquivo

        // Limpando memoria

        symbols.clear();
    
        // ---------------
        
        return output;
    }
    
    return "";
}
예제 #27
0
int main(void)
{
	eLibrary_CLT_registerClient();
	for (;;)
	{
		eLibrary_CLT_createRequest(str, &request);
		cache_hit = readCache(request, &response);
		if (false == cache_hit)
		{
			eLibrary_CLT_getResponse();
		}
		fillCache(response);
		writeOutput();

		freeResponse();
	}
	eLibrary_CLT_destroyClient();
}
      void
      CellWiseThermostatWithOutput::applyThermostat(int iteration)
      {
        saveV();
        //std::cout << "asdxsa" << std::endl;
        if (_ginterval != 0 && iteration % _ginterval == 0)
          {
            updateGlobalE();
          }

        if (_interval != 0 && iteration % _interval == 0)
          {
            updateLocalE();
            if (_ointerval != 0 && iteration % _ointerval == 0)
              writeOutput(_filename, iteration);
            adjustTemperature();
          }

      }
예제 #29
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QString AdjustOutputDirectory(const QString& pipelineFile)
{

  QString contents;

  // Read the Source File
  QFileInfo fi(pipelineFile);
  QFile source(pipelineFile);
  source.open(QFile::ReadOnly);
  contents = source.readAll();
  source.close();


  QString searchString = QString::fromLatin1("Data/Output/");
  QStringList outLines;
  QStringList list = contents.split(QRegExp("\\n"));
  QStringListIterator sourceLines(list);

  while (sourceLines.hasNext())
  {
    QString line = sourceLines.next();

    if( line.contains(QString("Data/")) == true && line.contains(searchString) == false )
    {
      line = line.replace(QString("Data/"), getDream3dDataDir() + "/Data/");
    }

    if(line.contains(searchString) )
    {
      line = line.replace(searchString, getTestTempDirectory());
    }

    outLines.push_back(line);

  }

  QString outFile = getTestTempDirectory() + fi.fileName();

  writeOutput(true, outLines, outFile);


  return outFile;
}
예제 #30
0
QDomElement HtmlTidy::output(QDomDocument& document)
{
    int errorLine = 0;
    int errorColumn = 0;
    QString errorText;

    QString html = writeOutput();
    if (!document.setContent(html, true, &errorText,
                            &errorLine, &errorColumn))
    {
        qWarning() << "---- parsing error:\n" << html << "\n----\n"
                   << errorText << " line:" << errorLine << " column:" << errorColumn;

        QDomElement domBody = document.createElement("body");
        domBody.appendChild(document.createTextNode(m_input));
        return domBody;
    }

    return document.documentElement().firstChildElement("body");
}