plottxt

Capsim Block Documentation

Short Description

Plot probe.

Top
Parameters
Num Description Type Name Default Value
0 Number of points in each plot (dynamic window size) int npts 128
1 Points to skip before first plot int skip 0
2 Plot title file title plot
3 X Axis label file x_axis Samples
4 Y-Axis label file y_axis Y
5 Plot Style: 1=Line,2=Points,5=Bar Chart int plotStyleParam 1
6 Control: 1=On, 0=Off int control 1
7 0=Static,1=Dynamic int mode 0
8 Sampling Rate int samplingRate 1
Top
States
Num Type Name Initial Value Description
0 int ibufs
1 int obufs
2 float* xpts
3 float* ypts[MAX_NUMBER_OF_PLOTS]
4 char* legends[100]
5 int count 0
6 int totalCount 0
7 int displayed FALSE
8 float dt
9 int blockOff 0
10 int bufi 0
Top

Declarations


 

	int samples;
    	int i,j,k,ii;
	int	operState;
	char curveTitle[80];
	char curveSubTitle[80];
	char	fname[100];
	FILE *time_F;



Top

Initialization Code



 

/* 
 * store as state the number of input/output buffers 
 */
if((ibufs = NO_INPUT_BUFFERS()) <= 0) {
	fprintf(stderr,"plot: no inputs connected\n");
	return(2);
}
if((obufs = NO_OUTPUT_BUFFERS()) > ibufs) {
	fprintf(stderr,"plot: too many outputs connected\n");
	return(3);
}
if(ibufs > MAX_NUMBER_OF_PLOTS) {
	fprintf(stderr,"plot: too many plots requested.  \n");
	return(4);
}
if(control && mode == DYNAMIC) {
	/*
	 * allocate arrays
	 */
	xpts = (float* )calloc(npts,sizeof(float));
	if(xpts==NULL) {
		fprintf(stderr,"Could not allocate space in plot \n");
		return(5);
	}
	for(i=0; i
    
Top

Main Code



 


for(samples = MIN_AVAIL(); samples > 0; --samples) {

    


    for(i=0; i i) {
				if(IT_OUT(i)) {
					KrnOverflow("plot",i);
					return(99);
				}
	 			OUTF(i,0) = INF(i,0);
			}
    }
    if(++totalCount > skip && control ) {
	if(mode == STATIC)
		count=blockOff + bufi;
	bufi++;

	if (bufi == BLOCK_SIZE && mode==STATIC) {
		blockOff += BLOCK_SIZE;
		xpts = (float *)realloc((char *) xpts,
			sizeof(float) * (blockOff + BLOCK_SIZE));
	        if(xpts==NULL) {
		         fprintf(stderr,"Could not allocate space in plot \n");
		         return(7);
	        }
		for(i=0; i
    
Top

Wrapup Code



 

if(control == 0) return(0);
if((totalCount - skip) > 0 ) {
   {
        	strcpy(fname,title);
       	 	strcat(fname,".tim");
        	time_F = fopen(fname,"w");
			for(k=0; k
    
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



 

/* plottxt.s */
/**********************************************************************
                                plot()
***********************************************************************
	inputs:		(arbitrary number)
	outputs:	(optional feed-through of input channels)
	parameters:	int npts, the number of points to plot
			int skip, number of points to skip before first plot
			file title,  the title of the plot
			file x_axis, the title for the x_axis
			file y_axis, the title for the y_axis
			int plotQ plot quality flag 0 = high , 1 = low
*************************************************************************
This routine will produce a set of plots from an arbitrary number of input
channels.  Optionally, the input channel data can 'flow through' to the
correspondingly numbered output channel.  This is useful if this star is
to be placed in line in a simulation (e.g. probe).
The first parameter represents the number of points plotted from each channel.
EVERY TIME this number of points is input, a new set of plots will be generated.
Default is set to (int 500).
The second parameter is the number of points to skip before the first plot set
is presented.  This enables skipping of any transient period.
Default is set to (int 0).
The third parameter represents the title for the plot.
Default is set to "PLOT".
The fourth parameter represents the title for the x_axis.
Default is set to "X".
The fifth parameter represents the title for the y_axis.
Default is set to "Y".
Programmer:     Sasan H. Ardalan	
Date: 	 	June 18, 1990	
Modified: Sasan Ardalan, Added Dynamic Capability
*/