示例#1
0
文件: fy.c 项目: AndTH/GCA
void move(void) {
  unsigned char alive = 0;
  unsigned int diff = 0;
  unsigned int newpos = 0;

  stepnr = getPosition(curtrack);
  newpos = getPosition(choice);

  ledOK = LEDOK_OFF;

  if( stepnr == newpos ) {
    waitMS( 500 );
    ledOK = LEDOK_ON;
    return;
  }

  updateDisplay();
  power = POWER_ON;
  pulswidth = MAX_PULSWIDTH;

  while( stepnr != newpos ) {

    if( stepnr > newpos ) {
      diff = stepnr - newpos;
      stepnr--;
      oneStep(STEP_LEFT);
    }
    else if( stepnr < newpos ) {
      diff = newpos - stepnr;
      stepnr++;
      oneStep(STEP_RIGHT);
    }

    if( diff < 150 && pulswidth < MAX_PULSWIDTH ) {
      // slower
      pulswidth += (MAX_PULSWIDTH - pulswidth) / 150;
    }
    else if(pulswidth > MIN_PULSWIDTH) {
      // faster
      pulswidth -= (pulswidth - MIN_PULSWIDTH) / 150;
    }

    alive++;

    if( alive > 100 ) {
      //ledOK = !ledOK;
      alive = 0;
    }

  }; // end while


  if( !readByte(ADDR_KEEPPOWER) )
    power = POWER_OFF;

  curtrack = choice;
  ledOK = LEDOK_ON;

}
示例#2
0
    void DynamicsSimulatorHandPose::oneStep(MarkerPublisher *markers_pub, int m_id) {
        KDL::Frame r_HAND_current;
        kin_model_->calculateFk(r_HAND_current, effector_name_, q_);
//        KDL::Twist diff = KDL::diff(r_HAND_current, r_HAND_target_, 1.0);
        KDL::Twist diff = pose_diff_function_(r_HAND_current, r_HAND_target_);
        oneStep(diff, markers_pub, m_id);
    }
示例#3
0
string Network::work()
{
    stringstream out;
    if (!checkNetworkToBeInfected())
        do
            out << oneStep();
        while (!checkNetworkToBeInfected());
    out << printLocalSystemStatus();
    return out.str();
}
示例#4
0
 void start()
 {
     Buffer* read = buff1;
     Buffer* write = buff2;
     for (uint32_t i = 0; i < steps; ++i)
     {
         oneStep(i, read, write);
         std::swap(read, write);
     }
 }
/*
 * Whole Simulation
 */
void Simulation::wholeSimulation() {
	curState = "0"; // set initial state
    int steps = 0;
    while(curState != "accept" && curState != "reject") {
        oneStep();
        steps++;
        if (steps > MAX_ITERATIONS) {
            std::cout << "Moved too many steps !" << std::endl;
            exit(1);
        }
    }
	std::cout << curState << std::endl;
}
示例#6
0
void Simulator::run()
{
	ProgressBar progressBar;
	for(int i = 0; i < step; ++i)
	{
		oneStep();
		progressBar.update(i/double(step));

		// print the result
		std::stringstream filename;
		filename << "./output/boids_" << i << ".xyz";
        if (write)  save(filename.str()); 
	}
}
示例#7
0
文件: Stepper2D.cpp 项目: desaic/fem
int Stepper2D::step()
{
  Timer t;
  for (int ii = 0; ii < nSteps; ii++){
    t.start();
    int ret = oneStep();
    t.end();
    float duration = t.getSeconds();
    //std::cout << ii << " time: " << duration << "\n";
    if (ret < 0){
      return ret;
    }
    else if (ret==1)
    {
      std::cout << "Failed!" << std::endl;
      return ret;
    }
  }
  return 0;
}
示例#8
0
//triggers a slot in the assembly class
void MainWindow::on_pushButton_2_clicked()
{
    emit oneStep();
}
示例#9
0
文件: fy.c 项目: AndTH/GCA
/*
 * setup service to define the track positions
 * control remains in this function as long as the setup button is active
 */
void setup(void) {
  confirm(5);

  // start with position mid
  stepnr = initpos;
  choice = MAX_TRACKS / 2 + 1;
  updateDisplay();

  pulswidth = MAX_PULSWIDTH;
  power = POWER_ON;
  waitMS(100);

  curtrack = choice;

  while( buttonSetup == BUTTON_ON ) {
    waitMS(10);

    if( buttonRight == BUTTON_ON && buttonLeft == BUTTON_ON ) {
      saveByte( ADDR_KEEPPOWER, readByte(ADDR_KEEPPOWER) ? KEEPPOWER_OFF:KEEPPOWER_ON );
      confirm(3);
      while( buttonRight == BUTTON_ON && buttonLeft == BUTTON_ON );
    }

    while( stepnr < MAX_STEPS && buttonLeft == BUTTON_OFF && buttonRight == BUTTON_ON ) {
      // turn right; end position is not reached
      stepnr++;
      oneStep(STEP_RIGHT);
    };

    while( stepnr > 0 && buttonLeft == BUTTON_ON && buttonRight == BUTTON_OFF ) {
      // turn left; start position is not reached
      stepnr--;
      oneStep(STEP_LEFT);
    };

    // check if the buttonSave is pressed
    if( buttonSave == BUTTON_ON ) {
      // save the new position in eeprom
      savePosition( choice, stepnr);
      confirm(1);

      choice++;
      if( choice > MAX_TRACKS )
        choice = 1;
      curtrack = choice;
      updateDisplay();

      while( buttonSave == BUTTON_ON )
        waitMS(10);
    }

    // check if the buttonNext is pressed
    if( buttonNext == BUTTON_ON ) {
      confirm(1);

      choice++;
      if( choice > MAX_TRACKS )
        choice = 1;
      curtrack = choice;
      updateDisplay();

      while( buttonNext == BUTTON_ON )
        waitMS(10);
    }

  } // end while

  if( !readByte(ADDR_KEEPPOWER) )
    power = POWER_OFF;  /* power off step motor */
}