Exemplo n.º 1
0
void
GeneratorBase::doInterface(IR__::InterfaceDef_ptr intface)
{
	beginInterface(intface);

	IR__::ContainedSeq_var contained_seq;
	CORBA::ULong len;
	CORBA::ULong i;

	// contained constants
	contained_seq = intface->contents(CORBA__::dk_Constant, false);
	len = contained_seq->length();
	for(i = 0; i < len; i++)
	{
		IR__::ConstantDef_var act_constant = IR__::ConstantDef::_narrow(((*contained_seq)[i]));
		doConstant(act_constant);
	}

	// contained typedefs
	contained_seq = intface->contents(CORBA__::dk_Typedef, false);
	len = contained_seq->length();
	for(i = 0; i < len; i++)
	{
		IR__::TypedefDef_var act_typedef = IR__::TypedefDef::_narrow(((*contained_seq)[i]));
		doTypedef(act_typedef);
	}

	// contained exceptions
	contained_seq = intface->contents(CORBA__::dk_Exception, false);
	len = contained_seq->length();
	for(i = 0; i < len; i++)
	{
		IR__::ExceptionDef_var act_exception = IR__::ExceptionDef::_narrow(((*contained_seq)[i]));
		doException(act_exception);
	}

	// contained attributes
	handleAttribute(intface);

	// contained operations
	handleOperation(intface);

	endInterface(intface);
}
Exemplo n.º 2
0
task main()
{
	wait1Msec(3);
	int beginning = beginInterface();
	wait1Msec(500);
	int ending = interface();
	wait1Msec(500);
	int timing = timeinterface();
	servo(servo3) = 0;
	waitForStart();


	wait10Msec(timing * 100);
	initialize();
	wait10Msec(30);

	switch(beginning)   // test 'nTaskToStart' in the switch
	{
  	case 2:
			// Move away from the wall
			motor[MOTOR_LEFT] = -40;
			motor[MOTOR_RIGHT] = -40;
			driveTo(4);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			// Turn toward the west wall
			gyroTurn(20, 87);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			// Drive toward the west wall
			motor[MOTOR_LEFT] = -40;
			motor[MOTOR_RIGHT] = -40;
			driveTo(25);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			// Turn toward the baskets
			gyroTurn(-20, 40);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
		case 3:
  		//Move away from the wall
  		motor[MOTOR_LEFT] = -40;
			motor[MOTOR_RIGHT] = -40;
			driveTo(2);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
  	case 4:
  	case 1:
  	default:
  }
	//-------------------------------

	// We're aligned with the baskets.
	// Start walking along them looking for the IR beacon
	motor[MOTOR_LEFT] = -60;
	motor[MOTOR_RIGHT] = -63;
 	driveTo(4);
	if(CheckIR(4) || checkIR(5)) // The first basket
	{
		motor[MOTOR_LEFT] = 0;
		motor[MOTOR_RIGHT] = 0;
		wait10Msec(4);
		servoTarget(servo3) = 180;
		wait10Msec(50);
		//forward/back
	}else { // The second basket
		driveTo(13);
		if(checkIR(4) || checkIR(5))
		{
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			servoTarget(servo3) = 180;
			wait10Msec(150);
			//forward/back
		}else{ // The third basket
			driveTo(35);
			if(sensorValue[IRsensor] == 6 || sensorValue[IRsensor] == 5)
			{
				motor[MOTOR_LEFT] = 0;
				motor[MOTOR_RIGHT] = 0;
				servoTarget(servo3) = 180;
				wait10Msec(150);
				//place block
				//forward/back
			}else{ // The fourth basket
				driveTo(45);
				motor[MOTOR_LEFT] = 0;
				motor[MOTOR_RIGHT] = 0;
				servoTarget(servo3) = 180; // Deploy the auto-scoring arm
				wait10Msec(150);
				//forward/back

			}
		}
	}
	servoTarget[servo3] = 0; // Retract the auto-scoring arm
	switch(ending)   // test 'nTaskToStart' in the switch
	{
  	case 1:											// if 'nTaskToStart' is '1':
  		// Drive to the end of the baskets.
			motor[MOTOR_LEFT] = 100;
			motor[MOTOR_RIGHT] = 97;
			while(abs(nMotorEncoder[MOTOR_RIGHT]) > 2000)
			{
			}
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;

			// Turn toward the ramp
			gyroTurn(20, 65);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;

			// Drive in front of the ramp
			motor[MOTOR_LEFT] = 90;
			motor[MOTOR_RIGHT] = 90;
			driveTo(20);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;

			// Turn toward the ramp agai
			gyroTurn(20, 30);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;

			motor[MOTOR_LEFT] = 90;
			motor[MOTOR_RIGHT] = 90;
			driveTo(25);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			gyroTurn(-20, 85);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			motor[MOTOR_LEFT] = -100;
			motor[MOTOR_RIGHT] = -100;
			driveTo(40);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
    	break;                 // break out of this switch statement and continue code after the '}'

  	case 2:                // if 'nTaskToStart' is '2':
			motor[MOTOR_LEFT] = -90;
			motor[MOTOR_RIGHT] = -90;
    	driveTo(51);
    	motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;



			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			motor[MOTOR_LEFT] = -90;
			motor[MOTOR_RIGHT] = -90;
			driveTo(10);
    	motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			gyroTurn(-40, 70);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			motor[MOTOR_LEFT] = -50;
			motor[MOTOR_RIGHT] = -50;
			driveTo(35);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
			gyroTurn(-40, 90);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			motor[MOTOR_LEFT] = -90;
			motor[MOTOR_RIGHT] = -90;
			driveTo(35);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0;
		/*	gyroTurn(-20, 70);
			nMotorEncoder[MOTOR_LEFT] = 0;
			nMotorEncoder[MOTOR_RIGHT] = 0;
			motor[MOTOR_LEFT] = 90;
			motor[MOTOR_RIGHT] = 90;
			driveTo(40);
			motor[MOTOR_LEFT] = 0;
			motor[MOTOR_RIGHT] = 0; */
			// start task Two
    	break;                 // break out of this switch statement and continue code after the '}'

  	default:               // if 'nTaskToStart' is anything other than '1' or '2':
    	      // start task Three
	}


}