void THTMLPedestal::createTableOfCuts()
{
	stringstream sectionContent;
	sectionContent<<"<h2>Seed and Hit Values in Units of Sigma</h2>\n";
	std::vector<std::vector< std::string > > tablecontent;
	std::vector<std::vector< std::string > > tablecontent2;
	tablecontent.resize(3);
	tablecontent.at(0).push_back("Detector");
	tablecontent.at(1).push_back("Seed");
	tablecontent.at(2).push_back("Hit");
	tablecontent2.resize(3);
	tablecontent2.at(0).push_back("Detector");
	tablecontent2.at(1).push_back("Seed");
	tablecontent2.at(2).push_back("Hit");
	for(UInt_t det =0;det <TPlaneProperties::getNDetectors();det+=2){
		tablecontent.at(0).push_back(TPlaneProperties::getStringForDetector(det));
		tablecontent.at(1).push_back(floatToString(settings->getClusterSeedFactor(det,0)));
		tablecontent.at(2).push_back(floatToString(settings->getClusterHitFactor(det,0)));
	}
	for(UInt_t det =1;det <TPlaneProperties::getNDetectors();det+=2){
		tablecontent2.at(0).push_back(TPlaneProperties::getStringForDetector(det));
		tablecontent2.at(1).push_back(floatToString(settings->getClusterSeedFactor(det,0)));
		tablecontent2.at(2).push_back(floatToString(settings->getClusterHitFactor(det,0)));
	}
	sectionContent<<"<br><h4> X Coordinates</h4><br>"<<this->createTable(tablecontent)<<"<br><br>";
	sectionContent<<"<br><h4> Y Coordinates</h4><br>"<<this->createTable(tablecontent2)<<"<br><br>";
	sectionContent<<"<h3>Seed-Cuts</h3>\n";
	sectionContent<<putImagesOfAllDetectors(path,"hPulseHeight_BiggestSignalInSigma");
	//	for(UInt_t det = 0; det< TPlaneProperties::getNSiliconDetectors();det+=2){
	//		stringstream name;
	//		name<<"hPulseHeight_BiggestHitChannelInSigma"<<TADCEventReader::getStringForDetector(det);
	//		sectionContent<<putImage(path,name.str());
	//	}
	//	for(UInt_t det = 1; det< TPlaneProperties::getNSiliconDetectors();det+=2){
	//		stringstream name;
	//		name<<"hPulseHeight_BiggestHitChannelInSigma"<<TADCEventReader::getStringForDetector(det);
	//		sectionContent<<putImage(path,name.str());
	//	}
	//	stringstream name;
	//	name<<"hPulseHeight_BiggestHitChannelInSigma"<<TADCEventReader::getStringForDetector(TPlaneProperties::getDetDiamond());
	//	sectionContent<<putImage(path,name.str());
	sectionContent<<"<h3>Hit-Cuts</h3>\n";
	sectionContent<<putImagesOfAllDetectors(path,"hPulseHeight_BiggestAdjacentInSigma_");
	//	for(UInt_t det = 0; det< TPlaneProperties::getNSiliconDetectors();det+=2){
	//		stringstream name;
	//		name<<"hPulseHeight_SecondBiggestHitChannelInSigma_"<<TADCEventReader::getStringForDetector(det);
	//		sectionContent<<putImage(path,name.str());
	//	}
	//	sectionContent<<"<br";
	//	for(UInt_t det = 1; det< TPlaneProperties::getNSiliconDetectors();det+=2){
	//		stringstream name;
	//		name<<"hPulseHeight_SecondBiggestHitChannelInSigma_"<<TADCEventReader::getStringForDetector(det);
	//		sectionContent<<putImage(path,name.str());
	//	}
	//	name.str("");name.clear();name.str("");
	//	name<<"hPulseHeight_SecondBiggestHitChannelInSigma_"<<TADCEventReader::getStringForDetector(TPlaneProperties::getDetDiamond());
	//	sectionContent<<putImage(path,name.str());
	this->addSection("Cluster Cuts",sectionContent.str());
}
Exemplo n.º 2
0
std::string SDT::toString()
{
	std::string result;

	result += "Class SDT contents:\n";
	result += "\tdate: ";
	result += m_date.toString();
	result += "\n\topeningPrice: ";
	result += floatToString(m_openingPrice);
	result += "\n\tclosingPrice: ";
	result += floatToString(m_closingPrice);
	result += "\n\ttoPrice: ";
	result += floatToString(m_topPrice);
	result += "\n\tfloorPrice: ";
	result += floatToString(m_floorPrice);
	result += "\n\tvolume: ";
	result += floatToString(m_volume);
	result +="\n\t20MaxPrice: ";
	result += floatToString(m_20Max);
	result += "\n\t20MinPrice: ";
	result += floatToString(m_20Min);
	result += "\n\t20AveragePrice: ";
	result += floatToString(m_20Average);
	result +="\n";
	return result;
}
void SelectBestCandidates::ntupleLoopCore(const int& entry_id)
{
  TString event_candidate_id =
      floatToString(stm_no) + 
      floatToString(exp_no) + 
      floatToString(run_no) + 
      floatToString(evt_no);
  
  EventCandidate event_candidate;
  event_candidate.entry = entry_id;
  event_candidate.momentum = l0_pcm + l1_pcm;
  
  unique_events_[event_candidate_id].push_back(event_candidate);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
void ofxGuiSlider::draw()
{
	glPushMatrix();

		glTranslatef(mObjX, mObjY, 0.0);

		if(mParamName != "")
			drawParamString(0.0, 0.0, mParamName + ": " + floatToString(mValue, mDisplay), false);

		float x = (mCtrWidth * valueToFraction(mValue));

		ofFill();

		//	background
		glColor4f(mGlobals->mCoverColor.r, mGlobals->mCoverColor.g, mGlobals->mCoverColor.b, mGlobals->mCoverColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

		//	action
		glColor4f(mGlobals->mSliderColor.r, mGlobals->mSliderColor.g, mGlobals->mSliderColor.b, mGlobals->mSliderColor.a);
		ofRect(mCtrX, mCtrY, x, mCtrHeight);

		//	handle
		glColor4f(mGlobals->mHandleColor.r, mGlobals->mHandleColor.g, mGlobals->mHandleColor.b, mGlobals->mHandleColor.a);
		ofRect(x, mCtrY, 1.0, mCtrHeight);

		ofNoFill();

		//	frame
		glColor4f(mGlobals->mFrameColor.r, mGlobals->mFrameColor.g, mGlobals->mFrameColor.b, mGlobals->mFrameColor.a);
		ofRect(mCtrX, mCtrY, mCtrWidth, mCtrHeight);

	glPopMatrix();
}
//Broadcasts readings
void broadcastReadings(float* rawReadings, char** units)
{
  logMsg("Broadcasting readings. . .", "INFO");
  //Requires an array of readings and an array of units
  int readingsLength = sizeof(*rawReadings)/sizeof(rawReadings[0]);
  int unitsLength = sizeof(*units)/sizeof(units[0]);
  
  if(readingsLength == unitsLength){

    char** formattedReadings;
    for(int j = 0; j < readingsLength ; ++j){
      strcpy(formattedReadings[j], floatToString(rawReadings[j]));
    }
    char* messageToBroadcast;
    for(int i = 0; i < readingsLength && i < unitsLength; ++i){
      //Put reading/unit pairs into message
      char* toAdd[] = {formattedReadings[i], MESSAGE_DELIMITER, units[i], MESSAGE_DELIMITER};
      messageToBroadcast = concatStrings(toAdd);
    }

//    sendMessage(messageToBroadcast, READING_IDENTIFIER);
  }
  else{
    logMsg("Readings and units vectors different lengths; they need to be the same size.", "ERROR"); 
  }
}
//Updates readings
float* updateValues()
{
  logMsg("Updating sensor values . . .", "DEBUG");
  float* sensorReadings[MY_NUM_SENSORS];

  float sensorRatios[MY_NUM_SENSORS];
  float resistances[MY_NUM_SENSORS];
  float readings[MY_NUM_SENSORS];

  // Step through available sensors and record a top and bottom value for each
  for(int i = 0; i < 2*MY_NUM_SENSORS; i += 2){
    //Steps through numSensors times
    float topReading = (float)analogRead(i);
    float bottomReading = (float)analogRead(i+1);
    float topBottom[] = { topReading, bottomReading };

    sensorReadings[i/2] = topBottom;
    sensorRatios[i/2] = sensorReadings[i][0]/sensorReadings[i][1];
    resistances[i/2] = (sensorRatios[i/2] - 1)*RBOTTOM;
    readings[i/2] = resistanceToTemp(resistances[i/2]);
    Serial.println(floatToString(readings[i/2]));
  }    
  logMsg("Sensor values updated.", "DEBUG");

  return readings;
}
Exemplo n.º 8
0
void Functions::toString(Aurora::NWScript::FunctionContext &ctx) {
	ctx.getReturn() = "";

	switch (ctx.getParams()[0].getType()) {
		case Aurora::NWScript::kTypeInt:
			intToString(ctx);
			break;

		case Aurora::NWScript::kTypeFloat:
			floatToString(ctx);
			break;

		case Aurora::NWScript::kTypeString:
			ctx.getReturn() = ctx.getParams()[0];
			break;

		case Aurora::NWScript::kTypeObject:
			objectToString(ctx);
			break;

		case Aurora::NWScript::kTypeVector:
			vectorToString(ctx);
			break;

		default:
			break;
	}
}
Exemplo n.º 9
0
 std::string Time::toString() const {
   std::string result;
   switch(kind) {
   case GE:        result = ">=" + floatToString(t1);
     break;
   case LE:        result  = "<=" + floatToString(t2);
     break;
   case INTERVAL:  result = "["+floatToString(t1)+","+floatToString(t2) + "]";
     break;
   case UNBOUNDED: result = "[0,infty]"; 
     break;
   default:
     break;
   } 
   return result;
 }
Exemplo n.º 10
0
void PnlGlobal::refresh(GRender& render) {

	std::string time = getTimeFormatted(getUptimeMS());

	render.print(26, 0, time.c_str());

	render.print(1, 0, "packets:");
	render.print(12, 0, intToString(sum.receivedPackets));

	render.print(1, 1, "bytes:");
	render.print(12, 1, intToString(sum.receivedBytes));


	render.print(12, 3, "Total");
	render.print(25, 3, "PerPacket");

	uint32_t payload = sum.receivedBytes - sum.receivedProtocolOverheadBytes;
	uint32_t payloadPerPacket = payload / (sum.receivedPackets + 0.00001);
	render.print(1, 4, "payload:");
	render.print(12, 4, intToString(payload).c_str());
	render.print(25, 4, intToString(payloadPerPacket).c_str());


	uint32_t protoOverhead = (sum.receivedProtocolOverheadBytes) / (float) (payload + 0.00001) * 100;
	uint32_t overheadPerPacket = sum.receivedProtocolOverheadBytes / (sum.receivedPackets + 0.00001);
	std::string overhead = "(" + floatToString(protoOverhead, 1) + "%)";
	render.print(1, 5, "overhead:");
	render.print(12, 5, intToString(sum.receivedProtocolOverheadBytes).c_str());
	render.print(25, 5, intToString(overheadPerPacket).c_str());
	render.print(29, 5, overhead.c_str());

}
Exemplo n.º 11
0
void Nimbits::recordValue(double value, String pointId) {
  EthernetClient client;

 String json;
 json =  "{\"d\":\"";
 json += floatToString(value, 4);

json +=  "\"}";
  String content;

  content += "&json=";
  content += json;
  content += "&id=";
  content +=  pointId;



  if (client.connect(_hostname.c_str(), _port)) {

    doPost(client, VALUE_API, content);

    String response = getFullResponse(client);


    client.stop();
  }
  else {

    client.stop();
  }

}
Exemplo n.º 12
0
//#define DEBUG
blobtype best_blob(double alpha_0, double alpha_F, double inc_alpha,
                   double a_0, double a_F, double inc_a, double w, double *target_att,
                   int target_length)
{
    blobtype retval;
    retval.order = 2;
    int alpha_size = FLOOR((alpha_F - alpha_0) / inc_alpha + 1);
    int a_size = FLOOR((a_F - a_0) / inc_a + 1);
    Image<double> att, ops;
    att().resize(alpha_size, a_size);
    ops().resize(alpha_size, a_size);
    int i, j;
    double a, alpha, best_a = -1, best_alpha = -1;
    double best_ops = 1e10, best_att = 0;
    for (i = 0, alpha = alpha_0; i < alpha_size; alpha += inc_alpha, i++)
        for (j = 0, a = a_0; j < a_size; a += inc_a, j++)
        {
            retval.radius = a;
            retval.alpha = alpha;
            A2D_ELEM(att(), i, j) = blob_att(w, retval);
            A2D_ELEM(ops(), i, j) = blob_ops(w, retval);
            if (j > 0)
                for (int n = target_length - 1; n >= 0; n--)
                    if (A2D_ELEM(att(), i, j - 1) > target_att[n] &&
                        A2D_ELEM(att(), i, j) < target_att[n])
                    {
                        A2D_ELEM(att(), i, j) = 0;
                        if (A2D_ELEM(ops(), i, j - 1) < best_ops &&
                            A2D_ELEM(att(), i, j - 1) >= best_att)
                        {
                            best_alpha = alpha;
                            best_a = a - inc_a;
                            best_ops = A2D_ELEM(ops(), i, j - 1);
                            best_att = target_att[n];
                        }
                    }
        }
#ifdef DEBUG
    att.write((std::string)"att" + floatToString(w) + ".xmp");
    ops.write((std::string)"ops" + floatToString(w) + ".xmp");
#endif

    retval.radius = best_a;
    retval.alpha = best_alpha;
    return retval;
}
Exemplo n.º 13
0
/*--------------------------------------------------------------------*//*!
 * \brief Write key-value-pair into log
 * \param log			qpTestLog instance
 * \param name			Unique identifier for entry
 * \param description	Human readable description
 * \param tag			Optional tag
 * \param value			Value of the key-value-pair
 * \return true if ok, false otherwise
 *//*--------------------------------------------------------------------*/
deBool qpTestLog_writeFloat (qpTestLog* log, const char* name, const char* description, const char* unit, qpKeyValueTag tag, float value)
{
	char tmpString[64];
	floatToString(value, tmpString, sizeof(tmpString));

	/* <Number Name="name" Description="description" Tag="Performance">15</Number> */
	return qpTestLog_writeKeyValuePair(log, "Number", name, description, unit, tag, tmpString);
}
Exemplo n.º 14
0
void GMLWriter::addPoint( float x, float y, float z, float time ) {
  char fp[5];
  String s;
  s += "<pt><x>";
  floatToString(&fp[0], x, 5);
  s += fp;
  s +=  "</x><y>";
  floatToString(&fp[0], y, 5);
  s += fp;
  s +=  "</y><z>";
  floatToString(&fp[0], z, 5);
  s += fp;
  s +=  "</z>";
  s += "<t>";
  floatToString(&fp[0], time, 5);
  s += fp;
  s += "</t></pt>";
  file.write(s.c_str());
}
Exemplo n.º 15
0
/*EDU US*/ 	void rgb_lcd::newWrite(double nbr){

	//--- On convertit en String
		DEBUG2("Le nbr recu est : ", nbr); 
		
		//- Enregistrement
		String nbrToStr;
		nbrToStr = floatToString(nbr);
		DEBUG2("Le nbr converti en chaine est : ", nbrToStr);
		effectiveNewWrite(nbrToStr);
}
Exemplo n.º 16
0
void ComputerView::setPingDelay(double delay)
{
	Wt::WString text;

	if (delay < 0)
		text = "Timeout";
	else
		text = Wt::WString("{1} ms").arg(floatToString(delay, 2));

	_ping_txt->setText(text);
	app->triggerUpdate();
}
Exemplo n.º 17
0
bool circleEmitter::updateParticle(particle *p){
    if(p != NULL && p->life > 0){
        p->prevPos.x = p->pos.x;
        p->prevPos.y = p->pos.y;
        p->prevPos.z = p->pos.z;
        
        p->dir = p->dir*(fmax((p->life),e->life/1.1)/(float)e->life);
        
        p->pos.x += p->dir.x;
        p->pos.y += p->dir.y;
        p->pos.z += p->dir.z;
        
        p->dir.x += e->force.x*cosf(p->pos.y)*p->side;
        p->dir.y += e->force.y*cosf(p->pos.y)*p->side;
        p->dir.z += e->force.z*cosf(p->pos.y)*p->side;
        
        p->life--;
        if(recording){
            *emitterInfo << floatToString(p->pos.x) << endl;
            *emitterInfo << floatToString(p->pos.y) << endl;
            *emitterInfo << floatToString(p->pos.z) << endl;
        }
        return true;
    }else if(p != NULL && p->life == 0){
        if(p->prev != NULL){
            p->prev->next = p->next;
        }else{
            e->particleList = p->next;
        }
        if(p->next != NULL){
            p->next->prev = p->prev;
        }
        p->next = *managerParticleList;
        p->prev = NULL;
        *managerParticleList = p;
        e->particleCount--;
    }
    
    return false;
}
Exemplo n.º 18
0
// Create deformed PDB =====================================================
FileName ProgNmaAlignment::createDeformedPDB(int pyramidLevel) const {
	String program;
	String arguments;
	FileName fnRandom;
	fnRandom.initUniqueName(nameTemplate,fnOutDir);
	const char * randStr = fnRandom.c_str();

	program = "xmipp_pdb_nma_deform";
	arguments = formatString(
			"--pdb %s -o %s_deformedPDB.pdb --nma %s --deformations ",
			fnPDB.c_str(), randStr, fnModeList.c_str());
	for (size_t i = 0; i < VEC_XSIZE(trial) - 5; ++i)
		arguments += floatToString(trial(i)) + " ";
	runSystem(program, arguments, false);

	program = "xmipp_volume_from_pdb";
	arguments = formatString(
			"-i %s_deformedPDB.pdb --size %i --sampling %f -v 0", randStr,
			imgSize, sampling_rate);

	if (do_centerPDB)
		arguments.append(" --centerPDB ");

	if (useFixedGaussian) {
		arguments.append(" --intensityColumn Bfactor --fixed_Gaussian ");
		if (sigmaGaussian >= 0)
			arguments += formatString("%f",sigmaGaussian);
	}
	//else
		//arguments +=" --poor_Gaussian"; // Otherwise, a detailed conversion of the atoms takes too long in this context
		
	progVolumeFromPDB->read(arguments);
	progVolumeFromPDB->tryRun();

	if (do_FilterPDBVol) {
		program = "xmipp_transform_filter";
		arguments = formatString(
						"-i %s_deformedPDB.vol --sampling %f --fourier low_pass %f  -v 0",
						randStr, sampling_rate, cutoff_LPfilter);
		runSystem(program, arguments, false);
	}

	if (pyramidLevel != 0) {
		Image<double> I;
		FileName fnDeformed = formatString("%s_deformedPDB.vol",randStr);
		I.read(fnDeformed);
		selfPyramidReduce(BSPLINE3, I(), pyramidLevel);
		I.write(fnDeformed);
	}
	return fnRandom;
}
Exemplo n.º 19
0
//Broadcasts readings
void broadcastReadings(float* rawReadings, char** units)
{
  logMsg("Broadcasting readings. . .", "INFO");
  //Requires an array of readings and an array of units
  int readingsLength = sizeof(*rawReadings)/sizeof(rawReadings[0]);
  int unitsLength = sizeof(*units)/sizeof(units[0]);
  
  char* messageToBroadcast;
  if(readingsLength == unitsLength){
    for(int i = 0; i < readingsLength && i < unitsLength; ++i){
      //Put reading/unit pairs into message
      char* temp = floatToString(rawReadings[i]);
      char* toAdd[] = {floatToString(rawReadings[i]), MESSAGE_DELIMITER, units[i]};
      char* newMsg[] = {messageToBroadcast, concatStrings(toAdd, sizeof(toAdd)/sizeof(toAdd[0]))};
      messageToBroadcast = concatStrings(newMsg, sizeof(newMsg)/sizeof(newMsg[0]));
    }
 //   Serial.println(messageToBroadcast);
    sendMessage(messageToBroadcast, READING_IDENTIFIER);
  }
  else{
    logMsg("Readings and units vectors different lengths; they need to be the same size.", "ERROR"); 
  }
}
Exemplo n.º 20
0
void GMLWriter::addPoint( float x, float y, float time ) {	
  String s;
  char fp[10];
  s += "<pt><x>";
  //sprintf(&fp[0],  "%f", x);
  floatToString(&fp[0], x, 5);
  Serial.print(fp);
  //itoa(x, fp, 10);
  s += fp;
  s +=  "</x><y>";
  //sprintf(&fp[0], 5, "%f", y);
  floatToString(&fp[0], y, 5);
  Serial.print(fp);
  s += fp;
  s +=  "</y><t>";
  //snprintf(&fp[0], 5, "%f", z);
  floatToString(&fp[0], time, 5);
  Serial.print(fp);
  s += fp;
  s +=  "</t></pt>";

  file.write(s.c_str());
}
Exemplo n.º 21
0
void NumberInputWidget::setValue(float value)
{
	if (!getText().empty())
	{
		m_oldValue = getValue();
	}
	value = constraintValue(value);
	std::string text = floatToString(value, m_precision);
	if (getText() != text)
	{
		replaceText(text);
		valueChanged(this, text);
	}
}
Exemplo n.º 22
0
std::string sdOSCMessage::getAllArgumentsAsString(void){
    int numArguments = typetags.size() -1;
    std::string str;
    for(int i = 0; i < numArguments; i++){
        switch(typetags[i+1]){ // we need to skip ','
            case 'i':
                str += intToString(getArgumentAsInt(i));
                break;
            case 'f':
                str += floatToString(getArgumentAsFloat(i));
                break;
            case 's':
                str += getArgumentAsString(i);
                break;
        }
        str += " ";
    }
    return str;
}
Exemplo n.º 23
0
std::map<std::string, std::string> Component::getAttributes() const
{
  std::map<std::string, std::string> attributes;
  
  attributes["id"] = mId;
  attributes["name"] = mName;
  
  if (mSampleRate != 0.0f)
  {
    attributes["sampleRate"] = floatToString(mSampleRate);
  }
  
  if (!mUuid.empty())
  {
    attributes["uuid"] = mUuid;
  }
  
  return attributes;
}
Exemplo n.º 24
0
	//-------------------------------------------------------------------------------
	void GameApp::renderDebugHUD()
	{
		if( m_renderDebugHUD )
		{
			m_renderer->pushCamera( m_debugCamera );
			m_mainFontParams.set( "text", std::string( "FPS: " ) + floatToString( m_currentFPS, 0 ) );
			mat4f modelMatrix( mat4f::IDENTITY );
			modelMatrix.translate( vec3f( (float)m_screenWidth, (float) m_screenHeight - 30.0f, 0.0f ) );
			m_mainFontParams.set( "modelMatrix", modelMatrix );
			m_mainFontParams.set( "posRel", std::string( "TOPRIGHT" ) );
			fireEvent( "renderText", m_mainFontParams );
			
			//m_mainFontParams.set( "posRel", std::string( "TOPLEFT" ) );
			//modelMatrix.loadIdentity();
			//modelMatrix.translate( vec3f( 0.0f, (float)m_screenHeight ) );
			//m_mainFontParams.set( "modelMatrix", modelMatrix );
			ProfileSystem::getInstance()->renderData( vec3f( 50.0f, (float)m_screenHeight - 30.0f, 0.0f ), m_debugCamera );
			m_renderer->popCamera();
		}
	}
Exemplo n.º 25
0
int main(void)
{
	GPIO_InitTypeDef GPIO_InitStructure;
	//RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); //enable gpioB peripherial clock
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);	//enable gpioA peripherial clock

	GPIO_InitStructure.GPIO_Pin = SCE|RES|DC|SCLK|SDIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	GPIO_Init(GPIOA, &GPIO_InitStructure);

	GPIO_SetBits(GPIOA, SCE|RES|DC|SCLK|SDIN);

	LCDinit(); //initialize LCD parameters


    while(count--)
    {
    	LCDString("Hello worlds! ");
    }
    setXY(0,5);
    //while(count2--){

    	//writeCharInv('C');
   // }

    newString("0.123457",0,2);
	
		
    floatToString(value-count2);
		newFont('V',55,5);

		/*To Do:
			
		*/
		
    return 0;
	
}
Exemplo n.º 26
0
int main(int argc, char *argv[])
{
  {
    // test toStringWithComma
    int x[] = {INT_MIN, -1234567890, -123456, -12345, -1000, -999, -1,
               0, 1, 999, 1000, 12345, 123456, 1234567890, INT_MAX};
    int n = sizeof(x)/ sizeof(x[0]);
    for (int i = 0; i < n; ++i) {
      printf("%-15d : %s\n", x[i], toStringWithComma(x[i]).c_str());
    }
  }

  {
    // test toString
    std::vector<double> a;
    a.push_back(1.1);
    a.push_back(2.0);
    std::string s = floatToString(a);
    printf("%s\n", s.c_str());
  }
  return 0;
}
Exemplo n.º 27
0
void Emitter::recordEmission(string outputFile){
    emitterInfo = new ofstream (outputFile.c_str());
    if (emitterInfo->is_open())
    {
        *emitterInfo << floatToString(e->pos.x) << endl;
        *emitterInfo << floatToString(e->pos.y) << endl;
        *emitterInfo << floatToString(e->pos.z) << endl;
        
        *emitterInfo << floatToString(e->dir.x) << endl;
        *emitterInfo << floatToString(e->dir.y) << endl;
        *emitterInfo << floatToString(e->dir.z) << endl;

        *emitterInfo << floatToString(e->dirVar.x) << endl;
        *emitterInfo << floatToString(e->dirVar.y) << endl;
        *emitterInfo << floatToString(e->dirVar.z) << endl;

        *emitterInfo << floatToString(e->speed) << endl;
        *emitterInfo << floatToString(e->speedVar) << endl;
        
        *emitterInfo << intToString(e->totalParticles) << endl;

        *emitterInfo << intToString(e->emitsPerFrame) << endl;
        *emitterInfo << intToString(e->emitVar) << endl;
        *emitterInfo << intToString(e->life) << endl;
        *emitterInfo << intToString(e->lifeVar) << endl;
        
        *emitterInfo << floatToString(e->force.x) << endl;
        *emitterInfo << floatToString(e->force.y) << endl;
        *emitterInfo << floatToString(e->force.z) << endl;
 
        recording = true;
    }
    else cout << "Unable to open file";
}
Exemplo n.º 28
0
void command_handler(uint8_t command){
	uint16_t wbuf;
	uint8_t bufh, bufl;
	float fbuf;
	char sbuf[10];
	switch(command){

		/* read temperature in human readable form */

		case READ_TEMP:
		sendByte(command);
		fbuf = getTemperature( ADC_read() );
		floatToString(fbuf, sbuf);
		sendString(sbuf);
		sendString(EOM);
		break;

		/* read temperature in raw ADC counts */
		case READ_TEMP_RAW:
		sendByte(command);
		wbuf = ADC_read();
		HexToAscii(sbuf, 4, wbuf);
		sendString(sbuf);
		sendString(EOM);
		break;

		/* set operational voltage @25°C */

		case SET_UBIAS_A:
		// echo the command
		sendByte(command);
		// waiting for a 4 character string
		receiveString(sbuf, 4);
		sendString(EOM);
		// set ADC register to given value
		wbuf = AsciiToHex(sbuf, 4);
		// max 0x7FF
		ADC_REG = 0x7FF & wbuf;
		break;

		/* set the temperature progression coefficient */

		case SET_COEFF:
		// echo...
		sendByte(command);
		// waiting for a 2 character string
		receiveString(sbuf, 2);
		sendString(EOM);
//		Vcoef = AsciiToHex(sbuf, 2);
		// max value = 0x7F
//		Vcoef &= 0x7F;		
		break;

		/* read the calculated adjusted operational voltage */

		case READ_UADJ_A:
		sendByte(command);
		// get temperature
		fbuf = getTemperature( ADC_read() );
		// calculate temperature adjusted voltage
		wbuf = calcAdjustedBiasVoltage(fbuf);
		// create string
		HexToAscii(sbuf, 5, wbuf);
		sendString(sbuf);
		sendString(EOM);
		break;

		/* read temperature coefficient */

		case READ_COEFF:
		sendByte(command);
		sendString(EOM);
		break;

		/* print help */

		case PRINT_HELP:
		sendByte(command);
		sendString("HW Version x.x SW Version 2.0");
		sendString(EOM);
		break;

		/* print sipm info of module */
		case SIPM_INFO:
		sendByte(command);
		sendString(EOM);
		break;
		
		case DAC_CAL:
		sendByte(command);
		sendString(EOM);
		break;
	
		default:
		MPPC_status = ADDRESSED;
	}


}
Exemplo n.º 29
0
void GuiEditor::updateDisplay() {

	if(opened == true) {

	int bufsize = -1;
	switch(myProg.iBufferSize){
		case 512:
			bufsize = 0;
			break;

		case 1024:
			bufsize = 1;
			break;

		case 2048:
			bufsize = 2;
			break;

		case 4096:
			bufsize = 3;
			break;

		case 8192:
			bufsize = 4;
			break;
	}
	bufferMenu->setCurrent(bufsize);

	float val = myProg.fGain;

	gainFader->setValue(val/(float)maxGain);
	gainDisplay->setText(floatToString(val).c_str());
	mySpectrumView->gain = val;

	val = myProg.fResponse;
	responseFader->setValue(val);
	responseDisplay->setText(floatToString(val).c_str());

	val = myProg.fXScale;
	xScaleFader->setValue(val/(float)maxXScale);
	xScaleDisplay->setText(floatToString(val).c_str());

	val = myProg.fYScale;
	yScaleFader->setValue(val/(float)maxYScale);
	yScaleDisplay->setText(floatToString(val).c_str());

	int nBands = myProg.iNBands;

	bandsFader->setValue(nBands/(float)maxBands);
	bandsDisplay->setText(intToString(nBands).c_str());
	mySpectrumView->nBands = nBands;

	ampScaleMenu->setCurrent(myProg.iAmpScale);
	freqScaleMenu->setCurrent(myProg.iFreqScale);
	displayMenu->setCurrent(myProg.iDisplay);
	mySpectrumView->display = myProg.iDisplay;
	typeMenu->setCurrent(myProg.iType);
	mySpectrumView->displayType = myProg.iType;
	resamplingMenu->setCurrent(myProg.iResampling);


	std::string address = myProg.sAddress;
	//const char * c = address.c_str();
	addressDisplay->setText(address.c_str());
	//addressDisplay->setText(c);

	std::string host = myProg.sHost;
	//const char * d = host.c_str();
	hostDisplay->setText(host.c_str());


	int port = myProg.iPort;
	portDisplay->setText(intToString(port).c_str());

	sender.setup(myProg.sHost, myProg.iPort);
	
	}

}
Exemplo n.º 30
0
//-----------------------------------------------------------------------------
void GuiEditor::valueChanged (CControl* control)
{
	//effect->setParameterAutomated (control->getTag (), control->getValue ());

	float value;
	int ival;
	const char* text;
	std::string result;
	char* tempt;

	switch (control->getTag())
	{

		case kBufferSize:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateBufferSize(ival);
			break;
	
		case kGain:
			value = control->getValue();
			result = floatToString(value*maxGain);
			gainDisplay->setText(result.c_str());
			updateGain(value*maxGain);
			break;

		case kGainText:
			text = ((CTextEdit*)(control))->getText();
			value = charToFloat(text);
			gainFader->setValue(value/(float)maxGain);
			updateGain(value);
			break;

		case kXScale:
			value = control->getValue();
			result = floatToString(value*maxXScale);
			xScaleDisplay->setText(result.c_str());
			updateXScale(value*maxXScale);
			break;

		case kXScaleText:
			text = ((CTextEdit*)(control))->getText();
			value = charToFloat(text);
			xScaleFader->setValue(value/(float)maxXScale);
			updateXScale(value);
			break;

		case kYScale:
			value = control->getValue();
			result = floatToString(value*maxYScale);
			yScaleDisplay->setText(result.c_str());
			updateYScale(value*maxYScale);
			break;

		case kYScaleText:
			text = ((CTextEdit*)(control))->getText();
			value = charToFloat(text);
			yScaleFader->setValue(value/(float)maxYScale);
			updateYScale(value);
			break;

		case kResponse:
			value = control->getValue();
			result = floatToString(value);
			responseDisplay->setText(result.c_str());
			updateResponse(value);
			break;

		case kResponseText:
			text = ((CTextEdit*)(control))->getText();
			value = charToFloat(text);
			responseFader->setValue(value);
			updateResponse(value);
			break;

		case kBands:
			ival = (int)(control->getValue()*maxBands);
			result = intToString(ival);
			bandsDisplay->setText(result.c_str());
			bandsFader->setValue(((float)ival)/(float)maxBands);
			updateBands(ival);
			break;

		case kBandsText:
			text = ((CTextEdit*)(control))->getText();
			ival = charToInt(text);
			bandsFader->setValue((float)value/(float)maxBands);
			updateBands(ival);
			break;

		case kAmpScale:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateAmpScale(ival);
			break;

		case kType:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateType(ival);
			break;

		case kDisplay:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateDisplayt(ival);
			break;

		case kResampling:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateResampling(ival);
			break;

		case kFreqScale:
			((COptionMenu*)(control))->getCurrent(tempt);
			ival = ((COptionMenu*)(control))->getIndex(tempt);
			updateFreqScale(ival);
			break;



		case kAddress:
			text = ((CTextEdit*)(control))->getText();
			updateAddress(text);
			break;

		case kPort:
			text = ((CTextEdit*)(control))->getText();
			ival = charToInt(text);
			updatePort(ival);
			break;

		case kHost:
			text = ((CTextEdit*)(control))->getText();
			updateHost(text);
			break;
	}

}