prfile

Capsim Block Documentation

Short Description

Prints samples from an arbitrary number of input buffers to a file, which is named as a parameter.

Top
Parameters
Num Description Type Name Default Value
0 Name of output file file file_name stdout
1 Print output control (0/Off, 1/On) int control 1
2 Buffer type:0= Float,1= Complex, 2=Integer int bufferType 0
Top
States
Num Type Name Initial Value Description
0 FILE* fp
1 int numberInputBuffers
2 int numberOutputBuffers
3 int displayFlag 0
Top

Declarations


 

	int i,j,k;
	complex val;



Top

Initialization Code



 

if((numberInputBuffers = NO_INPUT_BUFFERS()) <= 0) {
	fprintf(stdout,"prfile: no input buffers\n");
	return(1);
}
if((numberOutputBuffers = NO_OUTPUT_BUFFERS()) > numberInputBuffers) {
	fprintf(stdout,"prfile: more output than input buffers\n");
	return(2);
}
if(strcmp(file_name,"stdout") == 0) {
	fp = stdout;
	displayFlag = 1;
}
else if(strcmp(file_name,"stderr") == 0) {
	fp = stderr;
	displayFlag = 1;
}
else if((fp = fopen(file_name,"w")) == NULL) {
	fprintf(stdout,"prfile: can't open output file '%s'\n",
		file_name);
	return(3);
}
switch(bufferType) {
	case COMPLEX_BUFFER: 
		for(i=0; i< numberInputBuffers; i++)
			SET_CELL_SIZE_IN(i,sizeof(complex));
		for(i=0; i< numberOutputBuffers; i++)
			SET_CELL_SIZE_OUT(0,sizeof(complex));
		break;
	case FLOAT_BUFFER: 
		for(i=0; i< numberInputBuffers; i++)
			SET_CELL_SIZE_IN(i,sizeof(float));
		for(i=0; i< numberOutputBuffers; i++)
			SET_CELL_SIZE_OUT(0,sizeof(float));
		break;
	case INTEGER_BUFFER: 
		for(i=0; i< numberInputBuffers; i++)
			SET_CELL_SIZE_IN(i,sizeof(int));
		for(i=0; i< numberOutputBuffers; i++)
			SET_CELL_SIZE_OUT(0,sizeof(int));
		break;
	default: 
		fprintf(stderr,"Bad buffer type specified in prfile \n");
		return(4);
		break;
}




Top

Main Code



 

	
if(control) {
	if(displayFlag && MIN_AVAIL() > 0) {
		fprintf(fp,"\n");
		for(j=0; j<(numberInputBuffers-2); j++)
			fprintf(fp,"%-6s","");
		fprintf(fp,"Output From Prfile '%s'\n",block_P->name);
		for(j=0; j0; i--) {
		for(j=0; j
    
Top

Wrapup Code



 

	if(fp != stdout && fp != stderr)
		fclose(fp);




Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/**********************************************************************
			prfile()
***********************************************************************
Prints samples from an arbitrary number of input buffers to a file,
which is named as a parameter.  If the file name is set to "stdout",
or "stderr" the output goes to the terminal.
- A sample from each input is printed in columns on a single line.
	If printing to stdout, these are labeled with signal names.
- The printing function can be disabled without removing the star,
	via a control parameter.
- Data "flow-through" is implemented: if any outputs are connected,
	their values come from the correspondingly numbered input.
	(This feature is not affected by the control parameter.)
	(There cannot be more outputs than inputs.)

prfile


Prints samples from an arbitrary number of input buffers to a file,
which is named as a parameter.  If the file name is set to "stdout",
or "stderr" the output goes to the terminal.
- A sample from each input is printed in columns on a single line.
	If printing to stdout, these are labeled with signal names.
- The printing function can be disabled without removing the star,
	via a control parameter.
- Data "flow-through" is implemented: if any outputs are connected,
	their values come from the correspondingly numbered input.
	(This feature is not affected by the control parameter.)
	(There cannot be more outputs than inputs.)


Programmer:  L.J.Faber

*/