app_probe.C

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999 The Free Software Foundation
00006  *
00007  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00008  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024 
00025 /* ignore tag evaluated by for docuscangxsmplugins.pl -- this is no main plugin file
00026 % PlugInModuleIgnore
00027 */
00028 
00029 #include "app_probe.h"
00030 
00031 // Remote Disabled... PZ
00032 DSPProbeControl::DSPProbeControl (XSM_Hardware *Hard, GSList **RemoteEntryListXX, int InWindow)
00033 {
00034   int i;
00035   //  GSList **RemoteEntryList = new GSList *;
00036   GSList *EC_list=NULL;
00037 
00038   GtkWidget *box;
00039   GtkWidget *frame_param, *vbox_nb, *vbox_param, *hbox_param;
00040 
00041   GtkWidget *input;
00042   GtkWidget *button;
00043 
00044   Gtk_EntryControl *ec;
00045 
00046   PI_DEBUG (DBG_L2, "DSPProbeControl::DSPProbeControl");
00047 
00048   PrbList = NULL;
00049   prbscan = new ProbeScan;
00050 
00051   hard=Hard;
00052   itab=0;
00053 
00054 #define VOLT_MAX 10.
00055 #define VOLT_MIN -10.
00056 
00057   Unity       = new UnitObj(" "," ");
00058   Deg         = new UnitObj("°","°");
00059 
00060   UGapAdj     = new UnitObj("A/V","A/V");
00061   Current     = new UnitObj("nA","nA");
00062   Force       = new UnitObj("nN","nN");
00063   TimeUnitms  = new LinUnit("ms","ms", "Time", 1e-3);
00064   TimeUnit    = new UnitObj("s","s", "g", "Time");
00065   FrqUnit     = new UnitObj("Hz","Hz", "g", "Frq.");
00066 
00067   AppWidgetInit(PROBE_CONTROL_TITLE);
00068 
00069   PI_DEBUG (DBG_L2, "DSPProbeControl::DSPProbeControl widget setup ");
00070 
00071   box = gtk_vbox_new (FALSE, 0);
00072   gtk_widget_show (box);
00073   gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00074 
00075   GtkWidget *ProbeCtrl;
00076 
00077   notebook = gtk_notebook_new ();
00078   gtk_widget_show (notebook);
00079   gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, GNOME_PAD);
00080 
00081   for(itab=i=0; i < PRBMODESMAX && xsmres.prbname[i][0] != '-'; ++i){
00082 
00083     SPM_Probe_p *prbp;
00084     gchar *title = g_strconcat (xsmres.prbname[i], " [", xsmres.prbparam[i], "]", NULL);
00085     prbp = new SPM_Probe_p(xsmres.prbid[i], title);
00086     g_free (title);
00087     PrbList = g_slist_prepend( PrbList, prbp);
00088     UnitObj *ux, *uy;
00089     
00090     if (strcmp (xsmres.prbXunit[i], "1") == 0)
00091             ux = new LinUnit(" "," ", xsmres.prbXlabel[i], (double)xsmres.prbXfactor[i], (double)xsmres.prbXoffset[i]);
00092     else
00093             ux = new LinUnit(xsmres.prbXunit[i], xsmres.prbXunit[i], xsmres.prbXlabel[i], (double)xsmres.prbXfactor[i], (double)xsmres.prbXoffset[i]);
00094     ux->SetAlias (xsmres.prbXunit[i]);
00095 
00096 // Y:   1e-2/1e10*(10^(\$2/3.33))
00097 //      1e-2/1e10*(pow(10., (double)linebuffer[k]/3.33));
00098 
00099 
00100     if (strcmp (xsmres.prbYunit[i], "1") == 0)
00101             uy = new LinUnit(" ", " ", xsmres.prbYlabel[i], (double)xsmres.prbYfactor[i], (double)xsmres.prbYoffset[i]);
00102     else
00103             if (strncmp (xsmres.prbYunit[i], "log", 3) == 0)
00104                     uy = new LogUnit(" ", " ", xsmres.prbYlabel[i], (double)xsmres.prbYfactor[i], (double)xsmres.prbYoffset[i]);
00105             else
00106                     uy = new LinUnit(xsmres.prbYunit[i], xsmres.prbYunit[i], xsmres.prbYlabel[i], (double)xsmres.prbYfactor[i], (double)xsmres.prbYoffset[i]);
00107     uy->SetAlias (xsmres.prbYunit[i]);
00108 
00109     prbp->SetUnits (ux, uy);
00110     
00111     prbp->srcs  = 0;
00112     prbp->nsrcs = 0;
00113     for(int k=4; k<(int)strlen(xsmres.prbsrcs[i]); ++k)
00114       if(xsmres.prbsrcs[i][k]=='1'){
00115         prbp->srcs |= 1<<k;
00116         prbp->nsrcs++;
00117       } 
00118     
00119     prbp->outp = xsmres.prboutp[i];
00120     
00121     // add folder
00122     vbox_nb = gtk_vbox_new (FALSE, 0);
00123     gtk_widget_show (vbox_nb);
00124 //    gtk_container_add (GTK_CONTAINER (notebook), vbox_nb);
00125     
00126     // set label
00127     ProbeCtrl = gtk_label_new (xsmres.prbname[i]);
00128     gtk_widget_show (ProbeCtrl);
00129     gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_nb, ProbeCtrl);
00130     itab++;
00131 // set_notebook_tab (notebook, itab++, ProbeCtrl);
00132     
00133     // make frame, attach to folder
00134     frame_param = gtk_frame_new (xsmres.prbparam[i]);
00135     gtk_widget_show (frame_param);
00136     gtk_container_add (GTK_CONTAINER (vbox_nb), frame_param);
00137     
00138     vbox_param = gtk_vbox_new (FALSE, 0);
00139     gtk_widget_show (vbox_param);
00140     gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00141     
00142     // make input fields
00143     
00144     // ----------
00145     
00146     input = mygtk_create_input("Range: Start", vbox_param, hbox_param);
00147     ec = new Gtk_EntryControl(prbp->XUnit, MLD_WERT_NICHT_OK, &prbp->xS, VOLT_MIN, VOLT_MAX, "5.3f", input);
00148     
00149     input = mygtk_add_input("End", hbox_param);
00150     ec = new Gtk_EntryControl(prbp->XUnit, MLD_WERT_NICHT_OK, &prbp->xE, VOLT_MIN, VOLT_MAX, "5.3f", input);
00151     
00152     input = mygtk_add_input("GapAdj", hbox_param);
00153     ec = new Gtk_EntryControl(UGapAdj, MLD_WERT_NICHT_OK, &prbp->GapAdj, 0., 10., "5.3f", input);
00154         EC_list = g_slist_prepend( EC_list, ec);
00155     
00156     // ----------
00157     input = mygtk_create_input("AC: Amp", vbox_param, hbox_param);
00158     ec = new Gtk_EntryControl(prbp->XUnit, MLD_WERT_NICHT_OK, &prbp->ACAmp, VOLT_MIN, VOLT_MAX, "5.3f", input);
00159         EC_list = g_slist_prepend( EC_list, ec);
00160     
00161     input = mygtk_add_input("Frq", hbox_param);
00162     ec = new Gtk_EntryControl(FrqUnit, MLD_WERT_NICHT_OK, &prbp->ACFrq, 0., 1100., "4.0f", input);
00163         EC_list = g_slist_prepend( EC_list, ec);
00164 
00165     input = mygtk_add_input("Phase", hbox_param);
00166     ec = new Gtk_EntryControl(Deg, MLD_WERT_NICHT_OK, &prbp->ACPhase, 0., 360., "3.1f", input);
00167         EC_list = g_slist_prepend( EC_list, ec);
00168     // ----------
00169     
00170     input = mygtk_create_input("Points", vbox_param, hbox_param);
00171     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->nx, 2., 3400., "4.0f", input);
00172         EC_list = g_slist_prepend( EC_list, ec);
00173     
00174     input = mygtk_add_input("Delay", hbox_param);
00175     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->delay, 0., 1000., "5.3f", input);
00176         EC_list = g_slist_prepend( EC_list, ec);
00177     
00178     input = mygtk_add_input("#Ch", hbox_param);
00179     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->channels, 0., 3., "1.0f", input);
00180         EC_list = g_slist_prepend( EC_list, ec);
00181     
00182     // ----------
00183     
00184     input = mygtk_create_input("#Ave", vbox_param, hbox_param);
00185     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->nAve, 0., 1000., "4.0f", input);
00186         EC_list = g_slist_prepend( EC_list, ec);
00187     
00188     input = mygtk_add_input("ACMult", hbox_param);
00189     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->ACMultiplier, 1., 100., "1.0f", input);
00190         EC_list = g_slist_prepend( EC_list, ec);
00191     
00192     input = mygtk_add_input("CI", hbox_param);
00193     ec = new Gtk_EntryControl(Unity, MLD_WERT_NICHT_OK, &prbp->CIval, -1., 1., ".5f", input);
00194         EC_list = g_slist_prepend( EC_list, ec);
00195     
00196     // Buttons: Start/Stop
00197     // ----------
00198     hbox_param = gtk_hbox_new(FALSE, 0);
00199     gtk_widget_show (hbox_param);
00200     gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00201     
00202     button = gtk_button_new_with_label("Start");
00203     gtk_widget_show (button);
00204     gtk_box_pack_start (GTK_BOX (hbox_param), button, TRUE, TRUE, 0);
00205     
00206     gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)"StartProbe");
00207     gtk_object_set_data( GTK_OBJECT (button), "DSP_PROBE", (gpointer)prbp );
00208     gtk_signal_connect ( GTK_OBJECT (button), "pressed",
00209                          GTK_SIGNAL_FUNC (DSPProbeControl::CmdStartAction),
00210                          this);
00211     
00212     button = gtk_button_new_with_label("Stop");
00213     gtk_widget_show (button);
00214     gtk_container_add (GTK_CONTAINER (hbox_param), button);
00215     gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)"StopProbe");
00216     gtk_signal_connect (GTK_OBJECT (button), "pressed",
00217                         GTK_SIGNAL_FUNC (DSPProbeControl::CmdStopAction),
00218                         this);
00219   }
00220 
00221   // save list away...
00222   gtk_object_set_data( GTK_OBJECT (widget), "Probe_EC_list", EC_list);
00223 }
00224 
00225 DSPProbeControl::~DSPProbeControl (){
00226   PI_DEBUG (DBG_L2, "DSPProbeControl::~DSPProbeControl" );
00227   g_slist_foreach(PrbList, (GFunc) DSPProbeControl::delete_prb_cb, this);
00228   g_slist_free(PrbList);
00229 
00230   delete Unity;
00231   delete Deg;
00232   delete Current;
00233   delete Force;
00234   delete TimeUnitms;
00235   delete TimeUnit;
00236   delete FrqUnit;
00237 
00238   delete prbscan;
00239   PI_DEBUG (DBG_L2, "DSPProbeControl::~DSPProbeControl: done." );
00240 }
00241 
00242 void DSPProbeControl::delete_prb_cb(SPM_Probe_p *prb, DSPProbeControl *pc) { delete prb; }
00243 
00244 void DSPProbeControl::update(){
00245   g_slist_foreach
00246     ((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "Probe_EC_list"),
00247      (GFunc) App::update_ec, NULL);
00248 }
00249 
00250 void DSPProbeControl::CmdStartAction(GtkWidget *widget, DSPProbeControl *pc){
00251   PI_DEBUG (DBG_L2, (char*) gtk_object_get_data( GTK_OBJECT (widget), "DSP_cmd") );
00252   pc->prbscan->Probe
00253     (pc->hard, 
00254      (SPM_Probe_p *)(gtk_object_get_data
00255                      ( GTK_OBJECT (widget), "DSP_PROBE"))
00256      );
00257   pc->update();
00258 }
00259 
00260 void DSPProbeControl::CmdStopAction(GtkWidget *widget, DSPProbeControl *pc){
00261   PI_DEBUG (DBG_L2, (char*) gtk_object_get_data( GTK_OBJECT (widget), "DSP_cmd") );
00262   pc->prbscan->Stop();
00263   pc->update();
00264 }
00265 
00266 void DSPProbeControl::ChangedNotify(Param_Control* pcs, gpointer pc){
00267   PI_DEBUG (DBG_L2, "PRBC: " << pcs->Get_UsrString() );
00268   //  ((DSPProbeControl*)pc)->updateDSP();
00269 }
00270 
00271 void DSPProbeControl::ExecCmd(int cmd){
00272   gapp->xsm->hardware->ExecCmd(cmd);
00273 }
00274 
00275 

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