home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / MATH / VISSIM.ZIP / TANK.C < prev    next >
C/C++ Source or Header  |  1994-02-12  |  3KB  |  102 lines

  1. #include "windows.h"
  2. #include "vsuser.h"  
  3. #include <stdio.h> 
  4.                     
  5.  
  6.  
  7. /************   This is the base function in the DLL   ************/
  8. /************   Called by VisSim at every step size    ************/
  9.  
  10. void _export PASCAL level (param,inSig, outSig)
  11.  double far inSig[],FAR outSig[],FAR param[]; 
  12.  
  13.  { double simTime;
  14.      
  15.    outSig[0]=((param[1]+inSig[0]-inSig[1])/(param[0]))*100; 
  16.    outSig[1]=param[0];     /* display capacity  */ 
  17.    
  18.    getSimTime(&simTime);
  19.    outSig[2]=simTime;  
  20.    
  21.    if (outSig[0] > 100)
  22.      stopSimulation(1);     
  23.  
  24.    }    
  25.  
  26.  
  27.  
  28. /**************      Simulation Start Function      ***************/
  29. /*********  Called by VisSim at the start of simulation  **********/
  30.   
  31. void FAR PASCAL levelSS (double FAR param[],long FAR *runCount )
  32.  
  33.  {  if(*runCount > 1) 
  34.      param[1]=5;   /* autorestart:reset initial condition */
  35.    }       
  36.  
  37.  
  38.  
  39. /****************      Simulation End Function      ***************/
  40. /************  Called by VisSim at the end of simulation **********/ 
  41.  
  42. void FAR PASCAL levelSE (double FAR param[])
  43.  { 
  44.      debMsg("Simulation End");
  45.      
  46.    }  
  47.    
  48.    
  49. /****************    Parameter Allocation Function   **************/
  50. /****************   Called by VisSim on block creation ************/
  51.   
  52. long FAR PASCAL levelPA(pCount)
  53.   short FAR *pCount;
  54.   { 
  55.     *pCount=2;       /* number of prompted parameters */
  56.      return((*pCount)*sizeof(double)) ;
  57.    } 
  58.       
  59.       
  60. /***************   Parameter Initialization Function   *************/
  61. /***********   Called by VisSim after the PA function   ************/      
  62.        
  63. void FAR PASCAL levelPI(DOUBLE *param) 
  64.  
  65.  { 
  66.    param[0]=25;   /* capacity   */
  67.    param[1]=5;    /* initial level  */ 
  68.    
  69.    }      
  70.  
  71.  
  72. /*****************     Parameter Change Function   *****************/
  73. /********* Called by VisSim on right mouse button click ************/ 
  74.                  
  75. char FAR* PASCAL levelPC (DOUBLE *param)
  76. {                   
  77.  
  78.    return "Capacity;Initial_level";
  79.  
  80.  }  
  81.     
  82.     
  83. /*********This code is required for creating a Windows DLL ********/
  84.  
  85.  int DLLInst;   
  86.  
  87.  int FAR PASCAL LibMain(hInstance,wDataSeg,cbHeapSize,lpszCmdLine)
  88.   HINSTANCE hInstance; WORD wDataSeg, cbHeapSize; LPSTR lpszCmdLine;
  89.  
  90.  { 
  91.     DLLInst =hInst;
  92.     return TRUE; 
  93.    
  94.    }
  95.    
  96.  int FAR PASCAL WEP (param)
  97.  { 
  98.     return 1;
  99.  }
  100.  
  101. /****************************** end of file  *****************************/
  102.