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
8 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
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)
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 ----------------------------------------------------------------------*/
31 * $Id: dac_trig.c,v 1.1 2006-09-18 07:29:51 gerber Exp $
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),
50 static int init
, start
, stop
, error
;
53 * Prototypes of local functions
60 exec_trigger_start (void
62 /*-----------------------------------------------------------------------------
65 gchar
*err_msg
= NULL
;
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
);
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
);
89 g_message("exec_trigger_start: 3");
90 if((read(error
, ¶m_ok
, sizeof(int))) < 0) {
91 err_msg
= _("Fail in receipt of confirmation");
92 warning_gpiv(err_msg
);
96 g_message("exec_trigger_start: 4");
98 warning_gpiv("Invalid parameters entered \n");
102 g_message (_("Parameters: \n\
103 cam_acq_period: %lld \n\
104 laser_trig_pw: %lld \n\
110 trig_par
.ttime
.cam_acq_period
,
111 trig_par
.ttime
.laser_trig_pw
,
112 trig_par
.ttime
.time2laser
,
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
);
126 g_message("exec_trigger_start: 6");
127 /* gpiv_par.process_trig = TRUE; */
133 exec_trigger_stop (void
135 /*-----------------------------------------------------------------------------
138 gchar
*err_msg
= NULL
;
141 if((write(stop
, &off
, sizeof(int))) < 0) {
142 err_msg
= _("Fail stopping camera and Laser timing");
143 warning_gpiv(err_msg
);
147 /* gpiv_par.process_trig = FALSE; */
155 on_spinbutton_dac_trigger_dt(GtkSpinButton
* widget
,
158 /*-----------------------------------------------------------------------------
161 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
162 trig_par
.ttime
.dt
= (RTIME
) (GPIV_MILI2NANO
* val
);
168 on_spinbutton_dac_trigger_incrdt(GtkSpinButton
* widget
,
171 /*-----------------------------------------------------------------------------
174 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
175 trig_par
.ttime
.increment
= (RTIME
) (GPIV_MILI2NANO
* val
);
181 on_spinbutton_dac_trigger_cap(GtkSpinButton
* widget
,
184 /*-----------------------------------------------------------------------------
187 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
188 trig_par
.ttime
.cam_acq_period
= (RTIME
) (GPIV_MILI2NANO
* val
);
194 on_button_dac_triggerstart_enter(GtkWidget
*widget
,
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
);
208 on_button_dac_triggerstart(GtkWidget
* widget
,
211 /* ----------------------------------------------------------------------------
215 /* warning_gpiv(msg); */
216 cancel_process
= FALSE
;
217 exec_trigger_start();
223 on_button_dac_triggerstop_enter(GtkWidget
*widget
,
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
);
237 on_button_dac_triggerstop(GtkWidget
* widget
,
240 /* ----------------------------------------------------------------------------
244 /* warning_gpiv(msg); */
245 cancel_process
= TRUE
;
249 #endif /* ENABLE_TRIG */