Updated because of cvs conflict
[gpiv.git] / src / dac_trig.c
blobf1bbe015757e80312619ae7ab2007a81179358a8
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 Gerber van der Graaf
10 This file is part of gpiv.
12 Gpiv is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
15 any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ----------------------------------------------------------------------*/
29 * Dac callbacks
30 * $Id: dac_trig.c,v 1.1 2006-09-18 07:29:51 gerber Exp $
32 #ifdef ENABLE_TRIG
34 #include "gpiv_gui.h"
35 #include "console.h"
36 #include "dac_trig.h"
38 /* #include <sys/types.h> */
39 /* #include <sys/stat.h> */
40 /* #include <fcntl.h> */
44 * BUGFIX: Put somwhere to update on regular basis:
45 gtk_label_set_text(GTK_LABEL(gpiv->dac->label_temp),
46 "Temp");
49 static int init, start, stop, error;
52 * Prototypes of local functions
56 * Global functions
58 void
59 exec_trigger_start (void
61 /*-----------------------------------------------------------------------------
64 gchar *err_msg = NULL;
65 int on = 1, param_ok;
67 g_message("exec_trigger_start: 0");
68 if (!gpiv_trig_openrtfs(&init, &start, &stop, &error)) {
69 err_msg = _("Fail in fifo open");
70 warning_gpiv(err_msg);
71 return;
75 g_message("exec_trigger_start: 1");
76 gpiv_trig_test_parameter(&trig_par);
79 * write the timing details to /dev/rtf/1
81 g_message("exec_trigger_start: 2");
82 if((write(init, &trig_par.ttime, sizeof(GpivTrigTime))) < 0) {
83 err_msg = _("Fail in setting camera and Laser timing");
84 warning_gpiv(err_msg);
85 return;
88 g_message("exec_trigger_start: 3");
89 if((read(error, &param_ok, sizeof(int))) < 0) {
90 err_msg = _("Fail in receipt of confirmation");
91 warning_gpiv(err_msg);
92 return;
95 g_message("exec_trigger_start: 4");
96 if (param_ok != 1) {
97 warning_gpiv("Invalid parameters entered \n");
99 } else {
100 if (verbose)
101 g_message (_("Parameters: \n\
102 cam_acq_period: %lld \n\
103 laser_trig_pw: %lld \n\
104 time2laser: %lld \n\
105 dt: %lld \n\
106 mode: %d \n\
107 cycles: %d \n\
108 increment: %d\n"),
109 trig_par.ttime.cam_acq_period,
110 trig_par.ttime.laser_trig_pw,
111 trig_par.ttime.time2laser,
112 trig_par.ttime.dt,
113 trig_par.ttime.mode,
114 trig_par.ttime.cycles,
115 (int) trig_par.ttime.increment);
117 g_message("exec_trigger_start: 5");
118 if((write(start, &on, sizeof(int))) < 0) {
119 err_msg = _("Fail in starting camera and Laser timing");
120 warning_gpiv(err_msg);
121 return;
125 g_message("exec_trigger_start: 6");
126 /* gpiv_par.process_trig = TRUE; */
131 void
132 exec_trigger_stop (void
134 /*-----------------------------------------------------------------------------
137 gchar *err_msg = NULL;
138 int off = 0;
140 if((write(stop, &off, sizeof(int))) < 0) {
141 err_msg = _("Fail stopping camera and Laser timing");
142 warning_gpiv(err_msg);
143 return;
146 /* gpiv_par.process_trig = FALSE; */
151 * Callback functions
153 void
154 on_spinbutton_dac_trigger_dt(GtkSpinButton * widget,
155 GtkWidget * entry
157 /*-----------------------------------------------------------------------------
160 gfloat val = gtk_spin_button_get_value_as_float(widget);
161 trig_par.ttime.dt = (RTIME) (GPIV_MILI2NANO * val);
166 void
167 on_spinbutton_dac_trigger_incrdt(GtkSpinButton * widget,
168 GtkWidget * entry
170 /*-----------------------------------------------------------------------------
173 gfloat val = gtk_spin_button_get_value_as_float(widget);
174 trig_par.ttime.increment = (RTIME) (GPIV_MILI2NANO * val);
179 void
180 on_spinbutton_dac_trigger_cap(GtkSpinButton * widget,
181 GtkWidget * entry
183 /*-----------------------------------------------------------------------------
186 gfloat val = gtk_spin_button_get_value_as_float(widget);
187 trig_par.ttime.cam_acq_period = (RTIME) (GPIV_MILI2NANO * val);
192 void
193 on_button_dac_triggerstart_enter(GtkWidget *widget,
194 gpointer data
196 /*-----------------------------------------------------------------------------
199 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
200 gchar *msg = _("Uploads and Starts timings to kernel module");
201 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
206 void
207 on_button_dac_triggerstart(GtkWidget * widget,
208 gpointer data
210 /* ----------------------------------------------------------------------------
213 /* gchar *msg = */
214 /* warning_gpiv(msg); */
215 cancel_process = FALSE;
216 exec_trigger_start();
221 void
222 on_button_dac_triggerstop_enter(GtkWidget *widget,
223 gpointer data
225 /*-----------------------------------------------------------------------------
228 GpivConsole * gpiv = gtk_object_get_data(GTK_OBJECT(widget), "gpiv");
229 gchar *msg = _("Stops timings");
230 gnome_appbar_set_status(GNOME_APPBAR(gpiv->appbar), msg);
235 void
236 on_button_dac_triggerstop(GtkWidget * widget,
237 gpointer data
239 /* ----------------------------------------------------------------------------
242 /* gchar *msg = */
243 /* warning_gpiv(msg); */
244 cancel_process = TRUE;
245 exec_trigger_stop();
248 #endif /* ENABLE_TRIG */