AdaptiveOpticsControl
COREMOD_memory.h
Go to the documentation of this file.
1 
17 #ifndef _COREMODMEMORY_H
18 #define _COREMODMEMORY_H
19 
20 /* the number of images in the data structure is kept NB_IMAGES_BUFFER above the number of used images prior to the execution of any function. It means that no function should create more than 100 images. */
21 #define NB_IMAGES_BUFFER 500
22 /* when the number of free images in the data structure is below NB_IMAGES_BUFFER, it is increased by NB_IMAGES_BUFFER */
23 #define NB_IMAGES_BUFFER_REALLOC 600
24 
25 /* the number of variables in the data structure is kept NB_VARIABLES_BUFFER above the number of used variables prior to the execution of any function. It means that no function should create more than 100 variables. */
26 #define NB_VARIABLES_BUFFER 100
27 /* when the number of free variables in the data structure is below NB_VARIABLES_BUFFER, it is increased by NB_VARIABLES_BUFFER */
28 #define NB_VARIABLES_BUFFER_REALLOC 150
29 
30 
31 /*void print_sys_mem_info();*/
32 
33 
34 
35 
36 typedef struct
37 {
38  int on;
39  long long cnt;
40  long long filecnt;
41  long interval;
42  int logexit;
43  char fname[200];
44 } LOGSHIM_CONF;
45 
46 
47 
48 typedef struct
49 {
50  long cnt0;
51  long cnt1;
53 
54 
55 
56 
57 int_fast8_t init_COREMOD_memory();
58 
59 
60 
61 
62 
63 //int ImageCreateSem(IMAGE *image, long NBsem);
64 
65 //int ImageCreate(IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int NBkw);
66 
67 
68 
69 /* =============================================================================================== */
70 /* =============================================================================================== */
74 /* =============================================================================================== */
76 /* =============================================================================================== */
77 
78 
79 int_fast8_t memory_monitor(const char *termttyname);
80 
81 long compute_nb_image();
82 
83 long compute_nb_variable();
84 
85 long long compute_image_memory();
86 
88 
89 long image_ID(const char *name);
90 
91 long image_ID_noaccessupdate(const char *name);
92 
93 long variable_ID(const char *name);
94 
95 long next_avail_image_ID();
96 
98 
99 int_fast8_t delete_image_ID(const char* imname);
100 
101 int_fast8_t delete_image_ID_prefix(const char *prefix);
102 
103 int_fast8_t delete_variable_ID(const char* varname);
104 
105 long create_variable_long_ID(const char *name, long value);
106 
107 long create_variable_string_ID(const char *name, const char *value);
108 
109 long create_image_ID(const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int nbkw);
110 
111 int_fast8_t clearall();
112 
113 void *save_fits_function( void *ptr );
114 
116 
117 
118 
119 /* =============================================================================================== */
120 /* =============================================================================================== */
124 /* =============================================================================================== */
126 /* =============================================================================================== */
127 
128 long image_write_keyword_L(const char *IDname, const char *kname, long value, const char *comment);
129 long image_write_keyword_D(const char *IDname, const char *kname, double value, const char *comment);
130 long image_write_keyword_S(const char *IDname, const char *kname, const char *value, const char *comment);
131 
132 long image_list_keywords(const char *IDname);
133 
134 long image_read_keyword_D(const char *IDname, const char *kname, double *val);
135 long image_read_keyword_L(const char *IDname, const char *kname, long *val);
136 
138 
139 
140 
141 /* =============================================================================================== */
142 /* =============================================================================================== */
146 /* =============================================================================================== */
148 /* =============================================================================================== */
149 
150 
151 long read_sharedmem_image_size(const char *name, const char *fname);
152 long read_sharedmem_image(const char *name);
153 
155 
156 
157 
158 /* =============================================================================================== */
159 /* =============================================================================================== */
163 /* =============================================================================================== */
165 /* =============================================================================================== */
166 
167 
168 long create_1Dimage_ID(const char *ID_name, uint32_t xsize);
169 
170 long create_1DCimage_ID(const char *ID_name, uint32_t xsize);
171 
172 long create_2Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize);
173 
174 long create_2Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize);
175 
176 long create_2DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize);
177 
178 long create_2DCimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize);
179 
180 long create_3Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
181 
182 long create_3Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
183 
184 long create_3DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
185 
187 
188 
189 
190 /* =============================================================================================== */
191 /* =============================================================================================== */
195 /* =============================================================================================== */
197 /* =============================================================================================== */
198 
199 long create_variable_ID(const char *name, double value);
200 
202 
203 
204 
205 
206 
207 /* =============================================================================================== */
208 /* =============================================================================================== */
212 /* =============================================================================================== */
214 /* =============================================================================================== */
215 
216 long copy_image_ID(const char *name, const char *newname, int shared);
217 
218 long chname_image_ID(const char *ID_name, const char *new_name);
219 
220 long COREMOD_MEMORY_cp2shm(const char *IDname, const char *IDshmname);
221 
223 
224 
225 
226 
227 
228 /* =============================================================================================== */
229 /* =============================================================================================== */
233 /* =============================================================================================== */
235 /* =============================================================================================== */
236 
237 int_fast8_t init_list_image_ID_ncurses(const char *termttyname);
238 
239 void close_list_image_ID_ncurses( void );
240 
241 int_fast8_t list_image_ID_ncurses();
242 
243 int_fast8_t list_image_ID_ofp(FILE *fo);
244 
245 int_fast8_t list_image_ID_ofp_simple(FILE *fo);
246 
247 int_fast8_t list_image_ID();
248 
249 int_fast8_t list_image_ID_file(const char *fname);
250 
251 int_fast8_t list_variable_ID();
252 
253 int_fast8_t list_variable_ID_file(const char *fname);
254 
255 
257 
258 
259 
260 /* =============================================================================================== */
261 /* =============================================================================================== */
265 /* =============================================================================================== */
267 /* =============================================================================================== */
268 
269 int_fast8_t mk_complex_from_reim(const char *re_name, const char *im_name, const char *out_name, int sharedmem);
270 
271 int_fast8_t mk_complex_from_amph(const char *am_name, const char *ph_name, const char *out_name, int sharedmem);
272 
273 int_fast8_t mk_reim_from_complex(const char *in_name, const char *re_name, const char *im_name, int sharedmem);
274 
275 int_fast8_t mk_amph_from_complex(const char *in_name, const char *am_name, const char *ph_name, int sharedmem);
276 
277 int_fast8_t mk_reim_from_amph(const char *am_name, const char *ph_name, const char *re_out_name, const char *im_out_name, int sharedmem);
278 
279 int_fast8_t mk_amph_from_reim(const char *re_name, const char *im_name, const char *am_out_name, const char *ph_out_name, int sharedmem);
280 
282 
283 
284 
285 
286 
287 /* =============================================================================================== */
288 /* =============================================================================================== */
292 /* =============================================================================================== */
294 /* =============================================================================================== */
295 
296 int_fast8_t check_2Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize);
297 
298 int_fast8_t check_3Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize);
299 
300 long COREMOD_MEMORY_check_2Dsize(const char *IDname, uint32_t xsize, uint32_t ysize);
301 
302 long COREMOD_MEMORY_check_3Dsize(const char *IDname, uint32_t xsize, uint32_t ysize, uint32_t zsize);
303 
305 
306 
307 
308 
309 /* =============================================================================================== */
310 /* =============================================================================================== */
314 /* =============================================================================================== */
316 /* =============================================================================================== */
317 
318 int_fast8_t rotate_cube(const char *ID_name, const char *ID_out_name, int orientation);
319 
321 
322 
323 
324 
325 
326 /* =============================================================================================== */
327 /* =============================================================================================== */
331 /* =============================================================================================== */
333 /* =============================================================================================== */
334 
335 long COREMOD_MEMORY_image_set_status(const char *IDname, int status);
336 long COREMOD_MEMORY_image_set_cnt0(const char *IDname, int cnt0);
337 long COREMOD_MEMORY_image_set_cnt1(const char *IDname, int cnt1);
338 
340 
341 
342 
343 
344 /* =============================================================================================== */
345 /* =============================================================================================== */
349 /* =============================================================================================== */
351 /* =============================================================================================== */
352 
353 long COREMOD_MEMORY_image_set_createsem(const char *IDname, long NBsem);
354 long COREMOD_MEMORY_image_set_sempost(const char *IDname, long index);
355 long COREMOD_MEMORY_image_set_sempost_byID(long ID, long index);
356 
357 long COREMOD_MEMORY_image_set_sempost_loop(const char *IDname, long index, long dtus);
358 long COREMOD_MEMORY_image_set_semwait(const char *IDname, long index);
359 void *waitforsemID(void *ID);
360 long COREMOD_MEMORY_image_set_semwait_OR_IDarray(long *IDarray, long NB_ID);
361 long COREMOD_MEMORY_image_set_semflush_IDarray(long *IDarray, long NB_ID);
362 long COREMOD_MEMORY_image_set_semflush(const char *IDname, long index);
363 
365 
366 
367 
368 /* =============================================================================================== */
369 /* =============================================================================================== */
373 /* =============================================================================================== */
375 /* =============================================================================================== */
376 
377 
380 long COREMOD_MEMORY_streamDiff(const char *IDstream0_name, const char *IDstream1_name, const char *IDstreammask_name, const char *IDstreamout_name, long semtrig);
381 
382 
383 
386 long COREMOD_MEMORY_stream_halfimDiff(const char *IDstream_name, const char *IDstreamout_name, long semtrig);
387 
388 
398 long COREMOD_MEMORY_streamAve(const char *IDstream_name, int NBave, int mode, const char *IDout_name);
399 
400 
401 
402 
420 long COREMOD_MEMORY_image_streamupdateloop(const char *IDinname, const char *IDoutname, long usperiod, long NBcubes, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode);
421 
422 
423 
436 long COREMOD_MEMORY_image_streamupdateloop_semtrig(const char *IDinname, const char *IDoutname, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode);
437 
438 
439 
440 
441 long COREMOD_MEMORY_streamDelay(const char *IDin_name, const char *IDout_name, long delayus, long dtus);
442 
443 long COREMOD_MEMORY_SaveAll_snapshot(const char *dirname);
444 
445 long COREMOD_MEMORY_SaveAll_sequ(const char *dirname, const char *IDtrig_name, long semtrig, long NBframes);
446 
447 
448 
449 long COREMOD_MEMORY_image_NETWORKtransmit(const char *IDname, const char *IPaddr, int port, int mode, int RT_priority);
450 
451 long COREMOD_MEMORY_image_NETWORKreceive(int port, int mode, int RT_priority);
452 
453 
454 
455 long COREMOD_MEMORY_PixMapDecode_U(const char *inputstream_name, uint32_t xsizeim, uint32_t ysizeim, const char* NBpix_fname, const char* IDmap_name, const char *IDout_name, const char *IDout_pixslice_fname);
456 
458 
459 
460 
461 
462 
463 /* =============================================================================================== */
464 /* =============================================================================================== */
468 /* =============================================================================================== */
470 /* =============================================================================================== */
471 
472 
473 int_fast8_t COREMOD_MEMORY_logshim_printstatus(const char *IDname);
474 int_fast8_t COREMOD_MEMORY_logshim_set_on(const char *IDname, int setv);
475 int_fast8_t COREMOD_MEMORY_logshim_set_logexit(const char *IDname, int setv);
476 long COREMOD_MEMORY_sharedMem_2Dim_log(const char *IDname, uint32_t zsize, const char *logdir, const char *IDlogdata_name);
477 
479 
480 
481 #endif
long COREMOD_MEMORY_cp2shm(const char *IDname, const char *IDshmname)
Definition: COREMOD_memory.c:2729
long COREMOD_MEMORY_image_set_cnt0(const char *IDname, int cnt0)
Definition: COREMOD_memory.c:4075
int_fast8_t check_3Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:3840
long COREMOD_MEMORY_image_set_sempost_loop(const char *IDname, long index, long dtus)
Definition: COREMOD_memory.c:4207
long variable_ID(const char *name)
Definition: COREMOD_memory.c:1431
int_fast8_t list_image_ID_ofp(FILE *fo)
Definition: COREMOD_memory.c:3083
long create_1Dimage_ID(const char *ID_name, uint32_t xsize)
Definition: COREMOD_memory.c:2202
int_fast8_t clearall()
Definition: COREMOD_memory.c:1706
long image_write_keyword_L(const char *IDname, const char *kname, long value, const char *comment)
Definition: COREMOD_memory.c:1870
long COREMOD_MEMORY_image_streamupdateloop_semtrig(const char *IDinname, const char *IDoutname, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode)
takes a 3Dimage (circular buffer) and writes slices to a 2D image synchronized with an image semaphor...
Definition: COREMOD_memory.c:4980
long image_ID_noaccessupdate(const char *name)
Definition: COREMOD_memory.c:1400
long COREMOD_MEMORY_streamDiff(const char *IDstream0_name, const char *IDstream1_name, const char *IDstreammask_name, const char *IDstreamout_name, long semtrig)
Difference between two streams.
Definition: COREMOD_memory.c:4436
int_fast8_t memory_monitor(const char *termttyname)
Definition: COREMOD_memory.c:1293
int_fast8_t list_variable_ID_file(const char *fname)
Definition: COREMOD_memory.c:3334
long image_read_keyword_L(const char *IDname, const char *kname, long *val)
Definition: COREMOD_memory.c:2003
long image_ID(const char *name)
Definition: COREMOD_memory.c:1366
long create_image_ID(const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int nbkw)
Definition: COREMOD_memory.c:2133
long COREMOD_MEMORY_image_NETWORKreceive(int port, int mode, int RT_priority)
Definition: COREMOD_memory.c:5764
long create_3DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2377
long image_write_keyword_D(const char *IDname, const char *kname, double value, const char *comment)
Definition: COREMOD_memory.c:1899
long interval
Definition: COREMOD_memory.h:41
long long filecnt
Definition: COREMOD_memory.h:40
long read_sharedmem_image(const char *name)
Definition: COREMOD_memory.c:2093
long COREMOD_MEMORY_check_3Dsize(const char *IDname, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:3909
int_fast8_t mk_reim_from_amph(const char *am_name, const char *ph_name, const char *re_out_name, const char *im_out_name, int sharedmem)
Definition: COREMOD_memory.c:3773
long next_avail_image_ID()
Definition: COREMOD_memory.c:1464
int_fast8_t mk_amph_from_reim(const char *re_name, const char *im_name, const char *am_out_name, const char *ph_out_name, int sharedmem)
Definition: COREMOD_memory.c:3782
long COREMOD_MEMORY_check_2Dsize(const char *IDname, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:3881
int_fast8_t delete_image_ID(const char *imname)
Definition: COREMOD_memory.c:1522
Definition: COREMOD_memory.h:48
long create_3Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2358
int_fast8_t init_COREMOD_memory()
Definition: COREMOD_memory.c:1022
long COREMOD_MEMORY_stream_halfimDiff(const char *IDstream_name, const char *IDstreamout_name, long semtrig)
Definition: COREMOD_memory.c:4510
long COREMOD_MEMORY_image_set_status(const char *IDname, int status)
Definition: COREMOD_memory.c:4065
int_fast8_t list_image_ID_ofp_simple(FILE *fo)
Definition: COREMOD_memory.c:3213
long cnt1
Definition: COREMOD_memory.h:51
int_fast8_t mk_reim_from_complex(const char *in_name, const char *re_name, const char *im_name, int sharedmem)
Definition: COREMOD_memory.c:3580
long long compute_image_memory()
Definition: COREMOD_memory.c:1334
long COREMOD_MEMORY_image_set_createsem(const char *IDname, long NBsem)
Definition: COREMOD_memory.c:4113
long create_2Dimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2236
void * waitforsemID(void *ID)
Definition: COREMOD_memory.c:4270
long COREMOD_MEMORY_image_set_sempost(const char *IDname, long index)
Definition: COREMOD_memory.c:4135
long create_variable_ID(const char *name, double value)
Definition: COREMOD_memory.c:2424
int_fast8_t COREMOD_MEMORY_logshim_set_logexit(const char *IDname, int setv)
Definition: COREMOD_memory.c:6539
long COREMOD_MEMORY_streamAve(const char *IDstream_name, int NBave, int mode, const char *IDout_name)
Averages frames in stream.
Definition: COREMOD_memory.c:4586
Definition: COREMOD_memory.h:36
int logexit
Definition: COREMOD_memory.h:42
long chname_image_ID(const char *ID_name, const char *new_name)
Definition: COREMOD_memory.c:2700
long COREMOD_MEMORY_streamDelay(const char *IDin_name, const char *IDout_name, long delayus, long dtus)
Definition: COREMOD_memory.c:5142
long compute_nb_image()
Definition: COREMOD_memory.c:1308
int_fast8_t mk_complex_from_reim(const char *re_name, const char *im_name, const char *out_name, int sharedmem)
Definition: COREMOD_memory.c:3367
int_fast8_t delete_variable_ID(const char *varname)
Definition: COREMOD_memory.c:1688
int_fast8_t list_image_ID()
Definition: COREMOD_memory.c:3238
long COREMOD_MEMORY_image_NETWORKtransmit(const char *IDname, const char *IPaddr, int port, int mode, int RT_priority)
Definition: COREMOD_memory.c:5450
long COREMOD_MEMORY_sharedMem_2Dim_log(const char *IDname, uint32_t zsize, const char *logdir, const char *IDlogdata_name)
Definition: COREMOD_memory.c:6591
long cnt0
Definition: COREMOD_memory.h:50
long COREMOD_MEMORY_image_set_semflush_IDarray(long *IDarray, long NB_ID)
flush multiple semaphores
Definition: COREMOD_memory.c:4342
long create_3Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize, uint32_t zsize)
Definition: COREMOD_memory.c:2340
long create_2DCimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2300
long COREMOD_MEMORY_image_set_semwait(const char *IDname, long index)
Definition: COREMOD_memory.c:4249
long COREMOD_MEMORY_image_set_sempost_byID(long ID, long index)
Definition: COREMOD_memory.c:4173
int_fast8_t check_2Dsize(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:3820
long image_read_keyword_D(const char *IDname, const char *kname, double *val)
Definition: COREMOD_memory.c:1983
long create_2Dimage_ID_double(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2266
long compute_variable_memory()
Definition: COREMOD_memory.c:1347
long COREMOD_MEMORY_PixMapDecode_U(const char *inputstream_name, uint32_t xsizeim, uint32_t ysizeim, const char *NBpix_fname, const char *IDmap_name, const char *IDout_name, const char *IDout_pixslice_fname)
Definition: COREMOD_memory.c:6122
long COREMOD_MEMORY_image_set_semflush(const char *IDname, long index)
set semaphore value to 0
Definition: COREMOD_memory.c:4368
long create_1DCimage_ID(const char *ID_name, uint32_t xsize)
Definition: COREMOD_memory.c:2220
long create_variable_long_ID(const char *name, long value)
Definition: COREMOD_memory.c:2459
long read_sharedmem_image_size(const char *name, const char *fname)
Definition: COREMOD_memory.c:2038
long COREMOD_MEMORY_SaveAll_snapshot(const char *dirname)
Definition: COREMOD_memory.c:5264
void close_list_image_ID_ncurses(void)
Definition: COREMOD_memory.c:3067
int_fast8_t init_list_image_ID_ncurses(const char *termttyname)
Definition: COREMOD_memory.c:2882
long COREMOD_MEMORY_image_set_semwait_OR_IDarray(long *IDarray, long NB_ID)
Wait for multiple images semaphores [OR], only works for sem0 only.
Definition: COREMOD_memory.c:4306
int_fast8_t delete_image_ID_prefix(const char *prefix)
Definition: COREMOD_memory.c:1670
int_fast8_t list_image_ID_file(const char *fname)
Definition: COREMOD_memory.c:3256
long next_avail_variable_ID()
Definition: COREMOD_memory.c:1498
int_fast8_t mk_complex_from_amph(const char *am_name, const char *ph_name, const char *out_name, int sharedmem)
Definition: COREMOD_memory.c:3457
long create_2DCimage_ID(const char *ID_name, uint32_t xsize, uint32_t ysize)
Definition: COREMOD_memory.c:2282
long image_list_keywords(const char *IDname)
Definition: COREMOD_memory.c:1960
int on
Definition: COREMOD_memory.h:38
long long cnt
Definition: COREMOD_memory.h:39
int_fast8_t rotate_cube(const char *ID_name, const char *ID_out_name, int orientation)
Definition: COREMOD_memory.c:3954
long create_variable_string_ID(const char *name, const char *value)
Definition: COREMOD_memory.c:2495
int_fast8_t COREMOD_MEMORY_logshim_set_on(const char *IDname, int setv)
Definition: COREMOD_memory.c:6495
long COREMOD_MEMORY_SaveAll_sequ(const char *dirname, const char *IDtrig_name, long semtrig, long NBframes)
Definition: COREMOD_memory.c:5328
long compute_nb_variable()
Definition: COREMOD_memory.c:1321
int_fast8_t COREMOD_MEMORY_logshim_printstatus(const char *IDname)
Definition: COREMOD_memory.c:6434
void * save_fits_function(void *ptr)
Definition: COREMOD_memory.c:1727
long COREMOD_MEMORY_image_set_cnt1(const char *IDname, int cnt1)
Definition: COREMOD_memory.c:4085
int_fast8_t list_variable_ID()
Definition: COREMOD_memory.c:3322
int_fast8_t list_image_ID_ncurses()
Definition: COREMOD_memory.c:2906
int_fast8_t mk_amph_from_complex(const char *in_name, const char *am_name, const char *ph_name, int sharedmem)
Definition: COREMOD_memory.c:3675
long COREMOD_MEMORY_image_streamupdateloop(const char *IDinname, const char *IDoutname, long usperiod, long NBcubes, long period, long offsetus, const char *IDsync_name, int semtrig, int timingmode)
takes a 3Dimage (circular buffer) and writes slices to a 2D image with time interval specified in us ...
Definition: COREMOD_memory.c:4731
long image_write_keyword_S(const char *IDname, const char *kname, const char *value, const char *comment)
Definition: COREMOD_memory.c:1928
long copy_image_ID(const char *name, const char *newname, int shared)
Definition: COREMOD_memory.c:2554