Example #1
0
static void
goio_console_start_collection (GtkWidget *button, GObject *device)
{
  NgiSensor *sensor = ngi_device_get_sensor (NGI_DEVICE (device));
  printf ("Start collecting on %s\n",ngi_device_get_name(NGI_DEVICE(device)));
  ngi_device_start_collection (NGI_DEVICE (device));

  gtk_widget_set_sensitive (start_button, FALSE);
  gtk_widget_set_sensitive (stop_button, TRUE);

  if (sensor_data)
    {
      g_array_free (sensor_data, TRUE);
      sensor_data = NULL;
    }

  g_signal_connect (G_OBJECT (stop_button), "clicked",
		    G_CALLBACK (goio_console_stop_collection),
		    device);
  g_signal_connect (G_OBJECT (sensor), "data-changed",
		    G_CALLBACK (goio_console_update_readout),
		    NULL);


  gtk_plot_set_yrange (GTK_PLOT (active_plot), 0.0, 60.0);
  gtk_plot_set_xrange (GTK_PLOT (active_plot), 0.0, 60.0);
  g_timeout_add (60000, goio_console_update_graph, device);

}
Example #2
0
gint
update(gpointer data)
{
 GtkPlot *plot;
 gdouble x, y;
 gdouble xmin, xmax;

 plot = GTK_PLOT(data);

 px = (gdouble *)g_realloc(px, (dataset->num_points+1)*sizeof(gdouble));
 py = (gdouble *)g_realloc(py, (dataset->num_points+1)*sizeof(gdouble));

 y = rand()%10/10.;

 if(dataset->num_points == 0)
   x = 1;
 else
   x = px[dataset->num_points-1] + 1;

 px[dataset->num_points] = x;
 py[dataset->num_points] = y;

 gtk_plot_dataset_set_numpoints(dataset, dataset->num_points+1); 
 gtk_plot_dataset_set_x(dataset, px); 
 gtk_plot_dataset_set_y(dataset, py); 

 gtk_plot_get_xrange(plot, &xmin , &xmax);

 if(x > xmax)
   gtk_plot_set_xrange(plot, xmin + 5. , xmax + 5.);

 gtk_plot_layout_refresh(GTK_PLOT_LAYOUT(canvas));

 return TRUE;
}
Example #3
0
static gint
goio_console_update_graph (gpointer device)
{
  double secs =60;
  if (sensor_data)
    secs = sensor_data->len+60;
  gtk_plot_set_xrange (GTK_PLOT (active_plot), 0.0, secs);

  if (ngi_device_collecting (NGI_DEVICE (device)))
    return TRUE;
  else
    return FALSE;
}