DSPMover.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  * Gxsm Plugin Name: DSPMover.C
00006  * ========================================
00007  * 
00008  * Copyright (C) 1999 The Free Software Foundation
00009  *
00010  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00011  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00026  */
00027 
00028 /* Please do not change the Begin/End lines of this comment section!
00029  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00030  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00031  * All "% PlugInXXX" commentary tags are mandatory
00032  * All "% OptPlugInXXX" tags are optional
00033  * --------------------------------------------------------------------------------
00034 % PlugInModuleIgnore
00035 
00036 % BeginPlugInDocuSection
00037 % PlugInDocuCaption: Mover/Slider and coarse approch control (OBSOLETE)
00038 % PlugInName: DSPmover
00039 % PlugInAuthor: Percy Zahl
00040 % PlugInAuthorEmail: zahl@users.sf.net
00041 % PlugInMenuPath: Windows/DSP Mover
00042 
00043 % PlugInDescription
00044 Gxsm or better the DSP software provides a set of commands for coarse
00045 motion control. This includes a automatic approach and a general
00046 purpose mover/slider control (X/Y/Z/...) control.
00047 
00048 Supported are two principal types of coarse motion, which are to be
00049 configured via the preferences dialog. According to the type the
00050 presented control dialog will be different.
00051 
00052 \begin{description}
00053 \item[Slider] Are all type of coarse approach mechanism, which are
00054   driven by a external high voltage slider control box and from point
00055   of the Gxsm/DSP they are controlled by selecting a slider, setting a
00056   direction bit and putting out a clock/pulse signal to make a single
00057   step (width is controlled by some external settings on that box,
00058   Gxsm does not know about). Therefore the DSP's digital IO is used.
00059   Details of the wiring to IO-ports and control sequence are software
00060   coded in the DSP program, but can quit easy be changed/adapted, get
00061   in contact with the Gxsm team!  Out of the box supported types are
00062   the old and newer Omicron coarse motion slider controls. (used in
00063   Bremen and Essen, refer to the Gxsm user address list here:\\
00064   \GxsmWebLink{gxsm.sourceforge.net/index.php?content=gxsmusersfragment}
00065 \item[Mover] Are all type of ``simple'' slip and stick motions
00066   generated by some hard metal sliding on some other hard stuff (like
00067   sapphire balls), used typically in Besocke and Beetle type SPM
00068   designs, where a set of XY tube piezos is used to drive a circular
00069   up- and down motion of a ramp.  Therefore a sawtooth like (here a
00070   special parabola shaped voltage curve is used) voltage is generated
00071   by the DSP and amplified by the same piezodrive which is used for
00072   scanning as well.
00073 \end{description}
00074 
00075 % PlugInUsage
00076 The control dialog is opened via \GxsmMenu{Windows/DSP Mover} and
00077 appears dependen on configurated mode:
00078 
00079 \GxsmScreenShot{MoverControl-Rotation}{The Mover-Control window in Rotation settings.}
00080 \GxsmScreenShot{MoverControl-Auto}{The Mover-Control window in Auto folder.}
00081 \GxsmScreenShot{SliderControl}{The Slider-Control version.}
00082 
00083 
00084 %% OptPlugInSubSection: replace this line by the subsection caption
00085 %all following lines until next tag are going into this subsection
00086 
00087 
00088 % OptPlugInConfig
00089 Setup the control type:\\
00090 \GxsmPref{User}{User/SliderControlType}: mover,slider\\
00091 %
00092 Set motion control parameters:\\
00093 Motion Parameter Set Folders (AFM/Besocke mover type): Besocke X\&Y, PSD, Rotation, Lens, Auto\\
00094 Settings: Amplitude, Speed, Steps\\
00095 
00096 
00097 % OptPlugInKnownBugs
00098 In case the mover did not stop (can happen with older DSP software
00099 versions) press and release the center stop button or the same
00100 direction button again. To be safe, limit the maximal number of steps!
00101 
00102 % OptPlugInNotes
00103 This PlugIn is just the user frontend to interact with the DSP's
00104 mover/slider control commands.
00105 
00106 % OptPlugInHints
00107 Using the WRM Piezo drive, set Z gain to 15 and Z Offset to 6.0! Set
00108 popper U, I and CI values! And set the Z-gain to 10 or 15 in the DSP
00109 Control!
00110 
00111 % EndPlugInDocuSection
00112  * -------------------------------------------------------------------------------- 
00113  */
00114 
00115 #include <gtk/gtk.h>
00116 #include "config.h"
00117 #include "gxsm/plugin.h"
00118 
00119 static void DSPMover_about( void );
00120 static void DSPMover_query( void );
00121 static void DSPMover_cleanup( void );
00122 
00123 static void DSPMover_show_callback( GtkWidget*, void* );
00124 
00125 GxsmPlugin DSPMover_pi = {
00126         NULL,
00127         NULL,
00128         0,
00129         NULL,
00130         "DSPMover",
00131         "+spmHARD +srangerspmHARD +Innovative_DSP:SPMHARD +SRanger:SPMHARD +LAN_RHK:SPMHARD +STM +AFM",
00132 //  "+ALL",
00133         NULL,
00134         "Percy Zahl",
00135         N_("_Windows/"),
00136         N_("DSP Mover"),
00137         N_("open the DSP Mover controlwindow"),
00138         "DSP mover control",
00139         NULL,
00140         NULL,
00141         NULL,
00142         DSPMover_query,
00143         DSPMover_about,
00144         NULL,
00145         NULL,
00146         DSPMover_cleanup
00147 };
00148 
00149 static const char *about_text = N_("Gxsm DSPMover Plugin:\n"
00150                                    "This plugin runs a control window to send "
00151                                    "slider/mover motion commands to the DSP.\n"
00152                                    "There is a autoapproch control "
00153                                    "(STM/AFM: Slider and Besocke Type) "
00154                                    "an a general mover/slider motion control."
00155         );
00156 
00157 
00158 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00159         DSPMover_pi.description = g_strdup_printf(N_("Gxsm DSPMover plugin %s"), VERSION);
00160         return &DSPMover_pi; 
00161 }
00162 
00163 
00164 #include "gxsm/gxsm_app.h"
00165 
00166 #include "gxsm/unit.h"
00167 #include "gxsm/pcs.h"
00168 #include "gxsm/xsmtypes.h"
00169 #include "gxsm/glbvars.h"
00170 
00171 #include "include/dsp-pci32/xsm/xsmcmd.h"
00172 
00173 
00174 
00175 typedef union AmpIndex {
00176         struct { unsigned char ch, x, y, z; } s;
00177         unsigned long   l;
00178 };
00179 
00180  
00181 class DSPMoverControl : public AppBase{
00182 public:
00183         DSPMoverControl(DSP_Param *Dsp, XSM_Hardware *Hard, int InWindow=TRUE);
00184         virtual ~DSPMoverControl();
00185 
00186         void update();
00187         void updateDSP(int sliderno=-1);
00188         static void ExecCmd(int cmd);
00189         static void ChangedNotify(Param_Control* pcs, gpointer data);
00190         static int CmdAction(GtkWidget *widget, DSPMoverControl *dspc);
00191         static int StopAction(GtkWidget *widget, DSPMoverControl *dspc);
00192 
00193 private:
00194         void create_folder();
00195 
00196         UnitObj *Unity, *Volt, *Time, *Length;
00197         DSP_Param    *dsp;
00198         XSM_Hardware *hard;
00199 };
00200 
00201 DSPMoverControl *DSPMoverClass = NULL;
00202 
00203 static void DSPMover_query(void)
00204 {
00205         static GnomeUIInfo menuinfo[] = { 
00206                 { GNOME_APP_UI_ITEM, 
00207                   DSPMover_pi.menuentry, DSPMover_pi.help,
00208                   (gpointer) DSPMover_show_callback, NULL,
00209                   NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BLANK, 
00210                   0, GDK_CONTROL_MASK, NULL },
00211 
00212                 GNOMEUIINFO_END
00213         };
00214 
00215         gnome_app_insert_menus(GNOME_APP(DSPMover_pi.app->getApp()), DSPMover_pi.menupath, menuinfo);
00216 
00217         // new ...
00218 
00219         DSPMoverClass = new DSPMoverControl
00220                 ( & DSPMover_pi.app->xsm->data.hardpars, 
00221                   DSPMover_pi.app->xsm->hardware
00222                         );
00223         DSPMoverClass->SetResName ("WindowMoverControl", "false", xsmres.geomsave);
00224 
00225         if(DSPMover_pi.status) g_free(DSPMover_pi.status); 
00226         DSPMover_pi.status = g_strconcat(N_("Plugin query has attached "),
00227                                          DSPMover_pi.name, 
00228                                          N_(": DSPMover is created."),
00229                                          NULL);
00230 }
00231 
00232 static void DSPMover_about(void)
00233 {
00234         const gchar *authors[] = { "Percy Zahl", NULL};
00235         gtk_widget_show(gnome_about_new ( DSPMover_pi.name,
00236                                           VERSION,
00237                                           N_("(C) 2000 the Free Software Foundation"),
00238                                           about_text,
00239                                           authors,
00240                                           NULL, NULL, NULL
00241                                 ));
00242 }
00243 
00244 static void DSPMover_cleanup( void ){
00245         PI_DEBUG (DBG_L2, "DSPMover Plugin Cleanup" );
00246         gchar *mp = g_strconcat(DSPMover_pi.menupath, DSPMover_pi.menuentry, NULL);
00247         gnome_app_remove_menus (GNOME_APP( DSPMover_pi.app->getApp() ), mp, 1);
00248         g_free(mp);
00249 
00250         // delete ...
00251         if( DSPMoverClass )
00252                 delete DSPMoverClass ;
00253 }
00254 
00255 static void DSPMover_show_callback( GtkWidget* widget, void* data){
00256         if( DSPMoverClass )
00257                 DSPMoverClass->show();
00258 }
00259 
00260 DSPMoverControl::DSPMoverControl (DSP_Param *Dsp, XSM_Hardware *Hard, int InWindow)
00261 {
00262         dsp=Dsp;
00263         hard=Hard;
00264 
00265         Unity    = new UnitObj(" "," ");
00266         Volt     = new UnitObj("V","V");
00267         Time     = new UnitObj("s","s");
00268         Length   = new UnitObj("nm","nm");
00269 
00270         create_folder ();
00271 }
00272 
00273 DSPMoverControl::~DSPMoverControl (){
00274         delete Length;
00275         delete Time;
00276         delete Volt;
00277         delete Unity;
00278 }
00279 
00280 
00281 
00282 
00283 
00284 
00285 
00286 
00287 /* Parameter für DSP Programm (Regler etc. ...) */
00288 /* 
00289    *** THIS "DSP_Param" struct will become obsolete ASAP --
00290        i.e. all HwIs and other PIs are independent of it!! 
00291    *** 
00292 */
00293 typedef struct DSP_Param{
00294   /* Feedback Control */
00295   double        UTunnel;                /* Tunnelspannung */
00296   double        ITunnelSoll;            /* Tunnelsollstrom */
00297   double        SetPoint;               /* AFM FB Setpoint */
00298   double        LogOffset;              /* Offset für Logregler */
00299   double        LogSkl;                 /* Logskalierung */
00300   double        usrCP, usrCI, usrCD;    /* Reglerkonstante User */
00301   double        CP, CI, CS, tau;        /* Reglerkonstante DSP (scaled) */
00302   double        Rotation;               /* Bilddrehwinkel */
00303   double        fb_frq;                 /* Timerfrequenz des Regelinterrupts [Hz] */
00304   double        fir_fg;                 /* FIR Grenzfrq. / LowPass */
00305   int           LinLog;                 /* Lin / Log Flag */
00306   
00307   /* Scan Control */
00308   int   LS_nx2scan;             /* Scanlinelänge */
00309   int   LS_nx_pre;              /* Scan Vorlauflänge */
00310   int   LS_dnx;                 /* Meßpunktabstand */
00311   int   LS_stepsize;            /* max. Schrittweite */
00312   int   LS_nRegel;              /* Anzahl Reglerdurchläufe je Schritt */
00313   int   LS_nAve;                /* Anzahl durchzuführender Mittelungen */
00314   int   LS_IntAve;              /* =0: kein IntAve, =1: Aufsummieren von Punkte zu Punkt */
00315   
00316   int   MV_stepsize;            /* max. Schrittweite für MoveTo */
00317   int   MV_nRegel;              /* Anzahl Reglerdurchläufe je Schritt */
00318 
00319   /* Mover Control */
00320   double MOV_Ampl, MOV_Speed, MOV_Steps;
00321 
00322   /* Auto Approch */
00323   int    TIP_nSteps;            /* Anzahl Z Steps (grob) */
00324   double TIP_Delay;             /* Anzahl Wartezyclen zwischen Z-Steps */
00325   int    TIP_DUz;               /* Schrittweite für Z-Piezo-Spannung "ran" */
00326   int    TIP_DUzRev;            /* Schrittweite für Z-Piezo-Spannung "zurück" */
00327 
00328   /* AFM special */
00329   #define DSP_AFMMOV_MODES 4
00330   double  AFM_Amp, AFM_Speed, AFM_Steps; /* AFM Besocke Kontrolle */
00331   double  AFM_usrAmp[DSP_AFMMOV_MODES];
00332   double  AFM_usrSpeed[DSP_AFMMOV_MODES], AFM_usrSteps[DSP_AFMMOV_MODES]; /* Parameter Memory */
00333 
00334   /* SPA-LEED special */
00335   double SPA_Energy, SPA_EnergyVolt;
00336   double SPA_Gatetime;
00337   double SPA_Length;
00338 
00339 };
00340 
00341 
00342 
00343         xrm.Put("hardpars.MOV_Ampl", hardpars.MOV_Ampl);
00344         xrm.Put("hardpars.MOV_Speed", hardpars.MOV_Speed);
00345         xrm.Put("hardpars.MOV_Steps", hardpars.MOV_Steps);
00346         xrm.Put("hardpars.TIP_nSteps", hardpars.TIP_nSteps);
00347         xrm.Put("hardpars.TIP_Delay", hardpars.TIP_Delay);
00348         xrm.Put("hardpars.TIP_DUz", hardpars.TIP_DUz);
00349         xrm.Put("hardpars.TIP_DUzRev", hardpars.TIP_DUzRev);
00350 
00351         xrm.Put("hardpars.AFM_Amp", hardpars.AFM_Amp);
00352         xrm.Put("hardpars.AFM_Speed", hardpars.AFM_Speed);
00353         xrm.Put("hardpars.AFM_Steps", hardpars.AFM_Steps);
00354         xrm.Put("hardpars.AFM_usrAmp0", hardpars.AFM_usrAmp[0]);
00355         xrm.Put("hardpars.AFM_usrAmp1", hardpars.AFM_usrAmp[1]);
00356         xrm.Put("hardpars.AFM_usrAmp2", hardpars.AFM_usrAmp[2]);
00357         xrm.Put("hardpars.AFM_usrAmp3", hardpars.AFM_usrAmp[3]);
00358         xrm.Put("hardpars.AFM_usrSpeed0", hardpars.AFM_usrSpeed[0]);
00359         xrm.Put("hardpars.AFM_usrSpeed1", hardpars.AFM_usrSpeed[1]);
00360         xrm.Put("hardpars.AFM_usrSpeed2", hardpars.AFM_usrSpeed[2]);
00361         xrm.Put("hardpars.AFM_usrSpeed3", hardpars.AFM_usrSpeed[3]);
00362         xrm.Put("hardpars.AFM_usrSteps0", hardpars.AFM_usrSteps[0]);
00363         xrm.Put("hardpars.AFM_usrSteps1", hardpars.AFM_usrSteps[1]);
00364         xrm.Put("hardpars.AFM_usrSteps2", hardpars.AFM_usrSteps[2]);
00365         xrm.Put("hardpars.AFM_usrSteps3", hardpars.AFM_usrSteps[3]);
00366 
00367 
00368         xrm.Get("hardpars.MOV_Ampl", &hardpars.MOV_Ampl, "20.0");
00369         xrm.Get("hardpars.MOV_Speed", &hardpars.MOV_Speed, "4.0");
00370         xrm.Get("hardpars.MOV_Steps", &hardpars.MOV_Steps, "100.0");
00371         xrm.Get("hardpars.TIP_nSteps", &hardpars.TIP_nSteps, "10");
00372         xrm.Get("hardpars.TIP_Delay", &hardpars.TIP_Delay, "0.1");
00373         xrm.Get("hardpars.TIP_DUz", &hardpars.TIP_DUz, "5");
00374         xrm.Get("hardpars.TIP_DUzRev", &hardpars.TIP_DUzRev, "5");
00375         xrm.Get("hardpars.AFM_Amp", &hardpars.AFM_Amp);
00376         xrm.Get("hardpars.AFM_Speed", &hardpars.AFM_Speed);
00377         xrm.Get("hardpars.AFM_Steps", &hardpars.AFM_Steps);
00378 
00379         // defaults for AFM Mover (hardware SICAF)
00380         // [0] Besocke XY
00381         // [1] Besocke rotation
00382         // [2] Besocke PSD
00383         // [3] Besocke lens
00384   
00385         xrm.Get("hardpars.AFM_usrAmp0", &hardpars.AFM_usrAmp[0], "3.0");
00386         xrm.Get("hardpars.AFM_usrAmp1", &hardpars.AFM_usrAmp[1], "3.5");
00387         xrm.Get("hardpars.AFM_usrAmp2", &hardpars.AFM_usrAmp[2], "8.0");
00388         xrm.Get("hardpars.AFM_usrAmp3", &hardpars.AFM_usrAmp[3], "8.0");
00389         xrm.Get("hardpars.AFM_usrSpeed0", &hardpars.AFM_usrSpeed[0], "3");
00390         xrm.Get("hardpars.AFM_usrSpeed1", &hardpars.AFM_usrSpeed[1], "3");
00391         xrm.Get("hardpars.AFM_usrSpeed2", &hardpars.AFM_usrSpeed[2], "5");
00392         xrm.Get("hardpars.AFM_usrSpeed3", &hardpars.AFM_usrSpeed[3], "5");
00393         xrm.Get("hardpars.AFM_usrSteps0", &hardpars.AFM_usrSteps[0], "10");
00394         xrm.Get("hardpars.AFM_usrSteps1", &hardpars.AFM_usrSteps[1], "2");
00395         xrm.Get("hardpars.AFM_usrSteps2", &hardpars.AFM_usrSteps[2], "100");
00396         xrm.Get("hardpars.AFM_usrSteps3", &hardpars.AFM_usrSteps[3], "100");
00397 
00398 
00399 
00400 
00401 #define ARROW_SIZE 40
00402 
00403 static gboolean create_window_key_press_event_lcb(GtkWidget *widget, GdkEventKey *event,GtkWidget *win)
00404 {
00405         if (event->keyval == GDK_Escape) {
00406                 PI_DEBUG (DBG_L2, "Got escape\n" );
00407                 return TRUE;
00408         }
00409         return FALSE;
00410 }
00411                         
00412 
00413 void DSPMoverControl::create_folder (){
00414         GSList *EC_list=NULL;
00415 
00416         Gtk_EntryControl *ec;
00417 
00418         GtkWidget *box, *vbox_param, *hbox_param, *hbox, *vbox_param2, *frame_param;
00419         GtkWidget *input;
00420         GtkWidget *notebook;
00421         GtkWidget *MoverCrtl;
00422         GtkWidget *tab, *button;
00423         GtkAccelGroup *accel_group=NULL;
00424 
00425         if( IS_MOVER_CTRL ){
00426                 accel_group = gtk_accel_group_new ();
00427                 AppWidgetInit(MOV_MOVER_TITLE);
00428         }
00429         else
00430                 AppWidgetInit(MOV_SLIDER_TITLE);
00431 
00432         box = gtk_vbox_new (FALSE, 0);
00433         gtk_widget_show (box);
00434         gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00435 
00436         // ========================================
00437         notebook = gtk_notebook_new ();
00438         gtk_widget_show (notebook);
00439         gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, GNOME_PAD);
00440 
00441         const char *MoverNames[] = { "Besocke X&Y", "Rotation", "PSD", "Lens", "Auto", NULL};
00442 
00443         Gtk_EntryControl *Ampl, *Spd, *Stp;
00444         int i,itab;
00445         for(itab=i=0; MoverNames[i]; ++i){
00446                 if( IS_SLIDER_CTRL && i != 4 ) continue;
00447                 PI_DEBUG (DBG_L2, "DSPMoverControl::SiCaf - Mover:" << MoverNames[i]);
00448 
00449                 vbox_param = gtk_vbox_new (FALSE, 0);
00450                 gtk_widget_show (vbox_param);
00451                 MoverCrtl = gtk_label_new (MoverNames[i]);
00452                 gtk_widget_show (MoverCrtl);
00453                 itab++;
00454                 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_param, MoverCrtl);
00455 
00456                 if( i<4 ){
00457                         input = mygtk_create_input  ("Amplitude", vbox_param, hbox_param);
00458                         gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00459                         Ampl = new Gtk_EntryControl (Volt, MLD_WERT_NICHT_OK, &dsp->AFM_usrAmp[i], 0., 20., "5.2f", input);
00460                         Ampl->Set_ChangeNoticeFkt   (DSPMoverControl::ChangedNotify, this);
00461                         EC_list = g_slist_prepend   ( EC_list, Ampl);
00462       
00463                         input = mygtk_create_input  ("Speed", vbox_param, hbox_param);
00464                         gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00465                         Spd = new Gtk_EntryControl  (Unity, MLD_WERT_NICHT_OK, &dsp->AFM_usrSpeed[i], 1., 20., "4.0f", input);
00466                         Spd->Set_ChangeNoticeFkt    (DSPMoverControl::ChangedNotify, this);
00467                         EC_list = g_slist_prepend   ( EC_list, Spd);
00468       
00469                         input = mygtk_create_input  ("Steps", vbox_param, hbox_param);
00470                         gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00471                         Stp = new Gtk_EntryControl  (Unity, MLD_WERT_NICHT_OK, &dsp->AFM_usrSteps[i], 1., 5000., "4.0f", input);
00472                         Stp->Set_ChangeNoticeFkt    (DSPMoverControl::ChangedNotify, this);
00473                         EC_list = g_slist_prepend   ( EC_list, Stp);
00474                 }
00475                 if(i==4){
00476                         if( IS_MOVER_CTRL ){
00477                                 frame_param = gtk_frame_new ("Mover Timing");
00478                                 gtk_widget_show (frame_param);
00479                                 gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00480         
00481                                 vbox_param2 = gtk_vbox_new (FALSE, 0);
00482                                 gtk_widget_show (vbox_param2);
00483                                 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param2);
00484       
00485                                 input = mygtk_create_input("Ampl.", vbox_param2, hbox_param);
00486                                 ec = new Gtk_EntryControl (Volt, MLD_WERT_NICHT_OK, &dsp->MOV_Ampl, 0., 20., "5.2f", input);
00487                                 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00488                                 EC_list = g_slist_prepend( EC_list, ec);
00489         
00490                                 input = mygtk_create_input("Speed", vbox_param2, hbox_param);
00491                                 ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &dsp->MOV_Speed, 1., 20., "4.0f", input);
00492                                 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00493                                 EC_list = g_slist_prepend( EC_list, ec);
00494         
00495                                 input = mygtk_create_input("Steps", vbox_param2, hbox_param);
00496                                 ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &dsp->MOV_Steps, 1., 5000., "4.0f", input);
00497                                 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00498                                 EC_list = g_slist_prepend( EC_list, ec);
00499                         }
00500       
00501                         // ========================================
00502       
00503                         gchar *labtmp;
00504                         if(IS_MOVER_CTRL || IS_SLIDER_CTRL )
00505                                 labtmp=g_strconcat("Auto Approch Timing [", xsmres.SliderControlType, "]",NULL);
00506                         else
00507                                 labtmp=g_strconcat("Auto Approch Timing [", xsmres.SliderControlType, "]<=ERROR ",NULL);
00508                         frame_param = gtk_frame_new (labtmp);
00509                         g_free(labtmp);
00510                         gtk_widget_show (frame_param);
00511                         gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00512 
00513                         vbox_param2 = gtk_vbox_new (FALSE, 0);
00514                         gtk_widget_show (vbox_param2);
00515                         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param2);
00516 
00517                         if(! IS_MOVER_CTRL ){
00518                                 input = mygtk_create_input("Steps", vbox_param2, hbox_param);
00519                                 ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &dsp->TIP_nSteps, 0., 100., "4.0f", input);
00520                                 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00521                                 EC_list = g_slist_prepend( EC_list, ec);
00522         
00523                                 input = mygtk_create_input("Delay", vbox_param2, hbox_param);
00524                                 ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &dsp->TIP_Delay, 0.0005, 1., "6.5f", input);
00525                                 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00526                                 EC_list = g_slist_prepend( EC_list, ec);
00527                         }
00528 
00529                         input = mygtk_create_input("Z++", vbox_param2, hbox_param);
00530                         ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &dsp->TIP_DUz, 1., 32000., "5.0f", input);
00531                         ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00532                         EC_list = g_slist_prepend( EC_list, ec);
00533       
00534                         input = mygtk_create_input("Z--", vbox_param2, hbox_param);
00535                         ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &dsp->TIP_DUzRev, 1., 32000., "5.0f", input);
00536                         ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00537                         EC_list = g_slist_prepend( EC_list, ec);
00538 
00539                 }
00540                 // ========================================
00541     
00542                 tab = gtk_table_new (5, 3, FALSE);
00543                 gtk_widget_show (tab);
00544                 gtk_container_add (GTK_CONTAINER (vbox_param), tab);
00545     
00546                 // ========================================
00547                 // Direction Buttons
00548 
00549                 if( IS_MOVER_CTRL ){
00550 
00551                         // STOP
00552                         button = gtk_button_new();
00553                         gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00554                         gtk_widget_show (button);
00555                         gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 1, 2,
00556                                           (GtkAttachOptions)(GTK_FILL),
00557                                           (GtkAttachOptions)(GTK_FILL),
00558                                           FALSE, FALSE);
00559                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00560                                             GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00561                                             this);
00562                         // UP
00563                         button = create_arrow_button(GTK_ARROW_UP, GTK_SHADOW_OUT);
00564                         gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00565                         gtk_widget_show (button);
00566                         gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 0, 1,
00567                                           (GtkAttachOptions)(GTK_FILL),
00568                                           (GtkAttachOptions)(GTK_FILL),
00569                                           FALSE, FALSE);
00570                         gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_YP);
00571                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00572                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00573                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00574                                             this);
00575                         gtk_signal_connect (GTK_OBJECT (button), "released",
00576                                             GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00577                                             this);
00578                         gtk_signal_connect(GTK_OBJECT(box), "key_press_event", 
00579                                            G_CALLBACK(create_window_key_press_event_lcb), this);
00580 
00581 //      gtk_widget_add_accelerator (button, "pressed", accel_group,
00582 //                                  GDK_F3+4*i, (GdkModifierType)0,
00583 //                                  GTK_ACCEL_VISIBLE);
00584       
00585                         // LEFT
00586                         button = create_arrow_button(GTK_ARROW_LEFT, GTK_SHADOW_OUT);
00587                         gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00588                         gtk_widget_show (button);
00589                         gtk_table_attach (GTK_TABLE (tab), button, 1, 2, 1, 2,
00590                                           (GtkAttachOptions)(GTK_FILL),
00591                                           (GtkAttachOptions)(GTK_FILL),
00592                                           FALSE, FALSE);
00593                         gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_XM);
00594                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00595                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00596                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00597                                             this);
00598                         gtk_signal_connect (GTK_OBJECT (button), "released",
00599                                             GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00600                                             this);
00601 //      gtk_widget_add_accelerator (button, "pressed", accel_group,
00602 //                                  GDK_F1+4*i, (GdkModifierType)0,
00603 //                                  GTK_ACCEL_VISIBLE);
00604 
00605                         // RIGHT
00606                         button = create_arrow_button(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
00607                         gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00608                         gtk_widget_show (button);
00609                         gtk_table_attach (GTK_TABLE (tab), button, 3, 4, 1, 2,
00610                                           (GtkAttachOptions)(GTK_FILL),
00611                                           (GtkAttachOptions)(GTK_FILL),
00612                                           FALSE, FALSE);
00613                         gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_XP);
00614                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00615                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00616                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00617                                             this);
00618                         gtk_signal_connect (GTK_OBJECT (button), "released",
00619                                             GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00620                                             this);
00621 
00622 // gtk_widget_get_toplevel()
00623 //      gtk_widget_add_accelerator (button, "pressed", accel_group,
00624 //                                  GDK_F1+4*i, (GdkModifierType)0,
00625 //                                  GTK_ACCEL_VISIBLE);
00626 
00627                         // DOWN
00628                         button = create_arrow_button(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
00629                         gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00630                         gtk_widget_show (button);
00631                         gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 2, 3,
00632                                           (GtkAttachOptions)(GTK_FILL),
00633                                           (GtkAttachOptions)(GTK_FILL),
00634                                           FALSE, FALSE);
00635                         gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_YM);
00636                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00637                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00638                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00639                                             this);
00640                         gtk_signal_connect (GTK_OBJECT (button), "released",
00641                                             GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00642                                             this);
00643 //      gtk_widget_add_accelerator (button, "pressed", accel_group,
00644 //                                  GDK_F2+4*i, (GdkModifierType)0,
00645 //                                  GTK_ACCEL_VISIBLE);
00646 
00647     
00648                 }
00649                 // ========================================
00650                 // used to auto-center ...
00651                 hbox = gtk_hbox_new (TRUE, 0);
00652                 gtk_widget_show (hbox);
00653                 gtk_table_attach (GTK_TABLE (tab), hbox, 0, 1, 1, 2,
00654                                   (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00655                                   (GtkAttachOptions)(GTK_FILL),
00656                                   FALSE, FALSE);
00657     
00658                 hbox = gtk_hbox_new (TRUE, 0);
00659                 gtk_widget_show (hbox);
00660                 gtk_table_attach (GTK_TABLE (tab), hbox, 4, 5, 1, 2,
00661                                   (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00662                                   (GtkAttachOptions)(GTK_FILL),
00663                                   FALSE, FALSE);
00664     
00665                 if(i==4){
00666                         // ========================================
00667                         // Auto App. Control Buttons
00668                         button = gtk_button_new_with_label("Start");
00669                         gtk_widget_show (button);
00670                         gtk_table_attach (GTK_TABLE (tab), button, 4, 5, 0, 1,
00671                                           (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00672                                           (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00673                                           FALSE, FALSE);
00674                         if(IS_MOVER_CTRL)
00675                                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_APPROCH_MOV_XP);
00676                         else
00677                                 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_APPROCH);
00678 
00679                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00680                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00681                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00682                                             this);
00683       
00684                         button = gtk_button_new_with_label("Stop");
00685                         gtk_widget_show (button);
00686                         gtk_table_attach (GTK_TABLE (tab), button, 4, 5, 2, 3,
00687                                           (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00688                                           (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00689                                           FALSE, FALSE);
00690                         gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_CLR_PA);
00691                         gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00692                         gtk_signal_connect (GTK_OBJECT (button), "pressed",
00693                                             GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00694                                             this);
00695                 }
00696     
00697         }
00698   
00699         if(accel_group)
00700                 gtk_window_add_accel_group (GTK_WINDOW (GetWidget()), accel_group);
00701         // ============================================================
00702         // save List away...
00703         gtk_object_set_data( GTK_OBJECT (widget), "MOVER_EC_list", EC_list);
00704 
00705 
00706 }
00707 
00708 void DSPMoverControl::update(){
00709         g_slist_foreach
00710                 ( (GSList*) gtk_object_get_data( GTK_OBJECT (widget), "MOVER_EC_list"),
00711                   (GFunc) App::update_ec, NULL
00712                         );
00713 }
00714 
00715 void DSPMoverControl::updateDSP(int sliderno){
00716         PI_DEBUG (DBG_L2, "Hallo DSP ! Mover No:" << sliderno );
00717         if(sliderno >= 0 && sliderno < 4){
00718                 dsp->AFM_Amp   = dsp->AFM_usrAmp  [sliderno];
00719                 dsp->AFM_Speed = dsp->AFM_usrSpeed[sliderno];
00720                 dsp->AFM_Steps = dsp->AFM_usrSteps[sliderno];
00721         }else{
00722                 dsp->AFM_Amp   = dsp->MOV_Ampl;
00723                 dsp->AFM_Speed = dsp->MOV_Speed;
00724                 dsp->AFM_Steps = dsp->MOV_Steps;
00725         }
00726         DSPMover_pi.app->xsm->hardware->PutParameter(dsp);
00727 }
00728 
00729 int DSPMoverControl::CmdAction(GtkWidget *widget, DSPMoverControl *dspc){
00730         int idx=-1;
00731         int cmd;
00732         PI_DEBUG (DBG_L2, "MoverCrtl::CmdAction " );
00733         if(IS_MOVER_CTRL)
00734                 idx = (int)gtk_object_get_data( GTK_OBJECT (widget), "MoverNo");
00735         dspc->updateDSP(idx);
00736         cmd = (int)gtk_object_get_data( GTK_OBJECT (widget), "DSP_cmd");
00737         if(cmd>0)
00738                 dspc->ExecCmd(cmd);
00739         PI_DEBUG (DBG_L2, "cmd=" << cmd << " Mover=" << idx );
00740         return 0;
00741 }
00742 
00743 int DSPMoverControl::StopAction(GtkWidget *widget, DSPMoverControl *dspc){
00744         PI_DEBUG (DBG_L2, "DSPMoverControl::StopAction" );
00745         dspc->ExecCmd(DSP_CMD_CLR_PA);
00746         return 0;
00747 }
00748 
00749 void DSPMoverControl::ChangedNotify(Param_Control* pcs, gpointer dspc){
00750         int idx=-1;
00751 
00752         gchar *us=pcs->Get_UsrString();
00753         PI_DEBUG (DBG_L2, "MoverCrtl:: Param Changed: " << us );
00754         g_free(us);
00755 
00756         if(IS_MOVER_CTRL)
00757                 idx = (int)pcs->GetEntryData("MoverNo");
00758         ((DSPMoverControl*)dspc)->updateDSP(idx);
00759 }
00760 
00761 void DSPMoverControl::ExecCmd(int cmd){
00762         DSPMover_pi.app->xsm->hardware->ExecCmd(cmd);
00763 }

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