コード例 #1
0
ファイル: odometry.c プロジェクト: doebrowsk/tank-chair
/**
 * Creates the ini file for the odom and initializes the odom values to initial values
 */
void Odometry_Boot(Sensor * sensor,SensorVariable * start)
{
	/* MAKE THESE GLOBAL*/

	LOG.ODOMETRY("BOOTING THE ODOMETERY SENSOR");
	if(fileExists("config/odometry.ini"))
	{
		dictionary* config = iniparser_load("config/odometry.ini");
		Odometry_leftWheelMeterPerTick = iniparser_getdouble(config,"WheelEncoderConstant:MeterPerTickLeft",0);
		Odometry_rightWheelMeterPerTick = iniparser_getdouble(config,"WheelEncoderConstant:MeterPerTickRight",0);
		Odometry_trackInMeters = iniparser_getdouble(config,"DistanceBetweenWheels:track",0);
		Odometry_cvarL = iniparser_getdouble(config,"Variance:LeftWheel",.000049871);
		Odometry_cvarR = iniparser_getdouble(config,"Variance:RightWheel",.000073805);
		iniparser_freedict(config);
		LOG.ODOMETRY("Odometry Ini file loaded");
	}
	else
	{
		LOG.ERR("odomentry.ini was not found");
	}

	matrix Variance = Matrix_Create(2,2);
	Variance = Matrix_SetValue(Variance,1,1,.01);
	Variance = Matrix_SetValue(Variance,2,2,.01);
	sensor->state->Variance=Variance;
	sensor->state->State= Matrix_Create(3,1);
	sensor->H = Matrix_Create(2,6);
	sensor->H = Matrix_SetValue(sensor->H,1,4,PSOUpdateRateInS);
	sensor->H = Matrix_SetValue(sensor->H,1,5,Odometry_trackInMeters*PSOUpdateRateInS/2.0);
	sensor->H = Matrix_SetValue(sensor->H,2,4,PSOUpdateRateInS);
	sensor->H = Matrix_SetValue(sensor->H,2,5,-Odometry_trackInMeters*PSOUpdateRateInS/2.0);

	Odometry_rightWheelTicks=Microprocessor->getRightWheelTicks();
	Odometry_leftWheelTicks=Microprocessor->getLeftWheelTicks();
}
コード例 #2
0
void parseFile()
{
	char key[MAX_KEY_SIZE];
	int i;
	taskCount = iniparser_getnsec(file);
	tasks = (iniTask*) malloc(sizeof(iniTask) * taskCount);
	
	for(i = 0; i < taskCount; ++i) {
		sprintf(tasks[i].secname, "%s", iniparser_getsecname(file, i));
		
		sprintf(key, "%s:%s", tasks[i].secname, T_E_MAX);
		tasks[i].tEMax = iniparser_getdouble(file, key, 0);
		
		sprintf(key, "%s:%s", tasks[i].secname, T_D_MAX);
		tasks[i].tDMax = iniparser_getdouble(file, key, 0);
		
		sprintf(key, "%s:%s", tasks[i].secname, T_P_MIN);
		tasks[i].tPMin = iniparser_getdouble(file, key, 0);
		
		sprintf(key, "%s:%s", tasks[i].secname, T_B);
		tasks[i].tB = iniparser_getdouble(file, key, 0);
		
		sprintf(key, "%s:%s", tasks[i].secname, PRIORITY);
		tasks[i].prio = iniparser_getint(file, key, 0);
	}
}
コード例 #3
0
double InitParser::get_double(const string& key) const
{
	double d = iniparser_getdouble(dico, key.c_str(), -11111.111111356);
	// To be sure :) (bugfree)
	if (d==-11111.111111356) {
		d = iniparser_getdouble(dico, key.c_str(), 0.);
		if (d==0.) {
			cerr << "WARNING : Can't find the configuration key \"" << key << "\", default 0 value returned\n";
		}
	}
	return d;
}
コード例 #4
0
double InitParser::get_double(const string& key) const
{
	double d = iniparser_getdouble(dico, key.c_str(), -11111.111111356);
	// To be sure :) (bugfree)
	if (d==-11111.111111356) {
		d = iniparser_getdouble(dico, key.c_str(), 0.);
		if (d==0.) {
			//~ cerr << "WARNING : Can't find the configuration key \"" << key << "\", default 0 value returned\n";
			Log.write("Init_parser : can't find the configuration key \"" + key + "\", default 0 value returned", cLog::eLOG_TYPE_WARNING);
		}
	}
	return d;
}
コード例 #5
0
ファイル: ini_config.c プロジェクト: gozfree/libraries
static double ini_get_double(struct config *c, ...)
{
    dictionary *ini = (dictionary *)c->priv;
    char **key = NULL;
    char *tmp = NULL;
    double ret;
    int cnt = 0;
    va_list ap;
    va_start(ap, c);
    tmp = va_arg(ap, char *);
    while (tmp) {//last argument must be NULL
        cnt++;
        key = (char **)realloc(key, cnt*sizeof(char**));
        key[cnt-1] = tmp;
        tmp = va_arg(ap, char *);
    }
    va_end(ap);
    switch (cnt) {
    case 1:
        ret = iniparser_getdouble(ini, key[0], -1.0);
        break;
    default:
        break;
    }
    free(key);
    return ret;
}
コード例 #6
0
float MSG_db1_data::get_channel_Calibration_value_calibrated( int count )
{
  if (! is_data_ok( )) return 0;
  if (count < 0 && count >= ncalval) return 0.0;
  snprintf(infochuse, INFOCHLEN, "%s:%s(%d)", get_channel_INFO_variable( ),
           get_channel_INFO_variable_code( ), count);
  return (float) iniparser_getdouble(Calibration, infochuse, 0.0);
}
コード例 #7
0
ファイル: config.c プロジェクト: sanyaade-teachings/iouyap
int
ini_getdouble (double *value, char *key)
{
    if (!ini_find (key))
        return 0;
    *value = iniparser_getdouble (yap_config, key, -1.0);
    return 1;
}
コード例 #8
0
double ReadDouble( Props *p, const char *name, double def )
{
	if( p != NULL )
	{
		return iniparser_getdouble( p->p_Dict, name, def );
	}

	return 0;
}
コード例 #9
0
int parse_ini_file(char * ini_name)
{
	dictionary	*	ini=NULL ;
	dictionary	*	test_dict=NULL;	
	/* Some temporary variables to hold query results */
	int				b ;
	int				i ;
	double			d ;
	char		*	s ;
	char		*out_str=NULL;
        fprintf(stderr,"Loading...\n");
	ini = iniparser_load(ini_name);
	if (ini==NULL) {
		fprintf(stderr, "cannot parse file: %s\n", ini_name);
		return -1 ;
	}
        fprintf(stderr,"Dumping...\n");
	iniparser_dump_ini(ini, stderr);
        fprintf(stdout,"To_stringi...\n");
	out_str=iniparser_to_string(ini);
        fprintf(stdout,"\nstring:\n");
        fprintf(stdout,"%s\n",out_str);
        fprintf(stdout,"From_string\n");
	test_dict=iniparser_load_from_string(test_dict,out_str);
        fprintf(stderr,"Dict from string:\n");
	iniparser_dump_ini(test_dict, stderr);

	/* Get pizza attributes */
	printf("Pizza:\n");

	b = iniparser_getboolean(ini, "pizza:ham", -1);
	printf("Ham:       [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:mushrooms", -1);
	printf("Mushrooms: [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:capres", -1);
	printf("Capres:    [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:cheese", -1);
	printf("Cheese:    [%d]\n", b);

	/* Get wine attributes */
	printf("Wine:\n");
	s = iniparser_getstring(ini, "wine:grape", NULL);
    printf("Grape:     [%s]\n", s ? s : "UNDEF");
	
    i = iniparser_getint(ini, "wine:year", -1);
    printf("Year:      [%d]\n", i);

	s = iniparser_getstring(ini, "wine:country", NULL);
    printf("Country:   [%s]\n", s ? s : "UNDEF");
	
    d = iniparser_getdouble(ini, "wine:alcohol", -1.0);
    printf("Alcohol:   [%g]\n", d);

	iniparser_freedict(ini);
	return 0 ;
}
コード例 #10
0
ファイル: config.cpp プロジェクト: kampe004/compaction
double ConfigParser::getDouble(const char* name, bool required, double minval, double maxval, double defval){
   const char * rtnnam = "ConfigParser::getDouble()";
   double tmp;
   if (required){
      double missval = -9999.;
      tmp = iniparser_getdouble(_dict, name, missval);
      if (doubles_equal(tmp, missval)){
         logger << "ERROR: " << rtnnam << " required value not found: " << name << std::endl;
         std::abort();
      }
   } else {
      tmp = iniparser_getdouble(_dict, name, defval);
   }
   if (tmp < minval || tmp > maxval) {
      logger << "ERROR: " << rtnnam << " value out of bounds " << name << std::endl;
      logger << "ERROR: " << rtnnam << " val = " << tmp << ", minval = " << minval << ", maxval = " << maxval << std::endl;
      std::abort();
   }
   logger << "INFO: " << name << " = " << tmp << std::endl;
   return tmp;
}
コード例 #11
0
ファイル: compass.c プロジェクト: doebrowsk/tank-chair
/**
 * Initliazes the Compass with the .ini file 
 */
