si_step_cubecreate.c

00001 /* $Id: si_step_cubecreate.c,v 1.10 2005/10/08 10:34:50 amodigli Exp $
00002  *
00003  * This file is part of the CPL (Common Pipeline Library)
00004  * Copyright (C) 2002 European Southern Observatory
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2005/10/08 10:34:50 $
00023  * $Revision: 1.10 $
00024  * $Name:  $
00025  */
00026 
00027  /****************************************************************
00028   *           Object Data reduction                              *
00029   ****************************************************************/
00030 #include <strings.h>
00031 #include <string.h>
00032 #include <stdio.h>
00033 
00034 #ifdef HAVE_CONFIG_H
00035 #include <config.h>          /* allows the program compilation */
00036 #endif
00037 #include <cxmacros.h>
00038 #include <cxtypes.h>
00039 #include <cxmessages.h>     /* defines message level types */
00040 #include <cpl_memory.h>       /* defines memory allocation functions */
00041 
00042 #include <cpl_parameterlist.h>    /* defines parlist structure */
00043 #include <cpl_msg.h>  /* defines different messaging functions */
00044 
00045 
00046 #include <cpl_recipe.h>     /* recipe plugin definitions */
00047 #include <cpl_plugin.h>     /* memory allocations functions */
00048 #include <cpl_pluginlist.h> /* memory allocations functions */
00049 #include <cpl_frameset.h>   /* defines operations on frames */
00050 #include <sinfoni_general_config.h>
00051 #include <sinfoni_cube_create_config.h>
00052 #include <cubecreate.h>
00053 #include <create_resampled.h>
00054 #include <sinfoni_memory.h>
00055 
00056 
00057 
00058 
00059 static cxint si_step_cubecreate(cpl_parameterlist *, cpl_frameset *);
00060 const char * sinfoni_get_licence(void);
00061 cxint si_step_cubecreate_create(cpl_plugin *plugin);
00062 cxint si_step_cubecreate_exec(cpl_plugin *plugin);
00063 cxint si_step_cubecreate_destroy(cpl_plugin *plugin);
00064 static cxint si_step_cubecreate(cpl_parameterlist *config, cpl_frameset *set);
00065 int cpl_plugin_get_info(cpl_pluginlist *list);
00066 
00067 const char * sinfoni_get_licence(void)
00068 {
00069   return "bla bla";
00070 
00071 }
00072 
00073 
00074 cxint
00075 si_step_cubecreate_create(cpl_plugin *plugin)
00076 {
00077 
00078   /*
00079    * We have to provide the option we accept to the application.
00080    * We need to setup our parameter list and hook it into the recipe
00081    * interface.
00082    */
00083   cpl_recipe *recipe = (cpl_recipe *)plugin;
00084   recipe->parameters = cpl_parameterlist_new();
00085   if(recipe->parameters == NULL) {
00086     return 1;
00087   }
00088 
00089   /*
00090    * Fill the parameter list.
00091    */
00092   sinfoni_general_config_add(recipe->parameters);
00093   sinfoni_cubecreate_config_add(recipe->parameters); 
00094   return 0;
00095 
00096 }
00097 
00098 cxint
00099 si_step_cubecreate_exec(cpl_plugin *plugin)
00100 {
00101  
00102   cpl_recipe *recipe = (cpl_recipe *) plugin;
00103   if(recipe->parameters == NULL) {
00104     return 1;
00105   }
00106   if(recipe->frames == NULL) {
00107     return 1;
00108   }
00109   cpl_error_reset();
00110   return si_step_cubecreate(recipe->parameters, recipe->frames);
00111 
00112 }
00113 
00114 cxint
00115 si_step_cubecreate_destroy(cpl_plugin *plugin)
00116 {
00117   cpl_recipe *recipe = (cpl_recipe *) plugin;
00118   /*
00119    * We just destroy what was created during the plugin initializzation phase
00120    * i.e. the parameter list. The frame set is managed by the application which
00121    * called us, so that we must not touch it.
00122    */
00123 
00124   cpl_parameterlist_delete(recipe->parameters);
00125 
00126   return 0;
00127 
00128 }
00129 
00130 
00131 int
00132 cpl_plugin_get_info(cpl_pluginlist *list)
00133 {
00134 
00135   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00136   cpl_plugin *plugin = &recipe->interface;
00137 
00138   cpl_plugin_init(plugin,
00139           CPL_PLUGIN_API,
00140           SINFONI_BINARY_VERSION,
00141           CPL_PLUGIN_TYPE_RECIPE,
00142           "si_step_cubecreate",
00143           "Cubecreateect data reduction",
00144           "TBD",
00145           "A. Modigliani",
00146           "amodigli@eso.org",
00147           "No license",
00148           si_step_cubecreate_create,
00149           si_step_cubecreate_exec,
00150           si_step_cubecreate_destroy);
00151 
00152   cpl_pluginlist_append(list, plugin);
00153 
00154   return 0;
00155 
00156 }
00157 
00158 
00159 /*
00160  * The actual recipe actually start here.
00161  */
00162 
00163 static cxint
00164 si_step_cubecreate(cpl_parameterlist *config, cpl_frameset *set)
00165 {
00166   const cxchar *_id = "si_step_cubecreate";
00167    char name_s   [FILE_NAME_SZ];
00168   int  ind =0;
00169   cpl_parameter *p;                    
00170 
00171   /* 
00172    cpl_parameterlist_dump(config); 
00173   */
00174      p = cpl_parameterlist_find(config, "sinfoni.cubecreate.method");
00175      strcpy(name_s, cpl_parameter_get_string(p));
00176      cpl_msg_info(_id,"Method=%s\n",name_s);
00177 
00178 
00179     {
00180     if ( 0 == strcmp(name_s,"Normal") )
00181     {
00182             cpl_msg_info(_id,"Running");
00183             if ( -1 == (ind = cubecreate( config, set ) ) )
00184         {
00185             cpl_msg_error(_id,"no: %d\n", ind) ;
00186         return -1 ;
00187         }
00188             else
00189         {
00190           cpl_msg_info(_id,"success");
00191         }
00192     }
00193     else if ( 0 == strcmp (name_s, "Resampled") )
00194     {
00195             cpl_msg_info(_id,"Running");
00196         if ( -1 == (ind = create_resampled( config, set ) ) )
00197         {
00198             cpl_msg_error(_id,"no: %d\n", ind) ;
00199         return -1 ;
00200         }
00201             cpl_msg_info(_id,"success");
00202     }
00203     else
00204     {
00205         cpl_msg_error(_id,"wrong name recipe method given!\n") ;
00206         return -1 ;
00207     }
00208     }    
00209     return 0 ;
00210 
00211 }
00212 
00213 

Generated on Wed Oct 26 13:08:54 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001