updated copyright statement
[gpiv.git] / src / dac_trig.c
blobf3415fca54e64ba9d8112d42627c7ac892f49776
1 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 c-style: "K&R" -*- */
3 /*----------------------------------------------------------------------
5 gpiv - Graphic program for Particle Image Velocimetry, based on gtk/gnome
6 libraries.
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
9 Gerber van der Graaf
11 This file is part of gpiv.
13 Gpiv is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
16 any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ----------------------------------------------------------------------*/
30 * Dac callbacks
31 * $Id: dac_trig.c,v 1.1 2006-09-18 07:29:51 gerber Exp $
33 #ifdef ENABLE_TRIG
35 #include "gpiv_gui.h"
36 #include "console.h"
37 #include "dac_trig.h"
39 /* #include <sys/types.h> */
40 /* #include <sys/stat.h> */
41 /* #include <fcntl.h> */
45 * BUGFIX: Put somwhere to update on regular basis:
46 gtk_label_set_text(GTK_LABEL(gpiv->dac->label_temp),
47 "Temp");
50 static int init, start, stop, error;
53 * Prototypes of local functions
57 * Global functions
59 void
60 exec_trigger_start (void
62 /*-----------------------------------------------------------------------------
65 gchar *err_msg = NULL;
66 int on = 1, param_ok;
68 g_message("exec_trigger_start: 0");
69 if (!gpiv_trig_openrtfs(&init, &start, &stop, &error)) {
70 err_msg = _("Fail in fifo open");
71 warning_gpiv(err_msg);
72 return;
76 g_message("exec_trigger_start: 1");
77 gpiv_trig_test_parameter(&trig_par);
80 * write the timing details to /dev/rtf/1
82 g_message("exec_trigger_start: 2");
83 if((write(init, &trig_par.ttime, sizeof(GpivTrigTime))) < 0) {
84 err_msg = _("Fail in setting camera and Laser timing");
85 warning_gpiv(err_msg);
86 return;
89 g_message("exec_trigger_start: 3");
90 if((read(error, &param_ok, sizeof(int))) < 0) {
91 err_msg = _("Fail in receipt of confirmation");
92 warning_gpiv(err_msg);
93 return;
96 g_message("exec_trigger_start: 4");
97 if (param_ok != 1) {
98 warning_gpiv("Invalid parameters entered \n");
100 } else {
101 if (verbose)
102 g_message (_("Parameters: \n\
103 cam_acq_period: %lld \n\
104 laser_trig_pw: %lld \n\
105 time2laser: %lld \n\
106 dt: %lld \n\
107 mode: %d \n\
108 cycles: %d \n\
109 increment: %d\n"),
110 trig_par.ttime.cam_acq_period,
111 trig_par.ttime.laser_trig_pw,
112 trig_par.ttime.time2laser,
113 trig_par.ttime.dt,
114 trig_par.ttime.mode,
115 trig_par.ttime.cycles,
116 (int) trig_par.ttime.increment);
118 g_message("exec_trigger_start: 5");
119 if((write(start, &on, sizeof(int))) < 0) {
120 err_msg = _("Fail in starting camera and Laser timing");
121 warning_gpiv(err_msg);
122 return;
126 g_message("exec_trigger_start: 6");
127 /* gpiv_par.process_trig = TRUE; */
132 void
133 exec_trigger_stop (void
135 /*-----------------------------------------------------------------------------
138 gchar *err_msg = NULL;
139 int off = 0;
141 if((write(stop, &off, sizeof(int))) < 0) {
142 err_msg = _("Fail stopping camera and Laser timing");
143 warning_gpiv(err_msg);
144 return;
147 /* gpiv_par.process_trig = FALSE; */
152 * Callback functions
154 void
155 on_spinbutton_dac_trigger_dt(GtkSpinButton * widget,
156 GtkWidget * entry
158 /*-----------------------------------------------------------------------------
161 gfloat val = gtk_spin_button_get_value_as_float(widget);
162 trig_par.ttime.dt = (RTIME) (GPIV_MILI2NANO * val);
167 void
168 on_spinbutton_dac_trigger_incrdt(GtkSpinButton * widget,
169 GtkWidget * entry
171 /*-----------------------------------------------------------------------------
174 gfloat val = gtk_spin_button_get_value_as_float(widget);
175 trig_par.ttime.increment = (RTIME) (GPIV_MILI2NANO * val);
180 void
181 on_spinbutton_dac_trigger_cap(GtkSpinButton * widget,
182 GtkWidget * entry
184 /*-----------------------------------------------------------------------------
187 gfloat val = gtk_spin_button_get_value_as_float(widget);
188 trig_par.ttime.cam_acq_period = (RTIME) (GPIV_MILI2NANO * val);
193 void
194 on_button_dac_triggerstart_enter(GtkWidget *widget,
195 gpointer data
197 /*-----------------------------------------------------------------------------
200 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
201 gchar *msg = _("Uploads and Starts timings to kernel module");
202 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
207 void
208 on_button_dac_triggerstart(GtkWidget * widget,
209 gpointer data
211 /* ----------------------------------------------------------------------------
214 /* gchar *msg = */
215 /* warning_gpiv(msg); */
216 cancel_process = FALSE;
217 exec_trigger_start();
222 void
223 on_button_dac_triggerstop_enter(GtkWidget *widget,
224 gpointer data
226 /*-----------------------------------------------------------------------------
229 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
230 gchar *msg = _("Stops timings");
231 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
236 void
237 on_button_dac_triggerstop(GtkWidget * widget,
238 gpointer data
240 /* ----------------------------------------------------------------------------
243 /* gchar *msg = */
244 /* warning_gpiv(msg); */
245 cancel_process = TRUE;
246 exec_trigger_stop();
249 #endif /* ENABLE_TRIG */