コード例 #1
0
ファイル: parser_generator.c プロジェクト: brunzero/module_3
int main()
{
    project1();
    program2();
    project3();
    return 0;
}
コード例 #2
0
ファイル: Blinker.cpp プロジェクト: chsegala/angry_mailbox
void Blinker::_blink(void){  
  int maximumCount = 10;
  switch(_program){
    case 0:
      program0(); break;
    case 1:
      maximumCount = 30;
      program1(); break;
    case 2:
      maximumCount = 90;
      program2(); break;
  }
  
  _program_count++;
  if(_program_count > maximumCount){
    _program++;
    _program_count = 0;
    
    for(int i = 0; i < _array_size; i++)
      values[i] = 0;
    
  }
  
  if(_program > 2)
    _program = 0;
}
コード例 #3
0
int TestCustom59::execute()
{
	mStoreCtx = NULL;

	// Open the store.
	bool lSuccess = true;
	if (MVTApp::startStore())
	{
		mStoreCtx = MVTApp::getStoreCtx();
		ISession * lSession = MVTApp::startSession();
		MVTApp::mapURIs(lSession, "testcustom59.prop.", 2, mPropIds);

		if (!program1(*lSession)) lSuccess = false;
		if (!program2(*lSession)) lSuccess = false;
		if (!program3(*lSession)) lSuccess = false;
		if (!program4(*lSession)) lSuccess = false;
		if (!program5(*lSession)) lSuccess = false;
		if (!program5b(*lSession)) lSuccess = false;
		if (!program6(*lSession)) lSuccess = false;
		if (!program7(*lSession)) lSuccess = false;
		if (!program8(*lSession)) lSuccess = false;
		if (!program9(*lSession)) lSuccess = false;
		if (!program10(*lSession)) lSuccess = false;
		if (!program11(*lSession)) lSuccess = false;

		// Cleanup.
		lSession->terminate();
		MVTApp::stopStore();
	}

	return lSuccess ? 0 : 1;
}
コード例 #4
0
ファイル: NMCFile.cpp プロジェクト: cslr/resonanz
bool NMCFile::loadFile(const std::string& filename)
{
	FILE* handle = NULL;

	try{
		handle = fopen(filename.c_str(), "rb");
		if(handle == NULL) return false;

		std::unique_ptr<char> name1(new char[33]); // US-ASCII chars
		std::unique_ptr<char> name2(new char[33]);
		unsigned int len = 0;

		if(fread(name1.get(), sizeof(char), 32, handle) != 32){
			fclose(handle);
			return false;
		}

		if(fread(name2.get(), sizeof(char), 32, handle) != 32){
			fclose(handle);
			return false;
		}

		if(fread(&len, sizeof(unsigned int), 1, handle) != 1){ // assumes little endianess here...
			fclose(handle);
			return false;
		}

		if(len > 10000){ // sanity check [in practice values must be always "small"]
			fclose(handle);
			return false;
		}

		name1.get()[32] = '\0';
		name2.get()[32] = '\0';

		// next we read actual "program" data (floats)

		std::unique_ptr<float> program1(new float[len]); // 32bit floats [little endian]
		std::unique_ptr<float> program2(new float[len]);

		if(fread(program1.get(), sizeof(float), len, handle) != len){
			fclose(handle);
			return false;
		}

		if(fread(program2.get(), sizeof(float), len, handle) != len){
			fclose(handle);
			return false;
		}

		// all data has been successfully read, stores values to internal class variables
		signalName[0] = std::string(name1.get());
		signalName[1] = std::string(name2.get());

		// trimming
		signalName[0].erase(signalName[0].find_last_not_of(" ")+1);
		signalName[1].erase(signalName[1].find_last_not_of(" ")+1);

		program[0].resize(len);
		program[1].resize(len);

		for(unsigned int i=0;i<len;i++){
			program[0][i] = program1.get()[i];
			program[1][i] = program2.get()[i];
		}

		fclose(handle);
		return true;
	}
	catch(std::exception& e){
		return false;
	}



}
コード例 #5
0
task main()
{

	//waitForStart();
	/*
	list of programs

	starting		|what to
	position		|do
	______________________________
	1		ramp		|knock down poles
	2		parking	|knock down poles
	3						|
	4						|
	5						|
	6						|
	7						|
	8						|
	10					|
	11					|
	12					|
	13					|
	14					|
	15	anywhere|go straight 5 seconds
	*/
wait1Msec(2000);
	disableDiagnosticsDisplay();
	short colorValues[4];//these are the scanned values

	int j;
	long r;
	long g;
	long b;
//	wait1Msec(500);

		int minDifference = 32767; // MAX_INT
	int selectedColor = 0;//this is the color closest to the scanned color



while(true)
{
	for(j =0; j<4; j++)//get color sensor values
	{
		getColorSensorData(colorPort, 0, &colorValues[j]);
		r = colorValues[0];
		g = colorValues[1];
		b = colorValues[2];
	}


	for(int i = 0; i < COLOR_COUNT; i++)//here we find the closest color in our database
	{

		difference(//passing in the database values and the scanned values to find the difference
		colorTags[i][0],
		colorTags[i][1],
		colorTags[i][2],
		r, g, b);
		long diff = thediff;

		if (diff <= minDifference) {//if the difference between the color in the database that we are currently checking and the scanned color
			minDifference = diff;			//is less than the smallest difference between the other database colors, then the database color we are
			selectedColor = i;				//currently checking is the closest match so far
		}

		nxtDisplayCenteredTextLine(0, "%d, %d", diff, minDifference);//print all the values
		nxtDisplayCenteredTextLine(1, "%d,%d,%d", colorValues[0], colorValues[1], colorValues[2]);
		nxtDisplayCenteredTextLine(4, "%d,%d,%d,",	colorTags[i][0], colorTags[i][1], colorTags[i][2]);
	}

	nxtDisplayCenteredTextLine(2, "%s", colornames[selectedColor]);
	nxtDisplayCenteredTextLine(3, "Is this the color?");
	if(nNxtButtonPressed==2)
	{
		break;
	}
}

	waitForStart();

	switch(selectedColor)
	{
	case 1:
		program1();
		break;
	case 2:
		program2();
		break;
		/*case 3:
		break;
		case 4:
		break;
		case 5:
		break;
		case 6:
		break;
		case 7:
		break;
		case 8:
		break;
		case 9:
		break;
		case 10:
		break;
		case 11:
		break;
		case 12:
		break;
		case 13:
		break;
		case 14:
		break;*/
	case 15:
		program15();
		break;
	default:
		program15();
		break;
	}

}