00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
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 DSPControl *DSPControlClass;
00059 extern sranger_hwi_dev *sranger_hwi_hardware;
00060
00061 DSPMoverControl::DSPMoverControl ()
00062 {
00063 XsmRescourceManager xrm("sranger_hwi_control");
00064
00065 xrm.Get("MOV_Ampl", &mover_param.MOV_Ampl, "1.0");
00066 xrm.Get("MOV_Speed", &mover_param.MOV_Speed, "4.0");
00067 xrm.Get("MOV_Steps", &mover_param.MOV_Steps, "5.0");
00068 xrm.Get("AFM_Amp", &mover_param.AFM_Amp);
00069 xrm.Get("AFM_Speed", &mover_param.AFM_Speed);
00070 xrm.Get("AFM_Steps", &mover_param.AFM_Steps);
00071
00072
00073
00074
00075
00076
00077
00078 xrm.Get("AFM_usrAmp0", &mover_param.AFM_usrAmp[0], "1.0");
00079 xrm.Get("AFM_usrAmp1", &mover_param.AFM_usrAmp[1], "1.0");
00080 xrm.Get("AFM_usrAmp2", &mover_param.AFM_usrAmp[2], "1.0");
00081 xrm.Get("AFM_usrAmp3", &mover_param.AFM_usrAmp[3], "1.0");
00082 xrm.Get("AFM_usrSpeed0", &mover_param.AFM_usrSpeed[0], "3");
00083 xrm.Get("AFM_usrSpeed1", &mover_param.AFM_usrSpeed[1], "3");
00084 xrm.Get("AFM_usrSpeed2", &mover_param.AFM_usrSpeed[2], "5");
00085 xrm.Get("AFM_usrSpeed3", &mover_param.AFM_usrSpeed[3], "5");
00086 xrm.Get("AFM_usrSteps0", &mover_param.AFM_usrSteps[0], "10");
00087 xrm.Get("AFM_usrSteps1", &mover_param.AFM_usrSteps[1], "2");
00088 xrm.Get("AFM_usrSteps2", &mover_param.AFM_usrSteps[2], "100");
00089 xrm.Get("AFM_usrSteps3", &mover_param.AFM_usrSteps[3], "100");
00090
00091 xrm.Get("MOV_output", &mover_param.MOV_output, "0");
00092 xrm.Get("MOV_waveform_id", &mover_param.MOV_waveform_id, "0");
00093 xrm.Get("MOV_mode", &mover_param.MOV_mode, "0");
00094 xrm.Get("AUTO_final_delay", &mover_param.final_delay, "50");
00095
00096 mover_param.MOV_wave_len=1024;
00097 for (int i=0; i < MOV_MAXWAVELEN; ++i)
00098 mover_param.MOV_waveform[i] = (short)0;
00099
00100
00101 Unity = new UnitObj(" "," ");
00102 Volt = new UnitObj("V","V");
00103 Time = new UnitObj("ms","ms");
00104 Length = new UnitObj("nm","nm");
00105
00106 create_folder ();
00107 }
00108
00109
00110
00111 void DSPMoverControl::create_waveform (double amp, double duration){
00112 #define SR_VFAC (32767./2.05) // SRanger max Volt out is 2.05V
00113
00114 mover_param.MOV_wave_len = (int)round ( DSPControlClass->frq_ref*duration*1e-3);
00115
00116
00117 if (mover_param.MOV_wave_len > MOV_MAXWAVELEN)
00118 mover_param.MOV_wave_len = MOV_MAXWAVELEN;
00119
00120 if (mover_param.MOV_wave_len < 2)
00121 mover_param.MOV_wave_len = 2;
00122
00123
00124 std::cout << "DSPMoverControl::create_waveform:" << mover_param.MOV_wave_len << std::endl;
00125
00126
00127 double n = (double)mover_param.MOV_wave_len;
00128 double n2 = n/2.;
00129 double t=0.;
00130
00131 switch (mover_param.MOV_waveform_id){
00132 case MOV_WAVE_SAWTOOTH:
00133 for (int i=0; i < mover_param.MOV_wave_len; ++i)
00134 mover_param.MOV_waveform[i] = sranger_hwi_hardware->int_2_sranger_int ((short)round (SR_VFAC*amp*((double)i-n2)/n2));
00135 break;
00136 case MOV_WAVE_SINE:
00137 for (int i=0; i < mover_param.MOV_wave_len; ++i)
00138 mover_param.MOV_waveform[i] = sranger_hwi_hardware->int_2_sranger_int((short)round (SR_VFAC*amp*sin ((double)i*2.*M_PI/n)));
00139 break;
00140 case MOV_WAVE_CYCLO:
00141 t=M_PI;
00142 for (int i=0; i < mover_param.MOV_wave_len; ++i){
00143 double dt = 2.*M_PI*1e-3;
00144 double a = 1.;
00145 double x;
00146
00147 mover_param.MOV_waveform[i] = sranger_hwi_hardware->int_2_sranger_int((short)round(SR_VFAC*amp*(a * cos (t))));
00148 do {
00149 x = t - a*sin (t);
00150 t += dt;
00151 } while (x-M_PI < (double)i*M_PI/n && t < 2.*M_PI);
00152 }
00153 break;
00154 }
00155 }
00156
00157
00158 DSPMoverControl::~DSPMoverControl (){
00159 XsmRescourceManager xrm("sranger_hwi_control");
00160
00161 xrm.Put("MOV_Ampl", mover_param.MOV_Ampl);
00162 xrm.Put("MOV_Speed", mover_param.MOV_Speed);
00163 xrm.Put("MOV_Steps", mover_param.MOV_Steps);
00164
00165 xrm.Put("AFM_Amp", mover_param.AFM_Amp);
00166 xrm.Put("AFM_Speed", mover_param.AFM_Speed);
00167 xrm.Put("AFM_Steps", mover_param.AFM_Steps);
00168 xrm.Put("AFM_usrAmp0", mover_param.AFM_usrAmp[0]);
00169 xrm.Put("AFM_usrAmp1", mover_param.AFM_usrAmp[1]);
00170 xrm.Put("AFM_usrAmp2", mover_param.AFM_usrAmp[2]);
00171 xrm.Put("AFM_usrAmp3", mover_param.AFM_usrAmp[3]);
00172 xrm.Put("AFM_usrSpeed0", mover_param.AFM_usrSpeed[0]);
00173 xrm.Put("AFM_usrSpeed1", mover_param.AFM_usrSpeed[1]);
00174 xrm.Put("AFM_usrSpeed2", mover_param.AFM_usrSpeed[2]);
00175 xrm.Put("AFM_usrSpeed3", mover_param.AFM_usrSpeed[3]);
00176 xrm.Put("AFM_usrSteps0", mover_param.AFM_usrSteps[0]);
00177 xrm.Put("AFM_usrSteps1", mover_param.AFM_usrSteps[1]);
00178 xrm.Put("AFM_usrSteps2", mover_param.AFM_usrSteps[2]);
00179 xrm.Put("AFM_usrSteps3", mover_param.AFM_usrSteps[3]);
00180
00181 xrm.Put("MOV_output", mover_param.MOV_output);
00182 xrm.Put("MOV_waveform_id", mover_param.MOV_waveform_id);
00183 xrm.Put("MOV_mode", mover_param.MOV_mode);
00184 xrm.Put("AUTO_final_delay", mover_param.final_delay);
00185
00186 delete Length;
00187 delete Time;
00188 delete Volt;
00189 delete Unity;
00190 }
00191
00192
00193
00194 #define ARROW_SIZE 40
00195
00196 static gboolean create_window_key_press_event_lcb(GtkWidget *widget, GdkEventKey *event,GtkWidget *win)
00197 {
00198 if (event->keyval == GDK_Escape) {
00199 PI_DEBUG (DBG_L2, "Got escape\n" );
00200 return TRUE;
00201 }
00202 return FALSE;
00203 }
00204
00205
00206 #define KEY_LAB(L,A,B,C,D) \
00207 lab = gtk_label_new (L);\
00208 gtk_widget_show (lab);\
00209 gtk_table_attach (GTK_TABLE (tab), lab, A, B, C, D,\
00210 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),\
00211 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),\
00212 FALSE, FALSE)
00213
00214 void DSPMoverControl::create_folder (){
00215 GSList *EC_list=NULL;
00216
00217 Gtk_EntryControl *ec;
00218
00219 GtkWidget *box, *vbox_param, *hbox_param, *hbox, *vbox_param2, *frame_param, *frame_param2;
00220 GtkWidget *input;
00221 GtkWidget *notebook;
00222 GtkWidget *MoverCrtl;
00223 GtkWidget *tab, *button, *img, *lab;
00224 GtkAccelGroup *accel_group=NULL;
00225
00226 if( IS_MOVER_CTRL ){
00227 accel_group = gtk_accel_group_new ();
00228 AppWidgetInit(MOV_MOVER_TITLE);
00229 }
00230 else
00231 AppWidgetInit(MOV_SLIDER_TITLE);
00232
00233 box = gtk_vbox_new (FALSE, 0);
00234 gtk_widget_show (box);
00235 gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00236
00237
00238 notebook = gtk_notebook_new ();
00239 gtk_widget_show (notebook);
00240 gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, GNOME_PAD);
00241
00242 const char *MoverNames[] = { "Besocke X&Y", "Rotation", "PSD", "Lens", "Auto", "Config", NULL};
00243
00244 Gtk_EntryControl *Ampl, *Spd, *Stp;
00245 int i,itab;
00246 for(itab=i=0; MoverNames[i]; ++i){
00247 if( IS_SLIDER_CTRL && i < 4 ) continue;
00248 PI_DEBUG (DBG_L2, "DSPMoverControl::SiCaf - Mover:" << MoverNames[i]);
00249
00250 vbox_param = gtk_vbox_new (FALSE, 0);
00251 gtk_widget_show (vbox_param);
00252 MoverCrtl = gtk_label_new (MoverNames[i]);
00253 gtk_widget_show (MoverCrtl);
00254 itab++;
00255 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox_param, MoverCrtl);
00256
00257 if( i==5 ){
00258 GtkWidget *radiobutton;
00259 GSList *radiogroup;
00260
00261 frame_param = gtk_frame_new ("Output Configuration");
00262 gtk_widget_show (frame_param);
00263 gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00264
00265 lab = gtk_label_new ("*) Parabolic: DSP gen. wave, duration means speed here");
00266 gtk_box_pack_start (GTK_BOX (vbox_param), lab, FALSE, FALSE, 0);
00267 gtk_widget_show (lab);
00268
00269
00270 input = mygtk_create_input("Auto App. Delay", vbox_param, hbox_param);
00271 ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &mover_param.final_delay, 0., 500., "4.1f", input);
00272 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00273 EC_list = g_slist_prepend( EC_list, ec);
00274
00275 hbox = gtk_hbox_new (FALSE, 0);
00276 gtk_widget_show (hbox);
00277 gtk_container_add (GTK_CONTAINER (frame_param), hbox);
00278
00279 frame_param2 = gtk_frame_new ("Curve Mode");
00280 gtk_widget_show (frame_param2);
00281 gtk_container_add (GTK_CONTAINER (hbox), frame_param2);
00282
00283 vbox_param2 = gtk_vbox_new (FALSE, 0);
00284 gtk_widget_show (vbox_param2);
00285 gtk_container_add (GTK_CONTAINER (frame_param2), vbox_param2);
00286
00287 radiobutton = gtk_radio_button_new_with_label( NULL, "Parabolic *)");
00288 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00289 gtk_widget_show (radiobutton);
00290 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveMask", (gpointer)0);
00291 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00292 GTK_SIGNAL_FUNC (DSPMoverControl::config_mode), this);
00293
00294 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00295 GTK_TOGGLE_BUTTON (radiobutton)->active = mover_param.MOV_mode == 0 ? 1:0;
00296
00297 radiobutton = gtk_radio_button_new_with_label (radiogroup, "Wave: Sawtooth");
00298 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00299 gtk_widget_show (radiobutton);
00300 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveMask", (gpointer)AAP_MOVER_WAVE);
00301 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveId", (gpointer)MOV_WAVE_SAWTOOTH);
00302 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00303 GTK_SIGNAL_FUNC (DSPMoverControl::config_mode), this);
00304 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00305 GTK_SIGNAL_FUNC (DSPMoverControl::config_waveform), this);
00306
00307 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00308 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_mode == AAP_MOVER_WAVE && mover_param.MOV_waveform_id == MOV_WAVE_SAWTOOTH) ? 1:0;
00309
00310 radiobutton = gtk_radio_button_new_with_label (radiogroup, "Wave: Sine");
00311 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00312 gtk_widget_show (radiobutton);
00313 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveMask", (gpointer)AAP_MOVER_WAVE);
00314 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveId", (gpointer)MOV_WAVE_SINE);
00315 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00316 GTK_SIGNAL_FUNC (DSPMoverControl::config_mode), this);
00317 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00318 GTK_SIGNAL_FUNC (DSPMoverControl::config_waveform), this);
00319
00320 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00321 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_mode == AAP_MOVER_WAVE && mover_param.MOV_waveform_id == MOV_WAVE_SINE) ? 1:0;
00322
00323 radiobutton = gtk_radio_button_new_with_label (radiogroup, "Wave: Cyclo");
00324 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00325 gtk_widget_show (radiobutton);
00326 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveMask", (gpointer)AAP_MOVER_WAVE);
00327 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveId", (gpointer)MOV_WAVE_CYCLO);
00328 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00329 GTK_SIGNAL_FUNC (DSPMoverControl::config_mode), this);
00330 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00331 GTK_SIGNAL_FUNC (DSPMoverControl::config_waveform), this);
00332
00333 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00334
00335 radiobutton = gtk_radio_button_new_with_label (radiogroup, "CoolRunner TTL");
00336 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00337 gtk_widget_show (radiobutton);
00338 gtk_widget_set_sensitive (radiobutton, FALSE);
00339 gtk_object_set_data (GTK_OBJECT (radiobutton), "CurveMask", (gpointer)AAP_MOVER_PULSE);
00340 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00341 GTK_SIGNAL_FUNC (DSPMoverControl::config_mode), this);
00342
00343 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00344 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_mode == AAP_MOVER_PULSE) ? 1:0;
00345
00346
00347
00348 frame_param2 = gtk_frame_new ("Output on");
00349 gtk_widget_show (frame_param2);
00350 gtk_container_add (GTK_CONTAINER (hbox), frame_param2);
00351
00352 vbox_param2 = gtk_vbox_new (FALSE, 0);
00353 gtk_widget_show (vbox_param2);
00354 gtk_container_add (GTK_CONTAINER (frame_param2), vbox_param2);
00355
00356 radiobutton = gtk_radio_button_new_with_label( NULL, "XY-Offset");
00357 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00358 gtk_widget_show (radiobutton);
00359 gtk_object_set_data (GTK_OBJECT (radiobutton), "OutputMask", (gpointer)AAP_MOVER_XYOFFSET);
00360 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00361 GTK_SIGNAL_FUNC (DSPMoverControl::config_output), this);
00362
00363 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00364 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_output == AAP_MOVER_XYOFFSET) ? 1:0;
00365
00366 radiobutton = gtk_radio_button_new_with_label (radiogroup, "XY-Scan");
00367 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00368 gtk_widget_show (radiobutton);
00369 gtk_object_set_data (GTK_OBJECT (radiobutton), "OutputMask", (gpointer)AAP_MOVER_XYSCAN);
00370 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00371 GTK_SIGNAL_FUNC (DSPMoverControl::config_output), this);
00372
00373 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00374 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_output == AAP_MOVER_XYSCAN) ? 1:0;
00375
00376 radiobutton = gtk_radio_button_new_with_label (radiogroup, "X-Motor");
00377 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00378 gtk_widget_show (radiobutton);
00379 gtk_object_set_data (GTK_OBJECT (radiobutton), "OutputMask", (gpointer)AAP_MOVER_XYMOTOR);
00380 gtk_signal_connect (GTK_OBJECT (radiobutton), "clicked",
00381 GTK_SIGNAL_FUNC (DSPMoverControl::config_output), this);
00382
00383 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00384 GTK_TOGGLE_BUTTON (radiobutton)->active = (mover_param.MOV_output == AAP_MOVER_XYMOTOR) ? 1:0;
00385
00386 radiobutton = gtk_radio_button_new_with_label (radiogroup, "CoolRunner IOxx");
00387 gtk_box_pack_start (GTK_BOX (vbox_param2), radiobutton, FALSE, FALSE, 0);
00388 gtk_widget_show (radiobutton);
00389 gtk_widget_set_sensitive (radiobutton, FALSE);
00390
00391
00392
00393
00394 radiogroup = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton));
00395
00396
00397 continue;
00398 }
00399
00400 if( i<4 ){
00401 frame_param = gtk_frame_new ("Mover Timing");
00402 gtk_widget_show (frame_param);
00403 gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00404
00405 vbox_param2 = gtk_vbox_new (FALSE, 0);
00406 gtk_widget_show (vbox_param2);
00407 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param2);
00408
00409 input = mygtk_create_input ("Amplitude", vbox_param2, hbox_param);
00410 gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00411 Ampl = new Gtk_EntryControl (Volt, MLD_WERT_NICHT_OK, &mover_param.AFM_usrAmp[i], 0., 20., "5.2f", input);
00412 Ampl->Set_ChangeNoticeFkt (DSPMoverControl::ChangedNotify, this);
00413 EC_list = g_slist_prepend ( EC_list, Ampl);
00414
00415 input = mygtk_create_input ("Duration", vbox_param2, hbox_param);
00416 gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00417 Spd = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &mover_param.AFM_usrSpeed[i], 0.5, 50., "4.1f", input);
00418 Spd->Set_ChangeNoticeFkt (DSPMoverControl::ChangedNotify, this);
00419 EC_list = g_slist_prepend ( EC_list, Spd);
00420
00421 input = mygtk_create_input ("Max. Steps", vbox_param2, hbox_param);
00422 gtk_object_set_data( GTK_OBJECT (input), "MoverNo", (gpointer)i);
00423 Stp = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &mover_param.AFM_usrSteps[i], 1., 5000., "4.0f", input);
00424 Stp->Set_ChangeNoticeFkt (DSPMoverControl::ChangedNotify, this);
00425 EC_list = g_slist_prepend ( EC_list, Stp);
00426 }
00427 if(i==4){
00428 if( IS_MOVER_CTRL ){
00429 frame_param = gtk_frame_new ("Mover Timing");
00430 gtk_widget_show (frame_param);
00431 gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00432
00433 vbox_param2 = gtk_vbox_new (FALSE, 0);
00434 gtk_widget_show (vbox_param2);
00435 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param2);
00436
00437 input = mygtk_create_input("Amplitude", vbox_param2, hbox_param);
00438 ec = new Gtk_EntryControl (Volt, MLD_WERT_NICHT_OK, &mover_param.MOV_Ampl, 0., 20., "5.2f", input);
00439 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00440 EC_list = g_slist_prepend( EC_list, ec);
00441
00442 input = mygtk_create_input("Duration", vbox_param2, hbox_param);
00443 ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &mover_param.MOV_Speed, 0.5, 50., "4.1f", input);
00444 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00445 EC_list = g_slist_prepend( EC_list, ec);
00446
00447 input = mygtk_create_input("Max. Steps", vbox_param2, hbox_param);
00448 ec = new Gtk_EntryControl (Unity, MLD_WERT_NICHT_OK, &mover_param.MOV_Steps, 1., 5000., "4.0f", input);
00449 ec->Set_ChangeNoticeFkt(DSPMoverControl::ChangedNotify, this);
00450 EC_list = g_slist_prepend( EC_list, ec);
00451 }
00452 }
00453
00454
00455 frame_param = gtk_frame_new ("Direction & Action Control");
00456 gtk_widget_show (frame_param);
00457 gtk_container_add (GTK_CONTAINER (vbox_param), frame_param);
00458
00459 tab = gtk_table_new (6, 3, FALSE);
00460 gtk_widget_show (tab);
00461 gtk_container_add (GTK_CONTAINER (frame_param), tab);
00462
00463
00464
00465
00466 if( IS_MOVER_CTRL ){
00467
00468 button = gtk_button_new ();
00469 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00470 gtk_widget_show (button);
00471
00472 img = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_BUTTON);
00473 gtk_widget_show (img);
00474 gtk_container_add (GTK_CONTAINER (button), img);
00475
00476 gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 1, 2,
00477 (GtkAttachOptions)(GTK_FILL),
00478 (GtkAttachOptions)(GTK_FILL),
00479 FALSE, FALSE);
00480 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00481 GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00482 this);
00483
00484 button = create_arrow_button(GTK_ARROW_UP, GTK_SHADOW_OUT);
00485 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00486 gtk_widget_show (button);
00487 gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 0, 1,
00488 (GtkAttachOptions)(GTK_FILL),
00489 (GtkAttachOptions)(GTK_FILL),
00490 FALSE, FALSE);
00491 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_YP);
00492 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00493 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00494 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00495 this);
00496 gtk_signal_connect (GTK_OBJECT (button), "released",
00497 GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00498 this);
00499 gtk_signal_connect(GTK_OBJECT(box), "key_press_event",
00500 G_CALLBACK(create_window_key_press_event_lcb), this);
00501
00502
00503
00504
00505
00506 KEY_LAB (i==4?"Z-":"X-",0,1,1,2);
00507 KEY_LAB (i==4?"Z+":"X+",4,5,1,2);
00508 KEY_LAB ("Y+",0,1,0,1);
00509 KEY_LAB ("Y-",0,1,2,3);
00510
00511 button = create_arrow_button(GTK_ARROW_LEFT, GTK_SHADOW_OUT);
00512 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00513 gtk_widget_show (button);
00514 gtk_table_attach (GTK_TABLE (tab), button, 1, 2, 1, 2,
00515 (GtkAttachOptions)(GTK_FILL),
00516 (GtkAttachOptions)(GTK_FILL),
00517 FALSE, FALSE);
00518 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_XM);
00519 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00520 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00521 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00522 this);
00523 gtk_signal_connect (GTK_OBJECT (button), "released",
00524 GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00525 this);
00526
00527
00528
00529
00530
00531 button = create_arrow_button(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
00532 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00533 gtk_widget_show (button);
00534 gtk_table_attach (GTK_TABLE (tab), button, 3, 4, 1, 2,
00535 (GtkAttachOptions)(GTK_FILL),
00536 (GtkAttachOptions)(GTK_FILL),
00537 FALSE, FALSE);
00538 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_XP);
00539 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00540 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00541 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00542 this);
00543 gtk_signal_connect (GTK_OBJECT (button), "released",
00544 GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00545 this);
00546
00547
00548
00549
00550
00551
00552
00553 button = create_arrow_button(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
00554 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00555 gtk_widget_show (button);
00556 gtk_table_attach (GTK_TABLE (tab), button, 2, 3, 2, 3,
00557 (GtkAttachOptions)(GTK_FILL),
00558 (GtkAttachOptions)(GTK_FILL),
00559 FALSE, FALSE);
00560 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_AFM_MOV_YM);
00561 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00562 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00563 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00564 this);
00565 gtk_signal_connect (GTK_OBJECT (button), "released",
00566 GTK_SIGNAL_FUNC (DSPMoverControl::StopAction),
00567 this);
00568
00569
00570
00571
00572
00573 }
00574
00575
00576 hbox = gtk_hbox_new (TRUE, 0);
00577 gtk_widget_show (hbox);
00578 gtk_table_attach (GTK_TABLE (tab), hbox, 0, 1, 1, 2,
00579 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00580 (GtkAttachOptions)(GTK_FILL),
00581 FALSE, FALSE);
00582
00583 hbox = gtk_hbox_new (TRUE, 0);
00584 gtk_widget_show (hbox);
00585 gtk_table_attach (GTK_TABLE (tab), hbox, 4, 5, 1, 2,
00586 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00587 (GtkAttachOptions)(GTK_FILL),
00588 FALSE, FALSE);
00589
00590 if(i==4){
00591
00592
00593 lab = gtk_label_new ("Auto Control");
00594 gtk_widget_show (lab);
00595 gtk_table_attach (GTK_TABLE (tab), lab, 5, 6, 0, 1,
00596 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00597 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00598 FALSE, FALSE);
00599
00600 button = gtk_button_new ();
00601 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00602 gtk_widget_show (button);
00603
00604 img = gtk_image_new_from_stock ("gtk-connect", GTK_ICON_SIZE_BUTTON);
00605 gtk_widget_show (img);
00606 gtk_container_add (GTK_CONTAINER (button), img);
00607
00608 gtk_table_attach (GTK_TABLE (tab), button, 5, 6, 1, 2,
00609 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00610 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00611 FALSE, FALSE);
00612 if(IS_MOVER_CTRL)
00613 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_APPROCH_MOV_XP);
00614 else
00615 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_APPROCH);
00616
00617 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00618 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00619 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00620 this);
00621
00622 button = gtk_button_new ();
00623 gtk_widget_set_usize (button, ARROW_SIZE, ARROW_SIZE);
00624 gtk_widget_show (button);
00625
00626 img = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_BUTTON);
00627 gtk_widget_show (img);
00628 gtk_container_add (GTK_CONTAINER (button), img);
00629
00630 gtk_table_attach (GTK_TABLE (tab), button, 5, 6, 2, 3,
00631 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00632 (GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
00633 FALSE, FALSE);
00634 gtk_object_set_data( GTK_OBJECT (button), "DSP_cmd", (gpointer)DSP_CMD_CLR_PA);
00635 gtk_object_set_data( GTK_OBJECT (button), "MoverNo", (gpointer)i);
00636 gtk_signal_connect (GTK_OBJECT (button), "pressed",
00637 GTK_SIGNAL_FUNC (DSPMoverControl::CmdAction),
00638 this);
00639 }
00640
00641 }
00642
00643 if(accel_group)
00644 gtk_window_add_accel_group (GTK_WINDOW (GetWidget()), accel_group);
00645
00646
00647 gtk_object_set_data( GTK_OBJECT (widget), "MOVER_EC_list", EC_list);
00648
00649
00650 }
00651
00652 void DSPMoverControl::update(){
00653 g_slist_foreach
00654 ( (GSList*) gtk_object_get_data( GTK_OBJECT (widget), "MOVER_EC_list"),
00655 (GFunc) App::update_ec, NULL
00656 );
00657 }
00658
00659 void DSPMoverControl::updateDSP(int sliderno){
00660 PI_DEBUG (DBG_L2, "Hallo DSP ! Mover No:" << sliderno );
00661 if(sliderno >= 0 && sliderno < 4){
00662 mover_param.AFM_Amp = mover_param.AFM_usrAmp [sliderno];
00663 mover_param.AFM_Speed = mover_param.AFM_usrSpeed[sliderno];
00664 mover_param.AFM_Steps = mover_param.AFM_usrSteps[sliderno];
00665 }else{
00666 mover_param.AFM_Amp = mover_param.MOV_Ampl;
00667 mover_param.AFM_Speed = mover_param.MOV_Speed;
00668 mover_param.AFM_Steps = mover_param.MOV_Steps;
00669 }
00670 }
00671
00672 int DSPMoverControl::config_mode(GtkWidget *widget, DSPMoverControl *dspc){
00673 if (GTK_TOGGLE_BUTTON (widget)->active)
00674 dspc->mover_param.MOV_mode = (int)gtk_object_get_data( GTK_OBJECT (widget), "CurveMask");
00675 }
00676
00677 int DSPMoverControl::config_waveform(GtkWidget *widget, DSPMoverControl *dspc){
00678 if (GTK_TOGGLE_BUTTON (widget)->active)
00679 dspc->mover_param.MOV_waveform_id = (int)gtk_object_get_data( GTK_OBJECT (widget), "CurveId");
00680 }
00681
00682 int DSPMoverControl::config_output(GtkWidget *widget, DSPMoverControl *dspc){
00683 if (GTK_TOGGLE_BUTTON (widget)->active)
00684 dspc->mover_param.MOV_output = (int)gtk_object_get_data( GTK_OBJECT (widget), "OutputMask");
00685 }
00686
00687 int DSPMoverControl::CmdAction(GtkWidget *widget, DSPMoverControl *dspc){
00688 int idx=-1;
00689 int cmd;
00690 PI_DEBUG (DBG_L2, "MoverCrtl::CmdAction " );
00691 if(IS_MOVER_CTRL)
00692 idx = (int)gtk_object_get_data( GTK_OBJECT (widget), "MoverNo");
00693 dspc->updateDSP(idx);
00694 cmd = (int)gtk_object_get_data( GTK_OBJECT (widget), "DSP_cmd");
00695 if(cmd>0)
00696 dspc->ExecCmd(cmd);
00697 PI_DEBUG (DBG_L2, "cmd=" << cmd << " Mover=" << idx );
00698 return 0;
00699 }
00700
00701 int DSPMoverControl::StopAction(GtkWidget *widget, DSPMoverControl *dspc){
00702 PI_DEBUG (DBG_L2, "DSPMoverControl::StopAction" );
00703 dspc->ExecCmd(DSP_CMD_CLR_PA);
00704 return 0;
00705 }
00706
00707 void DSPMoverControl::ChangedNotify(Param_Control* pcs, gpointer dspc){
00708 int idx=-1;
00709
00710 gchar *us=pcs->Get_UsrString();
00711 PI_DEBUG (DBG_L2, "MoverCrtl:: Param Changed: " << us );
00712 g_free(us);
00713
00714 if(IS_MOVER_CTRL)
00715 idx = (int)pcs->GetEntryData("MoverNo");
00716 ((DSPMoverControl*)dspc)->updateDSP(idx);
00717 }
00718
00719 void DSPMoverControl::ExecCmd(int cmd){
00720 sranger_hwi_hardware->ExecCmd(cmd);
00721 }