/*
 *	$Source: /mit/hst/src/data/RCS/format.c,v $
 */
#ifndef lint
static char *rcs="$Header: /mit/hst/src/data/RCS/format.c,v 2.1 90/08/18 18:31:02 tldavis Exp $";
#endif

#include <stdio.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <ctype.h>
#include "../sim/CVDefs.h"
#include "Parameter.h"

#ifdef RSAIX
extern void *malloc();
#else
#ifdef __STDC__
#include <stdlib.h>
#else
#include <malloc.h>
#endif
#endif

static char *page[] = {
  "Heart Rate: %4.2lf%3s\n",
  "Total Blood Volume: %6.1lf%3s\n",
  "Trans-thoracic Pressure: %4.2lf%3s\n",

  "\nCapacitances: (ml/mmHg)\n------------\n",
  "LVsyst %4.2lf%3s LVdiast %4.2lf%3s Arterial %4.2lf%3s Venous %4.2lf%3s\n",
  "RVsyst %4.2lf%3s RVdiast %4.2lf%3s Pulm Art %4.2lf%3s Pulm V %4.2lf%3s\n",

  "\nZero-Pressure Volumes: (ml)\n---------------------\n",
  "LV %6.1lf%3s Arterial %6.1lf%3s Venous %6.1lf%3s\n",
  "RV %6.1lf%3s Pulm Art %6.1lf%3s Pulm V %6.1lf%3s\n",

  "\nResistances: (mmHg*sec/ml)\n-----------\n",
  "LV Inflow %4.2lf%3s LV Outflow %4.2lf%3s Microvascular %4.2lf%3s\n",
  "Venous    %4.2lf%3s RV Outflow %4.2lf%3s Pulmonary     %4.2lf%3s\n",
  };
    
static char *pm(a, b)
double a, b;
{ return (a > b ? "(+)" : ( a < b ? "(-)" : "   ")); 
}

/*PUBLIC*/ char *FormatParams(n, o)
SIMULATION *n, *o;
{
  static char line[512], buf[10000];

  buf[0] = '\0';
  sprintf(line,page[0], n->hr, pm(n->hr,o->hr)); strcat(buf, line);
  sprintf(line,page[1], n->bv, pm(n->bv,o->bv)); strcat(buf, line);
  sprintf(line,page[2], n->pth, pm(n->pth,o->pth)); strcat(buf, line);
  sprintf(line,page[3]); strcat(buf, line);
  sprintf(line,page[4],
	  n->Clsys,pm(n->Clsys,o->Clsys), n->Cldias,pm(n->Cldias,o->Cldias),
	  n->Ca,pm(n->Ca,o->Ca),n->Cv,pm(n->Cv,o->Cv)); 
  strcat(buf, line);
  sprintf(line,page[5],
	  n->Crsys,pm(n->Crsys,o->Crsys), n->Crdias,pm(n->Crdias,o->Crdias),
	  n->CPa,pm(n->CPa,o->CPa),n->CPv,pm(n->CPv,o->CPv)); 
  strcat(buf, line);
  sprintf(line,page[6]); 
  strcat(buf, line);
  sprintf(line,page[7], n->Vl0, pm(n->Vl0,o->Vl0),
	  n->Va0,  pm(n->Va0,o->Va0),   n->Vv0,  pm(n->Vv0,o->Vv0)); 
  strcat(buf, line);
  sprintf(line,page[8], n->Vr0, pm(n->Vr0,o->Vr0),
	  n->VPa0, pm(n->VPa0,o->VPa0), n->VPv0, pm(n->VPv0,o->VPv0)); 
  strcat(buf, line);
  sprintf(line,page[9]); 
  strcat(buf, line);
  sprintf(line,page[10], n->Rli,pm(n->Rli,o->Rli), n->Rlo,pm(n->Rlo,o->Rlo), 
	  n->Ra,pm(n->Ra,o->Ra)); 
  strcat(buf, line);
  sprintf(line,page[11], n->Rv,pm(n->Rv,o->Rv),    n->Rro,pm(n->Rro,o->Rro), 
	  n->RPv,pm(n->RPv,o->RPv)); 
  strcat(buf, line);
      
#ifdef DEBUG
  printf("SIMULATION PARAMETERS:\n\n %s\n", buf); fflush(stdout);
#endif
  return(strcpy(malloc(strlen(buf)+1),buf));
}