void Compass_Boot(Sensor * sensor,SensorVariable * start)
{
	LOG.COMPASS("Compassing Booting");
	if(fileExists("config/compass.ini"))
	{
		dictionary* config = iniparser_load("config/compass.ini");
		COMPASS_Variance = iniparser_getdouble(config,"Variance:Variance",0.523598776);
		COMPASS_Declination= iniparser_getdouble(config,"Declination:Declination",-7.5);
		iniparser_freedict(config);
		LOG.COMPASS("compass.ini file loaded");
	}
	else
	{
		LOG.COMPASS("compass.ini was not found");
	}
	sensor->H = Matrix_Create(1,5);
	sensor->H = Matrix_SetValue(sensor->H,1,3,1);
	sensor->state->State= Matrix_Create(1,1);
	sensor->state->Variance = Matrix_Create(1,1);
	LOG.COMPASS("Compassing Booted");
}
コード例 #12
0
int parse_ini_file(char * ini_name)
{
	dictionary	*	ini ;

	/* Some temporary variables to hold query results */
	int				b ;
	int				i ;
	double			d ;
	char		*	s ;

	ini = iniparser_load(ini_name);
	if (ini==NULL) {
		fprintf(stderr, "cannot parse file: %s\n", ini_name);
		return -1 ;
	}
	iniparser_dump(ini, stderr);

	/* Get pizza attributes */
	printf("Pizza:\n");

	b = iniparser_getboolean(ini, "pizza:ham", -1);
	printf("Ham:       [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:mushrooms", -1);
	printf("Mushrooms: [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:capres", -1);
	printf("Capres:    [%d]\n", b);
	b = iniparser_getboolean(ini, "pizza:cheese", -1);
	printf("Cheese:    [%d]\n", b);

	/* Get wine attributes */
	printf("Wine:\n");
	s = iniparser_getstring(ini, "wine:grape", NULL);
    printf("Grape:     [%s]\n", s ? s : "UNDEF");
	
    i = iniparser_getint(ini, "wine:year", -1);
    printf("Year:      [%d]\n", i);

	s = iniparser_getstring(ini, "wine:country", NULL);
    printf("Country:   [%s]\n", s ? s : "UNDEF");
	
    d = iniparser_getdouble(ini, "wine:alcohol", -1.0);
    printf("Alcohol:   [%g]\n", d);

	iniparser_freedict(ini);
	return 0 ;
}
コード例 #13
0
ファイル: scheduler_DSFQ.c プロジェクト: xuyiqi/vPFS
int dsfq_load_data_from_config (dictionary * dict)
{

	dsfq_depth=iniparser_getint(dict, "DSFQ:depth" ,dsfq_depth);
	dsfq_proxy_listen_port=iniparser_getint(dict,"DSFQ:listen_port",dsfq_proxy_listen_port);
	dsfq_threshold=iniparser_getint(dict, "DSFQ:threshold", dsfq_threshold);
	dsfq_min_share=iniparser_getdouble(dict, "DSFQ:min_share", dsfq_min_share);

	if (dsfq_depth<=0)
	{
		fprintf(stderr, "wrong depth\n");
		exit(-1);

	}
	if (dsfq_proxy_listen_port<=1024 || dsfq_proxy_listen_port>65535)
	{
		fprintf(stderr, "wrong port\n");
		exit(-1);

	}
	if (dsfq_proxy_listen_port==active_port)
	{
		fprintf(stderr, "conflict port with proxy\n");
		exit(-1);
	}
	if (dsfq_threshold<=0)
	{
		fprintf(stderr, "wrong threshold\n");
		exit(-1);

	}
	if (dsfq_min_share<=0.0001f)
	{
		fprintf(stderr, "wrong minimum share\n");
		exit(-1);

	}
	fprintf(stderr,"DSFQ using depth:%i\n",dsfq_depth);
	fprintf(stderr,"DSFQ using port:%i\n",dsfq_proxy_listen_port);
	dsfq_threshold*=1024;
	fprintf(stderr,"DSFQ using threshold:%i\n",dsfq_threshold);
	fprintf(stderr,"DSFQ using min_share:%f for HYBRID_DSFQ\n",dsfq_min_share);
}
コード例 #14
0
ファイル: et_params.c プロジェクト: kohr-h/ETreco
void
EtParams_assign_from_file (EtParams *params, const char *fname_params)
{
  double dtmp;
  dictionary *dict;

  CAPTURE_NULL_VOID (params);
  CAPTURE_NULL_VOID (fname_params);

  if ((dict = iniparser_load (fname_params)) == NULL)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Unable to read parameters from %s.", fname_params);
      return;
    }


  /* GEOMETRY */

  if ((dtmp = iniparser_getdouble (dict, "optics:magnification", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'magnification' not found in %s.", fname_params);
      return;
    }

  params->magnification = (float) dtmp;
  

  /* CTF */

  /* Ignore CTF if acc_voltage is zero or not present */
  if ((dtmp = iniparser_getdouble (dict, "electronbeam:acc_voltage", 0.0)) == 0.0)
    {
      use_ctf_flag = 0;
      iniparser_freedict (dict);
      return;
    }

  use_ctf_flag = 1;
  params->acc_voltage = (float) dtmp * ONE_KILOVOLT;

  if ((dtmp = iniparser_getdouble (dict, "electronbeam:energy_spread", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'energy_spread' not found in %s.", 
        fname_params);
      return;
    }

  params->energy_spread = (float) dtmp;

  if ((dtmp = iniparser_getdouble (dict, "optics:cs", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'cs' not found in %s.", fname_params);
      return;
    }

  params->cs = (float) dtmp * ONE_MILLIMETER;

  if ((dtmp = iniparser_getdouble (dict, "optics:cc", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'cc' not found in %s.", fname_params);
      return;
    }

  params->cc = (float) dtmp * ONE_MILLIMETER;

  if ((dtmp = iniparser_getdouble (dict, "optics:aperture", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'aperture' not found in %s.", fname_params);
      return;
    }

  params->aperture = (float) dtmp * ONE_MICROMETER;

  if ((dtmp = iniparser_getdouble (dict, "optics:focal_length", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'focal_length' not found in %s.", fname_params);
      return;
    }

  params->focal_length = (float) dtmp * ONE_MILLIMETER;

  if ((dtmp = iniparser_getdouble (dict, "optics:cond_ap_angle", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'cond_ap_angle' not found in %s.", fname_params);
      return;
    }

  params->cond_ap_angle = (float) dtmp * ONE_MILLIRADIAN;

  if ((dtmp = iniparser_getdouble (dict, "optics:defocus_nominal", -1.0)) == -1.0)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'defocus_nominal' not found in %s.", fname_params);
      return;
    }

  params->defocus_nominal = (float) dtmp * ONE_MICROMETER;

  /* If not found in config file, set to predefined ACR */
  params->acr = (float) iniparser_getdouble (dict, "volume:famp", ACR);

  /* The MTF parameters all have default values */

  use_mtf_flag = 1;
  
  params->mtf_a     = iniparser_getdouble (dict, "detector:mtf_a", 0.0);
  params->mtf_b     = iniparser_getdouble (dict, "detector:mtf_b", 0.0);
  params->mtf_c     = iniparser_getdouble (dict, "detector:mtf_c", 1.0);
  params->mtf_alpha = iniparser_getdouble (dict, "detector:mtf_alpha", 0.0);
  params->mtf_beta  = iniparser_getdouble (dict, "detector:mtf_beta", 0.0);
  params->mtf_p     = iniparser_getint (dict, "detector:mtf_p", 1);  
  params->mtf_q     = iniparser_getint (dict, "detector:mtf_q", 1);  

  /* If a and b are zero, the MTF collapses to a constant. This means 'no MTF'. */
  if ((params->mtf_a == 0.0) && (params->mtf_b == 0.0))
    use_mtf_flag = 0;
   

  iniparser_freedict (dict);


  /* Derived parameters */

  /* Compute relativistic wave number (unit: [1/nm]) */

  /* momentum * c [eV] */
  dtmp = sqrtf (params->acc_voltage * params->acc_voltage + 2 * params->acc_voltage * EL_REST_ENERGY); 
  params->wave_number = (float) 2 * M_PI * dtmp / HC;


  /* Compute constant derived from cc (unit: [nm]) */
  dtmp = 1.0 / (2 * EL_REST_ENERGY); // some factor
  params->cc1 = (float) (1 + 2 * dtmp * params->acc_voltage) 
                / (params->acc_voltage * (1 + dtmp * params->acc_voltage)) * params->cc;

  /* Compute cutoff radius due to aperture */
  params->aper_cutoff = (params->wave_number * params->aperture) / params->focal_length;

  return;
}
コード例 #15
0
float MSG_db1_data::get_INFO_schedule_elevation( )
{
  if (! is_data_ok( )) return 0;
  return (float) iniparser_getdouble(INFO, "Schedule:Elevation", 90.0);
}
コード例 #16
0
ファイル: Config.hpp プロジェクト: huangqundl/LD-Sketch
 inline double getdouble(const char* key, double notfound) {
     return iniparser_getdouble(dict_, strconcat(section_name_, key), notfound);
 }
コード例 #17
0
int 
mm_player_ini_load(void)
{
	static gboolean loaded = FALSE;
	dictionary * dict = NULL;
	gint idx = 0;

	if ( loaded )
		return MM_ERROR_NONE;

	dict = NULL;

	/* disabling ini parsing for launching */
#if 1 //debianize
	/* get player ini status because system will be crashed 
	 * if ini file is corrupted. 
	 */
	/* FIXIT : the api actually deleting illregular ini. but the function name said it's just checking. */
	__mm_player_ini_check_ini_status();

	/* first, try to load existing ini file */
	dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);

	/* if no file exists. create one with set of default values */
	if ( !dict )
	{
		#if 0
		debug_log("No inifile found. player will create default inifile.\n");
		if ( FALSE == __generate_default_ini() )
		{	
			debug_warning("Creating default inifile failed. Player will use default values.\n");
		}
		else
		{
			/* load default ini */
			dict = iniparser_load(MM_PLAYER_INI_DEFAULT_PATH);	
		}
		#else
		debug_log("No inifile found. \n");

		return MM_ERROR_FILE_NOT_FOUND;
		#endif
	}
#endif

	/* get ini values */
	memset( &g_player_ini, 0, sizeof(mm_player_ini_t) );

	if ( dict ) /* if dict is available */
	{
		/* general */
		g_player_ini.use_decodebin = iniparser_getboolean(dict, "general:use decodebin", DEFAULT_USE_DECODEBIN);
		g_player_ini.disable_segtrap = iniparser_getboolean(dict, "general:disable segtrap", DEFAULT_DISABLE_SEGTRAP);
		g_player_ini.skip_rescan = iniparser_getboolean(dict, "general:skip rescan", DEFAULT_SKIP_RESCAN);
		g_player_ini.video_surface = DEFAULT_VIDEO_SURFACE;
		g_player_ini.generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
		g_player_ini.provide_clock= iniparser_getboolean(dict, "general:provide clock", DEFAULT_PROVIDE_CLOCK);
		g_player_ini.live_state_change_timeout = iniparser_getint(dict, "general:live state change timeout", DEFAULT_LIVE_STATE_CHANGE_TIMEOUT);
		g_player_ini.localplayback_state_change_timeout = iniparser_getint(dict, "general:localplayback state change timeout", DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT);
		g_player_ini.eos_delay = iniparser_getint(dict, "general:eos delay", DEFAULT_EOS_DELAY);
		g_player_ini.async_start = iniparser_getboolean(dict, "general:async start", DEFAULT_ASYNC_START);
		g_player_ini.multiple_codec_supported = iniparser_getboolean(dict, "general:multiple codec supported", DEFAULT_MULTIPLE_CODEC_SUPPORTED);

		g_player_ini.delay_before_repeat = iniparser_getint(dict, "general:delay before repeat", DEFAULT_DELAY_BEFORE_REPEAT);

		MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_x, "general:videosink element x", DEFAULT_VIDEOSINK_X);
		MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_evas, "general:videosink element evas", DEFAULT_VIDEOSINK_EVAS);
		MMPLAYER_INI_GET_STRING( g_player_ini.videosink_element_fake, "general:videosink element fake", DEFAULT_VIDEOSINK_FAKE);
		MMPLAYER_INI_GET_STRING( g_player_ini.name_of_drmsrc, "general:drmsrc element", DEFAULT_DRMSRC );
		MMPLAYER_INI_GET_STRING( g_player_ini.name_of_audiosink, "general:audiosink element", DEFAULT_AUDIOSINK );
		MMPLAYER_INI_GET_STRING( g_player_ini.name_of_video_converter, "general:video converter element", DEFAULT_VIDEO_CONVERTER );

		__get_string_list( (gchar**) g_player_ini.exclude_element_keyword, 
			iniparser_getstring(dict, "general:element exclude keyword", DEFAULT_EXCLUDE_KEYWORD));

		MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[0], "general:gstparam1", DEFAULT_GST_PARAM );
		MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[1], "general:gstparam2", DEFAULT_GST_PARAM );
		MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[2], "general:gstparam3", DEFAULT_GST_PARAM );
		MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[3], "general:gstparam4", DEFAULT_GST_PARAM );
		MMPLAYER_INI_GET_STRING( g_player_ini.gst_param[4], "general:gstparam5", DEFAULT_GST_PARAM );

		/* audio filter (Preset)*/
		g_player_ini.use_audio_filter_preset = iniparser_getboolean(dict, "sound effect:audio filter preset", DEFAULT_USE_AUDIO_FILTER_PRESET);
		if (g_player_ini.use_audio_filter_preset)
		{
			MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_preset_list, MM_AUDIO_FILTER_PRESET_NUM,
					"sound effect:audio filter preset list", DEFAULT_AUDIO_FILTER_PRESET_LIST );
			MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_preset_earphone_only_list, MM_AUDIO_FILTER_PRESET_NUM,
					"sound effect:audio filter preset earphone only", DEFAULT_AUDIO_FILTER_PRESET_LIST_EARPHONE_ONLY );
		}
		/* for audio filter custom (EQ / Extension filters) */
		g_player_ini.use_audio_filter_custom = iniparser_getboolean(dict, "sound effect:audio filter custom", DEFAULT_USE_AUDIO_FILTER_CUSTOM);
		if (g_player_ini.use_audio_filter_custom)
		{
			MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_custom_list, MM_AUDIO_FILTER_CUSTOM_NUM,
					"sound effect:audio filter custom list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
			MMPLAYER_INI_GET_BOOLEAN_FROM_LIST( g_player_ini.audio_filter_custom_earphone_only_list, MM_AUDIO_FILTER_CUSTOM_NUM,
					"sound effect:audio filter custom earphone only", DEFAULT_AUDIO_FILTER_CUSTOM_LIST_EARPHONE_ONLY );
			/* for audio filter custom : EQ */
			if (g_player_ini.audio_filter_custom_list[MM_AUDIO_FILTER_CUSTOM_EQ])
			{
				g_player_ini.audio_filter_custom_eq_num = iniparser_getint(dict, "sound effect:audio filter eq num",
						DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM);
				if (g_player_ini.audio_filter_custom_eq_num < DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM || g_player_ini.audio_filter_custom_eq_num > MM_AUDIO_FILTER_EQ_BAND_MAX)
				{
					debug_error("audio_filter_custom_eq_num(%d) is not valid range(%d - %d), set the value %d",
						g_player_ini.audio_filter_custom_eq_num, DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM, MM_AUDIO_FILTER_EQ_BAND_MAX, DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM);
					g_player_ini.audio_filter_custom_eq_num = DEFAULT_AUDIO_FILTER_CUSTOM_EQ_NUM;
				}
			}
			/* for audio filter custom : extension filters */
			g_player_ini.audio_filter_custom_ext_num = iniparser_getint(dict, "sound effect:audio filter ext num",
					DEFAULT_AUDIO_FILTER_CUSTOM_EXT_NUM);
			if (g_player_ini.audio_filter_custom_ext_num > 0)
			{
				MMPLAYER_INI_GET_INT_FROM_LIST( g_player_ini.audio_filter_custom_min_level_list, MM_AUDIO_FILTER_CUSTOM_NUM,
						"sound effect:audio filter custom min list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
				MMPLAYER_INI_GET_INT_FROM_LIST( g_player_ini.audio_filter_custom_max_level_list, MM_AUDIO_FILTER_CUSTOM_NUM,
						"sound effect:audio filter custom max list", DEFAULT_AUDIO_FILTER_CUSTOM_LIST );
			}
		}
#if 0
		int i;
		for (i=0; i<MM_AUDIO_FILTER_PRESET_NUM; i++)
		{
			debug_log("audio_filter_preset_list: %d (is it for earphone only?(%d))\n", g_player_ini.audio_filter_preset_list[i], g_player_ini.audio_filter_preset_earphone_only_list[i]);
		}
		for (i=0; i<MM_AUDIO_FILTER_CUSTOM_NUM; i++)
		{
			debug_log("audio_filter_custom_list : %d (is it for earphone only?(%d))\n", g_player_ini.audio_filter_custom_list[i], g_player_ini.audio_filter_custom_earphone_only_list[i]);
		}
		debug_log("audio_filter_custom : eq_num(%d), ext_num(%d)\n", g_player_ini.audio_filter_custom_eq_num, g_player_ini.audio_filter_custom_ext_num )
		for (i=0; i<MM_AUDIO_FILTER_CUSTOM_NUM; i++)
		{
			debug_log("aaudio_filter_custom_level_min_max_list : min(%d), max(%d)\n", g_player_ini.audio_filter_custom_min_level_list[i], g_player_ini.audio_filter_custom_max_level_list[i]);
		}
#endif

		/* http streaming */
		MMPLAYER_INI_GET_STRING( g_player_ini.name_of_httpsrc, "http streaming:httpsrc element", DEFAULT_HTTPSRC );
		MMPLAYER_INI_GET_STRING( g_player_ini.http_file_buffer_path, "http streaming:http file buffer path", DEFAULT_HTTP_FILE_BUFFER_PATH );
		g_player_ini.http_buffering_limit = iniparser_getdouble(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_LIMIT);
		g_player_ini.http_max_size_bytes = iniparser_getint(dict, "http streaming:http max size bytes", DEFAULT_HTTP_MAX_SIZE_BYTES);
		g_player_ini.http_buffering_time = iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME);		
		g_player_ini.http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT);

		/* rtsp streaming */
		MMPLAYER_INI_GET_STRING( g_player_ini.name_of_rtspsrc, "rtsp streaming:rtspsrc element", DEFAULT_RTSPSRC );
		g_player_ini.rtsp_buffering_time = iniparser_getint(dict, "rtsp streaming:rtsp buffering time", DEFAULT_RTSP_BUFFERING);
		g_player_ini.rtsp_rebuffering_time = iniparser_getint(dict, "rtsp streaming:rtsp rebuffering time", DEFAULT_RTSP_REBUFFERING);
		g_player_ini.rtsp_do_typefinding = iniparser_getboolean(dict, "rtsp streaming:rtsp do typefinding", DEFAULT_RTSP_DO_TYPEFINDING);
		g_player_ini.rtsp_error_concealment = iniparser_getboolean(dict, "rtsp streaming:rtsp error concealment", DEFAULT_RTSP_ERROR_CONCEALMENT);

		/* hw accelation */
		g_player_ini.use_video_hw_accel = iniparser_getboolean(dict, "hw accelation:use video hw accel", DEFAULT_USE_VIDEO_HW_ACCEL);
		
		/* priority */
		g_player_ini.use_priority_setting = iniparser_getboolean(dict, "priority:use priority setting", DEFAULT_USE_PRIORITY_SETTING);
		g_player_ini.demux_priority = iniparser_getint(dict, "priority:demux", DEFAULT_PRIORITY_DEMUX);
		g_player_ini.videosink_priority = iniparser_getint(dict, "priority:videosink", DEFAULT_PRIORITY_VIDEO_SINK);
		g_player_ini.audiosink_priority = iniparser_getint(dict, "priority:audiosink", DEFAULT_PRIORITY_AUDIO_SINK);
		g_player_ini.ringbuffer_priority = iniparser_getint(dict, "priority:ringbuffer", DEFAULT_PRIORITY_RINGBUFFER);
	}	
	else /* if dict is not available just fill the structure with default value */
	{
コード例 #18
0
ファイル: test_iniparser.c プロジェクト: 2ion/iniparser
void Test_iniparser_getdouble(CuTest *tc)
{
    dictionary *dic;

    /* NULL test */
    CuAssertDblEquals(tc, -42, iniparser_getdouble(NULL, NULL, -42), 0);
    CuAssertDblEquals(tc, 4.2, iniparser_getdouble(NULL, "dummy", 4.2), 0);

    /* Check the def return element */
    dic = dictionary_new(10);
    CuAssertDblEquals(tc, 3.1415, iniparser_getdouble(dic, "dummy", 3.1415), 0);
    CuAssertDblEquals(tc, 0xFFFFFFFF, iniparser_getdouble(dic, NULL, 0xFFFFFFFF), 0);
    CuAssertDblEquals(tc, -0xFFFFFFFF, iniparser_getdouble(dic, "dummy", -0xFFFFFFFF), 0);

    /* Insert some values */
    dictionary_set(dic, "double", "");
    dictionary_set(dic, "double:good0", "0");
    dictionary_set(dic, "double:good1", "-0");
    dictionary_set(dic, "double:good2", "1.0");
    dictionary_set(dic, "double:good3", "3.1415");
    dictionary_set(dic, "double:good4", "6.6655957");
    dictionary_set(dic, "double:good5", "-123456789.123456789");

    /* Add dummy stuff too */
    dictionary_set(dic, "double:bad0", "foo");

    /* Get back the values */
    CuAssertDblEquals(tc, 0, iniparser_getdouble(dic, "double:good0", 0xFF), 0);
    CuAssertDblEquals(tc, 0, iniparser_getdouble(dic, "double:good1", 0xFF), 0);
    CuAssertDblEquals(tc, 1.0, iniparser_getdouble(dic, "double:good2", 0xFF), 0);
    CuAssertDblEquals(tc, 3.1415, iniparser_getdouble(dic, "double:good3", 0xFF), 0);
    CuAssertDblEquals(tc, 6.6655957, iniparser_getdouble(dic, "double:good4", 0xFF), 0);
    CuAssertDblEquals(tc, -123456789.123456789,
                         iniparser_getdouble(dic, "double:good5", 0xFF), 0);

    CuAssertDblEquals(tc, 0, iniparser_getdouble(dic, "double:bad0", 42.42), 0);

    dictionary_del(dic);
}
コード例 #19
0
ファイル: config.c プロジェクト: cheukyin699/cava
void load_config(char configPath[255], char supportedInput[255], void* params)
{

struct config_params *p = (struct config_params *)params;
FILE *fp;
	
//config: creating path to default config file
if (configPath[0] == '\0') {
	char *configFile = "config";
	char *configHome = getenv("XDG_CONFIG_HOME");
	if (configHome != NULL) {
		sprintf(configPath,"%s/%s/", configHome, PACKAGE);
	} else {
		configHome = getenv("HOME");
		if (configHome != NULL) {
			sprintf(configPath,"%s/%s/%s/", configHome, ".config", PACKAGE);
		} else {
			printf("No HOME found (ERR_HOMELESS), exiting...");
			exit(EXIT_FAILURE);
		}
	}

	// config: create directory
	mkdir(configPath, 0777);

	// config: adding default filename file
	strcat(configPath, configFile);
	
	fp = fopen(configPath, "ab+");
	if (fp) {
		fclose(fp);
	} else {
		printf("Unable to access config '%s', exiting...\n", configPath);
		exit(EXIT_FAILURE);
	}


} else { //opening specified file

	fp = fopen(configPath, "rb+");	
	if (fp) {
		fclose(fp);
	} else {
		printf("Unable to open file '%s', exiting...\n", configPath);
		exit(EXIT_FAILURE);
	}
}

// config: parse ini
dictionary* ini;
ini = iniparser_load(configPath);

//setting fifo to defaualt if no other input modes supported
inputMethod = (char *)iniparser_getstring(ini, "input:method", "fifo"); 

//setting alsa to defaualt if supported
#ifdef ALSA
	inputMethod = (char *)iniparser_getstring(ini, "input:method", "alsa"); 
#endif

//setting pulse to defaualt if supported
#ifdef PULSE
	inputMethod = (char *)iniparser_getstring(ini, "input:method", "pulse");
#endif


#ifdef NCURSES
	outputMethod = (char *)iniparser_getstring(ini, "output:method", "ncurses");
#endif
#ifndef NCURSES
	outputMethod = (char *)iniparser_getstring(ini, "output:method", "noncurses");
#endif

p->monstercat = 1.5 * iniparser_getdouble(ini, "smoothing:monstercat", 1);
p->waves = iniparser_getint(ini, "smoothing:waves", 0);
p->integral = iniparser_getdouble(ini, "smoothing:integral", 90);
p->gravity = iniparser_getdouble(ini, "smoothing:gravity", 100);
p->ignore = iniparser_getdouble(ini, "smoothing:ignore", 0);

p->color = (char *)iniparser_getstring(ini, "color:foreground", "default");
p->bcolor = (char *)iniparser_getstring(ini, "color:background", "default");

p->gradient = iniparser_getint(ini, "color:gradient", 0);
if (p->gradient) {
	p->gradient_color_1 = (char *)iniparser_getstring(ini, "color:gradient_color_1", "#0099ff");
	p->gradient_color_2 = (char *)iniparser_getstring(ini, "color:gradient_color_2", "#ff3399");
}

p->fixedbars = iniparser_getint(ini, "general:bars", 0);
p->bw = iniparser_getint(ini, "general:bar_width", 2);
p->bs = iniparser_getint(ini, "general:bar_spacing", 1);
p->framerate = iniparser_getint(ini, "general:framerate", 60);
p->sens = iniparser_getint(ini, "general:sensitivity", 100);
p->autosens = iniparser_getint(ini, "general:autosens", 1);
p->overshoot = iniparser_getint(ini, "general:overshoot", 20);
p->lowcf = iniparser_getint(ini, "general:lower_cutoff_freq", 50);
p->highcf = iniparser_getint(ini, "general:higher_cutoff_freq", 10000);

// config: output
channels =  (char *)iniparser_getstring(ini, "output:channels", "stereo");
p->raw_target = (char *)iniparser_getstring(ini, "output:raw_target", "/dev/stdout");
data_format = (char *)iniparser_getstring(ini, "output:data_format", "binary");
p->bar_delim = (char)iniparser_getint(ini, "output:bar_delimiter", 59);
p->frame_delim = (char)iniparser_getint(ini, "output:frame_delimiter", 10);
p->ascii_range = iniparser_getint(ini, "output:ascii_max_range", 1000);
p->bit_format = iniparser_getint(ini, "output:bit_format", 16);

// read & validate: eq
p->smooth = smoothDef;
p->smcount = iniparser_getsecnkeys(ini, "eq");
if (p->smcount > 0) {
	p->customEQ = 1;
	p->smooth = malloc(p->smcount*sizeof(p->smooth));
	#ifndef LEGACYINIPARSER
	const char *keys[p->smcount];
	iniparser_getseckeys(ini, "eq", keys);
	#endif
	#ifdef LEGACYINIPARSER
	char **keys = iniparser_getseckeys(ini, "eq");
	#endif
	for (int sk = 0; sk < p->smcount; sk++) {
		p->smooth[sk] = iniparser_getdouble(ini, keys[sk], 1);
	}
} else {
	p->customEQ = 0;
	p->smcount = 64; //back to the default one
}

// config: input
p->im = 0;
if (strcmp(inputMethod, "alsa") == 0) {
	p->im = 1;
	p->audio_source = (char *)iniparser_getstring(ini, "input:source", "hw:Loopback,1");
}
if (strcmp(inputMethod, "fifo") == 0) {
	p->im = 2;
	p->audio_source = (char *)iniparser_getstring(ini, "input:source", "/tmp/mpd.fifo");
}
if (strcmp(inputMethod, "pulse") == 0) {
	p->im = 3;
	p->audio_source = (char *)iniparser_getstring(ini, "input:source", "auto");
}

validate_config(supportedInput, params);
//iniparser_freedict(ini);

}
コード例 #20
0
ファイル: inifile.c プロジェクト: Felipeasg/rpilogger
int parse_ini_file(char *ini_name) 
{
    //printf("%s %s\n",__func__,ini_name);
    if (ini_name == NULL){
        logErrDate("%s: no ini name provided?!\n",__func__);
        exit_all(-1);
    }

    struct stat sts;
    if (stat(ini_name, &sts) != 0){ //file does not exist
        create_ini_file(ini_name);
        printf("No config file present. %s created.\n",ini_name);
    }
    
    dictionary  *ini ;
    ini = iniparser_load(ini_name);
    
    if (ini==NULL) {
        create_ini_file(ini_name);
        printf("Config file %s created.\n",ini_name);
        ini = iniparser_load(ini_name);
    }

    spsadc = iniparser_getint(ini, "default:spsadc", 860);
    sps = (float)iniparser_getdouble(ini, "default:sps", 500);
    pga[0] = iniparser_getint(ini, "default:pga_ch1", 0);
    pga[1] = iniparser_getint(ini, "default:pga_ch2", 0);
    pga[2] = iniparser_getint(ini, "default:pga_ch3", 0);
    pga[3] = iniparser_getint(ini, "default:pga_ch4", 0);
    auto_pga = iniparser_getint(ini, "default:auto_pga", 1);
    pga_updelay = max(iniparser_getint(ini, "default:pga_updelay", 300),1);
    
    char *s; //pointer to statically allocated char string
    s = iniparser_getstring(ini, "output:datafile_dir", "/home/pi/data");
    strcpy(datafiledir,s);
    s = iniparser_getstring(ini, "output:file_user", "pi");
    strcpy(file_user,s);
    
    //validity check
    if (isValueInIntArr(spsadc,SPSv,SPSv_count) && pga[0]>-1 && pga[0]<6 &&
    pga[1]>-1 && pga[1]<6 && pga[2]>-1 && pga[2]<6 && pga[3]>-1 && pga[3]<6){
        iniparser_freedict(ini);
        //verify spsadc for feasibility
        for (SPSc=0; SPSc<SPSv_count; SPSc++)
            if (SPSv[SPSc] == spsadc)
                break;
                
        //if not found
        if (SPSc >= SPSv_count){
            SPSc = SPSv_count-1;
            printf("Invalid spsadc specified (%d)! Will use %d instead!\n",
            spsadc,SPSv[SPSc]);
            spsadc=SPSv[SPSc];
        }
        
        sampl = (int)((float)60*sps);                
        printf("Config file %s read. sps=%gHz, spsadc: %iHz, (1 min contains "
        "%d samples)\n",ini_name,sps,SPSv[SPSc],sampl);

        if (auto_pga) 
            printf("Dynamic input voltage range selection (in 5 steps)\n");
        else
            printf("Input voltage ranges ch1:+/-%g, ch2: +/-%g, ch3: +/-%g, ch4: +/-%g\n",
                fmin(overvoltage,PGAv[pga[0]]),fmin(overvoltage,PGAv[pga[1]]),
                fmin(overvoltage,PGAv[pga[2]]),fmin(overvoltage,PGAv[pga[3]]));
        

        printf("Data location: %s, file owner: %s\n",datafiledir,file_user);
        return 0;
    }
    else {  
        logErrDate("Invalid config file!\n");
        create_ini_file(ini_name);
        printf("New config file %s created.\n",ini_name);
        iniparser_freedict(ini);
        return -1;
    }
    
}
コード例 #21
0
ファイル: gps.c プロジェクト: doebrowsk/tank-chair
// Initialize the GPS sensor
void GPS_Boot(Sensor * sensor,SensorVariable * start)
{
	if(fileExists("config/GPS.ini"))
	{
		dictionary* config = iniparser_load("config/GPS.ini");
		GPS_LatitudeRatio = iniparser_getdouble(config,"Conversion:Latitude",0);
		GPS_LongitudeRatio= iniparser_getdouble(config,"Conversion:Longitude",0);
		GPS_longLowLimit= iniparser_getdouble(config,"Limit:LowLongitude",0);
		GPS_longHighLimit= iniparser_getdouble(config,"Limit:HighLongitude",360);
		GPS_latLowLimit= iniparser_getdouble(config,"Limit:LowLatitude",0);
		GPS_latHighLimit= iniparser_getdouble(config,"Limit:HighLatitude",360);
		GPS_angleDtLength = iniparser_getdouble(config,"Angle:DtLength",1.0);
		GPS_angleVarianceMult = iniparser_getdouble(config,"Angle:VarianceMultiplyer",1);
		GPS_latOffset = iniparser_getdouble(config,"Offset:Latitude",1.0);
		GPS_longOffset = iniparser_getdouble(config,"Offset:Longitude",1);
		GPS_velocityMin = iniparser_getdouble(config,"Limit:VelocityMin",.5);
		GPS_velcityBeliefFactor = iniparser_getdouble(config,"Conversion:VelocityBeliefFactor",.5);
        GPS_networkOutputOnly = iniparser_getboolean(config, "Output:NetworkOutputOnly", 0);
		iniparser_freedict(config);
		LOG.GPS("GPS Ini file loaded");
	}
	else
	{
		LOG.GPS("gps.ini was not found");
	}

	// CHAD: I am awsome DELETE ME 
	GPS_angleVarianceMult = 10;

	GPS_angleLastLat = 0.0;
	GPS_angleLastLong  = 0.0;
	GPS_anglePrevious = 0;

	int bootUpAttempt = 0;
	GPS_angleSum=10000;
    GPS_networkOutputOnly = 1;

    // TODO: figure out if this is required or not
	/*
	 * This may or may not be required!!!!!!
	 * It is required for initalization purposes:)
	 */
	/*
	StateVariable TestState;
	while(bootUpAttempt == 0)
	{
		GPS_Update(sensor,TestState);
		if(sensor->hasBeenUpdated)
		{
			WOOOOO Major HACK
			if(sensor->state->Location.columns==2)
			{
				Matrix_SetValue(start->Location,1,1,Matrix_GetValue(sensor->state->Location,1,1));
				Matrix_SetValue(start->Location,2,1,Matrix_GetValue(sensor->state->Location,2,1));
			}
			else
			{
				LOG.VERBOSE("Retrying to find gps corrdinates to get an inital offset.");
			}
		}
		else
		{
			LOG.VERBOSE("Retrying to find gps corrdinates to get an inital offset.");
		}
	}
	*/
}
コード例 #22
0
ファイル: ai_params.c プロジェクト: kohr-h/ETreco
void
AiParams_assign_from_AiOpts (AiParams *params, const AiOpts *opts)
{
  int itmp;
  float ta_sx, ta_sy;
  double dtmp;
  dictionary *dict;

  CAPTURE_NULL_VOID (params);
  CAPTURE_NULL_VOID (opts);

  if ((dict = iniparser_load (opts->fname_params)) == NULL)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Unable to read parameters from %s.", opts->fname_params);
      return;
    }

  /* Regularization */

  /* TODO: implement anisotropic mollifier (3 gamma's) */
  vec3_set_all (params->gamma, opts->gamma * ONE_MICROMETER);
  params->moll_ft = moll_types[opts->moll_type];


  /* VOLUME */

  if ((itmp = iniparser_getint (dict, "volume:nx", -1)) == -1)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'nx' not found in %s.", opts->fname_params);
      return;
    }

  params->vol_shape[0] = itmp;
  
  if ((itmp = iniparser_getint (dict, "volume:ny", -1)) == -1)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'ny' not found in %s.", opts->fname_params);
      return;
    }

  params->vol_shape[1] = itmp;

  if ((itmp = iniparser_getint (dict, "volume:nz", -1)) == -1)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'nz' not found in %s.", opts->fname_params);
      return;
    }

  params->vol_shape[2] = itmp;

  if ((dtmp = iniparser_getdouble (dict, "volume:voxel_size", FLT_MAX)) == FLT_MAX)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'voxel_size' not found in %s.", opts->fname_params);
      return;
    }

  vec3_set_all (params->vol_csize, (float) dtmp);

  /* Overrides MRC header */
  params->vol_shift_px[0] = (float) iniparser_getdouble (dict, "volume:shift_x", FLT_MAX);
  params->vol_shift_px[1] = (float) iniparser_getdouble (dict, "volume:shift_y", FLT_MAX);
  params->vol_shift_px[2] = (float) iniparser_getdouble (dict, "volume:shift_z", FLT_MAX);

  
  /* GEOMETRY */
  
  /* Single axis: parallel tilt axis shift */
  dtmp = iniparser_getdouble (dict, "geometry:tilt_axis", 0.0);
  if (fabsf (dtmp) < 45.0)  /* Use "x" backprojection variant */
    {
      params->tilt_axis = 0;
      params->tilt_axis_rotation = (float) dtmp;
    }
  else
    {
      params->tilt_axis = 1;
      /* What's missing to +- 90 degrees */
      params->tilt_axis_rotation = (dtmp > 0) ? (float)(dtmp - 90.0) : (float)(-dtmp + 90.0);
    }

  ta_sx = (float) iniparser_getdouble (dict, "geometry:axis_shift_x", 0.0);
  ta_sy = (float) iniparser_getdouble (dict, "geometry:axis_shift_y", 0.0);

  params->tilt_axis_par_shift_px = ta_sx * sinf (params->tilt_axis_rotation * ONE_DEGREE) 
    + ta_sy * cosf (params->tilt_axis_rotation * ONE_DEGREE);


  
  /* DETECTOR */
  
  /* Overrides MRC header */
  dtmp = iniparser_getdouble (dict, "detector:pixel_size", 0.0);
  params->detector_px_size[0] = (float) dtmp * ONE_MICROMETER;
  params->detector_px_size[1] = (float) dtmp * ONE_MICROMETER;
  params->detector_px_size[2] = 1.0;


  iniparser_freedict (dict);


  /* REGULARIZATION 2 */

  if (use_ctf_flag && truncate_ctf_flag)
    params->ctf_trunc = opts->ctf_trunc;

  return;
}
コード例 #23
0
ファイル: INI.cpp プロジェクト: barankaraoguz/nSnake
double INI::get(std::string where, double default_value)
{
	return iniparser_getdouble(this->ini, where.c_str(), default_value);
}
コード例 #24
0
ファイル: map_drawer.c プロジェクト: Slipyx/wadslip
void DrawMap( map_t* map ) {
    cairo_surface_t* surface = NULL;
    cairo_t* cr = NULL;
    uint16_t surfaceW = (uint16_t)iniparser_getint( ini, "MapDrawer:maxSize", 1024 ),
             surfaceH = surfaceW;
    double scale = 1.0;
    uint32_t i = 0;
    color_t bgColor = {255, 255, 255};
    color_t wallColor = {0, 0, 0}; // Normal wall color
    color_t fdColor = {128, 128, 128}; // Floor difference
    color_t cdColor = {128, 128, 128}; // Ceiling difference
    color_t shColor = {128, 128, 128}; // Same height
    color_t trigColor = {224, 112, 0};
    // Boolean variables
    uint8_t drawThings = (uint8_t)iniparser_getboolean( ini, "MapDrawer:drawThings", 0 ),
            countThings = (uint8_t)iniparser_getboolean( ini, "MapDrawer:countThings", 0 );

    // Print info
    printf( "Name: %.8s\nDimensions: %ux%u\nThings: %d\nLinedefs: %d\n"
            "Sidedefs: %d\nVertexes: %d\nSectors: %d\n\n", map->name, map->width,
            map->height, map->numthings, map->numlinedefs, map->numsidedefs,
            map->numvertexes, map->numsectors );

    if ( map->width > map->height ) {
        surfaceH = (surfaceW * map->height) / map->width;
        scale = (double)(surfaceW - 8) / map->width;
    } else if ( map->height > map->width ) {
        surfaceW = (surfaceH * map->width) / map->height;
        scale = (double)(surfaceH - 8) / map->height;
    } else {
        scale = (double)(surfaceW - 8) / map->width;
    }
    surface = cairo_svg_surface_create( "map.svg", surfaceW, surfaceH );
    cr = cairo_create( surface );
    cairo_set_source_rgb( cr, NORM_COLOR(bgColor) );
    cairo_paint( cr );
    if ( !iniparser_getboolean( ini, "MapDrawer:antiAlias", 1 ) ) {
        cairo_set_antialias( cr, CAIRO_ANTIALIAS_NONE );
    }
    cairo_set_line_width( cr, iniparser_getdouble( ini, "MapDrawer:lineWidth", 2.0 ) );

    cairo_translate( cr, surfaceW / 2.0, surfaceH / 2.0 );
    // Draw the map's lines
    for ( i = 0; i < map->numlinedefs; ++i ) {
        vertex_t v1 = map->vertexes[map->linedefs[i].v1];
        vertex_t v2 = map->vertexes[map->linedefs[i].v2];
        linedef_t linedef = map->linedefs[i];
        uint16_t j = 0;

        // Offset to 0, 0
        v1.x += -map->centerv.x; v1.y += -map->centerv.y;
        v2.x += -map->centerv.x; v2.y += -map->centerv.y;

        // Default is regular solid wall
        cairo_set_source_rgb( cr, NORM_COLOR(wallColor) );

        // Check for two sided
        if ( linedef.sidenum[1] >= 0 ) {
            sector_t frontsector = map->sectors[map->sidedefs[linedef.sidenum[0]].sectornum];
            sector_t backsector = map->sectors[map->sidedefs[linedef.sidenum[1]].sectornum];
            if ( frontsector.floorheight != backsector.floorheight ) { // Floor difference
                cairo_set_source_rgb( cr, NORM_COLOR(fdColor) );
            } else if ( frontsector.ceilingheight != backsector.ceilingheight ) { // Ceiling difference
                cairo_set_source_rgb( cr, NORM_COLOR(cdColor) );
            } else { // Same height
                cairo_set_source_rgb( cr, NORM_COLOR(shColor) );
            }
        }

        // Check for triggers
        for ( j = 0; j < sizeof(trigLineNums) / sizeof(int16_t); ++j ) {
            if ( linedef.special == trigLineNums[j] ) {
                cairo_set_source_rgb( cr, NORM_COLOR(trigColor) );
                break;
            }
        }

        // Check for locked doors
        switch ( linedef.special ) {
            // Red door
            case 28: case 33: case 134: case 135:
                cairo_set_source_rgb( cr, 1.0, 0.0, 0.0 );
                break;
            // Blue door
            case 26: case 32: case 99: case 133:
                cairo_set_source_rgb( cr, 0.0, 0.0, 1.0 );
                break;
            // Yellow door
            case 27: case 34: case 136: case 137:
                cairo_set_source_rgb( cr, 1.0, 0.9, 0.0 );
                break;
            default:
                break;
        }

        cairo_move_to( cr, v1.x * scale, -(v1.y * scale) );
        cairo_line_to( cr, v2.x * scale, -(v2.y * scale) );
        cairo_stroke( cr );
    }
    // Draw and count the map's things
    if ( countThings || drawThings ) {
        for ( i = 0; i < map->numthings; ++i ) {
            int16_t type = map->things[i].type;
            // Count thing
            if ( countThings ) {
                CountThing( type, map->things[i].flags );
            }
            // Draw thing
            if ( drawThings ) {
                int16_t x = map->things[i].x += -map->centerv.x;
                int16_t y = map->things[i].y += -map->centerv.y;
                // Player 1 start (16 radius)
                if ( type == 1 ) {
                    cairo_set_source_rgb( cr, 0.0, 1.0, 0.0 );
                    cairo_rectangle( cr, (x * scale) - (16 * scale),
                                     -((y * scale) + (16 * scale)),
                                     32 * scale, 32 * scale );
                    cairo_fill( cr );
                // Keys (20 radius)
                } else if ( type == 5 || type == 40 ) { // Blue card / skull
                    cairo_set_source_rgb( cr, 0.0, 0.0, 1.0 );
                    cairo_rectangle( cr, (x * scale) - (20 * scale),
                                     -((y * scale) + (20 * scale)),
                                     40 * scale, 40 * scale );
                    cairo_fill( cr );
                } else if ( type == 13 || type == 38 ) { // Red card / skull
                    cairo_set_source_rgb( cr, 1.0, 0.0, 0.0 );
                    cairo_rectangle( cr, (x * scale) - (20 * scale),
                                     -((y * scale) + (20 * scale)),
                                     40 * scale, 40 * scale );
                    cairo_fill( cr );
                } else if ( type == 6 || type == 39 ) { // Yellow card / skull
                    cairo_set_source_rgb( cr, 1.0, 0.9, 0.0 );
                    cairo_rectangle( cr, (x * scale) - (20 * scale),
                                     -((y * scale) + (20 * scale)),
                                     40 * scale, 40 * scale );
                    cairo_fill( cr );
                }
            }
        }
    }

    // Print thing counts
    if ( countThings ) {
        PrintThingCounts();
    }

    // Write and cleanup
    cairo_surface_write_to_png( surface, "map.png" );
    cairo_destroy( cr );
    cairo_surface_destroy( surface );
}
コード例 #25
0
double InitParser::get_double(const string& section, const string& key, double def) const
{
	return iniparser_getdouble(dico, (section+":"+key).c_str(), def);
}
コード例 #26
0
ファイル: fpga.c プロジェクト: doebrowsk/tank-chair
//  Initializes the FPGA, the sabertooth and the mototrs
void FPGA_Boot(void)
{
	LOG.INFO("Initializing FPGA...");
	FPGA_Status = NiFpga_Initialize();
	if (NiFpga_IsNotError(FPGA_Status))
	{
		// opens a session, downloads the bitstream, and runs the FPGA.
		LOG.INFO("Opening a session FPGA...");

		NiFpga_MergeStatus(&FPGA_Status, NiFpga_Open(NiFpga_mainFPGA_Bitfile,
					NiFpga_mainFPGA_Signature,
					"RIO0",
					NiFpga_OpenAttribute_NoRun,
					&FPGA_Session));
		if (NiFpga_IsNotError(FPGA_Status))
		{
			LOG.INFO("ReDownloading the FPGA");
			NiFpga_MergeStatus(&FPGA_Status,NiFpga_Download(FPGA_Session));
			if (NiFpga_IsNotError(FPGA_Status))
			{
				LOG.INFO("Restarting the FPGA");
				NiFpga_MergeStatus(&FPGA_Status,NiFpga_Reset(FPGA_Session));
				if (NiFpga_IsNotError(FPGA_Status))
				{
					LOG.INFO("Running the FPGA");
					NiFpga_MergeStatus(&FPGA_Status,NiFpga_Run(FPGA_Session, 0));

					if (NiFpga_IsNotError(FPGA_Status))
					{
					}
					else
					{
						LOG.ERR("FPGA Fail to run  fpga %d ",FPGA_Status);
					}

				}
				else
				{
					LOG.ERR("FPGA Fail to redownload fpga %d ",FPGA_Status);
				}
			}
			else
			{
				LOG.ERR("FPGA Fail to redownload fpga %d ",FPGA_Status);
			}
		}
		else
		{
			LOG.ERR("FPGA Fail to  open a session. Error Code %d ",FPGA_Status);
		}
	}
	LOG.VERBOSE("Reading Constants for the fpga");

	if(fileExists("config/odometry.ini"))
	{
		dictionary* config = iniparser_load("config/odometry.ini");
		leftWheelConversionConstant  = 1/(iniparser_getdouble(config,"MotorEncoderConstant:MeterPerTickLeft",0)) * PIDUpdateRateInMs/1000;
		rightWheelConversionConstant = 1/(iniparser_getdouble(config,"MotorEncoderConstant:MeterPerTickRight",0)) * PIDUpdateRateInMs/1000;
		iniparser_freedict(config);
		LOG.VERBOSE("Odometry Ini file loaded for fpga!");

	}
	else
	{
		LOG.ERR("!!!!!!!!!!!!!!!!odomentry.ini was not found!!!!!!!!!!!!!!!!!!!!!!");
	}

        if(fileExists("config/pid.ini")) {
            dictionary* config = iniparser_load("config/pid.ini");
            max_pid_speed = (uint16_t) iniparser_getint(config, "Both:MaxSpeedTicksPerDt", 0);
            left_pid_pro_gain = iniparser_getint(config, "LeftPID:ProportionalGain",0);
            left_pid_int_gain = iniparser_getint(config, "LeftPID:IntegralGain",0);
            left_pid_der_gain = iniparser_getint(config, "LeftPID:DerivativeGain", 0);
            right_pid_pro_gain = iniparser_getint(config, "RightPID:ProportionalGain",0);
            right_pid_int_gain = iniparser_getint(config, "RightPID:IntegralGain",0);
            right_pid_der_gain = iniparser_getint(config, "RightPID:DerivativeGain",0);
            iniparser_freedict(config);
            LOG.VERBOSE("PID INI file loaded for FPGA");
        }
        else {
            LOG.ERR("PID.ini was not found");
        }

        if(fileExists("config/CRIO.ini")) {
            dictionary* config = iniparser_load("config/CRIO.ini");
            sabertooth_address = (uint8_t) iniparser_getint(config, "Sabertooth:Address", 130);
            iniparser_freedict(config);
            LOG.VERBOSE("Sabertooth address loaded for FPGA");            
        }
        else {
            LOG.ERR("Unable to load Sabertooth address");
        }

        NiFpga_MergeStatus(&FPGA_Status,NiFpga_WriteU8(FPGA_Session,NiFpga_mainFPGA_ControlU8_SlewRateControl, 10));
        if (NiFpga_IsError(FPGA_Status))
        {
                LOG.ERR("Failed to set Sabertooth slew rate");
        }

        FPGA_SetPIDdt(PIDUpdateRateInMs * 1000);
        FPGA_setMaxPIDSpeed(max_pid_speed);
        FPGA_setLPIDProGain(left_pid_pro_gain);
        FPGA_setLPIDIntGain(left_pid_int_gain);
        FPGA_setLPIDDerGain(left_pid_der_gain);
        FPGA_setRPIDProGain(right_pid_pro_gain);
        FPGA_setRPIDIntGain(right_pid_int_gain);
        FPGA_setRPIDDerGain(right_pid_der_gain);
        FPGA_setSabertoothAddress(sabertooth_address);

	    // This logs the version number
        LOG.INFO("FPGA VERSION =  %d",FPGA_GetVersion());

	LOG.INFO("Turning on the motors");
	FPGA_SetMotorStatus(1);
}
コード例 #27
0
int initilise(char *inifile){
	dictionary *d;
	d = iniparser_load(inifile);
	if (d==NULL) {
		printf("cannot parse file [%s]", inifile);
		return -1 ;
	}
	
//         iniparser_dump(d, stderr);

// 	char string[MAXLEN];
	char *string = malloc(MAXLEN*(sizeof(char)));
	char suffix1[5],suffix2[5],suffix3[5],suffix4[5];
//	Model parameters

	string = iniparser_getstring(d, "model:directory", "/nfs/local-cosmos2/projects/planck/jf334.private/Modes/");
	strcpy(directory,string);
	
	eflag_lmax = iniparser_getint(d, "model:lmax", 1000);
	
	nscalar = iniparser_getdouble(d, "model:nscalar", 9.60891e-1);
	deltaphi = iniparser_getdouble(d, "model:delta_phi", 1.5714e-8);
	kpivot = iniparser_getdouble(d, "model:kpivot", 5e-2);
	string = iniparser_getstring(d, "model:BN_file", "/nfs/local-cosmos2/projects/planck/jf334.private/DeltaDX9/smica/BN_smica_ml.txt");
	if(string[0] == '/'){
		strcpy(beam_noise_file,string);
	}else{
		beam_noise_file[0] = '\0';
		strcat(beam_noise_file, directory);
		strcat(beam_noise_file, string);
	}
	
	use_l_file = iniparser_getint(d, "model:use_l_file", 0);	
	string = iniparser_getstring(d, "model:lini_file", "lini.txt");
	if(string[0] == '/'){
		strcpy(lini_file,string);
	}else{
		lini_file[0] = '\0';
		strcat(lini_file, directory);
		strcat(lini_file, string);
	}

//	Basis parameters
	alpha_max = iniparser_getint(d, "basis:terms", 101);
	eflag_order_prim = iniparser_getint(d, "basis:order_prim", 3);
	eflag_order_late = iniparser_getint(d, "basis:order_late", 3);
	rflag_do3D = iniparser_getint(d, "basis:do3D", 1);
	clflag_uselens = iniparser_getint(d, "basis:uselens", 1);
	alpha_points = iniparser_getint(d, "basis:alpha_points", 100);

	
	string = iniparser_getstring(d, "model:transfer_wgt_file", "wmap7_Tl.txt");
	if(string[0] == '/'){
		strcpy(transfer_wgt_file,string);
	}else{
		transfer_wgt_file[0] = '\0';
		strcat(transfer_wgt_file, directory);
		strcat(transfer_wgt_file, string);
	}
	
	string = iniparser_getstring(d, "model:cls_lens_file", "cls_planck_lens.txt");
	if(string[0] == '/'){
		strcpy(lens_data_file,string);
	}else{
		lens_data_file[0] = '\0';
		strcat(lens_data_file, directory);
		strcat(lens_data_file, string);
	}
	
	string = iniparser_getstring(d, "model:cls_file", "cls_planck.txt");
	if(string[0] == '/'){
		strcpy(cls_data_file,string);
	}else{
		cls_data_file[0] = '\0';
		strcat(cls_data_file, directory);
		strcat(cls_data_file, string);
	}
	
	suffix1[0] = '\0';
	sprintf(suffix1, "%d", eflag_lmax);
	suffix2[0] = '\0';
	sprintf(suffix2, "%d", alpha_max);
	suffix3[0] = '\0';
	sprintf(suffix3, "%d", eflag_order_prim);
	suffix4[0] = '\0';
	sprintf(suffix4, "%d", eflag_order_late);
	
	string = iniparser_getstring(d, "model:order_file_prim", "order_dist.txt");
	if(string[0] == '/'){
		strcpy(edist_file,string);
	}else{
		edist_file[0] = '\0';
		strcat(edist_file, directory);
		strcat(edist_file, string);
	}
	
	string = iniparser_getstring(d, "model:order_file_late", "order_dist.txt");
	if(string[0] == '/'){
		strcpy(mdist_file,string);
	}else{
		mdist_file[0] = '\0';
		strcat(mdist_file, directory);
		strcat(mdist_file, string);
	}
	
	string = iniparser_getstring(d, "model:order_file_prim_tri", "order_dist_tri.txt");
	if(string[0] == '/'){
		strcpy(edist_tri_file,string);
	}else{
		edist_tri_file[0] = '\0';
		strcat(edist_tri_file, directory);
		strcat(edist_tri_file, string);
	}
	
	string = iniparser_getstring(d, "model:order_file_late_tri", "order_dist_tri.txt");
	if(string[0] == '/'){
		strcpy(mdist_tri_file,string);
	}else{
		mdist_tri_file[0] = '\0';
		strcat(mdist_tri_file, directory);
		strcat(mdist_tri_file, string);
	}
	
	string = iniparser_getstring(d, "basis:eigen_file", "eigen");
	if(string[0] == '/'){
		strcpy(eigen_data_file,string);
	}else{
		eigen_data_file[0] = '\0';
		strcat(eigen_data_file, directory);
		strcat(eigen_data_file, string);
		strcat(eigen_data_file, "_");
		strcat(eigen_data_file, suffix1);
		strcat(eigen_data_file, "_");
		strcat(eigen_data_file, suffix3);
		strcat(eigen_data_file, "_");
		strcat(eigen_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:eigen_file_tri", "eigen_tri");
	if(string[0] == '/'){
		strcpy(eigen_tri_data_file,string);
	}else{
		eigen_tri_data_file[0] = '\0';
		strcat(eigen_tri_data_file, directory);
		strcat(eigen_tri_data_file, string);
		strcat(eigen_tri_data_file, "_");
		strcat(eigen_tri_data_file, suffix1);
		strcat(eigen_tri_data_file, "_");
		strcat(eigen_tri_data_file, suffix3);
		strcat(eigen_tri_data_file, "_");
		strcat(eigen_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:modes_file", "modes");
	if(string[0] == '/'){
		strcpy(modes_data_file,string);
	}else{
		modes_data_file[0] = '\0';
		strcat(modes_data_file, directory);
		strcat(modes_data_file, string);
		strcat(modes_data_file, "_");
		strcat(modes_data_file, suffix1);
		strcat(modes_data_file, "_");
		strcat(modes_data_file, suffix4);
		strcat(modes_data_file, "_");
		strcat(modes_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:modes_file_tri", "modes_tri");
	if(string[0] == '/'){
		strcpy(modes_tri_data_file,string);
	}else{
		modes_tri_data_file[0] = '\0';
		strcat(modes_tri_data_file, directory);
		strcat(modes_tri_data_file, string);
		strcat(modes_tri_data_file, "_");
		strcat(modes_tri_data_file, suffix1);
		strcat(modes_tri_data_file, "_");
		strcat(modes_tri_data_file, suffix4);
		strcat(modes_tri_data_file, "_");
		strcat(modes_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:ortho_file", "ortho");
	if(string[0] == '/'){
		strcpy(ortho_data_file,string);
	}else{
		ortho_data_file[0] = '\0';
		strcat(ortho_data_file, directory);
		strcat(ortho_data_file, string);
		strcat(ortho_data_file, "_");
		strcat(ortho_data_file, suffix1);
		strcat(ortho_data_file, "_");
		strcat(ortho_data_file, suffix3);
		strcat(ortho_data_file, "_");
		strcat(ortho_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:ortho_file_tri", "ortho_tri");
	if(string[0] == '/'){
		strcpy(ortho_tri_data_file,string);
	}else{
		ortho_tri_data_file[0] = '\0';
		strcat(ortho_tri_data_file, directory);
		strcat(ortho_tri_data_file, string);
		strcat(ortho_tri_data_file, "_");
		strcat(ortho_tri_data_file, suffix1);
		strcat(ortho_tri_data_file, "_");
		strcat(ortho_tri_data_file, suffix3);
		strcat(ortho_tri_data_file, "_");
		strcat(ortho_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:orthol_file", "orthol");
	if(string[0] == '/'){
		strcpy(orthol_data_file,string);
	}else{
		orthol_data_file[0] = '\0';
		strcat(orthol_data_file, directory);
		strcat(orthol_data_file, string);
		strcat(orthol_data_file, "_");
		strcat(orthol_data_file, suffix1);
		strcat(orthol_data_file, "_");
		strcat(orthol_data_file, suffix4);
		strcat(orthol_data_file, "_");
		strcat(orthol_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:orthol_file_tri", "orthol_tri");
	if(string[0] == '/'){
		strcpy(orthol_tri_data_file,string);
	}else{
		orthol_tri_data_file[0] = '\0';
		strcat(orthol_tri_data_file, directory);
		strcat(orthol_tri_data_file, string);
		strcat(orthol_tri_data_file, "_");
		strcat(orthol_tri_data_file, suffix1);
		strcat(orthol_tri_data_file, "_");
		strcat(orthol_tri_data_file, suffix4);
		strcat(orthol_tri_data_file, "_");
		strcat(orthol_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:lambda_file", "lambda");
	if(string[0] == '/'){
		strcpy(lambda_data_file,string);
	}else{
		lambda_data_file[0] = '\0';
		strcat(lambda_data_file, directory);
		strcat(lambda_data_file, string);
		strcat(lambda_data_file, "_");
		strcat(lambda_data_file, suffix1);
		strcat(lambda_data_file, "_");
		strcat(lambda_data_file, suffix3);
		strcat(lambda_data_file, "_");
		strcat(lambda_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:lambda_file_tri", "lambda_tri");
	if(string[0] == '/'){
		strcpy(lambda_tri_data_file,string);
	}else{
		lambda_tri_data_file[0] = '\0';
		strcat(lambda_tri_data_file, directory);
		strcat(lambda_tri_data_file, string);
		strcat(lambda_tri_data_file, "_");
		strcat(lambda_tri_data_file, suffix1);
		strcat(lambda_tri_data_file, "_");
		strcat(lambda_tri_data_file, suffix3);
		strcat(lambda_tri_data_file, "_");
		strcat(lambda_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:lambdal_file", "lambdal");
	if(string[0] == '/'){
		strcpy(lambdal_data_file,string);
	}else{
		lambdal_data_file[0] = '\0';
		strcat(lambdal_data_file, directory);
		strcat(lambdal_data_file, string);
		strcat(lambdal_data_file, "_");
		strcat(lambdal_data_file, suffix1);
		strcat(lambdal_data_file, "_");
		strcat(lambdal_data_file, suffix4);
		strcat(lambdal_data_file, "_");
		strcat(lambdal_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:lambdal_file_tri", "lambdal_tri");
	if(string[0] == '/'){
		strcpy(lambdal_tri_data_file,string);
	}else{
		lambdal_tri_data_file[0] = '\0';
		strcat(lambdal_tri_data_file, directory);
		strcat(lambdal_tri_data_file, string);
		strcat(lambdal_tri_data_file, "_");
		strcat(lambdal_tri_data_file, suffix1);
		strcat(lambdal_tri_data_file, "_");
		strcat(lambdal_tri_data_file, suffix4);
		strcat(lambdal_tri_data_file, "_");
		strcat(lambdal_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:gamma_file", "gamma");
	if(string[0] == '/'){
		strcpy(gamma_data_file,string);
	}else{
		gamma_data_file[0] = '\0';
		strcat(gamma_data_file, directory);
		strcat(gamma_data_file, string);
		strcat(gamma_data_file, "_");
		strcat(gamma_data_file, suffix1);
		strcat(gamma_data_file, "_");
		strcat(gamma_data_file, suffix3);
		strcat(gamma_data_file, "_");
		strcat(gamma_data_file, suffix4);
		strcat(gamma_data_file, "_");
		strcat(gamma_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:gamma_tri_file", "gamma_tri");
	if(string[0] == '/'){
		strcpy(gamma_tri_data_file,string);
	}else{
		gamma_tri_data_file[0] = '\0';
		strcat(gamma_tri_data_file, directory);
		strcat(gamma_tri_data_file, string);
		strcat(gamma_tri_data_file, "_");
		strcat(gamma_tri_data_file, suffix1);
		strcat(gamma_tri_data_file, "_");
		strcat(gamma_tri_data_file, suffix3);
		strcat(gamma_tri_data_file, "_");
		strcat(gamma_tri_data_file, suffix4);
		strcat(gamma_tri_data_file, "_");
		strcat(gamma_tri_data_file, suffix2);
	}
	
	string = iniparser_getstring(d, "basis:proj_file", "proj");
	if(string[0] == '/'){
		strcpy(proj_data_file,string);
		proj_size_file[0] = '\0';
		strcat(proj_size_file, string);
		strcat(proj_size_file, "_size");
	}else{
		proj_data_file[0] = '\0';
		strcat(proj_data_file, directory);
		strcat(proj_data_file, string);
		strcat(proj_data_file, "_");
		strcat(proj_data_file, suffix1);
		strcat(proj_data_file, "_");
		strcat(proj_data_file, suffix3);
		proj_size_file[0] = '\0';
		strcat(proj_size_file, directory);
		strcat(proj_size_file, string);
		strcat(proj_size_file, "_");
		strcat(proj_size_file, suffix1);
		strcat(proj_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "basis:proj_tri_file", "proj_tri");
	if(string[0] == '/'){
		strcpy(proj_tri_data_file,string);
		proj_tri_size_file[0] = '\0';
		strcat(proj_tri_size_file, string);
		strcat(proj_tri_size_file, "_size");
	}else{
		proj_tri_data_file[0] = '\0';
		strcat(proj_tri_data_file, directory);
		strcat(proj_tri_data_file, string);
		strcat(proj_tri_data_file, "_");
		strcat(proj_tri_data_file, suffix1);
		strcat(proj_tri_data_file, "_");
		strcat(proj_tri_data_file, suffix3);
		proj_tri_size_file[0] = '\0';
		strcat(proj_tri_size_file, directory);
		strcat(proj_tri_size_file, string);
		strcat(proj_tri_size_file, "_");
		strcat(proj_tri_size_file, suffix1);
		strcat(proj_tri_size_file, "_size");
	}
	
//	Transfer parameters
	tflag_bessel = iniparser_getint(d, "transfer:flag_bessel", 0);
	tflag_transfer = iniparser_getint(d, "transfer:flag_transfer", 0);
	tflag_flat = iniparser_getint(d, "transfer:flag_flat", 0);
	tflag_limber = iniparser_getint(d, "transfer:flag_limber", 0);
	
	bessel_max = iniparser_getint(d, "transfer:bessel_max", 10000);
	bessel_points = iniparser_getint(d, "transfer:bessel_points", 8000);
	
	string = iniparser_getstring(d, "transfer:source_file", "source");
	if(string[0] == '/'){
		strcpy(source_data_file,string);
		source_size_file[0] = '\0';
		strcat(source_size_file, string);
		strcat(source_size_file, "_size");
	}else{
		source_data_file[0] = '\0';
		strcat(source_data_file, directory);
		strcat(source_data_file, string);
		source_size_file[0] = '\0';
		strcat(source_size_file, directory);
		strcat(source_size_file, string);
		strcat(source_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "transfer:bessel_file", "bessel");
	if(string[0] == '/'){
		strcpy(bessel_data_file,string);
		bessel_size_file[0] = '\0';
		strcat(bessel_size_file, string);
		strcat(bessel_size_file, "_size");
	}else{
		bessel_data_file[0] = '\0';
		strcat(bessel_data_file, directory);
		strcat(bessel_data_file, string);
		bessel_size_file[0] = '\0';
		strcat(bessel_size_file, directory);
		strcat(bessel_size_file, string);
		strcat(bessel_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "transfer:transfer_file", "transfer");
	if(string[0] == '/'){
		strcpy(transfer_data_file,string);
		transfer_size_file[0] = '\0';
		strcat(transfer_size_file, string);
		strcat(transfer_size_file, "_size");
	}else{
		transfer_data_file[0] = '\0';
		strcat(transfer_data_file, directory);
		strcat(transfer_data_file, string);
		transfer_size_file[0] = '\0';
		strcat(transfer_size_file, directory);
		strcat(transfer_size_file, string);
		strcat(transfer_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "transfer:flat_file", "flat");
	if(string[0] == '/'){
		strcpy(flat_data_file,string);
		flat_size_file[0] = '\0';
		strcat(flat_size_file, string);
		strcat(flat_size_file, "_size");
	}else{
		flat_data_file[0] = '\0';
		strcat(flat_data_file, directory);
		strcat(flat_data_file, string);
		flat_size_file[0] = '\0';
		strcat(flat_size_file, directory);
		strcat(flat_size_file, string);
		strcat(flat_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "transfer:limber_file", "limber");
	if(string[0] == '/'){
		strcpy(limber_data_file,string);
		limber_size_file[0] = '\0';
		strcat(limber_size_file, string);
		strcat(limber_size_file, "_size");
	}else{
		limber_data_file[0] = '\0';
		strcat(limber_data_file, directory);
		strcat(limber_data_file, string);
		limber_size_file[0] = '\0';
		strcat(limber_size_file, directory);
		strcat(limber_size_file, string);
		strcat(limber_size_file, "_size");
	}
	
//	Bispectrum
	bflag_lset = iniparser_getint(d, "bispectrum:flag_lset", 0);
	bflag_load = iniparser_getint(d, "bispectrum:flag_load", 0);
	multiplier = iniparser_getint(d, "bispectrum:multiplier", 20);
	section_count = iniparser_getint(d, "bispectrum:section_count", 10000);
	one_accuracy = iniparser_getdouble(d, "bispectrum:one_accuracy", 1e-6);
	initial_grid_size = iniparser_getint(d, "bispectrum:initial_grid_size", 100);
	depth = iniparser_getint(d, "bispectrum:depth", 3);
	tri_accuracy = iniparser_getdouble(d, "bispectrum:tri_accuracy", 5e-2);
	l_flat = iniparser_getint(d, "bispectrum:l_flat", 150);
	
	string = iniparser_getstring(d, "bispectrum:l_file", "l_values");
	if(string[0] == '/'){
		strcpy(l_data_file,string);
		l_size_file[0] = '\0';
		strcat(l_size_file, string);
		strcat(l_size_file, "_size");
	}else{
		l_data_file[0] = '\0';
		strcat(l_data_file, directory);
		strcat(l_data_file, string);
		l_size_file[0] = '\0';
		strcat(l_size_file, directory);
		strcat(l_size_file, string);
		strcat(l_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "bispectrum:l_int_file", "l_values_int");
	if(string[0] == '/'){
		strcpy(interpolated_l_data_file,string);
		interpolated_l_size_file[0] = '\0';
		strcat(interpolated_l_size_file, string);
		strcat(interpolated_l_size_file, "_size");
	}else{
		interpolated_l_data_file[0] = '\0';
		strcat(interpolated_l_data_file, directory);
		strcat(interpolated_l_data_file, string);
		interpolated_l_size_file[0] = '\0';
		strcat(interpolated_l_size_file, directory);
		strcat(interpolated_l_size_file, string);
		strcat(interpolated_l_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "bispectrum:bispectrum_file", "bispectrum");
	if(string[0] == '/'){
		strcpy(bispectrum_file,string);
	}else{
		bispectrum_file[0] = '\0';
		strcat(bispectrum_file, directory);
		strcat(bispectrum_file, string);
	}
	
	string = iniparser_getstring(d, "bispectrum:bispectrum_int_file", "bispectrum_int");
	if(string[0] == '/'){
		strcpy(interpolated_bispectrum_file,string);
	}else{
		interpolated_bispectrum_file[0] = '\0';
		strcat(interpolated_bispectrum_file, directory);
		strcat(interpolated_bispectrum_file, string);
	}
	
	string = iniparser_getstring(d, "bispectrum:trispectrum_file", "trispectrum");
	if(string[0] == '/'){
		strcpy(trispectrum_file,string);
	}else{
		trispectrum_file[0] = '\0';
		strcat(trispectrum_file, directory);
		strcat(trispectrum_file, string);
	}
	
	string = iniparser_getstring(d, "bispectrum:bispectrum_file", "bispectrum_load");
	if(string[0] == '/'){
		strcpy(bload_file,string);
	}else{
		bload_file[0] = '\0';
		strcat(bload_file, directory);
		strcat(bload_file, string);
	}
	
//	Old parameters
	step = iniparser_getint(d, "old:step", 20);
	dflag_out = iniparser_getint(d, "old:dflag_out", 1);
	dflag_dmax = iniparser_getint(d, "old:dflag_dmax", 10);
	gflag_pca = iniparser_getint(d, "old:gflag_pca", 1);
	tilt = iniparser_getdouble(d, "old:tilt", 0e0);
	
	string = iniparser_getstring(d, "old:restart_file", "restart");
	if(string[0] == '/'){
		strcpy(restart_file,string);
	}else{
		restart_file[0] = '\0';
		strcat(restart_file, directory);
		strcat(restart_file, string);
	}
	
	string = iniparser_getstring(d, "old:alpha_file", "alpha");
	if(string[0] == '/'){
		strcpy(alpha_data_file,string);
		alpha_size_file[0] = '\0';
		strcat(alpha_size_file, string);
		strcat(alpha_size_file, "_size");
	}else{
		alpha_data_file[0] = '\0';
		strcat(alpha_data_file, directory);
		strcat(alpha_data_file, string);
		alpha_size_file[0] = '\0';
		strcat(alpha_size_file, directory);
		strcat(alpha_size_file, string);
		strcat(alpha_size_file, "_size");
	}
	
	string = iniparser_getstring(d, "old:decompose_file", "decompose");
	if(string[0] == '/'){
		strcpy(decompose_data_file,string);
		decompose_size_file[0] = '\0';
		strcat(decompose_size_file, string);
		strcat(decompose_size_file, "_size");
	}else{
		decompose_data_file[0] = '\0';
		strcat(decompose_data_file, directory);
		strcat(decompose_data_file, string);
		decompose_size_file[0] = '\0';
		strcat(decompose_size_file, directory);
		strcat(decompose_size_file, string);
		strcat(decompose_size_file, "_size");
	}
	
	return 0;
}
コード例 #28
0
float MSG_db1_data::get_channel_Calibration_B( )
{
  if (! is_data_ok( )) return 0;
  return (float) iniparser_getdouble(Calibration, "Calibration:B", 0.0);
}
コード例 #29
0
ファイル: fwd_op_params.c プロジェクト: kohr-h/ETreco
void
FwdParams_assign_from_file (FwdParams *params, const char *fname_params)
{
  int itmp;
  float ta_sx, ta_sy;
  double dtmp;
  dictionary *dict;

  CAPTURE_NULL_VOID (params);
  CAPTURE_NULL_VOID (fname_params);

  if ((dict = iniparser_load (fname_params)) == NULL)
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Unable to read parameters from %s.", fname_params);
      return;
    }


  /* VOLUME */

  /* All these settings override MRC header */
  params->vol_shape[0] = iniparser_getint (dict, "volume:nx", -1);
  params->vol_shape[1] = iniparser_getint (dict, "volume:ny", -1);
  params->vol_shape[2] = iniparser_getint (dict, "volume:nz", -1);
  
  dtmp = iniparser_getdouble (dict, "volume:voxel_size", FLT_MAX);
  vec3_set_all (params->vol_csize, (float) dtmp);

  params->vol_shift_px[0] = (float) iniparser_getdouble (dict, "volume:shift_x", FLT_MAX);
  params->vol_shift_px[1] = (float) iniparser_getdouble (dict, "volume:shift_y", FLT_MAX);
  params->vol_shift_px[2] = (float) iniparser_getdouble (dict, "volume:shift_z", FLT_MAX);

  
  /* GEOMETRY */
  
  /* Single axis: parallel tilt axis shift */
  dtmp = iniparser_getdouble (dict, "geometry:tilt_axis", 0.0);
  if (fabsf (dtmp) < 45.0)  /* Use "x" backprojection variant */
    {
      params->tilt_axis = 0;
      params->tilt_axis_rotation = (float) dtmp;
    }
  else
    {
      params->tilt_axis = 1;
      /* What's missing to +- 90 degrees */
      params->tilt_axis_rotation = (dtmp > 0) ? (float)(dtmp - 90.0) : (float)(-dtmp + 90.0);
    }

  ta_sx = (float) iniparser_getdouble (dict, "geometry:axis_shift_x", 0.0);
  ta_sy = (float) iniparser_getdouble (dict, "geometry:axis_shift_y", 0.0);

  params->tilt_axis_par_shift_px = ta_sx * sinf (params->tilt_axis_rotation * ONE_DEGREE) 
    + ta_sy * cosf (params->tilt_axis_rotation * ONE_DEGREE);


  
  /* DETECTOR */

  if ( (itmp = iniparser_getint (dict, "detector:det_pix_x", -1)) == -1 )
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'detector:det_pix_x' not found in %s.", fname_params);
      return;
    }
  
  params->detector_shape[0] = itmp;
  
  if ( (itmp = iniparser_getint (dict, "detector:det_pix_y", -1)) == -1 )
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'detector:det_pix_y' not found in %s.", fname_params);
      return;
    }
  
  params->detector_shape[1] = itmp;
  params->detector_shape[2] = 1;
  
  if ( (dtmp = iniparser_getdouble (dict, "detector:pixel_size", FLT_MAX)) == FLT_MAX )
    {
      EXC_THROW_CUSTOMIZED_PRINT (EXC_IO, "Key 'detector:pixel_size' not found in %s.", fname_params);
      return;
    }

  params->detector_px_size[0] = (float) dtmp * ONE_MICROMETER;
  params->detector_px_size[1] = (float) dtmp * ONE_MICROMETER;
  params->detector_px_size[2] = 1.0;

  iniparser_freedict (dict);

  return;
}
コード例 #30
0
int main(int argc, const char *argv[]) {
    
    const char* argument;
    
    long int initial_timestamp;
    float initial_lat, initial_lng, initial_alt;
    float burst_alt, ascent_rate, drag_coeff, rmswinderror;
    int descent_mode;
    int scenario_idx, n_scenarios;
    int alarm_time;
    char* endptr;       // used to check for errors on strtod calls 
    
    wind_file_cache_t* file_cache;
    dictionary*        scenario = NULL;
    
    // configure command-line options parsing
    void *options = gopt_sort(&argc, argv, gopt_start(
        gopt_option('h', 0, gopt_shorts('h', '?'), gopt_longs("help")),
        gopt_option('z', 0, gopt_shorts(0), gopt_longs("version")),
        gopt_option('v', GOPT_REPEAT, gopt_shorts('v'), gopt_longs("verbose")),
        gopt_option('o', GOPT_ARG, gopt_shorts('o'), gopt_longs("output")),
        gopt_option('k', GOPT_ARG, gopt_shorts('k'), gopt_longs("kml")),
        gopt_option('t', GOPT_ARG, gopt_shorts('t'), gopt_longs("start_time")),
        gopt_option('i', GOPT_ARG, gopt_shorts('i'), gopt_longs("data_dir")),
        gopt_option('d', 0, gopt_shorts('d'), gopt_longs("descending")),
        gopt_option('e', GOPT_ARG, gopt_shorts('e'), gopt_longs("wind_error")),
        gopt_option('a', GOPT_ARG, gopt_shorts('a'), gopt_longs("alarm"))
    ));

    if (gopt(options, 'h')) {
        // Help!
        // Print usage information
        printf("Usage: %s [options] [scenario files]\n", argv[0]);
        printf("Options:\n\n");
        printf(" -h --help               Display this information.\n");
        printf(" --version               Display version information.\n");
        printf(" -v --verbose            Display more information while running,\n");
        printf("                           Use -vv, -vvv etc. for even more verbose output.\n");
        printf(" -t --start_time <int>   Start time of model, defaults to current time.\n");
        printf("                           Should be a UNIX standard format timestamp.\n");
        printf(" -o --output <file>      Output file for CSV data, defaults to stdout. Overrides scenario.\n");
        printf(" -k --kml <file>         Output KML file.\n");
        printf(" -d --descending         We are in the descent phase of the flight, i.e. after\n");
        printf("                           burst or cutdown. burst_alt and ascent_rate ignored.\n");
        printf(" -i --data_dir <dir>     Input directory for wind data, defaults to current dir.\n\n");
        printf(" -e --wind_error <err>   RMS windspeed error (m/s).\n");
        printf(" -a --alarm <seconds>    Use alarm() to kill pred incase it hangs.\n");
        printf("The scenario file is an INI-like file giving the launch scenario. If it is\n");
        printf("omitted, the scenario is read from standard input.\n");
      exit(0);
    }

    if (gopt(options, 'z')) {
      // Version information
      printf("Landing Prediction version: %s\nCopyright (c) CU Spaceflight 2009\n", VERSION);
      exit(0);
    }

    if (gopt_arg(options, 'a', &argument) && strcmp(argument, "-")) {
      alarm_time = strtol(argument, &endptr, 0);
      if (endptr == argument) {
        fprintf(stderr, "ERROR: %s: invalid alarm length\n", argument);
        exit(1);
      }
      alarm(alarm_time);
    }
    
    verbosity = gopt(options, 'v');
    
    if (gopt(options, 'd'))
        descent_mode = DESCENT_MODE_DESCENDING;
    else
        descent_mode = DESCENT_MODE_NORMAL;
      
    if (gopt_arg(options, 'k', &argument) && strcmp(argument, "-")) {
      kml_file = fopen(argument, "wb");
      if (!kml_file) {
        fprintf(stderr, "ERROR: %s: could not open KML file for output\n", argument);
        exit(1);
      }
    }
    else
      kml_file = NULL;

    if (gopt_arg(options, 't', &argument) && strcmp(argument, "-")) {
      initial_timestamp = strtol(argument, &endptr, 0);
      if (endptr == argument) {
        fprintf(stderr, "ERROR: %s: invalid start timestamp\n", argument);
        exit(1);
      }
    } else {
      initial_timestamp = time(NULL);
    }
    
    if (!(gopt_arg(options, 'i', &data_dir) && strcmp(data_dir, "-")))
      data_dir = "./";


    // populate wind data file cache
    file_cache = wind_file_cache_new(data_dir);

    // read in flight parameters
    n_scenarios = argc - 1;
    if(n_scenarios == 0) {
        // we'll parse from std in
        n_scenarios = 1;
    }

    for(scenario_idx = 0; scenario_idx < n_scenarios; ++scenario_idx) {
        char* scenario_output = NULL;

        if(argc > scenario_idx+1) {
            scenario = iniparser_load(argv[scenario_idx+1]);
        } else {
            scenario = iniparser_loadfile(stdin);
        }

        if(!scenario) {
            fprintf(stderr, "ERROR: could not parse scanario file.\n");
            exit(1);
        }

        if(verbosity > 1) {
            fprintf(stderr, "INFO: Parsed scenario file:\n");
            iniparser_dump_ini(scenario, stderr);
        }

        scenario_output = iniparser_getstring(scenario, "output:filename", NULL);

        if (gopt_arg(options, 'o', &argument) && strcmp(argument, "-")) {
            if(verbosity > 0) {
                fprintf(stderr, "INFO: Writing output to file specified on command line: %s\n", argument);
            }
            output = fopen(argument, "wb");
            if (!output) {
                fprintf(stderr, "ERROR: %s: could not open CSV file for output\n", argument);
                exit(1);
            }
        } else if (scenario_output != NULL) {
            if(verbosity > 0) {
                fprintf(stderr, "INFO: Writing output to file specified in scenario: %s\n", scenario_output);
            }
            output = fopen(scenario_output, "wb");
            if (!output) {
                fprintf(stderr, "ERROR: %s: could not open CSV file for output\n", scenario_output);
                exit(1);
            }
        } else {
            if(verbosity > 0) {
                fprintf(stderr, "INFO: Writing output to stdout.\n");
            }
            output = stdout;
        }

        // write KML header
        if (kml_file)
            start_kml();

        // The observant amongst you will notice that there are default values for
        // *all* keys. This information should not be spread around too well.
        // Unfortunately, this means we lack some error checking.

        initial_lat = iniparser_getdouble(scenario, "launch-site:latitude", 0.0);
        initial_lng = iniparser_getdouble(scenario, "launch-site:longitude", 0.0);
        initial_alt = iniparser_getdouble(scenario, "launch-site:altitude", 0.0);

        ascent_rate = iniparser_getdouble(scenario, "altitude-model:ascent-rate", 1.0);

        // The 1.1045 comes from a magic constant buried in
        // ~cuspaceflight/public_html/predict/index.php.
        drag_coeff = iniparser_getdouble(scenario, "altitude-model:descent-rate", 1.0) * 1.1045;

        burst_alt = iniparser_getdouble(scenario, "altitude-model:burst-altitude", 1.0);

        rmswinderror = iniparser_getdouble(scenario, "atmosphere:wind-error", 0.0);
        if(gopt_arg(options, 'e', &argument) && strcmp(argument, "-")) {
            rmswinderror = strtod(argument, &endptr);
            if (endptr == argument) {
                fprintf(stderr, "ERROR: %s: invalid RMS wind speed error\n", argument);
                exit(1);
            }
        }

        {
            int year, month, day, hour, minute, second;
            year = iniparser_getint(scenario, "launch-time:year", -1);
            month = iniparser_getint(scenario, "launch-time:month", -1);
            day = iniparser_getint(scenario, "launch-time:day", -1);
            hour = iniparser_getint(scenario, "launch-time:hour", -1);
            minute = iniparser_getint(scenario, "launch-time:minute", -1);
            second = iniparser_getint(scenario, "launch-time:second", -1);

            if((year >= 0) && (month >= 0) && (day >= 0) && (hour >= 0)
                    && (minute >= 0) && (second >= 0)) 
            {
                struct tm timeval = { 0 };
                time_t scenario_launch_time = -1;

                if(verbosity > 0) {
                    fprintf(stderr, "INFO: Using launch time from scenario: "
                            "%i/%i/%i %i:%i:%i\n",
                            year, month, day, hour, minute, second);
                }

                timeval.tm_sec = second;
                timeval.tm_min = minute;
                timeval.tm_hour = hour;
                timeval.tm_mday = day; /* 1 - 31 */
                timeval.tm_mon = month - 1; /* 0 - 11 */
                timeval.tm_year = year - 1900; /* f**k you Millenium Bug! */

#ifndef _BSD_SOURCE
#               warning This version of mktime does not allow explicit setting of timezone. 
#else
                timeval.tm_zone = "UTC";
#endif

                scenario_launch_time = mktime(&timeval);
                if(scenario_launch_time <= 0) {
                    fprintf(stderr, "ERROR: Launch time in scenario is invalid\n");
                    exit(1);
                } else {
                    initial_timestamp = scenario_launch_time;
                }
            }
        }

        if(verbosity > 0) {
            fprintf(stderr, "INFO: Scenario loaded:\n");
            fprintf(stderr, "    - Initial latitude  : %lf deg N\n", initial_lat);
            fprintf(stderr, "    - Initial longitude : %lf deg E\n", initial_lng);
            fprintf(stderr, "    - Initial altitude  : %lf m above sea level\n", initial_alt);
            fprintf(stderr, "    - Initial timestamp : %li\n", initial_timestamp);
            fprintf(stderr, "    - Drag coeff.       : %lf\n", drag_coeff);
            if(!descent_mode) {
                fprintf(stderr, "    - Ascent rate       : %lf m/s\n", ascent_rate);
                fprintf(stderr, "    - Burst alt.        : %lf m\n", burst_alt);
            }
            fprintf(stderr, "    - Windspeed err.    : %f m/s\n", rmswinderror);
        }
        
        {
            // do the actual stuff!!
            altitude_model_t* alt_model = altitude_model_new(descent_mode, burst_alt, 
                                                             ascent_rate, drag_coeff);
            if(!alt_model) {
                    fprintf(stderr, "ERROR: error initialising altitude profile\n");
                    exit(1);
            }

            if (!run_model(file_cache, alt_model, 
                           initial_lat, initial_lng, initial_alt, initial_timestamp,
                           rmswinderror)) {
                    fprintf(stderr, "ERROR: error during model run!\n");
                    exit(1);
            }

            altitude_model_free(alt_model);
        }

        // release the scenario
        iniparser_freedict(scenario);
        
        // write footer to KML and close output files
        if (kml_file) {
            finish_kml();
            fclose(kml_file);
        }

        if (output != stdout) {
            fclose(output);
        }
    }

    // release gopt data, 
    gopt_free(options);

    // release the file cache resources.
    wind_file_cache_free(file_cache);

    return 0;
}