CCDControl.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: CCDControl.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: CCD exposure control
00038 % PlugInName: CCDControl
00039 % PlugInAuthor: Percy Zahl
00040 % PlugInAuthorEmail: zahl@users.sf.net
00041 % PlugInMenuPath: Windows/CCD Control
00042 
00043 % PlugInDescription
00044 This is a control dialog for my (PZ) selfbuild Astro CCD camera, using
00045 a TC211, a control unit described in CT 19xx on a parallel port of the
00046 PC. It allows to set the exposure time and monitor control\dots
00047 
00048 \GxsmScreenShot{CCDControl}{The CCD Control window.}
00049 
00050 %% PlugInUsage
00051 %Write how to use it.
00052 
00053 %% OptPlugInConfig
00054 %describe the configuration options of your plug in here!
00055 
00056 % OptPlugInRefs
00057 CT 19xx
00058 
00059 %% OptPlugInKnownBugs
00060 %Are there known bugs? List! How to work around if not fixed?
00061 
00062 %% OptPlugInNotes
00063 %If you have any additional notes
00064 
00065 % EndPlugInDocuSection
00066  * -------------------------------------------------------------------------------- 
00067  */
00068 
00069 
00070 #include <gtk/gtk.h>
00071 #include "config.h"
00072 #include "gxsm/plugin.h"
00073 
00074 #include "gxsm/unit.h"
00075 #include "gxsm/pcs.h"
00076 #include "gxsm/glbvars.h"
00077 #include "plug-ins/hard/modules/ccd.h"
00078 
00079 #include "include/dsp-pci32/xsm/xsmcmd.h"
00080 
00081 
00082 
00083 static void CCDControl_about( void );
00084 static void CCDControl_query( void );
00085 static void CCDControl_cleanup( void );
00086 
00087 static void CCDControl_show_callback( GtkWidget*, void* );
00088 static void CCDControl_StartScan_callback( gpointer );
00089 
00090 GxsmPlugin CCDControl_pi = {
00091         NULL,
00092         NULL,
00093         0,
00094         NULL,
00095         "CCDControl",
00096         "+CCD",
00097         NULL,
00098         "Percy Zahl",
00099         N_("_Windows/"),
00100         N_("CCD Control"),
00101         N_("open the CCD exposure controlwindow"),
00102         "CCD exposure control",
00103         NULL,
00104         NULL,
00105         NULL,
00106         CCDControl_query,
00107         CCDControl_about,
00108         NULL,
00109         NULL,
00110         CCDControl_cleanup
00111 };
00112 
00113 static const char *about_text = N_("Gxsm CCDControl Plugin:\n"
00114                                    "This plugin runs a control window to set "
00115                                    "CCD exposure time and monitoring control mode."
00116         );
00117 
00118 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00119         CCDControl_pi.description = g_strdup_printf(N_("Gxsm CCDControl plugin %s"), VERSION);
00120         return &CCDControl_pi; 
00121 }
00122 
00123 
00124 class CCDControl : public AppBase{
00125 public:
00126         CCDControl();
00127         virtual ~CCDControl();
00128 
00129         void update();
00130         void updateCCD(int cmd=-1);
00131         static void ExecCmd(int cmd);
00132         static void ChangedNotify(Param_Control* pcs, gpointer data);
00133         static int ChangedAction(GtkWidget *widget, CCDControl *dspc);
00134         static int monitor_callback(GtkWidget *widget, CCDControl *dspc);
00135 
00136         /*
00137           static int autoexp_callback(GtkWidget *widget, CCDControl *dspc);
00138 
00139           static gint PFtmoutfkt(DSPProbeControl *pc);
00140 
00141           void addPFtmout(){
00142           if(!IdPFtmout)
00143           IdPFtmout = gtk_timeout_add(PFtmoutms, PFtmoutfkt, this);
00144           };
00145           void rmPFtmout(){
00146           if(IdPFtmout){
00147           gtk_timeout_remove(IdPFtmout);
00148           IdPFtmout=0;
00149           }
00150           };
00151           gint IdPFtmout;
00152 
00153         */
00154 
00155 private:
00156         UnitObj *Unity, *Time;
00157         double CCD_exptime;
00158 };
00159 
00160 
00161 CCDControl *CCDControlClass = NULL;
00162 
00163 static void CCDControl_query(void)
00164 {
00165         static GnomeUIInfo menuinfo[] = { 
00166                 { GNOME_APP_UI_ITEM, 
00167                   CCDControl_pi.menuentry, CCDControl_pi.help,
00168                   (gpointer) CCDControl_show_callback, NULL,
00169                   NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BLANK, 
00170                   0, GDK_CONTROL_MASK, NULL },
00171 
00172                 GNOMEUIINFO_END
00173         };
00174 
00175         gnome_app_insert_menus
00176                 ( GNOME_APP(CCDControl_pi.app->getApp()), 
00177                   CCDControl_pi.menupath, menuinfo );
00178 
00179         // new ...
00180         CCDControlClass = new CCDControl;
00181 
00182         CCDControlClass->SetResName ("WindowCCDControl", "false", xsmres.geomsave);
00183 
00184         CCDControl_pi.app->ConnectPluginToStartScanEvent
00185                 ( CCDControl_StartScan_callback );
00186 
00187         CCDControl_pi.status = g_strconcat(N_("Plugin query has attached "),
00188                                            CCDControl_pi.name, 
00189                                            N_(": CCDControl is created."),
00190                                            NULL);
00191 }
00192 
00193 static void CCDControl_about(void)
00194 {
00195         const gchar *authors[] = { "Percy Zahl", NULL};
00196         gtk_widget_show(gnome_about_new ( CCDControl_pi.name,
00197                                           VERSION,
00198                                           N_("(C) 2000 the Free Software Foundation"),
00199                                           about_text,
00200                                           authors,
00201                                           NULL, NULL, NULL
00202                                 ));
00203 }
00204 
00205 static void CCDControl_cleanup( void ){
00206         PI_DEBUG (DBG_L2, "CCDControl Plugin Cleanup" );
00207         gchar *mp = g_strconcat(CCDControl_pi.menupath, CCDControl_pi.menuentry, NULL);
00208         gnome_app_remove_menus (GNOME_APP( CCDControl_pi.app->getApp() ), mp, 1);
00209         g_free(mp);
00210 
00211         // delete ...
00212         if( CCDControlClass )
00213                 delete CCDControlClass ;
00214 }
00215 
00216 static void CCDControl_show_callback( GtkWidget* widget, void* data){
00217         if( CCDControlClass )
00218                 CCDControlClass->show();
00219 }
00220 
00221 static void CCDControl_StartScan_callback( gpointer ){
00222         CCDControlClass->update();
00223 }
00224 
00225 // Achtung: Remote is not released :=(
00226 // DSP-Param sollten lokal werden...
00227 CCDControl::CCDControl ()
00228 {
00229         GSList *EC_list=NULL;
00230         //  GSList **RemoteEntryList = new GSList *;
00231         //  *RemoteEntryList = NULL;
00232 
00233         Gtk_EntryControl *ec;
00234 
00235         GtkWidget *box;
00236         GtkWidget *frame_param, *vbox_param, *hbox_param;
00237 
00238         GtkWidget *input;
00239 
00240         GtkWidget *label;
00241         GtkWidget *checkbutton;
00242 
00243         Unity    = new UnitObj(" "," ");
00244         Time     = new UnitObj("ms","ms");
00245 
00246         AppWidgetInit(N_("CCD Control"));
00247 
00248         box = gtk_vbox_new (FALSE, 0);
00249         gtk_widget_show (box);
00250         gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
00251 
00252         // ========================================
00253         frame_param = gtk_frame_new (N_("CCD-Camera Settings"));
00254         gtk_widget_show (frame_param);
00255         gtk_container_add (GTK_CONTAINER (box), frame_param);
00256 
00257         vbox_param = gtk_vbox_new (FALSE, 0);
00258         gtk_widget_show (vbox_param);
00259         gtk_container_add (GTK_CONTAINER (frame_param), vbox_param);
00260 
00261         // ------- CCD Settings
00262 
00263         hbox_param = gtk_hbox_new (FALSE, 0);
00264         gtk_widget_show (hbox_param);
00265         gtk_container_add (GTK_CONTAINER (vbox_param), hbox_param);
00266         label = gtk_label_new (N_("CCD"));
00267         gtk_widget_set_usize (label, 100, -1);
00268         gtk_widget_show (label);
00269         gtk_box_pack_start (GTK_BOX (hbox_param), label, FALSE, TRUE, 0);
00270 
00271         checkbutton = gtk_check_button_new_with_label(N_("Monitor"));
00272         gtk_widget_set_usize (checkbutton, 100, -1);
00273         gtk_box_pack_start (GTK_BOX (hbox_param), checkbutton, TRUE, TRUE, 0);
00274         gtk_widget_show (checkbutton);
00275         gtk_signal_connect (GTK_OBJECT (checkbutton), "clicked",
00276                             GTK_SIGNAL_FUNC (CCDControl::monitor_callback), this);
00277 
00278 
00279         input = mygtk_create_input("Exposure", vbox_param, hbox_param);
00280         ec = new Gtk_EntryControl (Time, MLD_WERT_NICHT_OK, &CCD_exptime, 40., 99999., ".0f", input);
00281         ec->Set_ChangeNoticeFkt(CCDControl::ChangedNotify, this);
00282         EC_list = g_slist_prepend( EC_list, ec);
00283         //  *RemoteEntryList = ec->AddEntry2RemoteList("CCD_Exposure", *RemoteEntryList);
00284 
00285         // save List away...
00286         gtk_object_set_data( GTK_OBJECT (widget), "CCD_EC_list", EC_list);
00287 }
00288 
00289 CCDControl::~CCDControl (){
00290         delete Unity;
00291         delete Time;
00292 }
00293 
00294 void CCDControl::update(){
00295         g_slist_foreach((GSList*)gtk_object_get_data( GTK_OBJECT (widget), "CCD_EC_list"),
00296                         (GFunc) App::update_ec, NULL);
00297 }
00298 
00299 void CCDControl::updateCCD(int cmd){
00300         PI_DEBUG (DBG_L2, "Hallo CCD ! cmd=" << cmd );
00301 // **=  CCDControl_pi.app->xsm->hardware->PutParameter(dsp);
00302         if(cmd > 0)
00303                 ExecCmd(cmd);
00304 }
00305 
00306 int CCDControl::ChangedAction(GtkWidget *widget, CCDControl *dspc){
00307         dspc->updateCCD();
00308         return 0;
00309 }
00310 
00311 void CCDControl::ChangedNotify(Param_Control* pcs, gpointer dspc){
00312         //  gchar *us=pcs->Get_UsrString();
00313         //  PI_DEBUG (DBG_L2, "CCD: " << us );
00314         //  g_free(us);
00315         ((CCDControl*)dspc)->updateCCD();
00316 }
00317 
00318 void CCDControl::ExecCmd(int cmd){
00319         // Do it now here.
00320 }
00321 
00322 int CCDControl::monitor_callback( GtkWidget *widget, CCDControl *dspc){
00323         if (GTK_TOGGLE_BUTTON (widget)->active)
00324                 dspc->updateCCD(CCD_CMD_MONITORENABLE);
00325         return 0;
00326 }

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