void output_spectrum_record( struct timeval *tv) { int i; char *stamp = NULL, *prefix = NULL; if( !substitute_params( &prefix, tv, CF_output_files, NULL)) bailout( "error in output_files configuration"); if( bound_strcmp( prefix, out_prefix)) { char *filename = NULL; if( out_prefix) free( out_prefix); out_prefix = strdup( prefix); append_sprintf( &filename, "%s/%s", CF_datadir, out_prefix); report( 0, "using output file [%s]", filename); if( sf_fo) fclose( sf_fo); if( (sf_fo = fopen( filename, "a+")) == NULL) bailout( "cannot open [%s], %s", filename, strerror( errno)); if( CF_output_header) { // Header record required. Output a header every time sidc // is started - only way to handle band changes etc struct stat st; if( stat( filename, &st) < 0) bailout( "cannot stat output file %s: %s", filename, strerror( errno)); fputs( "# FREQ ", sf_fo); for( i = cuton; i < cutoff; i++) fprintf( sf_fo, "%.2f ", (i+0.5) * DF); fputs( "\n", sf_fo); } free( filename); } substitute_params( &stamp, tv, CF_timestamp, NULL); fprintf( sf_fo, "%s", stamp); for( i=cuton; i<cutoff; i++) { double e = left.powspec[i]/output_int; if( CF_log_scale) e = CF_offset_db + 10 * log10( e + 1e-9); fputs( " ", sf_fo); fprintf( sf_fo, CF_field_format, e); } fputs( "\n", sf_fo); fflush( sf_fo); free( prefix); free( stamp); }
sc_addr nsm_pattern_with_params::gen_goal_for_async(sc_addr goal_type, sc_addr result_attr) { clean_if_need(); substitute_params(); sc_addr arc_goal = gen_goal(sign_with_params, goal_type); attach_substitute_in_results_waiter(arc_goal, result_attr); return arc_goal; }
bool nsm_pattern_with_params::gen() { clean_if_need(); substitute_params(); bool rv = gen_goal_and_run(sign_with_params, NSM_GENERATE_, NSM_GENERATED_); if (rv) substitute_in_results(); return rv; }
bool nsm_pattern_with_params::search() { clean_if_need(); substitute_params(); bool rv = gen_goal_and_run(sign_with_params, NSM_SEARCH_, NSM_SEARCHED_); if (rv) substitute_in_results(); return rv; }
void output_record_each( struct timeval *tv) { int i, j; struct BAND *b; char *prefix = NULL; if( !substitute_params( &prefix, tv, CF_output_files, "ID")) bailout( "error in output_files configuration"); if( bound_strcmp( prefix, out_prefix)) { if( out_prefix) free( out_prefix); out_prefix = strdup( prefix); report( 0, "using output files [%s]", out_prefix); for( b = bands, i = 0; i < nbands; i++, b++) { char *prefix = NULL, *filename = NULL; if( b->fo) fclose( b->fo); substitute_params( &prefix, tv, CF_output_files, b->ident); append_sprintf( &filename, "%s/%s", CF_datadir, prefix); if( (b->fo=fopen( filename, "a")) == NULL) bailout( "cannot open [%s], %s", filename, strerror( errno)); if( CF_output_header) { // Header record required. Output a header every time sidc // is started - only way to handle band changes etc struct stat st; if( stat( filename, &st) < 0) bailout( "cannot stat output file %s: %s", filename, strerror( errno)); fputs( "# stamp power\n", b->fo); } free( prefix); free( filename); } } for( b = bands, i = 0; i < nbands; i++, b++) { double e = 0; int n1 = b->start/DF; int n2 = b->end/DF; char *stamp = NULL; substitute_params( &stamp, tv, CF_timestamp, b->ident); for( j=n1; j<= n2; j++) e += b->side->powspec[j]; e /= output_int * (n2 - n1 + 1); if( CF_log_scale) e = CF_offset_db + 10 * log10( e + 1e-9); fprintf( b->fo, "%s ", stamp); fprintf( b->fo, CF_field_format, e); fputs( "\n", b->fo); fflush( b->fo); free( stamp); } free( prefix); }