Пример #1
0
//if no ball is captured, lower the arm and roll in until one is.
//once a ball is captured, lift the arm to the top and stay there.
void Arm::load_sequence() {
	switch (arm_mode) {
		case FREE: 
			arm_mode = LOWERING;
		case LOWERING:
			if (at_bottom() || ball_captured())
				arm_mode = WAITING_FOR_BALL;
			else
				break;
		case WAITING_FOR_BALL:
			if (ball_captured()) {
				arm_mode = RAISING;
			} else {
				roller_mode = INTAKE;
				break;
			}
		case RAISING:
			if (at_top()) {
				arm_mode = ROLLING_IN_BALL;
				timer->Reset();
				timer->Start();
			} else {
				break;
			}
		case ROLLING_IN_BALL:
			if (timer->Get() > 1.0) {
				timer->Stop();
			} else {
				roller_mode = DEPLOY;
			}
			break;
		default:
			arm_mode = LOWERING;
	}
}
Пример #2
0
static int
process_path (char *pathname, char *name, bool leaf, char *parent,
	      mode_t mode, ino_t inum)
{
  struct stat stat_buf;
  static dev_t root_dev;	/* Device ID of current argument pathname. */
  int i;
  struct predicate *eval_tree;

  eval_tree = get_eval_tree ();
  /* Assume it is a non-directory initially. */
  stat_buf.st_mode = 0;

  /* The caller usually knows the inode number, either from readdir or
   * a *stat call.  We use that value (the caller passes 0 to indicate
   * ignorance of the inode number).
   */
  stat_buf.st_ino = inum;

  state.rel_pathname = name;
  state.type = 0;
  state.have_stat = false;
  state.have_type = false;
  state.already_issued_stat_error_msg = false;

  if (!digest_mode (&mode, pathname, name, &stat_buf, leaf))
    return 0;

  if (!S_ISDIR (state.type))
    {
      if (state.curdepth >= options.mindepth)
	apply_predicate (pathname, &stat_buf, eval_tree);
      return 0;
    }

  /* From here on, we're working on a directory.  */


  /* Now we really need to stat the directory, even if we know the
   * type, because we need information like struct stat.st_rdev.
   */
  if (get_statinfo (pathname, name, &stat_buf) != 0)
    return 0;

  state.have_stat = true;
  mode = state.type = stat_buf.st_mode;	/* use full info now that we have it. */
  state.stop_at_current_level =
    options.maxdepth >= 0
    && state.curdepth >= options.maxdepth;

  /* If we've already seen this directory on this branch,
     don't descend it again.  */
  for (i = 0; i <= dir_curr; i++)
    if (stat_buf.st_ino == dir_ids[i].ino &&
	stat_buf.st_dev == dir_ids[i].dev)
      {
	state.stop_at_current_level = true;
	issue_loop_warning (name, pathname, i);
      }

  if (dir_alloc <= ++dir_curr)
    {
      dir_alloc += DIR_ALLOC_STEP;
      dir_ids = (struct dir_id *)
	xrealloc ((char *) dir_ids, dir_alloc * sizeof (struct dir_id));
    }
  dir_ids[dir_curr].ino = stat_buf.st_ino;
  dir_ids[dir_curr].dev = stat_buf.st_dev;

  if (options.stay_on_filesystem)
    {
      if (state.curdepth == 0)
	root_dev = stat_buf.st_dev;
      else if (stat_buf.st_dev != root_dev)
	state.stop_at_current_level = true;
    }

  if (options.do_dir_first && state.curdepth >= options.mindepth)
    apply_predicate (pathname, &stat_buf, eval_tree);

  if (options.debug_options & DebugSearch)
    fprintf (stderr, "pathname = %s, stop_at_current_level = %d\n",
	     pathname, state.stop_at_current_level);

  if (state.stop_at_current_level == false)
    {
      /* Scan directory on disk. */
      process_dir (pathname, name, strlen (pathname), &stat_buf, parent);
    }

  if (options.do_dir_first == false && state.curdepth >= options.mindepth)
    {
      /* The fields in 'state' are now out of date.  Correct them.
       */
      if (!digest_mode (&mode, pathname, name, &stat_buf, leaf))
	return 0;

      if (0 == dir_curr)
	{
	  at_top (pathname, mode, stat_buf.st_ino, &stat_buf,
		  do_process_predicate);
	}
      else
	{
	  do_process_predicate (pathname, name, mode, stat_buf.st_ino,
				&stat_buf);
	}
    }

  dir_curr--;

  return 1;
}
Пример #3
0
/* Descend PATHNAME, which is a command-line argument.

   Actions like -execdir assume that we are in the
   parent directory of the file we're examining,
   and on entry to this function our working directory
   is whatever it was when find was invoked.  Therefore
   If PATHNAME is "." we just leave things as they are.
   Otherwise, we figure out what the parent directory is,
   and move to that.
*/
static void
process_top_path (char *pathname, mode_t mode, ino_t inum)
{
  at_top (pathname, mode, inum, NULL, do_process_top_dir);
}