1 /*  Scicos
2 *
3 *  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * See the file ./license.txt
20 */
21 #ifndef __SCICOS_H
22 #define __SCICOS_H
23 
24 #include "machine.h"
25 #include "import.h"
26 
27 /* maximum value for sum of number of inputs and outputs ports of a given
28 block of type 2 */
29 #define SZ_SIZE 60
30 
31 /* maximum value for sum of number of inputs and outputs of a given block
32 of type 0 */
33 #define TB_SIZE 500
34 
35 #ifdef _MSC_VER
36 typedef void (*voidf) ();
37 #else
38 typedef void (*voidf) (void);
39 #endif
40 
41 
42 /* Blocks prototypes */
43 #define I int
44 #define IP int*
45 #define DP double*
46 #define DPP double**
47 #define VP void*
48 #define DB scicos_block*
49 #define F scicos_flag
50 #define FP scicos_flag*
51 
52 /*                    flag  nclock ntvec  rpar  nrpar ipar  nipar  u  nu */
53 #define ARGS_scicosm1 IP,    IP,    IP,    DP,   IP,  IP,   IP,   DP, IP
54 
55 /* flag  nclock t    xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar  intabl  ni  outabl no */
56 #define ARGS_scicos0 FP,IP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DP,IP,DP,IP
57 
58 /*       flag   nclock t    xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar  intabl  .... */
59 #define ARGS_scicos FP,IP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP
60 
61 /*        flag   nclock t    xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar   args_in sz_in, n_in  args_out sz_out, n_out, funptr */
62 #define ARGS_scicos2 FP,IP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DPP,IP,IP,DPP,IP,IP,VP
63 
64 /*        flag   nclock t    xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar   args_in sz_in, n_in  args_out sz_out, n_out, funptr, g ng */
65 #define ARGS_scicos2z FP,IP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DPP,IP,IP,DPP,IP,IP,VP,DP,IP
66 
67 /*       flag   nclock t    residual xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar  intabl  .... */
68 
69 #define ARGS_scicosi FP,IP,DP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP,DP,IP
70 
71 /*        flag   nclockf t   residual xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar   args_in sz_in, n_in  args_out sz_out, n_out  */
72 #define ARGS_scicosi2 FP,IP,DP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DPP,IP,IP,DPP,IP,IP
73 
74 /*        flag   nclockf t   residual xd   x    nx   z   nz   tvec   ntvec  rpar  nrpar ipar  nipar   args_in sz_in, n_in  args_out sz_out, n_out g ng */
75 #define ARGS_scicosi2z FP,IP,DP,DP,DP,DP,IP,DP,IP,DP,IP,DP,IP,IP,IP,DPP,IP,IP,DPP,IP,IP,DP,IP
76 
77 /*         block     flag*/
78 #define ARGS_scicos4 DB, F
79 
80 typedef void (*ScicosFm1) (ARGS_scicosm1);
81 typedef void (*ScicosF0) (ARGS_scicos0);
82 typedef void (*ScicosF) (ARGS_scicos);
83 typedef void (*ScicosF2) (ARGS_scicos2);
84 typedef void (*ScicosF2z) (ARGS_scicos2z);
85 typedef void (*ScicosFi) (ARGS_scicosi);
86 typedef void (*ScicosFi2) (ARGS_scicosi2);
87 typedef void (*ScicosFi2z) (ARGS_scicosi2z);
88 typedef void (*ScicosF4) (ARGS_scicos4);
89 
90 typedef struct
91 {
92     char const* name;
93     ScicosF fonc;
94 } OpTab;
95 
96 /**
97  * @TODO add comment
98  *
99  * @param x_in
100  * @param xptr_in
101  * @param z__
102  * @param work
103  * @param zptr
104  * @param modptr_in
105  * @param oz
106  * @param ozsz
107  * @param oztyp
108  * @param ozptr
109  * @param iz
110  * @param izptr
111  * @param uid the uid values (stack formatted)
112  * @param uidptr the uid length : uid_length = uidptr($+1) - uidptr($)
113  * @param t0_in
114  * @param tf_in
115  * @param tevts_in
116  * @param evtspt_in
117  * @param nevts
118  * @param pointi_in
119  * @param outtbptr_in
120  * @param outtbsz_in
121  * @param outtbtyp_in
122  * @param outtb_elem_in
123  * @param nelem1
124  * @param nlnk1
125  * @param funptr
126  * @param funtyp_in
127  * @param inpptr_in
128  * @param outptr_in
129  * @param inplnk_in
130  * @param outlnk_in
131  * @param rpar
132  * @param rpptr
133  * @param ipar
134  * @param ipptr
135  * @param opar
136  * @param oparsz
137  * @param opartyp
138  * @param opptr
139  * @param clkptr_in
140  * @param ordptr_in
141  * @param nordptr1
142  * @param ordclk_in
143  * @param cord_in
144  * @param ncord1
145  * @param iord_in
146  * @param niord1
147  * @param oord_in
148  * @param noord1
149  * @param zord_in
150  * @param nzord1
151  * @param critev_in
152  * @param nblk1
153  * @param ztyp
154  * @param zcptr_in
155  * @param subscr
156  * @param nsubs
157  * @param simpar
158  * @param flag__
159  * @param ierr_out
160  * @return <ReturnValue>
161  */
162 int C2F(scicos) (double *x_in, int *xptr_in, double *z__,
163                  void **work, int *zptr, int *modptr_in,
164                  void **oz, int *ozsz, int *oztyp, int *ozptr,
165                  char **iz, int *izptr, char **uid, int *uidptr, double *t0_in,
166                  double *tf_in, double *tevts_in, int *evtspt_in,
167                  int *nevts, int *pointi_in, void **outtbptr_in,
168                  int *outtbsz_in, int *outtbtyp_in,
169                  outtb_el * outtb_elem_in, int *nelem1, int *nlnk1,
170                  void** funptr, int *funtyp_in, int *inpptr_in,
171                  int *outptr_in, int *inplnk_in, int *outlnk_in,
172                  double *rpar, int *rpptr, int *ipar, int *ipptr,
173                  void **opar, int *oparsz, int *opartyp, int *opptr,
174                  int *clkptr_in, int *ordptr_in, int *nordptr1,
175                  int *ordclk_in, int *cord_in, int *ncord1,
176                  int *iord_in, int *niord1, int *oord_in,
177                  int *noord1, int *zord_in, int *nzord1,
178                  int *critev_in, int *nblk1, int *ztyp, int *zcptr_in, int *subscr, int *nsubs, double *simpar, int *flag__, int *ierr_out);
179 
180 /**
181  * \brief Discrete time counter type
182  *
183  * Used on [evtdly4.c](@ref evtdly4), [m_frequ.c](@ref m_frequ) or
184  * [time_delay.c](@ref time_delay) to manage time difference.
185  *
186  * Warning: effect maximum simulation time (in term of max simulation step).
187  */
188 typedef long long int time_counter_t;
189 
190 /**
191 *
192 */
193 void callf(double *t, scicos_block * block, scicos_flag * flag);
194 
195 /**
196 *
197 */
198 int get_phase_simulation(void);
199 
200 /**
201 *
202 */
203 void set_block_error(int err);
204 
205 /**
206 *
207 */
208 double get_scicos_time(void);
209 
210 /**
211 *
212 */
213 void set_scicos_time(double t);
214 
215 /**
216 *
217 */
218 void set_pointer_xproperty(int *pointer);
219 
220 /**
221 *
222 */
223 void do_cold_restart(void);
224 
225 /**
226 *
227 */
228 int get_block_number(void);
229 
230 /**
231 *
232 */
233 void end_scicos_sim(void);
234 
235 /**
236 *
237 */
238 void Coserror(const char *fmt, ...);
239 
240 /**
241 *
242 */
243 void *funnum2(char *fname);
244 #endif
245 
246