void moverEnAutomatico(){
uart_rd_temp = ' ';
bandera_automatico = 1;       /* Con esta bandera se valida en la interrupcion que hacer cuando ocurre un choque. */
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,txtAutomatic);
/* Inicio de movimiento en automatico hacia adelante. */
 RC1_bit = 1;
 RC2_bit = 1;
 RC5_bit = 0;
 RC4_bit = 0;
 cargarDato();
 while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo automatico. */
   waitSignal();
   cargarDato();

   /* Al salir de modo automatico paramos los motores.*/
   if(uart_rd_temp == 'e')
     {
       RC1_bit = 0;
       RC2_bit = 0;
       RC5_bit = 0;
       RC4_bit = 0;
     }

 }
 pararVehiculo();
 bandera_automatico = 0;       /* al enviar e se sale de modo automatico.*/
}
Esempio n. 2
0
void GenVideoT::run() {

    int t = static_cast<int>(1000*dt);
    int i = 0;
    while(true) {
        while (isPaused()) sleep(1);
        if (isStoped()) break;

        setTime(i * (t/1000.0));
        emit nextImage();

        waitSignal();
        while (true) {
            QThread::msleep(t);
            if (isContinue()) break;
            if (isStoped()) goto END;
        }
        ++i;
        if (i == N) break;
    }
    END:
    mutex.lock();
    isstop = false;
    mutex.unlock();
    emit finishVideo();
}
void lockSemaphore(semaphore_t *p_semaphore)
{
	uint8_t irEnabled = enterAtomicBlock();
	
	p_semaphore->value += 1;
	if(p_semaphore->value > p_semaphore->maxValue)
		waitSignal(&(p_semaphore->signal));
		
	exitAtomicBlock(irEnabled);
}
void waitCondition(condition_t *p_cond, mutex_t *p_mutex)
{
	uint8_t irEnabled = enterAtomicBlock();
	
	unlockMutex(p_mutex);
	waitSignal(&(p_cond->signal));
		
	exitAtomicBlock(irEnabled);
	lockMutex(p_mutex);
}
void main() {

  TRISA = 0b00000000; // set PORTA -> salidas
  TRISB = 0b01000000; // set PORTB -> salida menos el pin 6.
  ANSEL  = 0;              // Configure AN2 pin as analog
  ANSELH = 0;
  C1ON_bit = 0;                      // Disable comparators
  C2ON_bit = 0;
  INTCON = 0b10100000; // INTERRUPCION POR TIMER0 Y GIE ACTIVADOS.
  /* INTCON.T0IE = 1;                 /\* Activado interrupcion por timer0 *\/ */
  OPTION_REG = 0b10000111; //  TMR0 temporizado:  RBPU, TOCS= INTERNAL INSTRUCTION CLOCK= 0 PSA =0   1:256
  TRISC = 0b10000000;                          // PUERTOC COMO SALIDA exepto pin 7
  PORTC = 0;                          // LIMPIAR PUERTOC
  setupTimer1();
  Delay_us(10);                 /* wait for acquisition time*/
  Lcd_Init();                        // Initialize LCD

  /* Programa principal */
  Lcd_Out(2,0,txtDefault);                 // Write text in second row
  UART1_Init(9600);                         // initialize UART1 module
  Delay_ms(100);                  // Wait for UART module to stabilize
  moverEnAutomatico();
  while (1) {
    waitSignal();
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     // leer el dato recibido del celular
      waitSignal();
      switch (uart_rd) {
      case 'A': {               /* Modo automático */
        Lcd_Out(2,6,txtAutomatic);
        moverEnAutomatico();
        break;
      }
      case 'M': {
        moverManual();
        break;
      }
      default:
        break;
      }
    }
  }
}
score_t AlignerPool::receiveScore() {
	score_t score;

	string filename = getMsgFile("stage1", left);
	waitSignal(filename);

	FILE* file = fopen(filename.c_str(), "rt");
	fscanf(file, "%d %d %d\n", &score.i, &score.j, &score.score);
	fclose(file);
	return score;

}
Esempio n. 7
0
GameMain::GameMain(int **tab, QWidget *parent)
		:QMainWindow(parent)
{

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			this->tab[i][j] = tab[i][j];
		}
	}

	SOCKET s = initSocket();
	//u_long iMode = 1;
	//ioctlsocket(s, FIONBIO, &iMode);
	Sea *sea = new Sea();
	user = new User(sea,s);

	user->ShipCreator(this->tab);

	Update *update = new Update(user);

	connect(update, SIGNAL(waitSignal()), this, SLOT(wait()));
	connect(update, SIGNAL(changeSignal(int, int)), this, SLOT(change(int, int)));
	connect(update, SIGNAL(noChangeSignal(int, int)), this, SLOT(noChange(int, int)));
	update->start();



	/*for (int o = 0; o < 10; o++) {
		for (int l = 0; l < 10; l++) {
			std::cout << tab[o][l];
	}
	std::cout << std::endl;
	}
	while (true) {
		if (user->Check() == true) {
			break;
		}
	}*/

	ui.setupUi(this);
	init();
	drawShip();


}
void moverManual(){
uart_rd_temp = ' ';
cargarDato();
bandera_automatico = 0;       /* Se limpia la bandera de automatico por si acaso. */
while (uart_rd_temp != 'e') { /* Si se le envía e se sale de modo manual */

waitSignal();
cargarDato();
if (uart_rd_temp == 'u' && bandera_mover) { /* Up: En la interrupción para el auto */
Lcd_Out(2,6,txtArriba);
avanzarVehiculo();
}
 else if (uart_rd_temp == 'd' && bandera_mover) { /* Down:  */
Lcd_Out(2,6,txtAbajo);
moverAtras();
}
 else if (uart_rd_temp == 'l' && bandera_mover) { /* left:  */
Lcd_Out(2,6,txtAbajo);
girarIzquierda();
avanzarVehiculo();
}
 else if (uart_rd_temp == 'r' && bandera_mover) { /* right:  */
Lcd_Out(2,6,txtAbajo);
girarDerecha();
avanzarVehiculo();
}

}
pararVehiculo();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,6,"Se salió de modo manual.");
Delay_ms(100);
uart_rd_temp = ' ';


}
void AlignerPool::waitId(int id) {
	string filename = getMsgFile("stage1", id);
	waitSignal(filename);
}