fors_img_screen_flat.c

00001 /* $Id: fors_img_screen_flat.c,v 1.7 2010/09/14 07:38:16 cizzo Exp $
00002  *
00003  * This file is part of the FORS Data Reduction Pipeline
00004  * Copyright (C) 2002-2010 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program 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
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 /*
00022  * $Author: cizzo $
00023  * $Date: 2010/09/14 07:38:16 $
00024  * $Revision: 1.7 $
00025  * $Name: fors-4_8_6 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 #include <fors_img_screen_flat_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_utils.h>
00035 
00036 #include <cpl.h>
00037 
00038 static int fors_img_screen_flat_create(cpl_plugin *);
00039 static int fors_img_screen_flat_exec(cpl_plugin *);
00040 static int fors_img_screen_flat_destroy(cpl_plugin *);
00041 
00062 int cpl_plugin_get_info(cpl_pluginlist *list)
00063 {
00064     cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe );
00065     cpl_plugin *plugin = &recipe->interface;
00066 
00067     if (FORS_BINARY_VERSION != fors_get_version_binary())
00068     {
00069         cpl_msg_error(cpl_func, 
00070               "I am fors_img_screen_flat version %d, but I am linking "
00071               "against the FORS library version %d. "
00072               "This will not work. "
00073               "Please remove all previous installations "
00074               "of the " PACKAGE_NAME " and try again.",
00075               FORS_BINARY_VERSION, fors_get_version_binary());
00076         return 1;
00077     }
00078 
00079     cpl_plugin_init(plugin,
00080                     CPL_PLUGIN_API,
00081                     FORS_BINARY_VERSION,
00082                     CPL_PLUGIN_TYPE_RECIPE,
00083                     fors_img_screen_flat_name,
00084                     fors_img_screen_flat_description_short,
00085                     fors_img_screen_flat_description,
00086                     fors_img_screen_flat_author,
00087                     fors_img_screen_flat_email,
00088                     fors_license,
00089                     fors_img_screen_flat_create,
00090                     fors_img_screen_flat_exec,
00091                     fors_img_screen_flat_destroy);
00092 
00093     cpl_pluginlist_append(list, plugin);
00094     
00095     return 0;
00096 }
00097 
00098 
00109 static int fors_img_screen_flat_create(cpl_plugin *plugin)
00110 {
00111     cpl_recipe    *recipe;
00112 
00113     if (cpl_error_get_code() != CPL_ERROR_NONE) {
00114         cpl_msg_error(cpl_func, 
00115                       "CPL error code is set (%s), "
00116                       "refusing to create recipe fors_img_screen_flat", 
00117                       cpl_error_get_message());
00118         return 1;
00119     }
00120     
00121     /* 
00122      * Check that the plugin is part of a valid recipe 
00123      */
00124 
00125     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00126         recipe = (cpl_recipe *)plugin;
00127     }
00128     else {
00129         return 1;
00130     }
00131 
00132     /* 
00133      * Create the parameters list in the cpl_recipe object 
00134      */
00135 
00136     recipe->parameters = cpl_parameterlist_new(); 
00137     
00138     fors_img_screen_flat_define_parameters(recipe->parameters);
00139 
00140     if (cpl_error_get_code() != CPL_ERROR_NONE) {
00141         cpl_msg_error(cpl_func, 
00142                       "Could not create fors_img_screen_flat parameters");
00143         return 1;
00144     }
00145         
00146     return 0;
00147 }
00148 
00149 
00158 static int fors_img_screen_flat_exec(cpl_plugin *plugin)
00159 {
00160     cpl_recipe *recipe;
00161     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00162 
00163     if (cpl_error_get_code() != CPL_ERROR_NONE) {
00164         cpl_msg_error(cpl_func, 
00165                       "CPL error code is set (%s), "
00166                       "refusing to execute recipe fors_img_screen_flat", 
00167                       cpl_error_get_message());
00168         return 1;
00169     }
00170     
00171     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00172         recipe = (cpl_recipe *)plugin;
00173     }
00174     else {
00175         return 1;
00176     }
00177 
00178     if (recipe->frames == NULL) {
00179         cpl_msg_error(cpl_func, 
00180                       "Null frameset");
00181         return 1;
00182     }
00183 
00184     if (recipe->parameters == NULL) {
00185         cpl_msg_error(cpl_func, 
00186                       "Null parameter list");
00187         return 1;
00188     }
00189 
00190     fors_begin(recipe->frames,
00191                fors_img_screen_flat_description_short);
00192 
00193     fors_img_screen_flat(recipe->frames, recipe->parameters);
00194 
00195     return fors_end(recipe->frames, initial_errorstate);
00196 }
00197 
00198 
00207 static int fors_img_screen_flat_destroy(cpl_plugin *plugin)
00208 {
00209     cpl_recipe *recipe;
00210     
00211     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00212         recipe = (cpl_recipe *)plugin;
00213     }
00214     else {
00215         return -1;
00216     }
00217 
00218     cpl_parameterlist_delete(recipe->parameters); 
00219 
00220     return 0;
00221 }
00222 

Generated on Fri Mar 4 09:46:00 2011 for FORS Pipeline Reference Manual by  doxygen 1.4.7