00001 /* Gnome gxsm - Gnome X Scanning Microscopy 00002 * universal STM/AFM/SARLS/SPALEED/... controlling and 00003 * data analysis software 00004 * 00005 * Gxsm Hardware Interface Plugin Name: LAN_rhk_hwi.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 00029 /* Please do not change the Begin/End lines of this comment section! 00030 * this is a LaTeX style section used for auto generation of the PlugIn Manual 00031 * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks! 00032 * All "% PlugInXXX" commentary tags are mandatory 00033 * All "% OptPlugInXXX" tags are optional and can be removed or commented in 00034 * -------------------------------------------------------------------------------- 00035 % BeginPlugInDocuSection 00036 % PlugInDocuCaption: Local Area Network (Internet) RHK Controller Hardware Interface (to be ported) 00037 % PlugInName: LAN_rhk_hwi 00038 % PlugInAuthor: Farid El Gabaly, Juan de la Figuera 00039 % PlugInAuthorEmail: johnnybegood@users.sourceforge.net 00040 % PlugInMenuPath: Hardware/LAN_RHK:SPM-HwI 00041 00042 % PlugInDescription 00043 This plugin/class provides a interface for SPM adquisition through a 00044 Local Area Network using sockets. In particular, this plugin provides 00045 the necessary interface to interact with the standalone \GxsmFile{rhk\_controller} program and 00046 thus use an \GxsmEmph{RHK STM-100} (the old stand-alone models before 00047 rev 7, not the new DSP based systems) with Gxsm. 00048 00049 It can be used as the foundation of a general SPM-through-the-internet plugin. 00050 00051 With this one, you can: 00052 \begin{itemize} 00053 \item read the settings of the RHK electronics (image size, offset, 00054 tunneling conditions, pixels in image) 00055 \item adquire images with the proper settings (either topographic, current 00056 or any other channel). 00057 \item change from XY to YX scanning 00058 \end{itemize} 00059 00060 The current limitations are: 00061 \begin{itemize} 00062 \item Only forward image (it is not difficult to implement saving the backward 00063 image) 00064 \item Only a single channel can be adquiered. Again it is not too complex to change this. 00065 \item No spectroscopy. Actually we have the code for doing IV curves, but we do not expect 00066 we will implement it in the \GxsmFile{rhk\_controller} program anytime soon. 00067 \end{itemize} 00068 00069 The ugliest code is due to Gxsm assuming that all settings (bias, scan size, etc) are set by Gxsm, not 00070 by the electronics itself (as is the case for the RHK electronics, which has its own 00071 scanning hardware). We have hacked the PutParameter call to also receive the data, and 00072 this is why a non standard scanning plugin is needed (rhk\_scancontrol). 00073 00074 The \GxsmFile{rhk\_controller} program (available from the Gsxm CVS, module RHK\_controller) 00075 handles all the low 00076 level details of data aquisition with an \GxsmEmph{RHK STM-100} \GxsmWWW{www.rhk-tech.com} 00077 with a simple DAQ card \GxsmEmph{I/O Tech Daqboard 2000} 00078 \GxsmWWW{www.IOtech.com}. A couple of cable adapters are needed to connect 00079 the electronics and the adquisition card: one was the \GxsmEmph{I/O 00080 Tech DBK202}, to separate the analogic and digital inputs and outputs 00081 of the andquisition card; the other was a home made one to adapt the 00082 DBK202 to the RHK unit (if anyone needs the pcb drawing, please contact Farid). 00083 The \GxsmFile{rhk\_controller} is run with simple ASCII commands to read the RHK 00084 settings, and select the adquisition channel, adquiere images and so on. 00085 Look at the program itself for more information (it is a fairly simple 00086 C program which uses lex/yacc to parse the commands), or connect to it with 00087 telnet localhost 5027 and type "help". 00088 We use a Omicron Coarse approach controller which is interfaced by TTL with 00089 the DAQ card. The DSPMover plugin works with it. 00090 00091 To manage the \GxsmEmph{I/O Tech Daqboard 2000} under linux we use the 00092 I/O tech linux driver. The Daqboard2000.tgz file from IOTech has: 00093 00094 \begin{itemize} 00095 \item the module with the device driver, \GxsmFile{db2k} 00096 \item the lib to acces the device driver from a user site, \GxsmFile{libdaqx} 00097 \item some examples 00098 \end{itemize} 00099 00100 The version used for the \GxsmEmph{I/O Tech Daqboard 2000} driver is 0.1 and 00101 is GPL licenced. This library is not thread-safe and calls way too many 00102 ''printk'' to print debug messages. A big 00103 problem is that it tries to reserve the buffer memory before each adquisition. 00104 We have a patch (in the src RHK\_controller) which eliminates the printk and 00105 reserves the memory buffer only at installation (2Mb). 00106 00107 % PlugInUsage 00108 Set the \GxsmPref{Hardware}{Card} to ''LAN\_RHK:SPM'', and the 00109 \GxsmPref{Device}{Hardware} to 00110 ''localhost:5027' if you are running \GxsmFile{rhk\_controller} in the same computer. 00111 Start the \GxsmFile{rhk\_controller} \GxsmEmph{before} the Gxsm program. The output of the 00112 \GxsmFile{rhk\_controller} program should say ''someone connected'' when starting Gxsm. 00113 00114 %% OptPlugInSources 00115 00116 %% OptPlugInDest 00117 00118 % OptPlugInNote 00119 00120 You can see some data taken with it in \GxsmWebLink{hobbes.fmc.uam.es/loma}. 00121 00122 % EndPlugInDocuSection 00123 * -------------------------------------------------------------------------------- 00124 */ 00125 00126 #include <sys/ioctl.h> 00127 00128 #include "config.h" 00129 #include "gxsm/plugin.h" 00130 #include "gxsm/xsmhard.h" 00131 00132 // Define HwI PlugIn reference name here, this is what is listed later within "Preferenced Dialog" 00133 // i.e. the string selected for "Hardware/Card"! 00134 #define THIS_HWI_PLUGIN_NAME "LAN_RHK:SPM" 00135 00136 // Plugin Prototypes 00137 static void LAN_rhk_hwi_init( void ); 00138 static void LAN_rhk_hwi_about( void ); 00139 static void LAN_rhk_hwi_configure( void ); 00140 static void LAN_rhk_hwi_cleanup( void ); 00141 00142 // Fill in the GxsmPlugin Description here 00143 GxsmPlugin LAN_rhk_hwi_pi = { 00144 NULL, // filled in and used by Gxsm, don't touch ! 00145 NULL, // filled in and used by Gxsm, don't touch ! 00146 0, // filled in and used by Gxsm, don't touch ! 00147 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00148 // filled in here by Gxsm on Plugin load, 00149 // just after init() is called !!! 00150 // ---------------------------------------------------------------------- 00151 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00152 "LAN_rhk_hwi-" 00153 "HW-INT-1S-SHORT", 00154 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00155 // In this case of Hardware-Interface-Plugin here is the interface-name required 00156 // this is the string selected for "Hardware/Card"! 00157 THIS_HWI_PLUGIN_NAME, 00158 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00159 "LAN_RHK hardware interface.", 00160 // Author(s) 00161 "Percy Zahl", 00162 // Menupath to position where it is appendet to -- not used by HwI PIs 00163 N_("Hardware/"), 00164 // Menuentry -- not used by HwI PIs 00165 N_(THIS_HWI_PLUGIN_NAME"-HwI"), 00166 // help text shown on menu 00167 N_("This is the "THIS_HWI_PLUGIN_NAME" - GXSM Hardware Interface"), 00168 // more info... 00169 "N/A", 00170 NULL, // error msg, plugin may put error status msg here later 00171 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00172 // init-function pointer, can be "NULL", 00173 // called if present at plugin load 00174 LAN_rhk_hwi_init, 00175 // query-function pointer, can be "NULL", 00176 // called if present after plugin init to let plugin manage it install itself 00177 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00178 // about-function, can be "NULL" 00179 // can be called by "Plugin Details" 00180 LAN_rhk_hwi_about, 00181 // configure-function, can be "NULL" 00182 // can be called by "Plugin Details" 00183 LAN_rhk_hwi_configure, 00184 // run-function, can be "NULL", if non-Zero and no query defined, 00185 // it is called on menupath->"plugin" 00186 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00187 // cleanup-function, can be "NULL" 00188 // called if present at plugin removeal 00189 LAN_rhk_hwi_cleanup 00190 }; 00191 00192 00193 // Text used in Aboutbox, please update!! 00194 static const char *about_text = N_("GXSM LAN_rhk_hwi Plugin\n\n" 00195 "LAN-RHK Hardware Interface for SPM."); 00196 00197 /* Here we go... */ 00198 00199 #include "LAN_rhk_hwi.h" 00200 00201 /* 00202 * PI global 00203 */ 00204 00205 LAN_rhk_hwi_dev *LAN_rhk_hwi_hardware = NULL; 00206 00207 /* 00208 * PI essential members 00209 */ 00210 00211 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00212 // Essential Plugin Function!! 00213 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00214 LAN_rhk_hwi_pi.description = g_strdup_printf(N_("GXSM HwI LAN_rhk_hwi plugin %s"), VERSION); 00215 return &LAN_rhk_hwi_pi; 00216 } 00217 00218 // Symbol "get_gxsm_hwi_hardware_class" is resolved by dlsym from Gxsm for all HwI type PIs, 00219 // Essential Plugin Function!! 00220 XSM_Hardware *get_gxsm_hwi_hardware_class ( void *data ) { 00221 return LAN_rhk_hwi_hardware; 00222 } 00223 00224 // init-Function 00225 static void LAN_rhk_hwi_init(void) 00226 { 00227 PI_DEBUG (DBG_L2, "LAN_rhk_hwi Plugin Init"); 00228 LAN_rhk_hwi_hardware = new LAN_rhk_hwi_spm (); 00229 } 00230 00231 // about-Function 00232 static void LAN_rhk_hwi_about(void) 00233 { 00234 const gchar *authors[] = { LAN_rhk_hwi_pi.authors, NULL}; 00235 gtk_widget_show(gnome_about_new ( LAN_rhk_hwi_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 // configure-Function 00245 static void LAN_rhk_hwi_configure(void) 00246 { 00247 if(LAN_rhk_hwi_pi.app) 00248 LAN_rhk_hwi_pi.app->message("LAN_rhk_hwi Plugin Configuration"); 00249 } 00250 00251 // cleanup-Function 00252 static void LAN_rhk_hwi_cleanup(void) 00253 { 00254 PI_DEBUG (DBG_L2, "LAN_rhk_hwi Plugin Cleanup"); 00255 delete LAN_rhk_hwi_hardware; 00256 LAN_rhk_hwi_hardware = NULL; 00257 } 00258