1 /* modelu.h
2 
3    Written by Don Maszle
4    7 October 1991
5 
6    Copyright (c) 1991-2017 Free Software Foundation, Inc.
7 
8    This file is part of GNU MCSim.
9 
10    GNU MCSim is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    as published by the Free Software Foundation; either version 3
13    of the License, or (at your option) any later version.
14 
15    GNU MCSim is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with GNU MCSim; if not, see <http://www.gnu.org/licenses/>
22 
23    Model utilities include file.
24 
25    Utility prototypes and structures used by the generated model
26    file.  The model typedefs need to be defined here so that
27    'modelu.c' can use them.
28 */
29 
30 #ifndef MODELU_H_DEFINED
31 
32 /* ----------------------------------------------------------------------------
33    Inclusions  */
34 
35 #include "modiface.h"
36 #include "delays.h"
37 
38 
39 /* ----------------------------------------------------------------------------
40    Constants  */
41 
42 #define ID_NULL     0x00000
43 #define ID_STATE    0x10000
44 #define ID_INPUT    0x20000
45 #define ID_OUTPUT   0x30000
46 #define ID_PARM     0x40000  /* Global parameter */
47 #define ID_INLINE   0xA0000  /* Inline statement */
48 
49 #define HV_TYPE_MASK   0xF0000 /* Handle to variable is a DWORD */
50 #define HV_INDEX_MASK  0x0FFFF /* == 0xtiiii, type and index */
51 
52 
53 /* ----------------------------------------------------------------------------
54    Typedefs  */
55 
56 /* Global Variable Map */
57 
58 typedef struct tagVM {
59     PSTR szName;     /* Name of the variable */
60     PVOID pVar;      /* Ptr to C variable */
61     HVAR hvar;       /* Handle to variable: ID_TYPE | index */
62 } VMMAPSTRCT, *PVMMAPSTRCT; /* Variable Map element */
63 
64 
65 /* ----------------------------------------------------------------------------
66    Macros  */
67 
68 #define TYPE(pvm)    ((pvm) ? (pvm)->hvar & HV_TYPE_MASK : ID_NULL)
69 #define INDEX(pvm)   ((pvm) ? (pvm)->hvar & HV_INDEX_MASK: ID_NULL)
70 
71 #define HTYPE(hvar)  ((hvar) & HV_TYPE_MASK)
72 #define HINDEX(hvar) ((int) ((hvar) & HV_INDEX_MASK))
73 
74 
75 /* ----------------------------------------------------------------------------
76    Prototypes  */
77 
78 void FixupDependentInputs (void);
79 
80 void        GetStartPeriods (PDOUBLE pdTime);
81 void        GetStateHandles (HVAR *phvar);
82 PVMMAPSTRCT GetVarPtr (PVMMAPSTRCT pvm, PSTR szName);
83 int         GetVarType (HVAR hvar);
84 
85 void PostUpdateSpikes (PDOUBLE pdTime);
86 
87 void UpdateDefaultInput (PIFN pifn, PDOUBLE pdTnext, PDOUBLE pdTime);
88 void UpdateNDoses (PIFN pifn, PDOUBLE pdTnext, PDOUBLE pdTime);
89 BOOL UpdateSpikes (PIFN pifn, PDOUBLE pdTnext, PDOUBLE pdTime);
90 
91 #define MODELU_H_DEFINED
92 #endif
93 
94 /* End */
95 
96