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
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #include <gtk/gtk.h>
00067 #include "config.h"
00068 #include "gxsm/plugin.h"
00069
00070 #include "gxsm/unit.h"
00071 #include "gxsm/pcs.h"
00072 #include "gxsm/xsmtypes.h"
00073 #include "gxsm/glbvars.h"
00074
00075 #include "include/dsp-pci32/spa/spacmd.h"
00076
00077
00078
00079 static void SpaLeedControl_about( void );
00080 static void SpaLeedControl_query( void );
00081 static void SpaLeedControl_cleanup( void );
00082
00083 static void SpaLeedControl_show_callback( GtkWidget*, void* );
00084 static void SpaLeedControl_StartScan_callback( gpointer );
00085
00086 GxsmPlugin SpaLeedControl_pi = {
00087 NULL,
00088 NULL,
00089 0,
00090 NULL,
00091 "SpaLeedControl",
00092 "+SPALEED",
00093 NULL,
00094 "Percy Zahl",
00095 N_("_Windows/"),
00096 N_("SPA-LEED Ctrl"),
00097 N_("open the SPA-LEED controlwindow"),
00098 "SPA-LEED control",
00099 NULL,
00100 NULL,
00101 NULL,
00102 SpaLeedControl_query,
00103 SpaLeedControl_about,
00104 NULL,
00105 NULL,
00106 SpaLeedControl_cleanup
00107 };
00108
00109 static const char *about_text = N_("Gxsm SpaLeedControl Plugin:\n"
00110 "This plugin runs a control window to change "
00111 "the SPALEED simulator settimgs."
00112 );
00113
00114 GxsmPlugin *get_gxsm_plugin_info ( void ){
00115 SpaLeedControl_pi.description = g_strdup_printf(N_("Gxsm SpaLeedControl plugin %s"), VERSION);
00116 return &SpaLeedControl_pi;
00117 }
00118
00119
00120 class SpaLeedControl : public AppBase{
00121 public:
00122 SpaLeedControl();
00123 virtual ~SpaLeedControl();
00124
00125 void update();
00126 void updateSPALEED(int cmd=-1);
00127 static void ExecCmd(int cmd);
00128 static void ChangedNotify(Param_Control* pcs, gpointer data);
00129 static int ChangedAction(GtkWidget *widget, SpaLeedControl *spac);
00130 static int epitaxy_callback(GtkWidget *widget, SpaLeedControl *spac);
00131
00132 private:
00133 UnitObj *Unity, *Current, *Volt, *Percent, *Kelvin;
00134
00135 gchar *ResName;
00136 double extractor;
00137 double chanhv;
00138 double chanrepeller;
00139 double cryfocus;
00140 double filament;
00141 double gunfocus;
00142 double gunanode;
00143 double smpdist;
00144 double smptemp;
00145 double growing;
00146 };
00147
00148
00149 SpaLeedControl *SpaLeedControlClass = NULL;
00150
00151 static void SpaLeedControl_query(void)
00152 {
00153 static GnomeUIInfo menuinfo[] = {
00154 { GNOME_APP_UI_ITEM,
00155 SpaLeedControl_pi.menuentry, SpaLeedControl_pi.help,
00156 (gpointer) SpaLeedControl_show_callback, NULL,
00157 NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BLANK,
00158 0, GDK_CONTROL_MASK, NULL },
00159
00160 GNOMEUIINFO_END
00161 };
00162
00163 gnome_app_insert_menus
00164 ( GNOME_APP(SpaLeedControl_pi.app->getApp()),
00165 SpaLeedControl_pi.menupath, menuinfo );
00166
00167
00168 SpaLeedControlClass = new SpaLeedControl;
00169
00170 SpaLeedControlClass->SetResName ("WindowSpaLeedControl", "false", xsmres.geomsave);
00171
00172 SpaLeedControl_pi.app->ConnectPluginToStartScanEvent
00173 ( SpaLeedControl_StartScan_callback );
00174
00175 SpaLeedControl_pi.status = g_strconcat(N_("Plugin query has attached "),
00176 SpaLeedControl_pi.name,
00177 N_(": SpaLeedControl is created."),
00178 NULL);
00179 }
00180
00181 static void SpaLeedControl_about(void)
00182 {
00183 const gchar *authors[] = { "Percy Zahl", NULL};
00184 gtk_widget_show(gnome_about_new ( SpaLeedControl_pi.name,
00185 VERSION,
00186 N_("(C) 2000 the Free Software Foundation"),
00187 about_text,
00188 authors,
00189 NULL, NULL, NULL
00190 ));
00191 }
00192
00193 static void SpaLeedControl_cleanup( void ){
00194 PI_DEBUG (DBG_L2, "SpaLeedControl Plugin Cleanup" );
00195 gchar *mp = g_strconcat(SpaLeedControl_pi.menupath, SpaLeedControl_pi.menuentry, NULL);
00196 gnome_app_remove_menus (GNOME_APP( SpaLeedControl_pi.app->getApp() ), mp, 1);
00197 g_free(mp);
00198
00199
00200 if( SpaLeedControlClass )
00201 delete SpaLeedControlClass ;
00202 }
00203
00204 static void SpaLeedControl_show_callback( GtkWidget* widget, void* data){
00205 if( SpaLeedControlClass )
00206 SpaLeedControlClass->show();
00207 }
00208
00209 static void SpaLeedControl_StartScan_callback( gpointer ){
00210 SpaLeedControlClass->update();
00211 }
00212
00213
00214
00215 SpaLeedControl::SpaLeedControl ()
00216 {
00217 GSList *EC_list=NULL;
00218
00219
00220
00221 Gtk_EntryControl *ec;
00222
00223 GtkWidget *box;
00224 GtkWidget *frame_param, *vbox_param, *hbox_param, *frontpanel;
00225
00226 GtkWidget *input;
00227
00228 GtkWidget *checkbutton;
00229
00230 ResName = g_strdup("SpaLeedControl");
00231
00232 XsmRescourceManager xrm(ResName);
00233 xrm.Get("spa_extractor", &extractor, "1.0");
00234 xrm.Get("spa_chanhv", &chanhv, "2000.0");
00235 xrm.Get("spa_chanrepeller", &chanrepeller, "1.0");
00236 xrm.Get("spa_cryfocus", &cryfocus, "0.5");
00237 xrm.Get("spa_filament", &filament, "2.4");
00238 xrm.Get("spa_gunfocus", &gunfocus, "0.5");
00239 xrm.Get("spa_gunanode", &gunanode, "100.0");
00240 xrm.Get("spa_smpdist", &smpdist, "20.0");
00241 xrm.Get("spa_smptemp", &smptemp, "300.0");
00242 xrm.Get("spa_growing", &growing, "0.0");
00243
00244
00245 Unity = new UnitObj(" "," ");
00246 Current = new UnitObj("A","A");
00247 Volt = new UnitObj("V","V");
00248 Percent = new LinUnit("%%","%%",1e-2);
00249 Kelvin = new UnitObj("K","K");
00250
00251 AppWidgetInit(N_("SPA-LEED Settings"));
00252
00253 box = gtk_vbox_new (FALSE, 0);
00254 gtk_widget_show (box);
00255 gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00256
00257
00258 frame_param = gtk_frame_new (N_("Leybold SPA-LEED Control"));
00259 gtk_widget_show (frame_param);
00260 gtk_container_add (GTK_CONTAINER (box), frame_param);
00261
00262 frontpanel = gtk_vbox_new (FALSE, 0);
00263 gtk_widget_show (frontpanel);
00264 gtk_container_add (GTK_CONTAINER (frame_param), frontpanel);
00265
00266
00267 frame_param = gtk_frame_new (N_("Energy"));
00268 gtk_widget_show (frame_param);
00269 gtk_container_add (GTK_CONTAINER (frontpanel), frame_param);
00270
00271 vbox_param = gtk_vbox_new (FALSE, 0);
00272 gtk_widget_show (vbox_param);
00273 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00274
00275
00276
00277 input = mygtk_create_input("Anode", vbox_param, hbox_param);
00278 ec = new Gtk_EntryControl
00279 (Volt, MLD_WERT_NICHT_OK, &gunanode,
00280 0., 200., "5.2f", input, 1., 2.);
00281 SetupScale(ec->GetAdjustment(), hbox_param);
00282 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00283 EC_list = g_slist_prepend( EC_list, ec);
00284
00285 input = mygtk_create_input("Filament", vbox_param, hbox_param);
00286 ec = new Gtk_EntryControl
00287 (Current, MLD_WERT_NICHT_OK, &filament,
00288 0., 3., "5.2f", input, 0.01, 0.02);
00289 SetupScale(ec->GetAdjustment(), hbox_param);
00290 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00291 EC_list = g_slist_prepend( EC_list, ec);
00292
00293
00294 frame_param = gtk_frame_new (N_("Focus"));
00295 gtk_widget_show (frame_param);
00296 gtk_container_add (GTK_CONTAINER (frontpanel), frame_param);
00297
00298 vbox_param = gtk_vbox_new (FALSE, 0);
00299 gtk_widget_show (vbox_param);
00300 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00301
00302 input = mygtk_create_input("Gun Focus", vbox_param, hbox_param);
00303 ec = new Gtk_EntryControl
00304 (Percent, MLD_WERT_NICHT_OK, &gunfocus,
00305 0., 1., "4.3f", input, 0.01, 0.01);
00306 SetupScale(ec->GetAdjustment(), hbox_param);
00307 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00308 EC_list = g_slist_prepend( EC_list, ec);
00309
00310 input = mygtk_create_input("Cryst. Focus", vbox_param, hbox_param);
00311 ec = new Gtk_EntryControl
00312 (Percent, MLD_WERT_NICHT_OK, &cryfocus,
00313 0., 1., "4.3f", input, 0.005, 0.005);
00314 SetupScale(ec->GetAdjustment(), hbox_param);
00315 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00316 EC_list = g_slist_prepend( EC_list, ec);
00317
00318
00319 frame_param = gtk_frame_new (N_("Channeltron"));
00320 gtk_widget_show (frame_param);
00321 gtk_container_add (GTK_CONTAINER (frontpanel), frame_param);
00322
00323 vbox_param = gtk_vbox_new (FALSE, 0);
00324 gtk_widget_show (vbox_param);
00325 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00326 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00327
00328 input = mygtk_create_input("Repeller", vbox_param, hbox_param);
00329 ec = new Gtk_EntryControl
00330 (Volt, MLD_WERT_NICHT_OK, &chanrepeller,
00331 0., 10., "5.2f", input, 0.01, 0.01);
00332 SetupScale(ec->GetAdjustment(), hbox_param);
00333 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00334 EC_list = g_slist_prepend( EC_list, ec);
00335
00336 input = mygtk_create_input("HV", vbox_param, hbox_param);
00337 ec = new Gtk_EntryControl
00338 (Volt, MLD_WERT_NICHT_OK, &chanhv,
00339 0., 6e3, "5.0f", input, 10., 20.);
00340 SetupScale(ec->GetAdjustment(), hbox_param);
00341 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00342 EC_list = g_slist_prepend( EC_list, ec);
00343
00344
00345
00346
00347 frame_param = gtk_frame_new (N_("Experiment"));
00348 gtk_widget_show (frame_param);
00349 gtk_container_add (GTK_CONTAINER (frontpanel), frame_param);
00350
00351 vbox_param = gtk_vbox_new (FALSE, 0);
00352 gtk_widget_show (vbox_param);
00353 gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00354
00355 input = mygtk_create_input("Temp.", vbox_param, hbox_param);
00356 ec = new Gtk_EntryControl
00357 (Kelvin, MLD_WERT_NICHT_OK, &smptemp,
00358 0., 3000., "6.1f", input, 10., 10.);
00359 SetupScale(ec->GetAdjustment(), hbox_param);
00360 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00361 EC_list = g_slist_prepend( EC_list, ec);
00362
00363 input = mygtk_create_input("Growing", vbox_param, hbox_param);
00364 ec = new Gtk_EntryControl
00365 (Unity, MLD_WERT_NICHT_OK, &growing,
00366 0., 10., "6.1f", input, 1., 0.1);
00367 SetupScale(ec->GetAdjustment(), hbox_param);
00368 ec->Set_ChangeNoticeFkt(SpaLeedControl::ChangedNotify, this);
00369 EC_list = g_slist_prepend( EC_list, ec);
00370
00371 checkbutton = gtk_check_button_new_with_label(N_("Epitaxy"));
00372 gtk_widget_set_usize (checkbutton, 100, -1);
00373 gtk_box_pack_start (GTK_BOX (hbox_param), checkbutton, TRUE, TRUE, 0);
00374 gtk_widget_show (checkbutton);
00375 gtk_signal_connect (GTK_OBJECT (checkbutton), "clicked",
00376 GTK_SIGNAL_FUNC (SpaLeedControl::epitaxy_callback), this);
00377
00378
00379 gtk_object_set_data( GTK_OBJECT (widget), "SPALEED_EC_list", EC_list);
00380 update();
00381 }
00382
00383 SpaLeedControl::~SpaLeedControl (){
00384
00385 XsmRescourceManager xrm(ResName);
00386 xrm.Put("spa_extractor", extractor);
00387 xrm.Put("spa_chanhv", chanhv);
00388 xrm.Put("spa_chanrepeller", chanrepeller);
00389 xrm.Put("spa_cryfocus", cryfocus);
00390 xrm.Put("spa_filament", filament);
00391 xrm.Put("spa_gunfocus", gunfocus);
00392 xrm.Put("spa_gunanode", gunanode);
00393 xrm.Put("spa_smpdist", smpdist);
00394 xrm.Put("spa_smptemp", smptemp);
00395 xrm.Put("spa_growing", growing);
00396 g_free(ResName);
00397 ResName=NULL;
00398
00399 delete Unity;
00400 delete Current;
00401 delete Volt;
00402 delete Percent;
00403 delete Kelvin;
00404 }
00405
00406 void SpaLeedControl::update(){
00407 g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "SPALEED_EC_list"),
00408 (GFunc) App::update_ec, NULL);
00409 }
00410
00411 void SpaLeedControl::updateSPALEED(int cmd){
00412 PARAMETER_SET hardpar;
00413
00414 hardpar.N = DSP_SPACTRL_GROWING+1;
00415 hardpar.Cmd = DSP_CMD_SPACTRL_SET;
00416
00417 hardpar.hp[DSP_SPACTRL_EXTRACTOR ].value = extractor;
00418 hardpar.hp[DSP_SPACTRL_CHANHV ].value = chanhv;
00419 hardpar.hp[DSP_SPACTRL_CHANREPELLER ].value = chanrepeller;
00420 hardpar.hp[DSP_SPACTRL_CRYFOCUS ].value = cryfocus;
00421 hardpar.hp[DSP_SPACTRL_FILAMENT ].value = filament;
00422 hardpar.hp[DSP_SPACTRL_GUNFOCUS ].value = gunfocus;
00423 hardpar.hp[DSP_SPACTRL_GUNANODE ].value = gunanode;
00424 hardpar.hp[DSP_SPACTRL_SMPDIST ].value = smpdist;
00425 hardpar.hp[DSP_SPACTRL_SMPTEMP ].value = smptemp;
00426 hardpar.hp[DSP_SPACTRL_GROWING ].value = growing;
00427 SpaLeedControl_pi.app->xsm->hardware->SetParameter(hardpar);
00428 }
00429
00430 int SpaLeedControl::ChangedAction(GtkWidget *widget, SpaLeedControl *spac){
00431 spac->updateSPALEED();
00432 return 0;
00433 }
00434
00435 void SpaLeedControl::ChangedNotify(Param_Control* pcs, gpointer spac){
00436 ((SpaLeedControl*)spac)->updateSPALEED();
00437 }
00438
00439 void SpaLeedControl::ExecCmd(int cmd){
00440 SpaLeedControl_pi.app->xsm->hardware->ExecCmd(cmd);
00441 }
00442
00443 int SpaLeedControl::epitaxy_callback( GtkWidget *widget, SpaLeedControl *spac){
00444 if (GTK_TOGGLE_BUTTON (widget)->active)
00445 spac->growing = 1.;
00446 else
00447 spac->growing = 0.;
00448 return 0;
00449 }