Capsim Block Documentation
Prints samples from an arbitrary number of input buffers to a file, which is named as a parameter.
| Num | Type | Name | Initial Value | Description |
|---|---|---|---|---|
| 0 | FILE* | fp | ||
| 1 | int | numberInputBuffers | ||
| 2 | int | numberOutputBuffers | ||
| 3 | int | displayFlag | 0 |
int i,j,k; complex val; |
|---|
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;
}
|
|---|
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; j |
|---|
if(fp != stdout && fp != stderr) fclose(fp); |
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD 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://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/********************************************************************** 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.) |
|---|