Exemplo n.º 1
0
__stdcall  function2(const char *graphName, const char *lineNum)
{ 
	static string outbuf;

    try
    {
		// ====== Find object or create a new one ===========
		GraphMap::iterator graphIter = graphs.find(graphName);

		if (graphIter != graphs.end())
		{
			int line = atoi(lineNum);
			if ((line > 0) && (line <= 4))
				graphIter->second.BarGraph(line, outbuf); // get line one of the graph
			else
				outbuf = "[bad line number]";
		}
		else
		{
			outbuf = "[No such graph]";
		}
        
	} catch (char *e) {
		outbuf = e;
	} catch (string s) {
		outbuf = s;
	} catch(...) {
        outbuf = "Exception";
    }

	return const_cast<char *>(outbuf.c_str());
}
Exemplo n.º 2
0
void SingleAnalysis::ComputeSystematics(int pointID, const GraphMap &nominalMap, const GraphMap &systGraphMap,
		GraphName graphName, GraphSystErrorMap &upperBoundErrorMap, GraphSystErrorMap &lowerBoundErrorMap)
{
	double systVar = 0.d;
	double nominalVar = 0.d;
	double systVarDiff = 0.d;

	nominalVar = nominalMap.find(graphName)->second->GetY()[pointID];
	systVar = systGraphMap.find(graphName)->second->GetY()[pointID];
	systVarDiff = systVar - nominalVar;

	std::cout << "Graph name : " << graphName << std::endl;
	std::cout << "syst error on point id " << pointID << " is " << systVarDiff << std::endl;

	if( systVarDiff > 0.d )
		upperBoundErrorMap[graphName] += systVarDiff*systVarDiff;
	else
		lowerBoundErrorMap[graphName] += systVarDiff*systVarDiff;
}
Exemplo n.º 3
0
Graph&
findOrCreateGraph(const char *param1, const char *param2)
{
	string graphName(param2);

	// check if we have seen this graph definition before
	GraphMap::iterator graphIter = graphs.find(graphName);

    if (graphIter != graphs.end())
	{
		assert(graphIter->first == graphName);
		if (graphIter->second.createParams == param1)
			return graphIter->second;

		// inital parameters have changed - delete the old object and create a new one.
		graphs.erase(graphIter);
	}
           
    // otherwise create the object  

	
        // ====== Parse parameters ===========
		// param1 is options and takes the form:
		//   HeightxWidth#Direction#BarStyle#SampleTime#min#max#CounterName
		// where:
		//   HeightxWidth is the size of the bar graph
		//   Direction is one of: d, u, l, r   [for down/up/left/right]
		//   SampleTime is how often the counter value is fetched, in 1/10 seconds.
		//   BarStyle selects the custom characters to use
		//   CounterName is a name of a performance counter (ie. '\Processor(0)\% Processor Time')
	    //   min - used for scaling graph.
	    //   max - used for scaling graph.
		// param2 is a name to use in function2 to get further lines.
	    
		// handle HeightxWidth
		unsigned int height = atoi(param1); 
		char *x = strchr(param1, 'x');
        if (x == NULL)
           throw "[HEIGHTxWIDTH required]";
		unsigned int width = atoi(x+1);
		if ((width < 1) || (width > 40))
			throw "[Width out of range]";
		if ((height < 1) || (height > 4))
			throw "[Height out of range]";

		// handle Direction
		Graph::Direction direction;
		char *hash = strchr(x, '#');
		if (hash != NULL)
		{
			hash ++;
			switch (*hash)
			{
			case 'l': direction = Graph::LEFT; break;
			case 'r': direction = Graph::RIGHT; break;
			case 'u': direction = Graph::UP; break;
			case 'd': direction = Graph::DOWN; break;
			default: throw "[Invalid direction]";
			}
		} 
		else
			direction = Graph::UP;

		// handle BarStyle
		unsigned int barStyle;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad bar style]";
			barStyle = atoi(hash);
		}
		else
			barStyle = 1;
		

		// handle SampleTime
		unsigned int sampleTime;
		if (hash != NULL)
			hash = strchr(hash, '#');

		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad sample time]";
			sampleTime = atoi(hash) * 100; // convert to mSec

			if (sampleTime < 1)
				throw "[Invalid Sample Time]";
		} 
		else
			sampleTime = 500; 
		


		// handle min
		unsigned int min;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad min]";
			min = atoi(hash);
		}
		else
			min = 0;

		// handle max
		unsigned int max;
		if (hash != NULL)
			hash = strchr(hash, '#');
	
		if (hash != NULL)
		{
			hash ++;
			if (!JustDigits(hash))
				throw "[perf: bad max]";
			max = atoi(hash);
		}
		else
			max = 100;
				
		// handle counterName
		char *counterName;
		if (hash != NULL)
			hash = strchr(hash, '#');

		if (hash != NULL)
		{
			hash ++;
			counterName = hash;
		}
		else
			counterName = "\\Processor(0)\\% Processor Time";

		
		// Convert our barStyle to that used by graph
		switch (barStyle)
		{
		case 0: break;
		case 1: break;
		case 2: barStyle |= SIXWIDE; break;
		case 3: barStyle |= SIXWIDE | SEVENHIGH; break;
		case 4: barStyle |= SEVENHIGH; break;
		case 5: break;
		case 9: barStyle = 6 | SEVENHIGH; break;
		case 13: barStyle = 7 | SEVENHIGH; break;
		case 99: barStyle = TINY; break;
		case 100: barStyle = TINY | SIXWIDE; break;
		case 101: barStyle = TINY | SIXWIDE | SEVENHIGH; break;
		case 102: barStyle = TINY | SEVENHIGH; break;
		default:
			throw "[perf: unknown bar style]";
		}


		if (barStyle & TINY) // special bar style for small (1x8 or less) graphs
		{
			if (height > 1)
				throw "[Graph too high for tiny graphs]";
			if (width > 8)
				throw "[Graph too wide for tiny graphs]";

			if (barStyle & SIXWIDE)
				width *= 6;
			else
				width *= 5; // there are 5 pixels in a custom chars.
		}

		
		graphs.insert(pair<string, GraphObj>(graphName, 
			GraphObj(param1, height, width, sampleTime, string(counterName), direction, barStyle, min, max)));
		GraphMap::iterator graphIter2 = graphs.find(graphName);
		assert(graphIter2 != graphs.end());
		return graphIter2->second;
}