/*---------------------------------------------------------------------------- File name : lwjitter.c Author : N. Devillard Created on : July 2000 Description : Main module for lwjitter ---------------------------------------------------------------------------*/ /* $Id: lwjitter.c,v 1.5 2001/01/24 14:12:18 ndevilla Exp $ $Author: ndevilla $ $Date: 2001/01/24 14:12:18 $ $Revision: 1.5 $ */ static char cvsId[] = "@(#) $Id: lwjitter.c,v 1.5 2001/01/24 14:12:18 ndevilla Exp $" ; /*---------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include #include #include "eclipse.h" #include "lwjit_defs.h" #include "lwjit_ini.h" #include "lwjit_engine.h" /*---------------------------------------------------------------------------- Defines ---------------------------------------------------------------------------*/ #define OPT_FILE 1000 #define OPT_GENERATE 1001 #define OPT_TIMING 1002 #define OPT_IN 2000 #define OPT_OUT 2001 #define OPT_CALIB 2002 /*---------------------------------------------------------------------------- Functions and variables private to this module ---------------------------------------------------------------------------*/ static void usage(char *pname) ; static char prog_desc[] = "isaac long wavelength jitter imaging"; /*--------------------------------------------------------------------------- Main code ---------------------------------------------------------------------------*/ int main(int argc, char *argv[]) { char ini_name[FILENAMESZ]; int gen_flag ; int timing_flag ; long total_inpix ; int c ; char name_i[FILENAMESZ] ; char name_o[FILENAMESZ] ; char name_c[FILENAMESZ] ; /* Initialize ini name to default value */ strcpy(ini_name, "lwjitter.ini"); gen_flag = 0 ; timing_flag = 0 ; strcpy(name_i, "framelist.ascii"); strcpy(name_o, "lwjit_result"); name_c[0] = 0 ; /* Command-line argument loop */ while (1) { int option_index = 0 ; static struct option long_options[] = { /* Long option names */ {"license", 0, 0, OPT_LICENSE}, {"version", 0, 0, OPT_VERSION}, {"file", 1, 0, OPT_FILE}, {"help", 0, 0, OPT_HELP}, {"generate",0, 0, OPT_GENERATE}, {"time", 0, 0, OPT_TIMING}, {"in", 1, 0, OPT_IN}, {"out", 1, 0, OPT_OUT}, {"calib", 1, 0, OPT_CALIB}, {0, 0, 0, 0} } ; c = getopt_long(argc, argv, "Lc:f:ghi:o:t", long_options, &option_index) ; if (c==-1) break ; switch(c) { /* Standard option: display license undocumented option */ case OPT_LICENSE: case 'L': eclipse_display_license() ; return 0 ; /* Standard option: give version number */ case OPT_VERSION: print_eclipse_version() ; printf("%s\n", cvsId); return 0 ; case OPT_HELP: case 'h': usage(argv[0]) ; break ; /* Local options */ /* name of the .ini file */ case OPT_FILE: case 'f': strcpy(ini_name, optarg) ; break ; /* generate a default .ini file */ case OPT_GENERATE: case 'g': gen_flag = 1 ; break ; /* timing flag: use it to get an evaluation of CPU time */ case OPT_TIMING: case 't': timing_flag = 1 ; break ; /* Input list name */ case OPT_IN: case 'i': strcpy(name_i, optarg); break ; /* Output base name */ case OPT_OUT: case 'o': strcpy(name_o, optarg); break ; /* Calibration file list name */ case OPT_CALIB: case 'c': strcpy(name_c, optarg); break ; /* Any other unrecognized option prints the help message */ default: usage(argv[0]) ; break ; } } /* Dis bonjour a la dame */ hello_world(argv[0], prog_desc); /* Initialize eclipse environment */ eclipse_init() ; if (gen_flag) { /* Generate a default ini file */ if (lwjit_ini_generate(ini_name, name_i, name_o, name_c)==0) { fprintf(stderr, "ini file [%s] has been generated\n", ini_name); } return 0 ; } else { /* Launch the jitter engine, timing is not mandatory */ if (timing_flag) eclipse_cpu_timing(START_CLOCK, -1) ; /* MAIN CALL TO THE JITTER ENGINE */ total_inpix = lwjit_engine(ini_name); if (timing_flag) { printf("\n"); printf("performance:\n"); printf("\t (s)\t (us)\t(kpix/s)\n") ; eclipse_cpu_timing(STOP_CLOCK, total_inpix) ; } else { if (total_inpix>0) e_comment(0, "%ld pixels processed in input", total_inpix); } } if (debug_active()) xmemory_status() ; return 0 ; } /* This function gives the usage for the program */ static void usage(char *pname) { hello_world(pname, prog_desc) ; printf("\n") ; printf("use : %s [flags] [options]\n", pname) ; printf("flags are :\n\n") ; printf("\t-g or --generate : generate a .ini file\n") ; printf("\t-t or --time : estimate used CPU time\n") ; printf("\t-h or --help : get this help\n") ; printf("\noptions are :\n\n") ; printf("\t-f or --file \n") ; printf("\tto specify which .ini file to work on (default: jitter.ini)\n"); printf("\n"); printf("following options are only valid with -g or --generate:\n"); printf("\t-i or --in provide input file name\n"); printf("\t-o or --out provide output file name\n"); printf("\t-c or --calib provide calibration file name\n"); printf("\n\n") ; exit(0) ; }