home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / NEURLNET / NERVES.ZIP / PRINT / NSPRINT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-22  |  4.2 KB  |  164 lines

  1. #include "defn.h"
  2. #define EXTERN
  3. #include "nsdata.c"
  4.  
  5. void main(int argc,char *argv[])
  6.  {
  7.   int i,j;
  8.   struct neuron *np;
  9.   struct Iint *ip;
  10.   struct con *cp;
  11.   char str[20];
  12.   FILE *file;
  13.  
  14.   if (argc != 2)
  15.    return;
  16.  
  17.   ns = calloc(150,sizeof(struct neuron));
  18.   Iinta = calloc(75,sizeof(struct Iint));
  19.   cona = calloc(300,sizeof(struct con));
  20.  
  21.   file = fopen(argv[1],"rb");
  22.   if (file == NULL)
  23.    return;
  24.   fread(&nn,2,1,file);
  25.   for (np=ns, j=0; j<nn; np++, j++)
  26.    fread(np,sizeof(struct neuron)-22,1,file);
  27.   fread(&ni,2,1,file);
  28.   for (ip=Iinta, j=0; j<ni; ip++, j++)
  29.    fread(ip,40,1,file);
  30.   fread(&nc,2,1,file);
  31.   for (cp=cona, j=0; j<nc; cp++, j++)
  32.    fread(cp,sizeof(struct con)-4,1,file);
  33.   fclose(file);
  34.  
  35.   /* change pointers */
  36.   for (j=0, np=ns; j<nn; j++, np++)
  37.    {
  38.     if (np->Iint != NULL)
  39.      np->Iint = Iinta + ((int)np->Iint - 1)/40;
  40.     if (np->con != NULL)
  41.      np->con = cona + ((int)np->con - 1)/32;
  42.    }
  43.   for (j=0, cp=cona; j<nc; j++, cp++)
  44.    {
  45.     if (cp->next != NULL)
  46.      cp->next = cona + ((int)cp->next - 1)/32;
  47.    }
  48.  
  49.   /* print file */
  50.   printf("Prepare printer (LPT1) and press any key\n");
  51.   bioskey(0);
  52.   fprintf(stdprn,"%s\n\n",argv[1]);
  53.   for (i=0, np=ns; i<nn; i++, np++)
  54.    {
  55.     if (np->name[0])
  56.      {
  57.       fprintf(stdprn,"%s\n",np->name);
  58.       fprintf(stdprn,"  Gmem   Cmem   Vt     Fmin   Gain\n");
  59.       fprintf(stdprn,"  %-6.1f %-6.1f %-6.1f %-6.1f %-6.1f\n\n",
  60.           1e6*np->Gmem,1e9*np->Cmem,1e3*np->Vt,
  61.           np->Fmin,1e-3*np->Gain);
  62.       if (np->Iint == NULL)
  63.        fprintf(stdprn,"  Iint\n  NONE\n\n");
  64.       else
  65.        {
  66.     ip = np->Iint;
  67.     if (ip->type == 0)
  68.      {
  69.       fprintf(stdprn,"  Iint       IL     Vthr   Base   Mult   IL     Duration\n");
  70.       fprintf(stdprn,"  NON-RANDOM %-6.1f %-6.1f %-6.1f %-6.2f %-6.1f %-6.1f\n\n",
  71.           1e9*ip->IL,1e3*ip->pL[0],1e3*ip->pL[1],ip->pL[2],
  72.           1e9*ip->IL,1e3*ip->pH[0]);
  73.      }
  74.     else
  75.      {
  76.       fprintf(stdprn,"  Iint       IL     Min    Max    IL     Min    Max\n");
  77.       fprintf(stdprn,"  RANDOM     %-6.1f %-6.1f %-6.1f %-6.1f %-6.1f %-6.1f\n\n",
  78.           1e9*ip->IL,1e3*ip->pL[0],1e3*ip->pL[1],
  79.           1e9*ip->IH,1e3*ip->pH[0],1e3*ip->pH[0]);
  80.      }
  81.        }
  82.       if (!np->Isens)
  83.        {
  84.     fprintf(stdprn,"  Sensory-function\n");
  85.     fprintf(stdprn,"  NONE\n\n");
  86.        }
  87.       else
  88.        if (np->Isens == OS)
  89.     {
  90.      fprintf(stdprn,"  Sensory-function Param-1    Param-2\n");
  91.      fprintf(stdprn,"  ODOR STRENGTH    %-9.4f  %-9.4f\n\n",
  92.          1e9*np->pI[0],1e9*np->pI[1]);
  93.     }
  94.        else
  95.     {
  96.      fprintf(stdprn,"  Sensory-function    Param\n");
  97.      switch (np->Isens)
  98.       {
  99.        case LAF:
  100.         strcpy(str,"LEG ANGLE FORWARD");
  101.         break;
  102.        case LAB:
  103.         strcpy(str,"LEG ANGLE BACKWARD");
  104.         break;
  105.        case AC:
  106.         strcpy(str,"ANTENNA CONTACT");
  107.         break;
  108.        case EC:
  109.         strcpy(str,"ENERGY CAPACITY");
  110.         break;
  111.        case MC:
  112.         strcpy(str,"MOUTH CONTACT");
  113.         break;
  114.        default:
  115.         str[0] = 0;
  116.       }
  117.      fprintf(stdprn,"  %-19s %-6.1f\n\n",str,1e9*np->pI[0]);
  118.     }
  119.       if (!np->mtype)
  120.        fprintf(stdprn,"  Motor-output\n  NONE\n\n");
  121.       else
  122.        {
  123.     fprintf(stdprn,"  Motor-output  Type    Param\n");
  124.     if (np->mtype == 1)
  125.      {
  126.       if (np->mname == 0)
  127.        strcpy(str,"FORWARD");
  128.       else
  129.        if (np->mname == 1)
  130.         strcpy(str,"BACKWARD");
  131.        else
  132.         strcpy(str,"LATERAL");
  133.       fprintf(stdprn,"  FORCE         %-5s %-6.1f\n\n",str,np->mconst);
  134.      }
  135.     else
  136.      {
  137.       if (np->mname == 0)
  138.        strcpy(str,"FOOT");
  139.       else
  140.        strcpy(str,"MOUTH");
  141.       fprintf(stdprn,"  STATE         %-5s %-6.1f\n\n",str,np->mconst);
  142.      }
  143.        }
  144.       fprintf(stdprn,"  CONNECTIONS:\n");
  145.       if (np->con)
  146.        {
  147.     fprintf(stdprn,"  Sending   Current   Type      Compound  Current   State\n");
  148.     for (cp=np->con; cp!=NULL; cp=cp->next)
  149.      {
  150.       if (cp->ctype == 0)
  151.        fprintf(stdprn,"  %-6s    %-6.1f    DIRECT\n",cp->sname,cp->Isr*1e9);
  152.       else
  153.        if (cp->ctype == 1)
  154.         fprintf(stdprn,"  %-6s    %-6.1f    GATED     %-6s    %-6.1f    %d\n",
  155.             cp->sname,cp->Isr*1e9,cp->cname,cp->Icr*1e9,cp->U);
  156.        else
  157.         fprintf(stdprn,"  %-6s    %-6.1f    MODULATED %-6s    %-6.1f\n",
  158.             cp->sname,cp->Isr*1e9,cp->cname,cp->Icr*1e9);
  159.      }
  160.        }
  161.       fprintf(stdprn,"\n\n");
  162.      }
  163.    }
  164.  }