sranger_hwi_control.C

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00027 
00028 /* ignore this module for docuscan
00029 % PlugInModuleIgnore
00030 */
00031 
00032 
00033 
00034 #include <locale.h>
00035 #include <libintl.h>
00036 
00037 #include <time.h>
00038 
00039 #include "glbvars.h"
00040 #include "plug-ins/hard/modules/dsp.h"
00041 #include <fcntl.h>
00042 #include <sys/ioctl.h>
00043 
00044 #include "gxsm/action_id.h"
00045 
00046 #include "dsp-pci32/xsm/xsmcmd.h"
00047 
00048 #include "sranger_hwi_control.h"
00049 #include "sranger_hwi.h"
00050 #include "gtkspinbuttonsci.h"
00051 #include "../plug-ins/hard/modules/sranger_ioctl.h"
00052 
00053 #define UTF8_DEGREE    "\302\260"
00054 #define UTF8_MU        "\302\265"
00055 #define UTF8_ANGSTROEM "\303\205"
00056 
00057 extern GxsmPlugin sranger_hwi_pi;
00058 extern sranger_hwi_dev *sranger_hwi_hardware;
00059 
00060 #define X_SOURCE_MSK 0x10000000 // select for X-mapping
00061 #define P_SOURCE_MSK 0x20000000 // select for plotting
00062 
00063 #define REMOTE_PREFIX "DSP_"
00064 #define ADD_EC_WITH_SCALE(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST) \
00065         do{\
00066                     GtkWidget *input = mygtk_create_spin_input(_(LABEL), vbox_param, hbox_param);\
00067                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00068                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00069                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00070                     SetupScale(ec->GetAdjustment(), hbox_param);\
00071                     EC_list = g_slist_prepend( EC_list, ec);\
00072                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00073         }while(0)
00074 #define ADD_EC_SPIN(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST) \
00075         do{\
00076                     GtkWidget *input = mygtk_create_spin_input(_(LABEL), vbox_param, hbox_param);\
00077                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00078                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00079                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00080                     EC_list = g_slist_prepend( EC_list, ec);\
00081                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00082         }while(0)
00083 #define ADD_EC_SPIN_LIST(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, LIST) \
00084         do{\
00085                     GtkWidget *input = mygtk_create_spin_input(_(LABEL), vbox_param, hbox_param);\
00086                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00087                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00088                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00089                     EC_list = g_slist_prepend( EC_list, ec);\
00090                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00091                     LIST = g_slist_prepend (LIST, input);               \
00092         }while(0)
00093 #define ADD_EC_SPIN_I(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, INFO) \
00094         do{\
00095                     GtkWidget *input = mygtk_create_spin_input(_(LABEL), vbox_param, hbox_param);\
00096                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00097                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00098                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00099                     ec->set_info (_(INFO));                                     \
00100                     EC_list = g_slist_prepend( EC_list, ec);\
00101                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00102         }while(0)
00103 
00104 #define APP_EC_SPIN(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST) \
00105         do{\
00106                     GtkWidget *input = mygtk_add_spin(hbox_param);\
00107                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00108                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00109                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00110                     EC_list = g_slist_prepend( EC_list, ec);\
00111                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00112         }while(0)
00113 #define APP_EC_SPIN_I(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, INFO) \
00114         do{\
00115                     GtkWidget *input = mygtk_add_spin(hbox_param);\
00116                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00117                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00118                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00119                     ec->set_info (_(INFO));                                     \
00120                     EC_list = g_slist_prepend( EC_list, ec);\
00121                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00122         }while(0)
00123 #define APP_EC_SPIN_LIST(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, LIST) \
00124         do{\
00125                     GtkWidget *input = mygtk_add_spin(hbox_param);\
00126                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00127                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00128                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00129                     EC_list = g_slist_prepend( EC_list, ec);\
00130                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00131                     LIST = g_slist_prepend (LIST, input);               \
00132         }while(0)
00133 #define APP_EC_SPIN_LIST_I(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, LIST, INFO) \
00134         do{\
00135                     GtkWidget *input = mygtk_add_spin(hbox_param);\
00136                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00137                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00138                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00139                     ec->set_info (_(INFO));                                     \
00140                     EC_list = g_slist_prepend( EC_list, ec);\
00141                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00142                     LIST = g_slist_prepend (LIST, input);               \
00143         }while(0)
00144 #define APP_EC_SPIN_SIZE(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, W, XTERN) \
00145         do{\
00146                 GtkWidget *input = mygtk_add_spin(hbox_param, -1, W);   \
00147                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00148                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00149                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00150                     EC_list = g_slist_prepend( EC_list, ec);\
00151                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00152                     XTERN;\
00153         }while(0)
00154 #define ADD_EC_SPIN_XTERN(LABEL, UNIT, ERROR_TEXT, VAR, LO, HI, FMT, STEP, PAGE, REMOTE_LIST, XTERN) \
00155         do{\
00156                 GtkWidget *input = mygtk_create_spin_input(_(LABEL), vbox_param, hbox_param);   \
00157                     gtk_object_set_data (GTK_OBJECT (input), "Adjustment_PCS_Name", (void*)(REMOTE_PREFIX LABEL));\
00158                     Gtk_EntryControl *ec = new Gtk_EntryControl (UNIT, _(ERROR_TEXT), VAR, LO, HI, FMT, input, STEP, PAGE);\
00159                     ec->Set_ChangeNoticeFkt(DSPControl::ChangedNotify, this);\
00160                     EC_list = g_slist_prepend( EC_list, ec);\
00161                     REMOTE_LIST = ec->AddEntry2RemoteList(REMOTE_PREFIX LABEL, REMOTE_LIST);\
00162                     XTERN;\
00163         }while(0)
00164 
00165 #define ADD_LABEL(LABEL)                        \
00166         do{\
00167         label = gtk_label_new (N_(LABEL));\
00168         gtk_widget_set_usize (label, 50, -1);\
00169         gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);\
00170         }while(0)
00171 
00172 #define ADD_LABEL_LIST(LABEL, LIST)                     \
00173         do{\
00174         label = gtk_label_new (N_(LABEL));\
00175         gtk_widget_set_usize (label, 50, -1);\
00176         gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);\
00177         LIST = g_slist_prepend (LIST, label);                           \
00178         }while(0)
00179 
00180 #define ADD_TOGGLE(LABEL, CONTAINER, SOURCE, BIT_CODE, CB_FUNC) \
00181         do {\
00182                    GtkWidget *checkbutton = gtk_check_button_new_with_label(_(LABEL)); \
00183                    gtk_container_add(GTK_CONTAINER(CONTAINER), checkbutton);\
00184                    gtk_object_set_data(GTK_OBJECT(checkbutton), "Bit_Mask", (gpointer*) BIT_CODE);\
00185                    GTK_TOGGLE_BUTTON(checkbutton)->active = (((SOURCE) & (BIT_CODE))?1:0); \
00186                    g_signal_connect(checkbutton, "toggled",G_CALLBACK(CB_FUNC), this);\
00187         }while(0)
00188 
00189 #define ADD_TOGGLE_TO_TAB(LABEL, TAB, X, Y, SOURCE_CHANNEL_BIT_CODE, XTERN)     \
00190         do {\
00191                    GtkWidget *checkbutton = gtk_check_button_new_with_label(_(LABEL)); \
00192                    gtk_table_attach (GTK_TABLE(TAB), checkbutton, X, (X)+1, Y, (Y)+1, GTK_FILL, GTK_FILL, 5,1); \
00193                    gtk_object_set_data (GTK_OBJECT(checkbutton), "Source_Channel", (gpointer*) SOURCE_CHANNEL_BIT_CODE);\
00194                    if (SOURCE_CHANNEL_BIT_CODE & X_SOURCE_MSK)\
00195                            GTK_TOGGLE_BUTTON (checkbutton)->active = (((SOURCE_CHANNEL_BIT_CODE & 0xfffffff) & XSource)?1:0); \
00196                    else if (SOURCE_CHANNEL_BIT_CODE & P_SOURCE_MSK)\
00197                            GTK_TOGGLE_BUTTON (checkbutton)->active = (((SOURCE_CHANNEL_BIT_CODE & 0xfffffff) & PSource)?1:0); \
00198                    else\
00199                            GTK_TOGGLE_BUTTON (checkbutton)->active = (((SOURCE_CHANNEL_BIT_CODE & 0xfffffff) & Source)?1:0); \
00200                    g_signal_connect(checkbutton, "toggled",G_CALLBACK(change_source_callback), this);\
00201                    XTERN;\
00202         }while(0)
00203 
00204 
00205 #define ADD_STATUS(LABEL, W, LIST)                      \
00206         do {\
00207                 hbox_param = gtk_hbox_new (FALSE, 0);\
00208                 gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);\
00209                 GtkWidget* label = gtk_label_new (_(LABEL));\
00210                 LIST = g_slist_prepend (LIST, label);\
00211                 gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);\
00212                 gtk_widget_set_size_request (label, MYGTK_LSIZE, -1);\
00213                 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);\
00214                 W = gtk_entry_new ();\
00215                 gtk_entry_set_text (GTK_ENTRY(W), " --- ");\
00216                 gtk_entry_set_editable (GTK_ENTRY(W), FALSE);\
00217                 LIST = g_slist_prepend (LIST, W);\
00218                 gtk_container_add (GTK_CONTAINER (hbox_param), W);\
00219         }while(0)
00220 
00221 #define BUILD_STANDART_PROBE_CONTROLS(HAVE_DUAL, OPTION_FLAGS, OPTION_CB, AUTO_FLAGS, AUTO_CB, EXEC_CB, WRITE_CB, GRAPH_CB) \
00222         do {\
00223                 hbox_param = gtk_hbox_new (FALSE, 0);   \
00224                 gtk_widget_show (hbox_param);                           \
00225                 gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param); \
00226                 ADD_TOGGLE  ("Feedback On", hbox_param, OPTION_FLAGS, FLAG_FB_ON, OPTION_CB); \
00227                 if(HAVE_DUAL) {                                         \
00228                         ADD_TOGGLE  ("Dual", hbox_param, OPTION_FLAGS, FLAG_DUAL, OPTION_CB); \
00229                 }                                                       \
00230                 ADD_TOGGLE  ("Int", hbox_param, OPTION_FLAGS, FLAG_INTEGRATE, OPTION_CB); \
00231                 ADD_TOGGLE  ("Ramp", hbox_param, OPTION_FLAGS, FLAG_SHOW_RAMP, OPTION_CB);      \
00232                 ADD_TOGGLE  ("Save", hbox_param, AUTO_FLAGS, FLAG_AUTO_SAVE, AUTO_CB); \
00233                 ADD_TOGGLE  ("Plot", hbox_param, AUTO_FLAGS, FLAG_AUTO_PLOT, AUTO_CB); \
00234                                                                         \
00235                 frame_param = gtk_frame_new (N_("Controller"));         \
00236                 gtk_widget_show(frame_param);                           \
00237                 gtk_container_add(GTK_CONTAINER (box), frame_param);    \
00238                                                                         \
00239                 hbox_param = gtk_hbox_new (FALSE, 0);                   \
00240                 gtk_container_add (GTK_CONTAINER (frame_param), hbox_param); \
00241                                                                         \
00242                 button = gtk_button_new_with_label(N_("Execute"));      \
00243                 gtk_widget_set_usize (button, 100, -1);                 \
00244                 gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0); \
00245                 gtk_widget_show (button);                               \
00246                 gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (EXEC_CB), this);   \
00247                                                                         \
00248                 button = gtk_button_new_with_label(N_("Write Vectors")); \
00249                 gtk_widget_set_usize (button, 100, -1);                 \
00250                 gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0); \
00251                 gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (WRITE_CB), this);  \
00252                 expert_list = g_slist_prepend (expert_list, button);    \
00253                                                                         \
00254                 button = gtk_button_new_with_label(N_("Plot"));         \
00255                 gtk_widget_set_usize (button, 100, -1);                 \
00256                 gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0); \
00257                 gtk_widget_show (button);                               \
00258                 gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (GRAPH_CB), this); \
00259         }while(0)
00260 
00261 
00262 #define OUT_OF_RANGE _("Value out of range!")
00263 
00264 // Achtung: Remote is not released :=(
00265 // DSP-Param sollten lokal werden...
00266 DSPControl::DSPControl ()
00267 {
00268         int i,j;
00269         AmpIndex  AmpI;
00270         GSList *EC_list=NULL;
00271 
00272         RemoteEntryList = NULL;
00273 
00274         GSList *expert_list=NULL;
00275 
00276         GtkWidget *notebook;
00277         GtkWidget *scrolled_contents;
00278 
00279         GtkWidget *box;
00280         GtkWidget *frame_param, *vbox_param, *hbox_param;
00281 
00282         GtkWidget* wid, *label, *input;
00283         GtkWidget* menu;
00284         GtkWidget* menuitem;
00285         GtkWidget *checkbutton;
00286         GtkWidget *button;
00287 
00288 
00289         IV_status = NULL;
00290         LM_status = NULL;
00291         FZ_status = NULL;
00292 
00293 
00294         write_vector_mode=PV_MODE_NONE;
00295 
00296         probedata_list = NULL;
00297         num_probe_events = 0;
00298         last_probe_data_index = 0;
00299         nun_valid_data_sections = 0;
00300 
00301         probe_trigger_single_shot = 0;
00302         current_probe_data_index = 0;
00303 
00304         for (i=0; i<NUM_PROBEDATA_ARRAYS; ++i)
00305                 garray_probedata [i] = NULL;
00306 
00307         XsmRescourceManager xrm("sranger_hwi_control");
00308         xrm.Get ("frq_ref", &frq_ref, "22100.0");
00309         xrm.Get ("bias", &bias, "0.0");
00310         xrm.Get ("current_set_point", &current_set_point, "0.1");
00311         xrm.Get ("voltage_set_point", &voltage_set_point, "0.1");
00312         xrm.Get ("move_speed_x", &move_speed_x, "500.0");
00313         xrm.Get ("scan_speed_x", &scan_speed_x, "500.0");
00314         xrm.Get ("gain_ratio", &gain_ratio, "1.0");
00315         xrm.Get ("usr_cp", &usr_cp, "0.1");
00316         xrm.Get ("usr_ci", &usr_ci, "0.1");
00317         xrm.Get ("dynamic_zoom", &dynamic_zoom, "1.0");
00318         xrm.Get ("pre_points", &pre_points, "0");
00319         xrm.Get ("expert_mode", &expert_mode, "0");
00320 
00321         ue_bias = bias;
00322         ue_scan_speed_x = 0.;
00323         ue_usr_ci = 0.;
00324         ue_usr_cp = 0.;
00325         ue_current_set_point = current_set_point;
00326         ue_voltage_set_point = voltage_set_point;
00327 
00328         // LockIn and LockIn phase probe
00329         xrm.Get ("AC_amp", &AC_amp, "0.1");
00330         xrm.Get ("AC_frq", &AC_frq, "688");
00331         xrm.Get ("AC_phaseA", &AC_phaseA, "0");
00332         xrm.Get ("AC_phaseB", &AC_phaseB, "90");
00333         xrm.Get ("AC_lockin_avg_cycels", &AC_lockin_avg_cycels, "7");
00334         xrm.Get ("AC_phase_span", &AC_phase_span, "360");
00335         xrm.Get ("AC_points", &AC_points, "720");
00336         xrm.Get ("AC_repetitions", &AC_repetitions, "1");
00337         xrm.Get ("AC_phase_slope", &AC_phase_slope, "12");
00338         xrm.Get ("AC_final_delay", &AC_final_delay, "0.01");
00339         xrm.Get ("AC_option_flags", &AC_option_flags, "0");
00340         xrm.Get ("AC_auto_flags", &AC_auto_flags, "0");
00341 
00342         // Probing
00343         xrm.Get ("Probing_Sources", &Source, "0x3030");
00344         xrm.Get ("Probing_XSources", &XSource, "0x0");
00345         xrm.Get ("Probing_PSources", &PSource, "0x0");
00346         xrm.Get ("Probing_probe_trigger_raster_points", &probe_trigger_raster_points_user, "0");
00347         probe_trigger_raster_points = 0;
00348 
00349         // STS I-V
00350         xrm.Get ("Probing_IV_Ustart", &IV_start, "-1.0");
00351         xrm.Get ("Probing_IV_Uend", &IV_end, "1.0");
00352         xrm.Get ("Probing_IV_repetitions", &IV_repetitions, "1");
00353         xrm.Get ("Probing_IV_dz", &IV_dz, "0.0");
00354         xrm.Get ("Probing_IVdz_repetitions", &IVdz_repetitions, "1");
00355         xrm.Get ("Probing_IV_points", &IV_points, "100");
00356         xrm.Get ("Probing_IV_slope", &IV_slope, "10");
00357         xrm.Get ("Probing_IV_slope_ramp", &IV_slope_ramp, "50");
00358         xrm.Get ("Probing_IV_final_delay", &IV_final_delay, "0.01");
00359         xrm.Get ("Probing_IV_recover_delay", &IV_recover_delay, "0.3");
00360         xrm.Get ("Probing_IV_option_flags", &IV_option_flags, "0");
00361         xrm.Get ("Probing_IV_auto_flags", &IV_auto_flags, "0");
00362         // FZ
00363         xrm.Get ("Probing_FZ_Z_start", &FZ_start,"0.0");
00364         xrm.Get ("Probing_FZ_Z_end", &FZ_end,"100.0");
00365         xrm.Get ("Probing_FZ_points", &FZ_points,"100");
00366         xrm.Get ("Probing_FZ_slope", &FZ_slope,"100");
00367         xrm.Get ("Probing_FZ_slope_ramp", &FZ_slope_ramp, "100");
00368         xrm.Get ("Probing_FZ_final_delay", &FZ_final_delay,"0.01");
00369         xrm.Get ("Probing_FZ_option_flags", &FZ_option_flags, "0");
00370         xrm.Get ("Probing_FZ_auto_flags", &FZ_auto_flags, "0");
00371         // PL
00372         xrm.Get ("Probing_PL_duration", &PL_duration,"10");
00373         xrm.Get ("Probing_PL_volt", &PL_volt,"2");
00374         xrm.Get ("Probing_PL_slope", &PL_slope,"1e4");
00375         xrm.Get ("Probing_PL_repetitions", &PL_repetitions,"1");
00376         xrm.Get ("Probing_PL_final_delay", &PL_final_delay,"0.01");
00377         xrm.Get ("Probing_PL_option_flags", &PL_option_flags, "0");
00378         xrm.Get ("Probing_PL_auto_flags", &PL_auto_flags, "0");
00379         // LM
00380         xrm.Get ("Probing_LM_dx", &LM_dx,"100.0");
00381         xrm.Get ("Probing_LM_dy", &LM_dy,"0.0");
00382         xrm.Get ("Probing_LM_dz", &LM_dz,"0.0");
00383         xrm.Get ("Probing_LM_points", &LM_points,"100");
00384         xrm.Get ("Probing_LM_slope", &LM_slope,"1000");
00385         xrm.Get ("Probing_LM_final_delay", &LM_final_delay,"0.01");
00386         xrm.Get ("Probing_LM_option_flags", &LM_option_flags, "0");
00387         xrm.Get ("Probing_LM_auto_flags", &LM_auto_flags, "0");
00388 
00389 
00390         Unity    = new UnitObj(" "," ");
00391         Volt     = new UnitObj("V","V");
00392         Angstroem= new UnitObj(UTF8_ANGSTROEM,"A");
00393         Frq      = new UnitObj("Hz","Hz");
00394         Time     = new UnitObj("s","s");
00395         msTime   = new UnitObj("ms","ms");
00396         Deg      = new UnitObj(UTF8_DEGREE,"Deg");
00397         Current  = new UnitObj("nA","nA");
00398         Speed    = new UnitObj(UTF8_ANGSTROEM"/s","A/s");
00399         PhiSpeed = new UnitObj(UTF8_DEGREE"/s","Deg/s");
00400         Vslope   = new UnitObj("V/s","V/s");
00401         SetPtUnit = sranger_hwi_pi.app->xsm->MakeUnit (xsmres.daqZunit[0], xsmres.daqZlabel[0]);
00402 
00403         probe_fname = g_strdup ("probe_test.data");
00404         probe_findex = 0;
00405 
00406         AppWidgetInit(N_("SR DSP Control"));
00407 
00408 
00409         notebook = gtk_notebook_new ();
00410         gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
00411         gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, GNOME_PAD);
00412         gtk_widget_show (notebook);
00413 
00414 //        gtk_widget_set_size_request  (notebook, 460, 400);
00415         gtk_widget_set_size_request  (notebook, 462, 320);
00416         
00417 // ==== Folder: Feedback & Scan ========================================
00418         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00419         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00420                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00421         box = gtk_vbox_new (FALSE, 0);
00422         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00423                 
00424         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00425                                   scrolled_contents,
00426                                   gtk_label_new ("Feedback & Scan"));
00427 
00428 
00429 
00430         gtk_widget_show (box);
00431 //      gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00432 
00433         // ========================================
00434         frame_param = gtk_frame_new (N_("SR-FB Characteristics"));
00435         gtk_widget_show (frame_param);
00436         gtk_container_add (GTK_CONTAINER (box), frame_param);
00437 
00438         vbox_param = gtk_vbox_new (FALSE, 0);
00439         gtk_widget_show (vbox_param);
00440         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00441 
00442         // ------- FB Characteristics
00443 
00444 
00445 #ifdef DSP_MASTER_CONTROL_MODE
00446 
00447         hbox_param = gtk_hbox_new (FALSE, 0);
00448         gtk_widget_show (hbox_param);
00449         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00450         label = gtk_label_new (N_("FB Switch"));
00451         gtk_widget_set_usize (label, 100, -1);
00452         gtk_widget_show (label);
00453         gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);
00454 
00455         checkbutton = gtk_check_button_new_with_label(N_("Feed Back"));
00456         gtk_widget_set_usize (checkbutton, 100, -1);
00457         gtk_box_pack_start (GTK_BOX (hbox_param), checkbutton, TRUE, TRUE, 0);
00458         gtk_widget_show (checkbutton);
00459         gtk_signal_connect (GTK_OBJECT (checkbutton), "clicked",
00460                             GTK_SIGNAL_FUNC (DSPControl::feedback_callback), this);
00461 
00462         // -------- Automatic Raster Probe Mode Select
00463         GtkWidget *auto_probe_wid = gtk_option_menu_new ();
00464         gtk_widget_set_usize (auto_probe_wid, 60, -1);
00465         gtk_widget_show (auto_probe_wid);
00466         gtk_container_add (GTK_CONTAINER (hbox_param), auto_probe_wid);
00467 
00468         GtkWidget* auto_probe_menu = gtk_menu_new ();
00469         menuitem = gtk_menu_item_new_with_label (_("No Auto Probe"));
00470         gtk_widget_show (menuitem);
00471         gtk_menu_append (GTK_MENU (auto_probe_menu), menuitem);
00472         Gtk_EntryControl* raster_ec;
00473         APP_EC_SPIN_SIZE ("Raster", Unity, OUT_OF_RANGE, &probe_trigger_raster_points_user, 0, 200, "5g", 1., 10.,  RemoteEntryList, 30, raster_ec=ec);
00474         raster_ec->Freeze ();
00475         gtk_object_set_data(GTK_OBJECT (menuitem), "raster_ec", (gpointer)raster_ec);
00476         gtk_object_set_data(GTK_OBJECT (menuitem), "auto_probe_mode", (gpointer)PV_MODE_NONE);
00477         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00478                             GTK_SIGNAL_FUNC (DSPControl::auto_probe_callback),
00479                             this);
00480 #endif
00481 
00482         ADD_EC_WITH_SCALE ("Bias", Volt, OUT_OF_RANGE, &bias, -10., 10., "5g", 0.001, 0.01,  RemoteEntryList);
00483         if (IS_AFM_CTRL) // AFM
00484                 ADD_EC_WITH_SCALE ("SetPoint", SetPtUnit, OUT_OF_RANGE,  &voltage_set_point, -500., 500., "5g", 0.001, 0.01,  RemoteEntryList);
00485         else // STM
00486                 ADD_EC_WITH_SCALE ("Current", Current, OUT_OF_RANGE, &current_set_point, 0.0001, 50., "5g", 0.001, 0.01,  RemoteEntryList);
00487 
00488         ADD_EC_WITH_SCALE ("CP", Unity, OUT_OF_RANGE, &usr_cp, -1., 1., "5g", 0.001, 0.01,  RemoteEntryList);
00489         ADD_EC_WITH_SCALE ("CI", Unity, OUT_OF_RANGE, &usr_ci, -1., 1., "5g", 0.001, 0.01,  RemoteEntryList);
00490 
00491         // ========================================
00492         frame_param = gtk_frame_new (N_("Scan Characteristics"));
00493         gtk_widget_show (frame_param);
00494         gtk_container_add (GTK_CONTAINER (box), frame_param);
00495 
00496         vbox_param = gtk_vbox_new (FALSE, 0);
00497         gtk_widget_show (vbox_param);
00498         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00499 
00500 //      ADD_EC_WITH_SCALE ("DynZoom", Unity, OUT_OF_RANGE, &dynamic_zoom, 0., 5., "5g", 0.01, 0.1,  RemoteEntryList);
00501         ADD_EC_WITH_SCALE ("MoveSpd", Speed, OUT_OF_RANGE, &move_speed_x, 0.1, 2000., "5g", 1., 10.,  RemoteEntryList);
00502         ADD_EC_WITH_SCALE ("ScanSpd", Speed, OUT_OF_RANGE, &scan_speed_x, 0.1, 2000., "5g", 1., 10.,  RemoteEntryList);
00503 //      ADD_EC_WITH_SCALE ("PrePts", Unity, OUT_OF_RANGE, &pre_points, 0., 100., "5g", 1., 10.,  RemoteEntryList);
00504 
00505 
00506         // ======================================== Piezo Drive / Amplifier Settings
00507         frame_param = gtk_frame_new (N_("Piezo Drive Settings"));
00508         gtk_widget_show (frame_param);
00509         gtk_container_add (GTK_CONTAINER (box), frame_param);
00510 
00511         vbox_param = gtk_vbox_new (FALSE, 0);
00512         gtk_widget_show (vbox_param);
00513         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00514 
00515         /* Amplifier Settings */
00516         hbox_param = gtk_hbox_new (FALSE, 0);
00517         gtk_widget_show (hbox_param);
00518         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00519 
00520         for(j=0; j<6; j++){
00521                 if (j == 3 && gapp->xsm->Inst->OffsetMode () == OFM_DSP_OFFSET_ADDING)
00522                         break;
00523                 if (j == 3){
00524                         hbox_param = gtk_hbox_new (FALSE, 0);
00525                         gtk_widget_show (hbox_param);
00526                         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00527                 }
00528 
00529                 switch(j){
00530                 case 0: label = gtk_label_new ("VX"); break;
00531                 case 1: label = gtk_label_new ("VY"); break;
00532                 case 2: label = gtk_label_new ("VZ"); break;
00533                 case 3: label = gtk_label_new ("VX0"); break;
00534                 case 4: label = gtk_label_new ("VY0"); break;
00535                 case 5: label = gtk_label_new ("VZ0"); break;
00536                 }
00537                 gtk_widget_show (label);
00538                 gtk_container_add (GTK_CONTAINER (hbox_param), label);
00539                 //    gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);
00540                 gtk_widget_set_usize (label, 20, -1);
00541 
00542                 wid = gtk_option_menu_new ();
00543                 gtk_widget_set_usize (wid, 50, -1);
00544                 gtk_widget_show (wid);
00545                 gtk_container_add (GTK_CONTAINER (hbox_param), wid);
00546 
00547                 menu = gtk_menu_new ();
00548 
00549                 // Init gain-choicelist
00550                 gchar *Vxyz;
00551                 for(i=0; i<GAIN_POSITIONS; i++){
00552                         Vxyz = g_strdup_printf("%g",xsmres.V[i]);
00553                         menuitem = gtk_menu_item_new_with_label (Vxyz);
00554                         gtk_widget_show (menuitem);
00555                         gtk_menu_append (GTK_MENU (menu), menuitem);
00556                         /* connect with signal-handler if selected */
00557                         AmpI.l = 0L;
00558                         AmpI.s.ch = j;
00559                         AmpI.s.x  = i;
00560                         gtk_object_set_data(GTK_OBJECT (menuitem), "chindex", (gpointer)AmpI.l);
00561                         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00562                                             GTK_SIGNAL_FUNC (DSPControl::choice_Ampl_callback),
00563                                             this);
00564                 }
00565                 gtk_option_menu_set_menu (GTK_OPTION_MENU (wid), menu);
00566                 switch(j){
00567                 case 0: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VXdefault); break;
00568                 case 1: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VYdefault); break;
00569                 case 2: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VZdefault); break;
00570                 case 3: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VX0default); break;
00571                 case 4: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VY0default); break;
00572                 case 5: gtk_option_menu_set_history (GTK_OPTION_MENU (wid), xsmres.VZ0default); break;
00573                 }
00574         }
00575 
00576         gtk_widget_show_all (scrolled_contents);
00577 
00578 
00579 
00580 
00581 #ifndef DSP_MASTER_CONTROL_MODE
00582 
00583 // ==== Folder: Advanced or DSP Expert (advanced Feedback & Scan settings) ========================================
00584         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00585         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00586                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00587         box = gtk_vbox_new (FALSE, 0);
00588         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00589                 
00590         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00591                                   scrolled_contents,
00592                                   gtk_label_new ("Advanced"));
00593         gtk_widget_show (box);
00594 
00595         // ========================================
00596         frame_param = gtk_frame_new (N_("SR-FB Characteristics"));
00597         gtk_widget_show (frame_param);
00598         gtk_container_add (GTK_CONTAINER (box), frame_param);
00599 
00600         vbox_param = gtk_vbox_new (FALSE, 0);
00601         gtk_widget_show (vbox_param);
00602         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00603 
00604         // ------- FB Characteristics
00605 
00606         hbox_param = gtk_hbox_new (FALSE, 0);
00607         gtk_widget_show (hbox_param);
00608         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00609         label = gtk_label_new (N_("FB Switch"));
00610         gtk_widget_set_usize (label, 100, -1);
00611         gtk_widget_show (label);
00612         gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);
00613 
00614         checkbutton = gtk_check_button_new_with_label(N_("Enable Feed Back Controller"));
00615         gtk_widget_set_usize (checkbutton, 100, -1);
00616         gtk_box_pack_start (GTK_BOX (hbox_param), checkbutton, TRUE, TRUE, 0);
00617         // read currect FB (MD_PID) state
00618         read_dsp_state ();
00619         GTK_TOGGLE_BUTTON(checkbutton)->active = dsp_state.mode & MD_PID ? 1:0;
00620         gtk_widget_show (checkbutton);
00621         gtk_signal_connect (GTK_OBJECT (checkbutton), "clicked",
00622                             GTK_SIGNAL_FUNC (DSPControl::feedback_callback), this);
00623 
00624         // -------- Automatic Raster Probe Mode Select
00625         frame_param = gtk_frame_new (N_("Automatic Raster Probe Trigger Control & Probe Details"));
00626         gtk_widget_show (frame_param);
00627         gtk_container_add (GTK_CONTAINER (box), frame_param);
00628 
00629         vbox_param = gtk_vbox_new (FALSE, 0);
00630         gtk_widget_show (vbox_param);
00631         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00632         hbox_param = gtk_hbox_new (FALSE, 0);
00633         gtk_widget_show (hbox_param);
00634         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00635 
00636         GtkWidget *auto_probe_wid = gtk_option_menu_new ();
00637         gtk_widget_show (auto_probe_wid);
00638         gtk_box_pack_start (GTK_BOX (hbox_param), auto_probe_wid, FALSE, FALSE, 0);
00639 
00640         GtkWidget* auto_probe_menu = gtk_menu_new ();
00641         menuitem = gtk_menu_item_new_with_label (_("No Auto Probe"));
00642         gtk_widget_show (menuitem);
00643         gtk_menu_append (GTK_MENU (auto_probe_menu), menuitem);
00644 
00645         Gtk_EntryControl* raster_ec;
00646         ADD_EC_SPIN_XTERN ("Raster", Unity, OUT_OF_RANGE, &probe_trigger_raster_points_user, 0, 200, "5g", 1., 10.,  RemoteEntryList, raster_ec=ec);
00647         raster_ec->Freeze ();
00648         gtk_object_set_data(GTK_OBJECT (menuitem), "raster_ec", (gpointer)raster_ec);
00649         gtk_object_set_data(GTK_OBJECT (menuitem), "auto_probe_mode", (gpointer)PV_MODE_NONE);
00650         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00651                             GTK_SIGNAL_FUNC (DSPControl::auto_probe_callback),
00652                             this);
00653 
00654         hbox_param = gtk_hbox_new (FALSE, 0);
00655         gtk_widget_show (hbox_param);
00656         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00657         GtkWidget *expert_checkbutton = gtk_check_button_new_with_label(_("Show Expert Controls"));
00658         gtk_container_add(GTK_CONTAINER(hbox_param), expert_checkbutton);
00659         GTK_TOGGLE_BUTTON(expert_checkbutton)->active = expert_mode;
00660         g_signal_connect(expert_checkbutton, "toggled",G_CALLBACK(DSPControl::DSP_expert_callback), this);
00661 
00662         // ========================================
00663         frame_param = gtk_frame_new (N_("Scan Characteristics - Expert"));
00664         gtk_widget_show (frame_param);
00665         gtk_container_add (GTK_CONTAINER (box), frame_param);
00666 
00667         vbox_param = gtk_vbox_new (FALSE, 0);
00668         gtk_widget_show (vbox_param);
00669         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00670 
00671         ADD_EC_WITH_SCALE ("DynZoom", Unity, OUT_OF_RANGE, &dynamic_zoom, 0., 5., "5g", 0.01, 0.1,  RemoteEntryList);
00672         ADD_EC_WITH_SCALE ("PrePts", Unity, OUT_OF_RANGE, &pre_points, 0., 100., "5g", 1., 10.,  RemoteEntryList);
00673 
00674         gtk_widget_show_all (scrolled_contents);
00675 
00676 #endif
00677 
00678 
00679 // ==== Folder Set for Vector Probe ========================================
00680 // ==== Folder: I-V STS setup ========================================
00681         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00682         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00683                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00684         box = gtk_vbox_new (FALSE, 0);
00685         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00686 
00687         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00688                                   scrolled_contents,
00689                                   gtk_label_new ("STS"));
00690         gtk_widget_show (box);
00691 
00692         // add item to auto-probe-menu
00693         menuitem = gtk_menu_item_new_with_label (_("STS-Raster"));
00694         gtk_widget_show (menuitem);
00695         gtk_menu_append (GTK_MENU (auto_probe_menu), menuitem);
00696         gtk_object_set_data(GTK_OBJECT (menuitem), "raster_ec", (gpointer)raster_ec);
00697         gtk_object_set_data(GTK_OBJECT (menuitem), "auto_probe_mode", (gpointer)PV_MODE_IV);
00698         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00699                             GTK_SIGNAL_FUNC (DSPControl::auto_probe_callback),
00700                             this);
00701 
00702         
00703         // ========================================
00704         frame_param = gtk_frame_new (N_("I-V Type Spectroscopy"));
00705 
00706         gtk_widget_show (frame_param);
00707         gtk_container_add (GTK_CONTAINER (box), frame_param);
00708         vbox_param = gtk_vbox_new (FALSE, 0);
00709         gtk_widget_show (vbox_param);
00710         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00711 
00712         // stuff here ...
00713         ADD_EC_SPIN ("IV-Start-End", Volt, OUT_OF_RANGE, &IV_start, -10.0, 10., "5.3g", 0.1, 0.025,  RemoteEntryList);
00714         APP_EC_SPIN ("IV-End", Volt, OUT_OF_RANGE, &IV_end, -10.0, 10.0, "5.3g", 0.1, 0.025,  RemoteEntryList);
00715         ADD_LABEL_LIST ("#", expert_list);
00716         APP_EC_SPIN_LIST ("IV-rep", Unity, OUT_OF_RANGE, &IV_repetitions, 1., 100., "3g", 1., 5.,  RemoteEntryList, expert_list);
00717         ADD_EC_SPIN ("IV-dz", Angstroem, OUT_OF_RANGE, &IV_dz, -1000.0, 1000.0, "5.4g", 1., 2.,  RemoteEntryList);
00718         ADD_LABEL_LIST ("#", expert_list);
00719         APP_EC_SPIN_LIST ("IV-dz-rep", Unity, OUT_OF_RANGE, &IVdz_repetitions, 1., 100., "3g", 1., 10.,  RemoteEntryList, expert_list);
00720         ADD_EC_SPIN ("Points", Unity, OUT_OF_RANGE, &IV_points, 1, 1000.0, "5g", 1., 10.,  RemoteEntryList);
00721         ADD_EC_SPIN ("IV-Slope", Vslope, OUT_OF_RANGE, &IV_slope,0.1,1000.0, "5.3g", 1., 10.,  RemoteEntryList);
00722         ADD_EC_SPIN ("Slope-Ramp", Vslope, OUT_OF_RANGE, &IV_slope_ramp,0.1,1000.0, "5.3g", 1., 10.,  RemoteEntryList);
00723         ADD_EC_SPIN ("Final-Delay", Time, OUT_OF_RANGE, &IV_final_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList);
00724         ADD_LABEL_LIST ("Recover-Delay", expert_list);
00725         APP_EC_SPIN_LIST ("Recover-Delay", Time, OUT_OF_RANGE, &IV_recover_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList, expert_list);
00726         ADD_STATUS ("Status", IV_status, expert_list);
00727 
00728         BUILD_STANDART_PROBE_CONTROLS (TRUE, IV_option_flags, callback_change_IV_option_flags, IV_auto_flags,  callback_change_IV_auto_flags,
00729                                        DSPControl::Probing_exec_IV_callback, DSPControl::Probing_write_IV_callback, DSPControl::Probing_graph_callback);
00730 
00731         gtk_widget_show_all (scrolled_contents);
00732 
00733 // ==== Folder: FZ (Force-Distance/AFM) setup ========================================
00734         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00735         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00736                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00737         box = gtk_vbox_new (FALSE, 0);
00738         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00739 
00740         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00741                                   scrolled_contents,
00742                                   gtk_label_new ("Z"));
00743         gtk_widget_show (box);
00744         
00745         // add item to auto-probe-menu
00746         menuitem = gtk_menu_item_new_with_label (_("Z-Raster"));
00747         gtk_widget_show (menuitem);
00748         gtk_menu_append (GTK_MENU (auto_probe_menu), menuitem);
00749         gtk_object_set_data(GTK_OBJECT (menuitem), "raster_ec", (gpointer)raster_ec);
00750         gtk_object_set_data(GTK_OBJECT (menuitem), "auto_probe_mode", (gpointer)PV_MODE_FZ);
00751         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00752                             GTK_SIGNAL_FUNC (DSPControl::auto_probe_callback),
00753                             this);
00754 
00755         // ========================================
00756         frame_param = gtk_frame_new (N_("Z Manipulation (F-Z, Tip tune, ...)"));
00757         gtk_widget_show (frame_param);
00758         gtk_container_add (GTK_CONTAINER (box), frame_param);
00759         vbox_param = gtk_vbox_new (FALSE, 0);
00760         gtk_widget_show (vbox_param);
00761         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00762 
00763         // stuff here ...
00764         ADD_EC_SPIN ("Z-Start-End", Angstroem, OUT_OF_RANGE, &FZ_start, -1000.0, 1000., "5.3g", 1., 10.,  RemoteEntryList);
00765         APP_EC_SPIN ("Z-End", Angstroem, OUT_OF_RANGE, &FZ_end, -1000.0, 1000.0, "5.3g", 1., 10.,  RemoteEntryList);
00766         ADD_EC_SPIN ("Points", Unity, OUT_OF_RANGE, &FZ_points, 1, 4000, "5g", 1., 10.,  RemoteEntryList);
00767         ADD_EC_SPIN ("Z-Slope", Speed, OUT_OF_RANGE, &FZ_slope,0.1,10000.0, "5.3g", 1., 10.,  RemoteEntryList);
00768         ADD_EC_SPIN ("Slope-Ramp", Speed, OUT_OF_RANGE, &FZ_slope_ramp,0.1,10000.0, "5.3g", 1., 10.,  RemoteEntryList);
00769         ADD_EC_SPIN ("Final-Delay", Time, OUT_OF_RANGE, &FZ_final_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList);
00770         ADD_STATUS ("Status", FZ_status, expert_list);
00771 
00772         BUILD_STANDART_PROBE_CONTROLS (TRUE, FZ_option_flags, callback_change_FZ_option_flags, FZ_auto_flags, callback_change_FZ_auto_flags,
00773                                        DSPControl::Probing_exec_FZ_callback, DSPControl::Probing_write_FZ_callback, DSPControl::Probing_graph_callback);
00774 
00775         gtk_widget_show_all (scrolled_contents);
00776 
00777 // ==== Folder: PL (Puls) setup ========================================
00778         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00779         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00780                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00781         box = gtk_vbox_new (FALSE, 0);
00782         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00783 
00784         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00785                                   scrolled_contents,
00786                                   gtk_label_new ("PL"));
00787         gtk_widget_show (box);
00788         
00789         // add item to auto-probe-menu
00790         menuitem = gtk_menu_item_new_with_label (_("PL-Raster"));
00791         gtk_widget_show (menuitem);
00792         gtk_menu_append (GTK_MENU (auto_probe_menu), menuitem);
00793         gtk_object_set_data(GTK_OBJECT (menuitem), "raster_ec", (gpointer)raster_ec);
00794         gtk_object_set_data(GTK_OBJECT (menuitem), "auto_probe_mode", (gpointer)PV_MODE_PL);
00795         gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
00796                             GTK_SIGNAL_FUNC (DSPControl::auto_probe_callback),
00797                             this);
00798 
00799         // ========================================
00800         frame_param = gtk_frame_new (N_("Bias Puls Control (Tip tune, ...)"));
00801         gtk_widget_show (frame_param);
00802         gtk_container_add (GTK_CONTAINER (box), frame_param);
00803         vbox_param = gtk_vbox_new (FALSE, 0);
00804         gtk_widget_show (vbox_param);
00805         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00806 
00807         // stuff here ...
00808         ADD_EC_SPIN ("Duration", msTime, OUT_OF_RANGE, &PL_duration, 0., 1000., ".2f", 1., 10.,  RemoteEntryList);
00809         ADD_EC_SPIN ("Volts", Volt, OUT_OF_RANGE, &PL_volt, -10, 10, ".3f", .1, 1.,  RemoteEntryList);
00810         ADD_EC_SPIN ("Slope", Vslope, OUT_OF_RANGE, &PL_slope, 0.1,1e5, "5.3g", 1., 10.,  RemoteEntryList);
00811         ADD_EC_SPIN ("Final-Delay", Time, OUT_OF_RANGE, &PL_final_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList);
00812         ADD_EC_SPIN ("Repetitions", Unity, OUT_OF_RANGE, &PL_repetitions, 1., 100., ".0f", 1, 10,  RemoteEntryList);
00813         ADD_STATUS ("Status", PL_status, expert_list);
00814 
00815         BUILD_STANDART_PROBE_CONTROLS (FALSE, PL_option_flags, callback_change_PL_option_flags, PL_auto_flags,  callback_change_PL_auto_flags,
00816                                        DSPControl::Probing_exec_PL_callback, DSPControl::Probing_write_PL_callback, DSPControl::Probing_graph_callback);
00817 
00818         gtk_widget_show_all (scrolled_contents);
00819 
00820 
00821 // ==== Folder: LatMan (lateral manipulation) setup ========================================
00822         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00823         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00824                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00825         box = gtk_vbox_new (FALSE, 0);
00826         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00827 
00828         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00829                                   scrolled_contents,
00830                                   gtk_label_new ("LM"));
00831         gtk_widget_show (box);
00832         
00833         // ========================================
00834         frame_param = gtk_frame_new (N_("Lateral (&Z) Manipulation at fixed Bias"));
00835         gtk_widget_show (frame_param);
00836         gtk_container_add (GTK_CONTAINER (box), frame_param);
00837         vbox_param = gtk_vbox_new (FALSE, 0);
00838         gtk_widget_show (vbox_param);
00839         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00840 
00841         // stuff here ...
00842         ADD_EC_SPIN ("dxyz", Angstroem, OUT_OF_RANGE, &LM_dx, -1000.0, 1000.0, "6.4g", 1., 10.,  RemoteEntryList);
00843         APP_EC_SPIN ("dy", Angstroem, OUT_OF_RANGE, &LM_dy, -1000.0, 1000.0, "6.4g", 1., 10.,  RemoteEntryList);
00844         APP_EC_SPIN ("dz", Angstroem, OUT_OF_RANGE, &LM_dz, -1000.0, 1000.0, "6.4g", 1., 10.,  RemoteEntryList);
00845         ADD_EC_SPIN ("Points", Unity, OUT_OF_RANGE, &LM_points, 1, 4000, "5g", 1., 10.,  RemoteEntryList);
00846         ADD_EC_SPIN ("LM-Slope", Speed, OUT_OF_RANGE, &LM_slope, 0.1,1000.0, "5.4g", 1., 10.,  RemoteEntryList);
00847         ADD_EC_SPIN ("Final-Delay", Time, OUT_OF_RANGE, &LM_final_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList);
00848         ADD_STATUS ("Status", LM_status, expert_list);
00849 
00850         BUILD_STANDART_PROBE_CONTROLS (TRUE, LM_option_flags, callback_change_LM_option_flags, LM_auto_flags, callback_change_LM_auto_flags,
00851                                        DSPControl::Probing_exec_LM_callback, DSPControl::Probing_write_LM_callback, DSPControl::Probing_graph_callback);
00852 
00853         gtk_widget_show_all (scrolled_contents);
00854 
00855 
00856 // ==== Folder: LockIn  ========================================
00857         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00858         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00859                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00860         box = gtk_vbox_new (FALSE, 0);
00861         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00862                 
00863         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00864                                   scrolled_contents,
00865                                   gtk_label_new ("LockIn"));
00866         gtk_widget_show (box);
00867 
00868         // ========================================
00869         frame_param = gtk_frame_new (N_("Digital Lock-In settings"));
00870         gtk_widget_show (frame_param);
00871         gtk_container_add (GTK_CONTAINER (box), frame_param);
00872 
00873         vbox_param = gtk_vbox_new (FALSE, 0);
00874         gtk_widget_show (vbox_param);
00875         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00876 
00877         ADD_EC_SPIN ("AC-Amplitude", Volt, OUT_OF_RANGE, &AC_amp, 0., 1., "5g", 0.001, 0.01,  RemoteEntryList);
00878         ADD_EC_SPIN ("AC-Frequency", Frq, OUT_OF_RANGE, &AC_frq, 0., 2000., "5g", 10., 100.,  RemoteEntryList);
00879         ADD_EC_SPIN_I ("AC-Phase-AB", Deg, OUT_OF_RANGE, &AC_phaseA, -360., 360., "5g", 1., 10.,  RemoteEntryList, " :A");
00880         APP_EC_SPIN_I ("AC-Phase-B", Deg, OUT_OF_RANGE, &AC_phaseB, -360., 360., "5g", 1., 10.,  RemoteEntryList, " :B");
00881         APP_EC_SPIN_LIST_I ("AC-Phase-Span", Deg, OUT_OF_RANGE, &AC_phase_span, -360., 360., "5g", 1., 10.,  RemoteEntryList, expert_list, " :span");
00882         ADD_EC_SPIN ("AC-avg-Cycels", Unity, OUT_OF_RANGE, &AC_lockin_avg_cycels, 1., 128., "5g", 1., 2.,  RemoteEntryList);
00883         APP_EC_SPIN_LIST_I ("AC-Points", Unity, OUT_OF_RANGE, &AC_points, 1, 1440, "5g", 1., 10.,  RemoteEntryList, expert_list, " #pts");
00884         ADD_EC_SPIN_LIST ("AC-Slope", PhiSpeed, OUT_OF_RANGE, &AC_phase_slope, 0.01,120.0, "5.4g", 1., 10.,  RemoteEntryList, expert_list);
00885         ADD_EC_SPIN_LIST ("AC-Final-Delay", Time, OUT_OF_RANGE, &AC_final_delay, 0., 1., "5.3g", 0.001, 0.01,  RemoteEntryList, expert_list);
00886         APP_EC_SPIN_LIST_I ("AC-Repetitions", Unity, OUT_OF_RANGE, &AC_repetitions, 1., 100., ".0f", 1, 10,  RemoteEntryList, expert_list, " #reps");
00887         ADD_STATUS ("Status", AC_status, expert_list);
00888 
00889         BUILD_STANDART_PROBE_CONTROLS (TRUE, AC_option_flags, callback_change_AC_option_flags, AC_auto_flags, callback_change_AC_auto_flags,
00890                                        DSPControl::LockIn_exec_callback, DSPControl::LockIn_write_callback, DSPControl::Probing_graph_callback);
00891 
00892 //      hbox_param = gtk_hbox_new (FALSE, 0);
00893 //      gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00894 //      label = gtk_label_new (N_("Manual update:"));
00895 //      gtk_widget_set_usize (label, 100, -1);
00896 //      gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);
00897 //      expert_list = g_slist_prepend (expert_list, label);
00898 
00899 //      button = gtk_button_new_with_label(N_("Read"));
00900 //      gtk_widget_set_usize (button, 100, -1);
00901 //      gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0);
00902 //      gtk_signal_connect (GTK_OBJECT (button), "clicked",
00903 //                          GTK_SIGNAL_FUNC (DSPControl::LockIn_read_callback), this);
00904 //      expert_list = g_slist_prepend (expert_list, button);
00905 
00906 //      button = gtk_button_new_with_label(N_("Write"));
00907 //      gtk_widget_set_usize (button, 100, -1);
00908 //      gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0);
00909 //      gtk_signal_connect (GTK_OBJECT (button), "clicked",
00910 //                          GTK_SIGNAL_FUNC (DSPControl::LockIn_write_callback), this);
00911 //      expert_list = g_slist_prepend (expert_list, button);
00912 
00913         gtk_widget_show_all (scrolled_contents);
00914 
00915 
00916 // ==== Folder: Graphs -- Vector Probe Data Visualisation setup ========================================
00917         scrolled_contents = gtk_scrolled_window_new (NULL, NULL);
00918         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_contents), 
00919                                         GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
00920         box = gtk_vbox_new (FALSE, 0);
00921         gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_contents), box);
00922 
00923         gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
00924                                   scrolled_contents,
00925                                   gtk_label_new ("Graphs"));
00926         gtk_widget_show (box);
00927 
00928         gtk_widget_show_all (scrolled_contents);
00929 
00930         frame_param = gtk_frame_new(N_("Probe Sources & Graph Setup"));
00931         gtk_widget_show(frame_param);
00932         gtk_container_add(GTK_CONTAINER (box), frame_param);
00933         // source channel setup
00934         GtkWidget *hbox_source;
00935         hbox_source = gtk_hbox_new (FALSE, 0);
00936         gtk_container_add (GTK_CONTAINER (frame_param), hbox_source);
00937         
00938         GtkWidget *tab = gtk_table_new (12,8, FALSE);
00939         gtk_container_add (GTK_CONTAINER (hbox_source), tab);
00940 
00941         int   msklookup[] = { 0x000020, 0x000040, 0x000080, 0x000100, 0x000200, 0x000010, 0x000400, 0x10000000,
00942                               0x000001, 0x000002, 
00943                               0x000800, 0x001000, 0x002000, 0x004000, 0x008000, 0,
00944                               0x0100000, 0x0200000, 0x0400000, 0x0800000, 0x1000000, 0x2000000, 0x4000000,
00945                               -1 
00946         };
00947         char* lablookup[] = { "ADC0", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5-I","ADC6","ADC7",
00948                               "Zmon", "Umon",
00949                               "LockIn0", "LockIn1stA",  "LockIn1stB", "LockIn2ndA", "LockIn2ndB", "-",
00950                               "Time", "XS", "YS", "ZS", "U", "PHI", "SEC",
00951                               NULL
00952         };
00953         
00954         {
00955                 int c=0;
00956                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Source"), c+0, c+1, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00957                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("X  "), c+1, c+2, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00958                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Y  "), c+2, c+3, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00959                 c+=4;
00960                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Source"), c+0, c+1, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00961                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("X  "), c+1, c+2, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00962                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Y  "), c+2, c+3, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00963                 c+=4;
00964                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Data"), c+0, c+1, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00965                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("X  "), c+1, c+2, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00966                 gtk_table_attach (GTK_TABLE(tab), gtk_label_new ("Y  "), c+2, c+3, 0, 1, GTK_FILL, GTK_FILL, 10,1);
00967         }
00968 
00969         for (i=0; msklookup[i] >= 0 && lablookup[i]; ++i){
00970                 if (!msklookup[i]) 
00971                         continue;
00972                 int c=i/8; 
00973                 c*=4;
00974                 ADD_TOGGLE_TO_TAB (lablookup[i], tab, c, i%8+1, (int) msklookup[i], expert_list);
00975                 ADD_TOGGLE_TO_TAB (" ", tab, c+1, i%8+1, (int) (X_SOURCE_MSK | msklookup[i]), expert_list);
00976                 ADD_TOGGLE_TO_TAB (" ", tab, c+2, i%8+1, (int) (P_SOURCE_MSK | msklookup[i]), expert_list);
00977         }
00978 
00979 
00980         frame_param = gtk_frame_new(N_("Save current data in buffer"));
00981         gtk_widget_show(frame_param);
00982         gtk_container_add(GTK_CONTAINER (box), frame_param);
00983         vbox_param = gtk_vbox_new (FALSE, 0);
00984         gtk_widget_show (vbox_param);
00985         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00986 
00987         hbox_param = gtk_hbox_new (FALSE, 0);
00988         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00989         button = gtk_button_new_with_label(N_("Save now (automatic naming)"));
00990         gtk_widget_set_usize (button, 100, -1);
00991         gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0);
00992         gtk_widget_show (button);
00993         gtk_signal_connect (GTK_OBJECT (button), "clicked",
00994                             GTK_SIGNAL_FUNC (DSPControl::Probing_save_callback), this);
00995         
00996         save_button = button;
00997 
00998         gtk_widget_show_all (scrolled_contents);
00999 
01000 // ==== Folder List: Vector Probes ========================================
01001 // Automatic frame generation
01002 
01003 
01004 // ==== finish auto_probe_menu now
01005         gtk_option_menu_set_menu (GTK_OPTION_MENU (auto_probe_wid), auto_probe_menu);
01006         gtk_option_menu_set_history (GTK_OPTION_MENU (auto_probe_wid), 0);
01007 
01008 // ------------------------------------------------------------
01009         sranger_hwi_pi.app->RemoteEntryList = g_slist_concat (sranger_hwi_pi.app->RemoteEntryList, RemoteEntryList);
01010 
01011         // save List away...
01012         gtk_object_set_data( GTK_OBJECT (widget), "DSP_EC_list", EC_list);
01013         gtk_object_set_data( GTK_OBJECT (expert_checkbutton), "DSP_expert_list", expert_list);
01014 
01015         DSP_expert_callback (expert_checkbutton, this);
01016 }
01017 
01018 
01019 
01020 static void remove(gpointer entry, gpointer from){
01021         from = (gpointer) g_slist_remove ((GSList*)from, entry);
01022 }
01023 
01024 DSPControl::~DSPControl (){
01025         store_values ();
01026 
01027         g_slist_foreach(RemoteEntryList, (GFunc) remove, sranger_hwi_pi.app->RemoteEntryList);
01028         g_slist_free (RemoteEntryList);
01029         RemoteEntryList = NULL;
01030 
01031         free_probedata_arrays ();
01032 
01033         delete Unity;
01034         delete Volt;
01035         delete Angstroem;
01036         delete Frq;
01037         delete Deg;
01038         delete Current;
01039         delete Speed;
01040         delete PhiSpeed;
01041         delete Vslope;
01042         delete Time;
01043         delete msTime;
01044         delete SetPtUnit;
01045 }
01046 
01047 void DSPControl::store_values (){
01048         XsmRescourceManager xrm("sranger_hwi_control");
01049         xrm.Put ("frq_ref", frq_ref);
01050         xrm.Put ("bias", bias);
01051         xrm.Put ("current_set_point", current_set_point);
01052         xrm.Put ("voltage_set_point", voltage_set_point);
01053         xrm.Put ("move_speed_x", move_speed_x);
01054         xrm.Put ("scan_speed_x", scan_speed_x);
01055         xrm.Put ("gain_ratio", gain_ratio);
01056         xrm.Put ("usr_cp", usr_cp);
01057         xrm.Put ("usr_ci", usr_ci);
01058         xrm.Put ("dynamic_zoom", dynamic_zoom);
01059         xrm.Put ("pre_points", pre_points);
01060         xrm.Put ("expert_mode", expert_mode);
01061 
01062         // LockIn and LockIn phase probe
01063         xrm.Put ("AC_amp", AC_amp);
01064         xrm.Put ("AC_frq", AC_frq);
01065         xrm.Put ("AC_phaseA", AC_phaseA);
01066         xrm.Put ("AC_phaseB", AC_phaseB);
01067         xrm.Put ("AC_lockin_avg_cycels", AC_lockin_avg_cycels);
01068         xrm.Put ("AC_phase_span", AC_phase_span);
01069         xrm.Put ("AC_points", AC_points);
01070         xrm.Put ("AC_repetitions", AC_repetitions);
01071         xrm.Put ("AC_phase_slope", AC_phase_slope);
01072         xrm.Put ("AC_final_delay", AC_final_delay);
01073         xrm.Put ("AC_option_flags", AC_option_flags);
01074         xrm.Put ("AC_auto_flags", AC_auto_flags);
01075 
01076         // Probing
01077         xrm.Put ("Probing_Sources", Source);
01078         xrm.Put ("Probing_XSources", XSource);
01079         xrm.Put ("Probing_PSources", PSource);
01080         xrm.Put ("Probing_probe_trigger_raster_points", probe_trigger_raster_points_user);
01081         // STS
01082         xrm.Put ("Probing_IV_Ustart", IV_start);
01083         xrm.Put ("Probing_IV_Uend", IV_end);
01084         xrm.Put ("Probing_IV_repetitions", IV_repetitions);
01085         xrm.Put ("Probing_IV_dz", IV_dz);
01086         xrm.Put ("Probing_IVdz_repetitions", IVdz_repetitions);
01087         xrm.Put ("Probing_IV_points", IV_points);
01088         xrm.Put ("Probing_IV_slope", IV_slope);
01089         xrm.Put ("Probing_IV_slope_ramp", IV_slope_ramp);
01090         xrm.Put ("Probing_IV_final_delay", IV_final_delay);
01091         xrm.Put ("Probing_IV_recover_delay", IV_recover_delay);
01092         xrm.Put ("Probing_IV_option_flags", IV_option_flags);
01093         xrm.Put ("Probing_IV_auto_flags", IV_auto_flags);
01094         // FZ
01095         xrm.Put ("Probing_FZ_Z_start", FZ_start);
01096         xrm.Put ("Probing_FZ_Z_end", FZ_end);
01097         xrm.Put ("Probing_FZ_points", FZ_points);
01098         xrm.Put ("Probing_FZ_slope", FZ_slope);
01099         xrm.Put ("Probing_FZ_slope_ramp", FZ_slope_ramp);
01100         xrm.Put ("Probing_FZ_final_delay", FZ_final_delay);
01101         xrm.Put ("Probing_FZ_option_flags", FZ_option_flags);
01102         xrm.Put ("Probing_FZ_auto_flags", FZ_auto_flags);
01103         // PL
01104         xrm.Put ("Probing_PL_duration", PL_duration);
01105         xrm.Put ("Probing_PL_volt", PL_volt);
01106         xrm.Put ("Probing_PL_slope", PL_slope);
01107         xrm.Put ("Probing_PL_final_delay", PL_final_delay);
01108         xrm.Put ("Probing_PL_repetitions", PL_repetitions);
01109         xrm.Put ("Probing_PL_option_flags", PL_option_flags);
01110         xrm.Put ("Probing_PL_auto_flags", PL_auto_flags);
01111         // LM
01112         xrm.Put ("Probing_LM_dx", LM_dx);
01113         xrm.Put ("Probing_LM_dy", LM_dy);
01114         xrm.Put ("Probing_LM_dz", LM_dz);
01115         xrm.Put ("Probing_LM_points", LM_points);
01116         xrm.Put ("Probing_LM_slope", LM_slope);
01117         xrm.Put ("Probing_LM_final_delay", LM_final_delay);
01118         xrm.Put ("Probing_LM_option_flags", LM_option_flags);
01119         xrm.Put ("Probing_LM_auto_flags", LM_auto_flags);
01120 }
01121 
01122 void DSPControl::save_values (NcFile *ncf){
01123 
01124         g_print ("DSPControl::save_values\n");
01125         gchar *i=NULL;
01126         gchar *hwii=NULL;
01127         if (sranger_hwi_hardware)
01128                 hwii = sranger_hwi_hardware->get_info ();
01129 
01130         if (IS_AFM_CTRL) // AFM (linear)
01131                 i = g_strconcat ("SRanger HwI interface: AFM mode selected.\nHardware-Info:\n", hwii, NULL);
01132         else
01133                 i = g_strconcat ("SRanger HwI interface: STM mode selected.\nHardware-Info:\n", hwii, NULL);
01134 
01135         NcDim* infod  = ncf->add_dim("sranger_info_dim", strlen(i));
01136         NcVar* info   = ncf->add_var("sranger_info", ncChar, infod);
01137         info->add_att("long_name", "SRanger HwI plugin information");
01138         info->put(i, strlen(i));
01139         g_free (i);
01140         g_free (hwii);
01141 
01142 
01143 // Basic Feedback/Scan Parameter ============================================================
01144 
01145         NcVar* ncv_bias = ncf->add_var ("sranger_hwi_bias", ncDouble);
01146         ncv_bias->add_att ("long_name", "SRanger: (Sample or Tip) Bias Voltage");
01147         ncv_bias->add_att ("unit", "Volt");
01148         ncv_bias->put (&bias);
01149 
01150 
01151         if (IS_AFM_CTRL){ // AFM (linear)
01152                 NcVar* ncv_sp = ncf->add_var ("sranger_hwi_voltage_set_point", ncDouble);
01153                 ncv_sp->add_att ("long_name", "SRanger: Feedback Set Point (AFM, linear FB mode)");
01154                 ncv_sp->add_att ("unit", xsmres.daqZunit[0]);
01155                 ncv_sp->put (&voltage_set_point);
01156         } else {
01157                 NcVar* ncv_sp = ncf->add_var ("sranger_hwi_current_set_point", ncDouble);
01158                 ncv_sp->add_att ("long_name", "SRanger: Current set point (STM, log FB mode)");
01159                 ncv_sp->add_att ("unit", "nA");
01160                 ncv_sp->put (&current_set_point);
01161         }
01162 
01163         NcVar* ncv_move_speed = ncf->add_var ("sranger_hwi_move_speed_x", ncDouble);
01164         ncv_move_speed->add_att ("long_name", "SRanger: Move speed X");
01165         ncv_move_speed->add_att ("unit", "A/s");
01166         ncv_move_speed->put (&move_speed_x);
01167 
01168         NcVar* ncv_scan_speed = ncf->add_var ("sranger_hwi_scan_speed_x", ncDouble);
01169         ncv_scan_speed->add_att ("long_name", "SRanger: Scan speed X");
01170         ncv_scan_speed->add_att ("unit", "A/s");
01171         ncv_scan_speed->put (&scan_speed_x);
01172 
01173         NcVar* ncv_usr_cp = ncf->add_var ("sranger_hwi_usr_cp", ncDouble);
01174         ncv_usr_cp->add_att ("long_name", "SRanger: User CP");
01175         ncv_usr_cp->add_att ("unit", "1");
01176         ncv_usr_cp->put (&usr_cp);
01177 
01178         NcVar* ncv_usr_ci = ncf->add_var ("sranger_hwi_usr_ci", ncDouble);
01179         ncv_usr_ci->add_att ("long_name", "SRanger: User CI");
01180         ncv_usr_ci->add_att ("unit", "1");
01181         ncv_usr_ci->put (&usr_ci);
01182 
01183         NcVar* ncv_pre_points = ncf->add_var ("sranger_hwi_pre_points", ncDouble);
01184         ncv_pre_points->add_att ("long_name", "SRanger: Pre-Scanline points");
01185         ncv_pre_points->add_att ("unit", "1");
01186         ncv_pre_points->put (&pre_points);
01187 
01188         NcVar* ncv_Inst_VX = ncf->add_var ("sranger_hwi_XSM_Inst_VX", ncDouble);
01189         ncv_Inst_VX->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VX (X-gain)");
01190         ncv_Inst_VX->add_att ("unit", "1");
01191         { double tmp=sranger_hwi_pi.app->xsm->Inst->VX (); ncv_Inst_VX->put (&tmp); }
01192 
01193         NcVar* ncv_Inst_VY = ncf->add_var ("sranger_hwi_XSM_Inst_VY", ncDouble);
01194         ncv_Inst_VY->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VY (Y-gain)");
01195         ncv_Inst_VY->add_att ("unit", "1");
01196         { double tmp=sranger_hwi_pi.app->xsm->Inst->VY (); ncv_Inst_VY->put (&tmp); }
01197 
01198         NcVar* ncv_Inst_VZ = ncf->add_var ("sranger_hwi_XSM_Inst_VZ", ncDouble);
01199         ncv_Inst_VZ->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VZ (Z-gain)");
01200         ncv_Inst_VZ->add_att ("unit", "1");
01201         { double tmp=sranger_hwi_pi.app->xsm->Inst->VZ (); ncv_Inst_VZ->put (&tmp); }
01202 
01203         if (gapp->xsm->Inst->OffsetMode() == OFM_ANALOG_OFFSET_ADDING){
01204                 NcVar* ncv_Inst_VX0 = ncf->add_var ("sranger_hwi_XSM_Inst_VX0", ncDouble);
01205                 ncv_Inst_VX0->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VX0 (X0-gain) used for analog offset adding");
01206                 ncv_Inst_VX0->add_att ("unit", "1");
01207                 { double tmp=sranger_hwi_pi.app->xsm->Inst->VX0 (); ncv_Inst_VX0->put (&tmp); }
01208                 
01209                 NcVar* ncv_Inst_VY0 = ncf->add_var ("sranger_hwi_XSM_Inst_VY0", ncDouble);
01210                 ncv_Inst_VY0->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VY0 (Y0-gain) used for analog offset adding");
01211                 ncv_Inst_VY0->add_att ("unit", "1");
01212                 { double tmp=sranger_hwi_pi.app->xsm->Inst->VY0 (); ncv_Inst_VY0->put (&tmp); }
01213                 
01214                 NcVar* ncv_Inst_VZ0 = ncf->add_var ("sranger_hwi_XSM_Inst_VZ0", ncDouble);
01215                 ncv_Inst_VZ0->add_att ("long_name", "FYI only::SRanger/XSM: Instrument VZ0 (Z0-gain) used for analog offset adding");
01216                 ncv_Inst_VZ0->add_att ("unit", "1");
01217                 { double tmp=sranger_hwi_pi.app->xsm->Inst->VZ0 (); ncv_Inst_VZ0->put (&tmp); }
01218         }
01219 
01220 // LockIn ============================================================
01221 
01222         NcVar* ncv_tmp = ncf->add_var ("sranger_hwi_AC_amp", ncDouble);
01223         ncv_tmp->add_att ("long_name", "SRanger: (Sample) AC Amplitude (LockIn)");
01224         ncv_tmp->add_att ("unit", "Volt");
01225         ncv_tmp->put (&AC_amp);
01226 
01227         ncv_tmp = ncf->add_var ("sranger_hwi_AC_frq", ncDouble);
01228         ncv_tmp->add_att ("long_name", "SRanger: (Sample) AC Frequency (LockIn)");
01229         ncv_tmp->add_att ("unit", "Hertz");
01230         ncv_tmp->put (&AC_frq);
01231 
01232         ncv_tmp = ncf->add_var ("sranger_hwi_AC_phaseA", ncDouble);
01233         ncv_tmp->add_att ("long_name", "SRanger: (Sample) AC Phase A (LockIn)");
01234         ncv_tmp->add_att ("unit", "deg");
01235         ncv_tmp->put (&AC_phaseA);
01236 
01237         ncv_tmp = ncf->add_var ("sranger_hwi_AC_phaseB", ncDouble);
01238         ncv_tmp->add_att ("long_name", "SRanger: (Sample) AC Phase B (LockIn)");
01239         ncv_tmp->add_att ("unit", "deg");
01240         ncv_tmp->put (&AC_phaseB);
01241 
01242         ncv_tmp = ncf->add_var ("sranger_hwi_AC_lockin_avg_cycels", ncInt);
01243         ncv_tmp->add_att ("long_name", "SRanger: (Sample) AC LockIn average cycels (LockIn)");
01244         ncv_tmp->add_att ("unit", "#");
01245         ncv_tmp->put (&AC_lockin_avg_cycels);
01246 
01247 // Vector Probe ============================================================
01248 // to-do !!!???
01249 }
01250 
01251 
01252 #define NC_GET_VARIABLE(VNAME, VAR) if(ncf->get_var(VNAME)) ncf->get_var(VNAME)->get(VAR)
01253 
01254 void DSPControl::load_values (NcFile *ncf){
01255         g_print ("DSPControl::load_values\n");
01256         // Values will also be written in old style DSP Control window for the reason of backwards compatibility
01257         // OK -- but will be obsoleted and removed at any later point -- PZ
01258         NC_GET_VARIABLE ("sranger_hwi_bias", &bias);
01259         NC_GET_VARIABLE ("sranger_hwi_bias", &gapp->xsm->data.s.Bias);
01260         NC_GET_VARIABLE ("sranger_hwi_voltage_set_point", &voltage_set_point);
01261         NC_GET_VARIABLE ("sranger_hwi_current_set_point", &current_set_point);
01262 
01263         update ();
01264 }
01265 
01266 #define CONV_16(X) X = sranger_hwi_hardware->int_2_sranger_int (X)
01267 #define CONV_32(X) X = sranger_hwi_hardware->long_2_sranger_long (X)
01268 
01269 void DSPControl::read_dsp_state (){
01270         if (!sranger_hwi_hardware) return; 
01271 
01272         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.statemachine, SRANGER_SEEK_DATA_SPACE);
01273         read (sranger_hwi_hardware->dsp, &dsp_state, sizeof(dsp_state)); 
01274 
01275         CONV_16 (dsp_state.mode);
01276         CONV_16 (dsp_state.DataProcessTime);
01277         CONV_16 (dsp_state.IdleTime);
01278 }
01279 
01280 void DSPControl::write_dsp_state (){
01281 }
01282         
01283 void DSPControl::conv_dsp_feedback (){
01284         CONV_16 (dsp_feedback.cp);
01285         CONV_16 (dsp_feedback.ci);
01286         CONV_16 (dsp_feedback.setpoint);
01287 }
01288 
01289 void DSPControl::read_dsp_feedback (){
01290         if (!sranger_hwi_hardware) return; 
01291 
01292         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.feedback, SRANGER_SEEK_DATA_SPACE);
01293         read (sranger_hwi_hardware->dsp, &dsp_feedback, MAX_WRITE_SPM_PI_FEEDBACK<<1); 
01294 
01295         // from DSP to PC -- only SetPoint!
01296         conv_dsp_feedback ();
01297 }
01298 
01299 void DSPControl::write_dsp_feedback (){
01300         if (!sranger_hwi_hardware) return; 
01301 
01302         // Scale Regler Consts. with 1/VZ and convert to SR-Q15
01303         dsp_feedback.cp = sranger_hwi_hardware->float_2_sranger_q15 (usr_cp / sranger_hwi_pi.app->xsm->Inst->VZ ());
01304         dsp_feedback.ci = sranger_hwi_hardware->float_2_sranger_q15 (usr_ci / sranger_hwi_pi.app->xsm->Inst->VZ ());
01305 
01306         // from PC to DSP
01307         conv_dsp_feedback ();
01308 
01309         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.feedback, SRANGER_SEEK_DATA_SPACE);
01310         write (sranger_hwi_hardware->dsp, &dsp_feedback, MAX_WRITE_SPM_PI_FEEDBACK<<1); 
01311 
01312         // from DSP to PC
01313         conv_dsp_feedback ();
01314 }
01315 
01316 
01317 void DSPControl::conv_dsp_analog (){
01318         CONV_16 (dsp_analog.bias);
01319 }
01320 
01321 void DSPControl::read_dsp_analog (){
01322         // only "bias" is touched here!
01323         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.analog, SRANGER_SEEK_DATA_SPACE);
01324         read  (sranger_hwi_hardware->dsp, &dsp_analog, sizeof (dsp_analog)); 
01325 
01326         // from DSP to PC
01327         conv_dsp_analog ();
01328 }
01329 
01330 void DSPControl::write_dsp_analog (){
01331         if (!sranger_hwi_hardware) return; 
01332 
01333         // only "bias" is touched here!
01334 
01335         // from PC to DSP
01336         conv_dsp_analog ();
01337 
01338         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.analog+START_WRITE_ANALOG, SRANGER_SEEK_DATA_SPACE);
01339         write (sranger_hwi_hardware->dsp, &dsp_analog.x_offset, MAX_WRITE_ANALOG<<1); 
01340 
01341         // from DSP to PC
01342         conv_dsp_analog ();
01343 }
01344 
01345 void DSPControl::conv_dsp_scan (){
01346 //      CONV_16 (dsp_scan.rotxx);
01347 //      CONV_16 (dsp_scan.rotxy);
01348 //      CONV_16 (dsp_scan.rotyx);
01349 //      CONV_16 (dsp_scan.rotyy);
01350         CONV_16 (dsp_scan.nx_pre);
01351         CONV_16 (dsp_scan.dnx_probe);
01352         CONV_16 (dsp_scan.raster_a);
01353         CONV_16 (dsp_scan.raster_b);
01354         CONV_16 (dsp_scan.srcs_xp);
01355         CONV_16 (dsp_scan.srcs_xm);
01356         CONV_16 (dsp_scan.srcs_2nd_xp);
01357         CONV_16 (dsp_scan.srcs_2nd_xm);
01358         CONV_16 (dsp_scan.nx);
01359         CONV_16 (dsp_scan.ny);
01360         CONV_32 (dsp_scan.fs_dx);
01361         CONV_32 (dsp_scan.fs_dy);
01362         CONV_32 (dsp_scan.num_steps_move_xy);
01363         CONV_32 (dsp_scan.fm_dx);
01364         CONV_32 (dsp_scan.fm_dy);
01365         CONV_16 (dsp_scan.dnx);
01366         CONV_16 (dsp_scan.dny);
01367         CONV_16 (dsp_scan.Zoff_2nd_xp);
01368         CONV_16 (dsp_scan.Zoff_2nd_xm);
01369         CONV_32 (dsp_scan.Xpos);
01370         CONV_32 (dsp_scan.Ypos);
01371         CONV_32 (dsp_scan.cfs_dx);
01372         CONV_32 (dsp_scan.cfs_dy);
01373 // RO:
01374         CONV_16 (dsp_scan.sstate);
01375         CONV_16 (dsp_scan.pflg);
01376 }
01377 
01378 void DSPControl::read_dsp_scan (){
01379         if (!sranger_hwi_hardware) return; 
01380 
01381         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.scan, SRANGER_SEEK_DATA_SPACE);
01382         read  (sranger_hwi_hardware->dsp, &dsp_scan, sizeof (dsp_scan));
01383 
01384         // from DSP to PC
01385         conv_dsp_scan ();
01386 }
01387 
01388 void DSPControl::write_dsp_scan (){
01389         if (!sranger_hwi_hardware) return; 
01390 
01391         // from PC to DSP
01392         conv_dsp_scan ();
01393 
01394         // adjust ScanParams/Speed...
01395         lseek (sranger_hwi_hardware->dsp, sranger_hwi_hardware->magic_data.scan, SRANGER_SEEK_DATA_SPACE);
01396         write  (sranger_hwi_hardware->dsp, &dsp_scan, MAX_WRITE_SCAN<<1);
01397 
01398         // from DSP to PC
01399         conv_dsp_scan ();
01400 }
01401 
01402 
01403 void DSPControl::update(){
01404         g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "DSP_EC_list"),
01405                         (GFunc) App::update_ec, NULL);
01406 }
01407 
01408 
01409 double factor(double N, double delta){
01410         while (fmod (N, delta) != 0.) 
01411                 delta -= 1.;
01412         return delta;
01413 }
01414 
01415 void DSPControl::updateDSP(int FbFlg){
01416         if (!sranger_hwi_hardware) return; 
01417         PI_DEBUG (DBG_L2, "Hallo SR DSP ! FB=" << FbFlg );
01418         switch(FbFlg){
01419         case DSP_FB_ON: sranger_hwi_hardware->ExecCmd(DSP_CMD_START); break;
01420         case DSP_FB_OFF: sranger_hwi_hardware->ExecCmd(DSP_CMD_HALT); break;
01421         }
01422 
01423         if (IS_AFM_CTRL){ // AFM (linear)
01424                 if (strncmp (xsmres.daqZunit[0], "nN", 2) == 0)
01425                         dsp_feedback.setpoint = (int)(gapp->xsm->Inst->VoltIn2Dig (gapp->xsm->Inst->nNewton2V (voltage_set_point)));
01426                 else if (strncmp (xsmres.daqZunit[0], "Hz", 2) == 0)
01427                         dsp_feedback.setpoint = (int)(gapp->xsm->Inst->VoltIn2Dig (gapp->xsm->Inst->dHertz2V (voltage_set_point)));
01428                 else
01429                         dsp_feedback.setpoint = (int)(gapp->xsm->Inst->VoltIn2Dig (voltage_set_point));
01430         } else {// STM (log)
01431                 dsp_feedback.setpoint = (int)(gapp->xsm->Inst->VoltIn2Dig (gapp->xsm->Inst->nAmpere2V (current_set_point)));
01432                 if (dsp_feedback.setpoint < 1)
01433                         dsp_feedback.setpoint = 1;
01434         }
01435         write_dsp_feedback ();
01436 
01437         // Analog values (bias only is changed)
01438         read_dsp_analog ();
01439         dsp_analog.bias = (int)(gapp->xsm->Inst->VoltOut2Dig (gapp->xsm->Inst->BiasV2Vabs (bias)));
01440         write_dsp_analog ();
01441 
01442 
01443         int addflag=FALSE;
01444         if (fabs (ue_bias - bias) > 1e-6){
01445                 add_user_event_now (g_strdup_printf (_("Bias from %g V to %g V"), ue_bias, bias), addflag);
01446                 ue_bias = bias;
01447                 addflag=TRUE;
01448         }
01449         if (fabs (ue_current_set_point - current_set_point) > 1e-6){
01450                 add_user_event_now (g_strdup_printf (_("Current Set Pt. from %g nA to %g nA"), ue_current_set_point, current_set_point), addflag);
01451                 ue_current_set_point = current_set_point;
01452                 addflag=TRUE;
01453         }
01454         if (fabs (ue_voltage_set_point - voltage_set_point) > 1e-6){
01455                 add_user_event_now (g_strdup_printf (_("Voltage Set Pt. from %g V to %g V"), ue_voltage_set_point, voltage_set_point), addflag);
01456                 ue_voltage_set_point = voltage_set_point;
01457                 addflag=TRUE;
01458         }
01459         if (fabs (ue_usr_cp - usr_cp) > 1e-6){
01460                 add_user_event_now (g_strdup_printf (_("CP from %g V to %g V"), ue_usr_cp, usr_cp), addflag);
01461                 ue_usr_cp = usr_cp;
01462                 addflag=TRUE;
01463         }
01464         if (fabs (ue_usr_ci - usr_ci) > 1e-6){
01465                 add_user_event_now (g_strdup_printf (_("CI from %g V to %g V"), ue_usr_ci, usr_ci), addflag);
01466                 ue_usr_ci = usr_ci;
01467                 addflag=TRUE;
01468         }
01469 
01470 
01471         // Scan characteristics update while scanning
01472         read_dsp_scan ();
01473         if (dsp_scan.pflg && fabs (ue_scan_speed_x - scan_speed_x) > 1e-6){
01474                 // compute 32bit stepsize and num steps inbetween from scan_speed_x and Dx, Dy
01475                 // sranger_hwi_pi.app->xsm->Inst->XA2Dig, Dig2XA
01476 
01477                 double frac  = (1<<16);
01478                 double delta;
01479                 double fs_dx = frac * sranger_hwi_pi.app->xsm->Inst->XA2Dig (scan_speed_x) / frq_ref;
01480                 double fs_dy = frac * sranger_hwi_pi.app->xsm->Inst->YA2Dig (scan_speed_x) / frq_ref;
01481 
01482 //              dsp_scan.dnx = (DSP_INT) (floor (ceil (frac * sranger_hwi_hardware->Dx / fs_dx) / (scanpoints - 1)))* 
01483 //                      scanpoints + 1;
01484                 
01485                 // fs_dx * N =!= frac*Dx  -> N = ceil [frac*Dx/fs_dx]  -> fs_dx' = frac*Dx/N
01486 
01487 
01488 // -- exact variant --
01489 //              delta = factor (frac * sranger_hwi_hardware->Dx, ceil (fs_dx));
01490                 delta = fs_dx;
01491                 dsp_scan.fs_dx = (DSP_LONG) delta;
01492                 dsp_scan.dnx   = (DSP_INT)  (frac * sranger_hwi_hardware->Dx * dynamic_zoom / delta);
01493                 
01494                 scan_speed_x = sranger_hwi_pi.app->xsm->Inst->Dig2XA ((long)(delta * frq_ref / frac));
01495 
01496 #ifdef DEBUGMSGS
01497                 std::cout << "Delta Computation: (N=" << (long)(frac * sranger_hwi_hardware->Dx) 
01498                           << "::" << sranger_hwi_hardware->Dx
01499                           << ", delta0=" << ceil (fs_dx) << ", sspd0=" << scan_speed_x << " )" << std::endl
01500                           << "delta          = " << delta << std::endl
01501                           << "dsp_scan.fs_dx = " << dsp_scan.fs_dx << std::endl
01502                           << "dsp_scan.dnx   = " << dsp_scan.dnx << std::endl
01503                           << "scan_speed_x   = " << scan_speed_x << std::endl;
01504 #endif
01505                 
01506 //              ec->PutValue ();
01507 
01508 
01509 
01510 // -- exact variant --
01511 //              delta = factor (frac * sranger_hwi_hardware->Dy, ceil (fs_dy));
01512                 delta = fs_dy;
01513                 dsp_scan.fs_dy = (DSP_LONG) delta * sranger_hwi_hardware->scan_direction;
01514                 dsp_scan.dny   = (DSP_INT)  (frac * sranger_hwi_hardware->Dy * dynamic_zoom / delta);
01515                 
01516                 if ((frac * sranger_hwi_hardware->Dx / delta) > (1<<15) || (frac * sranger_hwi_hardware->Dy / delta) > (1<<15)){
01517                         std::cout << "Too slow, reaching 1<<15 steps inbetween! -- no change." << std::endl;
01518                         return;
01519                 }
01520                         
01521                 // N: dnx
01522 //              dsp_scan.dnx = (DSP_INT) ceil (frac * sranger_hwi_hardware->Dx / fs_dx);
01523 //              dsp_scan.dny = (DSP_INT) ceil (frac * sranger_hwi_hardware->Dy / fs_dy);
01524 
01525 //              dsp_scan.fs_dx = (DSP_LONG) (frac*sranger_hwi_hardware->Dx / ceil (frac * sranger_hwi_hardware->Dx / fs_dx));
01526 //              dsp_scan.fs_dy = (DSP_LONG) (frac*sranger_hwi_hardware->Dy / ceil (frac * sranger_hwi_hardware->Dy / (fs_dy*double(sranger_hwi_hardware->scan_direction))));
01527 
01528                 // this is the number of subscanpoints needed to get to the next data point
01529 
01530                 dsp_scan.nx_pre = dsp_scan.dnx * pre_points;
01531                 write_dsp_scan ();
01532 
01533                 add_user_event_now (g_strdup_printf (_("Speed from %g A/s to %g A/s [fs_dx:%d, dnx:%d]"), ue_scan_speed_x, scan_speed_x, dsp_scan.fs_dx, dsp_scan.dnx), addflag);
01534                 ue_scan_speed_x = scan_speed_x;
01535                 addflag=TRUE;
01536         }
01537 }
01538 
01539 int DSPControl::ChangedAction(GtkWidget *widget, DSPControl *dspc){
01540         dspc->updateDSP();
01541         return 0;
01542 }
01543 
01544 void DSPControl::ChangedNotify(Param_Control* pcs, gpointer dspc){
01545         //  gchar *us=pcs->Get_UsrString();
01546         //  PI_DEBUG (DBG_L2, "DSPC: " << us );
01547         //  g_free(us);
01548         ((DSPControl*)dspc)->updateDSP();
01549 }
01550 
01551 int DSPControl::feedback_callback( GtkWidget *widget, DSPControl *dspc){
01552         if (GTK_TOGGLE_BUTTON (widget)->active)
01553                 dspc->updateDSP(DSP_FB_ON);
01554         else
01555                 dspc->updateDSP(DSP_FB_OFF);
01556         return 0;
01557 }
01558 
01559 // LockIn write (optional)
01560 
01561 int DSPControl::LockIn_read_callback( GtkWidget *widget, DSPControl *dspc){
01562         dspc->read_dsp_probe ();
01563 }
01564 
01565 int DSPControl::LockIn_write_callback( GtkWidget *widget, DSPControl *dspc){
01566         dspc->write_dsp_probe ();
01567 }
01568 
01569 // PV write
01570 // Note: Exec and/or Write always includes LockIn and PV data write to DSP!
01571 
01572 int DSPControl::LockIn_exec_callback( GtkWidget *widget, DSPControl *dspc){
01573         dspc->write_dsp_probe (0, PV_MODE_NONE);
01574 
01575         dspc->current_auto_flags = dspc->AC_auto_flags;
01576         dspc->probe_trigger_single_shot = 1;
01577         dspc->write_dsp_probe (1, PV_MODE_AC); // Exec AC-phase probing here
01578         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01579 }
01580 
01581 int DSPControl::Probing_exec_IV_callback( GtkWidget *widget, DSPControl *dspc){
01582         dspc->write_dsp_probe (0, PV_MODE_NONE);
01583 
01584         dspc->current_auto_flags = dspc->IV_auto_flags;
01585         dspc->probe_trigger_single_shot = 1;
01586         dspc->write_dsp_probe (1, PV_MODE_IV); // Exec STS probing here
01587         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01588 }
01589 
01590 int DSPControl::Probing_write_IV_callback( GtkWidget *widget, DSPControl *dspc){
01591         dspc->write_dsp_probe (0, PV_MODE_IV);
01592 }
01593 
01594 int DSPControl::Probing_exec_FZ_callback( GtkWidget *widget, DSPControl *dspc){
01595         dspc->write_dsp_probe (0, PV_MODE_NONE);
01596 
01597         dspc->current_auto_flags = dspc->FZ_auto_flags;
01598         dspc->probe_trigger_single_shot = 1;
01599         dspc->write_dsp_probe (1, PV_MODE_FZ); // Exec FZ probing here
01600         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01601 }
01602 
01603 int DSPControl::Probing_write_FZ_callback( GtkWidget *widget, DSPControl *dspc){
01604         dspc->write_dsp_probe (0, PV_MODE_FZ);
01605 }
01606 
01607 // PL
01608 
01609 int DSPControl::Probing_exec_PL_callback( GtkWidget *widget, DSPControl *dspc){
01610         dspc->write_dsp_probe (0, PV_MODE_NONE);
01611 
01612         dspc->current_auto_flags = dspc->PL_auto_flags;
01613         dspc->probe_trigger_single_shot = 1;
01614         dspc->write_dsp_probe (1, PV_MODE_PL); // Exec FZ probing here
01615         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01616 }
01617 
01618 int DSPControl::Probing_write_PL_callback( GtkWidget *widget, DSPControl *dspc){
01619         dspc->write_dsp_probe (0, PV_MODE_PL);
01620 }
01621 
01622 // LM
01623 
01624 int DSPControl::Probing_exec_LM_callback( GtkWidget *widget, DSPControl *dspc){
01625         dspc->write_dsp_probe (0, PV_MODE_NONE);
01626 
01627         dspc->current_auto_flags = dspc->LM_auto_flags;
01628 
01629         dspc->probe_trigger_single_shot = 1;
01630         dspc->write_dsp_probe (1, PV_MODE_LM); // Exec FZ probing here
01631         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01632 }
01633 
01634 int DSPControl::Probing_write_LM_callback( GtkWidget *widget, DSPControl *dspc){
01635         dspc->write_dsp_probe (0, PV_MODE_LM);
01636 }
01637 
01638 // for TESTING and DEBUGGIG only
01639 int DSPControl::Probing_exec_RF_callback( GtkWidget *widget, DSPControl *dspc){
01640         dspc->probe_trigger_single_shot = 1;
01641         sranger_hwi_hardware->start_fifo_read (0, 0,0,0,0, NULL,NULL,NULL,NULL);
01642 }
01643 
01644 
01645 void DSPControl::StartScanPreCheck (){
01646         dynamic_zoom = 1.;
01647         update ();
01648 
01649         if (write_vector_mode == PV_MODE_NONE)
01650                 probe_trigger_raster_points = 0;
01651         else{
01652                 probe_trigger_raster_points = probe_trigger_raster_points_user;
01653                 raster_auto_flags = current_auto_flags;
01654                 write_dsp_probe (0, write_vector_mode);
01655         }
01656 }
01657 
01658 int DSPControl::auto_probe_callback(GtkWidget *widget, DSPControl *dspc){
01659         dspc->write_vector_mode = (pv_mode) ((int)(gtk_object_get_data( GTK_OBJECT (widget), "auto_probe_mode")));
01660         Gtk_EntryControl* ri = (Gtk_EntryControl*) gtk_object_get_data( GTK_OBJECT (widget), "raster_ec");
01661         if (!ri) return 0;
01662 
01663         if (dspc->write_vector_mode == PV_MODE_NONE)
01664                 ri->Freeze ();
01665         else
01666                 ri->Thaw ();
01667 
01668         return 0;             
01669 }
01670 
01671 
01672 int DSPControl::choice_Ampl_callback (GtkWidget *widget, DSPControl *dspc){
01673         AmpIndex i;
01674         i.l=(long)gtk_object_get_data( GTK_OBJECT (widget), "chindex");
01675         switch(i.s.ch){
01676         case 0: sranger_hwi_pi.app->xsm->Inst->VX((int)i.s.x);
01677                 if (gapp->xsm->Inst->OffsetMode() == OFM_DSP_OFFSET_ADDING)
01678                         sranger_hwi_pi.app->xsm->Inst->VX0((int)i.s.x);
01679                 break;
01680         case 1: sranger_hwi_pi.app->xsm->Inst->VY((int)i.s.x);
01681                 if (gapp->xsm->Inst->OffsetMode() == OFM_DSP_OFFSET_ADDING)
01682                         sranger_hwi_pi.app->xsm->Inst->VY0((int)i.s.x);
01683                 break;
01684         case 2: sranger_hwi_pi.app->xsm->Inst->VZ((int)i.s.x); 
01685                 if (gapp->xsm->Inst->OffsetMode() == OFM_DSP_OFFSET_ADDING)
01686                         sranger_hwi_pi.app->xsm->Inst->VZ0((int)i.s.x); 
01687                 break;
01688         case 3:
01689                 if (gapp->xsm->Inst->OffsetMode() == OFM_ANALOG_OFFSET_ADDING)
01690                         sranger_hwi_pi.app->xsm->Inst->VX0((int)i.s.x);
01691                 break;
01692         case 4:
01693                 if (gapp->xsm->Inst->OffsetMode() == OFM_ANALOG_OFFSET_ADDING)
01694                         sranger_hwi_pi.app->xsm->Inst->VY0((int)i.s.x);
01695                 break;
01696         case 5:
01697                 if (gapp->xsm->Inst->OffsetMode() == OFM_ANALOG_OFFSET_ADDING)
01698                         sranger_hwi_pi.app->xsm->Inst->VZ0((int)i.s.x);
01699                 break;
01700         }
01701         PI_DEBUG (DBG_L2, "Ampl: " << i.l << " " << (int)i.s.ch << " " << (int)i.s.x );
01702         sranger_hwi_pi.app->spm_range_check(NULL, sranger_hwi_pi.app);
01703         dspc->updateDSP();
01704         return 0;
01705 }
01706 
01707 int DSPControl::callback_change_AC_option_flags (GtkWidget *widget, DSPControl *dspc){
01708         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01709         if (GTK_TOGGLE_BUTTON(widget)->active)
01710                 dspc->AC_option_flags = (dspc->AC_option_flags & (~msk)) | msk;
01711         else
01712                 dspc->AC_option_flags &= ~msk;
01713 
01714 }
01715 int DSPControl::callback_change_AC_auto_flags (GtkWidget *widget, DSPControl *dspc){
01716         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01717         if (GTK_TOGGLE_BUTTON(widget)->active)
01718                 dspc->AC_auto_flags = (dspc->AC_auto_flags & (~msk)) | msk;
01719         else
01720                 dspc->AC_auto_flags &= ~msk;
01721 
01722         if (dspc->write_vector_mode == PV_MODE_AC)
01723                 dspc->raster_auto_flags = dspc->AC_auto_flags;
01724 
01725 }
01726 
01727 int DSPControl::callback_change_IV_option_flags (GtkWidget *widget, DSPControl *dspc){
01728         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01729         if (GTK_TOGGLE_BUTTON(widget)->active)
01730                 dspc->IV_option_flags = (dspc->IV_option_flags & (~msk)) | msk;
01731         else
01732                 dspc->IV_option_flags &= ~msk;
01733 
01734 }
01735 int DSPControl::callback_change_IV_auto_flags (GtkWidget *widget, DSPControl *dspc){
01736         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01737         if (GTK_TOGGLE_BUTTON(widget)->active)
01738                 dspc->IV_auto_flags = (dspc->IV_auto_flags & (~msk)) | msk;
01739         else
01740                 dspc->IV_auto_flags &= ~msk;
01741 
01742         if (dspc->write_vector_mode == PV_MODE_IV)
01743                 dspc->raster_auto_flags = dspc->IV_auto_flags;
01744 
01745 }
01746 
01747 int DSPControl::callback_change_FZ_option_flags (GtkWidget *widget, DSPControl *dspc){
01748         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01749         if (GTK_TOGGLE_BUTTON(widget)->active)
01750                 dspc->FZ_option_flags = (dspc->FZ_option_flags & (~msk)) | msk;
01751         else
01752                 dspc->FZ_option_flags &= ~msk;
01753 
01754 }
01755 int DSPControl::callback_change_FZ_auto_flags (GtkWidget *widget, DSPControl *dspc){
01756         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01757         if (GTK_TOGGLE_BUTTON(widget)->active)
01758                 dspc->FZ_auto_flags = (dspc->FZ_auto_flags & (~msk)) | msk;
01759         else
01760                 dspc->FZ_auto_flags &= ~msk;
01761 
01762         if (dspc->write_vector_mode == PV_MODE_FZ)
01763                 dspc->raster_auto_flags = dspc->FZ_auto_flags;
01764 }
01765 
01766 int DSPControl::callback_change_PL_option_flags (GtkWidget *widget, DSPControl *dspc){
01767         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01768         if (GTK_TOGGLE_BUTTON(widget)->active)
01769                 dspc->PL_option_flags = (dspc->PL_option_flags & (~msk)) | msk;
01770         else
01771                 dspc->PL_option_flags &= ~msk;
01772 
01773         if (dspc->write_vector_mode == PV_MODE_PL)
01774                 dspc->raster_auto_flags = dspc->PL_auto_flags;
01775 }
01776 
01777 int DSPControl::callback_change_PL_auto_flags (GtkWidget *widget, DSPControl *dspc){
01778         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01779         if (GTK_TOGGLE_BUTTON(widget)->active)
01780                 dspc->PL_auto_flags = (dspc->PL_auto_flags & (~msk)) | msk;
01781         else
01782                 dspc->PL_auto_flags &= ~msk;
01783 
01784 }
01785 
01786 int DSPControl::callback_change_LM_option_flags (GtkWidget *widget, DSPControl *dspc){
01787         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01788         if (GTK_TOGGLE_BUTTON(widget)->active)
01789                 dspc->LM_option_flags = (dspc->LM_option_flags & (~msk)) | msk;
01790         else
01791                 dspc->LM_option_flags &= ~msk;
01792 
01793         if (dspc->write_vector_mode == PV_MODE_LM)
01794                 dspc->raster_auto_flags = dspc->LM_auto_flags;
01795 }
01796 
01797 int DSPControl::callback_change_LM_auto_flags (GtkWidget *widget, DSPControl *dspc){
01798         long msk = (int) gtk_object_get_data(GTK_OBJECT(widget), "Bit_Mask");
01799         if (GTK_TOGGLE_BUTTON(widget)->active)
01800                 dspc->LM_auto_flags = (dspc->LM_auto_flags & (~msk)) | msk;
01801         else
01802                 dspc->LM_auto_flags &= ~msk;
01803 
01804 }
01805 
01806 int DSPControl::DSP_expert_callback (GtkWidget *widget, DSPControl *dspc){
01807         if (GTK_TOGGLE_BUTTON(widget)->active)
01808                 g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "DSP_expert_list"),
01809                                 (GFunc) gtk_widget_show, NULL);
01810         else
01811                 g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "DSP_expert_list"),
01812                                 (GFunc) gtk_widget_hide, NULL);
01813 
01814         dspc->expert_mode = GTK_TOGGLE_BUTTON(widget)->active;
01815 }
01816 
01817 int DSPControl::change_source_callback (GtkWidget *widget, DSPControl *dspc){
01818         long channel;
01819         channel = (int) gtk_object_get_data(GTK_OBJECT(widget), "Source_Channel");
01820         if (GTK_TOGGLE_BUTTON(widget)->active) {
01821                 if (channel & X_SOURCE_MSK)
01822                         dspc->XSource |= channel;
01823                 else if (channel & P_SOURCE_MSK)
01824                         dspc->PSource |= channel;
01825                 else
01826                         dspc->Source |= channel;
01827                 
01828         }
01829         else {
01830                 if (channel & X_SOURCE_MSK)
01831                         dspc->XSource &= ~channel;
01832                 else if (channel & P_SOURCE_MSK)
01833                         dspc->PSource &= ~channel;
01834                 else
01835                         dspc->Source &= ~channel;
01836         }
01837         return 0;
01838 }
01839 
01840 

Generated on Sat Apr 1 09:04:18 2006 for GXSM by  doxygen 1.4.6