Beispiel #1
0
static void start_pulse(const device_config *device)
{
	ttl74123_t *chip = get_safe_token(device);

	attotime duration = compute_duration(chip);

	if (timer_running(chip))
	{
		/* retriggering, but not if we are called to quickly */
		attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * chip->intf->cap * 220);

		if (attotime_compare(timer_timeelapsed(chip->timer), delay_time) >= 0)
		{
			timer_adjust_oneshot(chip->timer, duration, 0);

			if (LOG) logerror("74123 %s:  Retriggering pulse.  Duration: %f\n", device->tag, attotime_to_double(duration));
		}
		else
		{
			if (LOG) logerror("74123 %s:  Retriggering failed.\n", device->tag);
		}
	}
	else
	{
		/* starting */
		timer_adjust_oneshot(chip->timer, duration, 0);

		set_output(device);

		if (LOG) logerror("74123 %s:  Starting pulse.  Duration: %f\n", device->tag, attotime_to_double(duration));
	}
}
Beispiel #2
0
void ttl74123_device::start_pulse()
{
	attotime duration = compute_duration();

	if(timer_running())
	{
		/* retriggering, but not if we are called to quickly */
		attotime delay_time = attotime(0, ATTOSECONDS_PER_SECOND * m_cap * 220);

		if(m_timer->elapsed() >= delay_time)
		{
			m_timer->adjust(duration);

			if (LOG) logerror("74123 %s:  Retriggering pulse.  Duration: %f\n", tag(), duration.as_double());
		}
		else
		{
			if (LOG) logerror("74123 %s:  Retriggering failed.\n", tag());
		}
	}
	else
	{
		/* starting */
		m_timer->adjust(duration);

		set_output();

		if (LOG) logerror("74123 %s:  Starting pulse.  Duration: %f\n", tag(), duration.as_double());
	}
}
Beispiel #3
0
void ttl74123_device::start_pulse()
{
	attotime duration = compute_duration();

	if(timer_running())
	{
		/* retriggering, but not if we are called to quickly */
		attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * m_config.m_cap * 220);

		if(attotime_compare(timer_timeelapsed(m_timer), delay_time) >= 0)
		{
			timer_adjust_oneshot(m_timer, duration, 0);

			if (LOG) logerror("74123 %s:  Retriggering pulse.  Duration: %f\n", tag(), attotime_to_double(duration));
		}
		else
		{
			if (LOG) logerror("74123 %s:  Retriggering failed.\n", tag());
		}
	}
	else
	{
		/* starting */
		timer_adjust_oneshot(m_timer, duration, 0);

		set_output();

		if (LOG) logerror("74123 %s:  Starting pulse.  Duration: %f\n", tag(), attotime_to_double(duration));
	}
}
Beispiel #4
0
static void start_pulse(TTL74123_state *chip)
{
	attotime duration = compute_duration(chip);

	if (timer_running(chip))
	{
		/* retriggering, but not if we are called to quickly */
		attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * chip->intf->cap * 220);

		if (attotime_compare(timer_timeelapsed(chip->timer), delay_time) >= 0)
		{
			timer_adjust(chip->timer, duration, 0, attotime_never);

			if (LOG) logerror("74123 #%d:  Retriggering pulse.  Duration: %f\n", chip->which, attotime_to_double(duration));
		}
		else
		{
			if (LOG) logerror("74123 #%d:  Retriggering failed.\n", chip->which);
		}
	}
	else
	{
		/* starting */
		timer_adjust(chip->timer, duration, 0, attotime_never);

		set_output(chip);

		if (LOG) logerror("74123 #%d:  Starting pulse.  Duration: %f\n", chip->which, attotime_to_double(duration));
	}
}
Beispiel #5
0
static void
run_checkpoint_actions (bool do_write)
{
  struct checkpoint_action *p;

  for (p = checkpoint_action; p; p = p->next)
    {
      switch (p->opcode)
	{
	case cop_dot:
	  fputc ('.', stdlis);
	  fflush (stdlis);
	  break;

	case cop_bell:
	  if (!tty)
	    tty = fopen ("/dev/tty", "w");
	  if (tty)
	    {
	      fputc ('\a', tty);
	      fflush (tty);
	    }
	  break;

	case cop_echo:
	  {
	    int n = fprintf (stderr, "%s: ", program_name);
	    format_checkpoint_string (stderr, n, p->v.command, do_write,
				      checkpoint);
	    fputc ('\n', stderr);
	  }
	  break;

	case cop_ttyout:
	  if (!tty)
	    tty = fopen ("/dev/tty", "w");
	  if (tty)
	    format_checkpoint_string (tty, 0, p->v.command, do_write,
				      checkpoint);
	  break;

	case cop_sleep:
	  sleep (p->v.time);
	  break;

	case cop_exec:
	  sys_exec_checkpoint_script (p->v.command,
				      archive_name_cursor[0],
				      checkpoint);
	  break;

	case cop_totals:
	  compute_duration ();
	  print_total_stats ();
	}
    }
}
Beispiel #6
0
/* src_offset and dst_offset need to be in [0.0, 1.0] range */
static gboolean
animate (GstyleSlidein *self,
         gdouble        target_offset)
{
  GtkWidget *child;

  g_assert (GSTYLE_IS_SLIDEIN (self));
  g_assert (0.0 <= target_offset && target_offset <= 1.0);

  child = gtk_bin_get_child (GTK_BIN (self));
  if (child == NULL || self->overlay_child == NULL)
    return FALSE;

  animate_stop (self);

  if (!self->duration_set)
    self->duration = gstyle_animation_check_enable_animation () ? compute_duration (self) : 0;

  self->src_offset = self->offset;
  self->dst_offset = target_offset;
  gtk_widget_set_child_visible (child, TRUE);

  if (self->src_offset == self->dst_offset)
    return FALSE;

  if (self->src_offset < self->dst_offset)
    {
      self->is_opening = TRUE;
      g_signal_emit (self, signals [OPENING], 0);
    }
  else
    {
      self->is_closing = TRUE;
      g_signal_emit (self, signals [CLOSING], 0);
    }

  if (self->duration == 0)
    {
      self->offset = target_offset;
      animation_done_cb (self);
      gtk_widget_queue_resize (GTK_WIDGET (self));
    }
  else if (!self->animation_handler_id)
    {
      self->animation_starttime = g_get_monotonic_time();
      self->animation_handler_id = gtk_widget_add_tick_callback (GTK_WIDGET (self),
                                                                 animation_tick_cb,
                                                                 self,
                                                                 NULL);
    }

  return TRUE;
}
Beispiel #7
0
static int
format_checkpoint_string (FILE *fp, size_t len,
			  const char *input, bool do_write,
			  unsigned cpn)
{
  const char *opstr = do_write ? gettext ("write") : gettext ("read");
  char uintbuf[UINTMAX_STRSIZE_BOUND];
  char *cps = STRINGIFY_BIGINT (cpn, uintbuf);
  const char *ip;

  static char *argbuf = NULL;
  static size_t arglen = 0;
  char *arg = NULL;

  if (!input)
    {
      if (do_write)
	/* TRANSLATORS: This is a "checkpoint of write operation",
	 *not* "Writing a checkpoint".
	 E.g. in Spanish "Punto de comprobaci@'on de escritura",
	 *not* "Escribiendo un punto de comprobaci@'on" */
	input = gettext ("Write checkpoint %u");
      else
	/* TRANSLATORS: This is a "checkpoint of read operation",
	 *not* "Reading a checkpoint".
	 E.g. in Spanish "Punto de comprobaci@'on de lectura",
	 *not* "Leyendo un punto de comprobaci@'on" */
	input = gettext ("Read checkpoint %u");
    }

  for (ip = input; *ip; ip++)
    {
      if (*ip == '%')
	{
	  if (*++ip == '{')
	    {
	      arg = getarg (ip, &ip, &argbuf, &arglen);
	      if (!arg)
		{
		  fputc ('%', fp);
		  fputc (*ip, fp);
		  len += 2;
		  continue;
		}
	    }
	  switch (*ip)
	    {
	    case 'c':
	      len += format_checkpoint_string (fp, len, def_format, do_write,
					       cpn);
	      break;

	    case 'u':
	      fputs (cps, fp);
	      len += strlen (cps);
	      break;

	    case 's':
	      fputs (opstr, fp);
	      len += strlen (opstr);
	      break;

	    case 'd':
	      len += fprintf (fp, "%.0f", compute_duration ());
	      break;

	    case 'T':
	      {
		const char **fmt = checkpoint_total_format, *fmtbuf[3];
		struct wordsplit ws;
		compute_duration ();

		if (arg)
		  {
		    ws.ws_delim = ",";
		    if (wordsplit (arg, &ws, WRDSF_NOVAR | WRDSF_NOCMD |
				           WRDSF_QUOTE | WRDSF_DELIM))
		      ERROR ((0, 0, _("cannot split string '%s': %s"),
			      arg, wordsplit_strerror (&ws)));
		    else
		      {
			int i;

			for (i = 0; i < ws.ws_wordc; i++)
			  fmtbuf[i] = ws.ws_wordv[i];
			for (; i < 3; i++)
			  fmtbuf[i] = NULL;
			fmt = fmtbuf;
		      }
		  }
		len += format_total_stats (fp, fmt, ',', 0);
		if (arg)
		  wordsplit_free (&ws);
	      }
	      break;

	    case 't':
	      {
		struct timeval tv;
		struct tm *tm;
		const char *fmt = arg ? arg : "%c";

		gettimeofday (&tv, NULL);
		tm = localtime (&tv.tv_sec);
		len += fprintftime (fp, fmt, tm, 0, tv.tv_usec * 1000);
	      }
	      break;

	    case '*':
	      {
		long w = arg ? strtol (arg, NULL, 10) : getwidth (fp);
		for (; w > len; len++)
		  fputc (' ', fp);
	      }
	      break;

	    default:
	      fputc ('%', fp);
	      fputc (*ip, fp);
	      len += 2;
	      break;
	    }
	  arg = NULL;
	}
      else
	{
	  fputc (*ip, fp);
	  if (*ip == '\r')
	    {
	      len = 0;
	      tty_cleanup = 1;
	    }
	  else
	    len++;
	}
    }
  fflush (fp);
  return len;
}