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 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)
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 ----------------------------------------------------------------------*/
30 * $Id: dac_trig.c,v 1.1 2006-09-18 07:29:51 gerber Exp $
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),
49 static int init
, start
, stop
, error
;
52 * Prototypes of local functions
59 exec_trigger_start (void
61 /*-----------------------------------------------------------------------------
64 gchar
*err_msg
= NULL
;
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
);
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
);
88 g_message("exec_trigger_start: 3");
89 if((read(error
, ¶m_ok
, sizeof(int))) < 0) {
90 err_msg
= _("Fail in receipt of confirmation");
91 warning_gpiv(err_msg
);
95 g_message("exec_trigger_start: 4");
97 warning_gpiv("Invalid parameters entered \n");
101 g_message (_("Parameters: \n\
102 cam_acq_period: %lld \n\
103 laser_trig_pw: %lld \n\
109 trig_par
.ttime
.cam_acq_period
,
110 trig_par
.ttime
.laser_trig_pw
,
111 trig_par
.ttime
.time2laser
,
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
);
125 g_message("exec_trigger_start: 6");
126 /* gpiv_par.process_trig = TRUE; */
132 exec_trigger_stop (void
134 /*-----------------------------------------------------------------------------
137 gchar
*err_msg
= NULL
;
140 if((write(stop
, &off
, sizeof(int))) < 0) {
141 err_msg
= _("Fail stopping camera and Laser timing");
142 warning_gpiv(err_msg
);
146 /* gpiv_par.process_trig = FALSE; */
154 on_spinbutton_dac_trigger_dt(GtkSpinButton
* widget
,
157 /*-----------------------------------------------------------------------------
160 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
161 trig_par
.ttime
.dt
= (RTIME
) (GPIV_MILI2NANO
* val
);
167 on_spinbutton_dac_trigger_incrdt(GtkSpinButton
* widget
,
170 /*-----------------------------------------------------------------------------
173 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
174 trig_par
.ttime
.increment
= (RTIME
) (GPIV_MILI2NANO
* val
);
180 on_spinbutton_dac_trigger_cap(GtkSpinButton
* widget
,
183 /*-----------------------------------------------------------------------------
186 gfloat val
= gtk_spin_button_get_value_as_float(widget
);
187 trig_par
.ttime
.cam_acq_period
= (RTIME
) (GPIV_MILI2NANO
* val
);
193 on_button_dac_triggerstart_enter(GtkWidget
*widget
,
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
);
207 on_button_dac_triggerstart(GtkWidget
* widget
,
210 /* ----------------------------------------------------------------------------
214 /* warning_gpiv(msg); */
215 cancel_process
= FALSE
;
216 exec_trigger_start();
222 on_button_dac_triggerstop_enter(GtkWidget
*widget
,
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
);
236 on_button_dac_triggerstop(GtkWidget
* widget
,
239 /* ----------------------------------------------------------------------------
243 /* warning_gpiv(msg); */
244 cancel_process
= TRUE
;
248 #endif /* ENABLE_TRIG */