si_step_stack.c

00001 /* $Id: si_step_stack.c,v 1.17 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.17 $
00024  * $Name:  $
00025  */
00026 
00027  /****************************************************************
00028   *          Prepare_Stacked_Frames Frames Data Reduction                          *
00029   ****************************************************************/
00030 #include <strings.h>
00031 #include <string.h>
00032 #include <stdio.h>
00033 #include <xmemory.h>
00034 
00035 #ifdef HAVE_CONFIG_H
00036 #include <config.h>          /* allows the program compilation */
00037 #endif
00038 #include <cxmacros.h>
00039 #include <cxtypes.h>
00040 #include <cxmessages.h>     /* defines message level types */
00041 #include <cpl_memory.h>       /* defines memory allocation functions */
00042 
00043 #include <cpl_parameterlist.h>    /* defines parlist structure */
00044 #include <cpl_msg.h>  /* defines different messaging functions */
00045 #include <cpl_error.h>
00046 
00047 #include <cpl_recipe.h>     /* recipe plugin definitions */
00048 #include <cpl_plugin.h>     /* memory allocations functions */
00049 #include <cpl_pluginlist.h> /* memory allocations functions */
00050 #include <cpl_frameset.h>   /* defines operations on frames */
00051 #include <sinfoni_pro_types.h>
00052 #include <sinfoni_tpl_dfs.h>
00053 #include <sinfoni_general_config.h>
00054 #include <sinfoni_prepare_stacked_frames_config.h>
00055 #include <prepare_stacked_frames.h>
00056 #include <sinfoni_globals.h>
00057 #include <sinfoni_memory.h>
00058 
00059 static cxint si_step_stack(cpl_parameterlist *, cpl_frameset *);
00060 const char * sinfoni_get_licence(void);
00061 cxint si_step_stack_create(cpl_plugin *plugin);
00062 cxint si_step_stack_exec(cpl_plugin *plugin);
00063 cxint si_step_stack_destroy(cpl_plugin *plugin);
00064 static cxint si_step_stack(cpl_parameterlist *config, cpl_frameset *set);
00065 int cpl_plugin_get_info(cpl_pluginlist *list);
00066 
00067 
00068 const char * sinfoni_get_licence(void)
00069 {
00070   return "bla bla";
00071 
00072 } 
00073 
00074  /*
00075   *
00076   * Create the recipe instance, i.e. setup the parameter list for this
00077   * recipe and make it available to the application using the interface.
00078   *
00079   */
00080 
00081 
00082 cxint
00083 si_step_stack_create(cpl_plugin *plugin)
00084 {
00085 
00086   /*
00087    * We have to provide the option we accept to the application.
00088    * We need to setup our parameter list and hook it into the recipe
00089    * interface.
00090    */
00091   cpl_recipe *recipe = (cpl_recipe *)plugin;
00092   recipe->parameters = cpl_parameterlist_new();
00093   if(recipe->parameters == NULL) {
00094     return 1;
00095   }
00096 
00097   /*
00098    * Fill the parameter list.
00099    */
00100   sinfoni_prepare_stacked_frames_config_add(recipe->parameters);
00101   
00102   return 0;
00103 
00104 }
00105 
00106 cxint
00107 si_step_stack_exec(cpl_plugin *plugin)
00108 {
00109 
00110   cpl_recipe *recipe = (cpl_recipe *) plugin;
00111   if(recipe->parameters == NULL) {
00112     return 1;
00113   }
00114   if(recipe->frames == NULL) {
00115     return 1;
00116   }
00117   cpl_error_reset();
00118   return si_step_stack(recipe->parameters, recipe->frames);
00119 
00120 }
00121 
00122 cxint
00123 si_step_stack_destroy(cpl_plugin *plugin)
00124 {
00125 
00126   cpl_recipe *recipe = (cpl_recipe *) plugin;
00127   /*
00128    * We just destroy what was created during the plugin initializzation phase
00129    * i.e. the parameter list. The frame set is managed by the application which
00130    * called us, so that we must not touch it.
00131    */
00132   cpl_parameterlist_delete(recipe->parameters);
00133 
00134   return 0;
00135 
00136 }
00137 
00138 int
00139 cpl_plugin_get_info(cpl_pluginlist *list)
00140 {
00141 
00142   cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00143   cpl_plugin *plugin = &recipe->interface;
00144 
00145 
00146   cpl_plugin_init(plugin,
00147           CPL_PLUGIN_API,
00148           SINFONI_BINARY_VERSION,
00149           CPL_PLUGIN_TYPE_RECIPE,
00150           "si_step_stack",
00151           "Frames stacking",
00152           "TBD",
00153           "A. Modigliani",
00154           "amodigli@eso.org",
00155           "No license",
00156           si_step_stack_create,
00157           si_step_stack_exec,
00158           si_step_stack_destroy);
00159 
00160   cpl_pluginlist_append(list, plugin);
00161 
00162   return 0;
00163 
00164 }
00165 
00166 
00167 /*
00168  * The actual recipe actually start here.
00169  */
00170 
00171 static cxint
00172 si_step_stack(cpl_parameterlist *config, cpl_frameset *set)
00173 {
00174  
00175   const char *_id = "si_step_stack";
00176   int  ind =0; 
00177   fake* fk=fake_new();
00178 
00179   if(sinfoni_dfs_set_groups(set)) {
00180 
00181     cpl_msg_error(_id, "Cannot indentify RAW and CALIB frames") ;
00182     return -1;
00183 
00184   }
00185 
00186     strcpy(fk->pro_class,"DEFAULT");
00187 
00188     {
00189     cpl_msg_info (_id,"running") ; 
00190         if ( -1 == (ind = prepare_stacked_frames(config, set, PRO_STACKED, 0, fk ) ) )
00191         {
00192         cpl_msg_error(_id," no: %d\n", ind) ;
00193         return -1 ;
00194     }
00195     cpl_msg_info (_id,"success") ; 
00196     }    
00197       fake_delete(fk);
00198     return 0 ;
00199   
00200 
00201 }

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