cacao  Release 0.1.03-dev
Compute And Control For Adaptive Optics
ImageStreamIO.h
Go to the documentation of this file.
1 
10 #ifndef _IMAGESTREAMIO_H
11 #define _IMAGESTREAMIO_H
12 
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17 
18 #include "ImageStruct.h"
19 
20 
21 void __attribute__ ((constructor)) libinit_ImageStreamIO();
22 
23 
24 
26 
33 
43 errno_t ImageStreamIO_set_printError( errno_t (*new_printError)( const char *, const char *, int, errno_t, char * ) );
44 
45 
46 /* =============================================================================================== */
47 /* =============================================================================================== */
50 /* =============================================================================================== */
51 /* =============================================================================================== */
52 
53 inline uint64_t ImageStreamIO_nbSlices(const IMAGE *image) {
54  return (image->md->naxis == 3 ? image->md->size[2] : 1);
55 }
56 
57 inline uint64_t ImageStreamIO_writeIndex(const IMAGE *image) {
58  return (image->md->cnt1 + 1) % ImageStreamIO_nbSlices(image);
59 }
60 
61 inline uint64_t ImageStreamIO_readLastWroteIndex(const IMAGE *image) {
62  return (image->md->naxis == 3 ? image->md->cnt1 : 0);
63 }
64 
89  const IMAGE *image,
90  const unsigned int slice_index,
91  void **buffer
92 );
93 
114  const IMAGE *image,
115  void **buffer
116 ) {
117  const uint64_t write_index = ImageStreamIO_writeIndex(image);
118  return ImageStreamIO_readBufferAt(image, write_index, buffer);
119 }
120 
121 
142  const IMAGE *image,
143  void **buffer
144 ) {
145  const int64_t read_index = ImageStreamIO_readLastWroteIndex(image);
146  return ImageStreamIO_readBufferAt(image, read_index, buffer);
147 }
148 
166  char * file_name,
167  size_t ssz,
168  const char * im_name
169 );
170 
176 int ImageStreamIO_typesize( uint8_t atype
177  );
178 
184 int ImageStreamIO_bitpix( uint8_t atype
185  );
186 
188 
189 /* =============================================================================================== */
190 /* =============================================================================================== */
193 /* =============================================================================================== */
194 /* =============================================================================================== */
195 
198  IMAGE *image,
199  const char *name,
200  long naxis,
201  uint32_t *size,
202  uint8_t atype,
203  int shared,
204  int NBkw
205 );
206 
209  IMAGE *image,
210  const char *name,
211  long naxis,
212  uint32_t *size,
213  uint8_t atype,
214  int8_t location,
215  int shared,
216  int NBsem,
217  int NBkw,
218  uint64_t imagetype
219 );
220 
237  IMAGE *image
238 );
239 
245  IMAGE *image,
246  const char *name
247 );
248 
249 
250 
252 
255  const char *name,
256  IMAGE *image
257 );
258 
259 
269 
271 
272 /* =============================================================================================== */
273 /* =============================================================================================== */
276 /* =============================================================================================== */
277 /* =============================================================================================== */
278 
293  IMAGE *image
294 );
295 
312  IMAGE *image,
313  long NBsem
314 );
315 
335  IMAGE *image,
336  long index
337 );
338 
356  IMAGE *image,
357  long index
358 );
359 
360 
361 
383  IMAGE *image,
384  long index,
385  long dtus
386 );
387 
394  IMAGE *image,
395  int semindexdefault
396 );
397 
398 
416  IMAGE *image,
417  int index
418 );
420  IMAGE *image,
421  int index
422 );
424  IMAGE *image,
425  int index,
426  const struct timespec *semwts
427 );
428 
429 
448  IMAGE *image,
449  long index
450 );
451 
453 
454 
455 #ifdef __cplusplus
456 } //extern "C"
457 #endif
458 
459 
460 #endif
461 
462 
errno_t ImageStreamIO_readLastWroteBuffer(const IMAGE *image, void **buffer)
Get the raw pointer where the consumer will find the last frame wrote.
Definition: ImageStreamIO.h:141
uint64_t ImageStreamIO_nbSlices(const IMAGE *image)
Definition: ImageStreamIO.h:53
errno_t ImageStreamIO_writeBuffer(const IMAGE *image, void **buffer)
Get the raw pointer where the producer should write.
Definition: ImageStreamIO.h:113
errno_t ImageStreamIO_filename(char *file_name, size_t ssz, const char *im_name)
Get the standard stream filename.
Definition: ImageStreamIO.c:370
errno_t ImageStreamIO_createIm_gpu(IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t atype, int8_t location, int shared, int NBsem, int NBkw, uint64_t imagetype)
Create shared memory image stream.
Definition: ImageStreamIO.c:601
long ImageStreamIO_sempost_excl(IMAGE *image, long index)
Post all shmim semaphores except one.
Definition: ImageStreamIO.c:1522
void __attribute__((constructor)) libinit_ImageStreamIO()
Initialize module.
Definition: ImageStreamIO.c:77
errno_t ImageStreamIO_closeIm(IMAGE *image)
Close a shared memmory image stream.
Definition: ImageStreamIO.c:1249
IMAGE structure The IMAGE structure includes :
Definition: ImageStruct.h:330
errno_t ImageStreamIO_destroyIm(IMAGE *image)
Deallocate and remove an IMAGE structure.
Definition: ImageStreamIO.c:891
errno_t ImageStreamIO_read_sharedmem_image_toIMAGE(const char *name, IMAGE *image)
Read / connect to existing shared memory image stream.
Definition: ImageStreamIO.c:1017
errno_t ImageStreamIO_set_default_printError()
Set the error reporting function to the default provided by the library.
Definition: ImageStreamIO.c:103
uint64_t cnt1
Definition: ImageStruct.h:303
uint8_t naxis
Number of axis.
Definition: ImageStruct.h:210
int ImageStreamIO_semtimedwait(IMAGE *image, int index, const struct timespec *semwts)
Definition: ImageStreamIO.c:1703
errno_t ImageStreamIO_readBufferAt(const IMAGE *image, const unsigned int slice_index, void **buffer)
Get the raw pointer to the beginning of the slice slice_index.
Definition: ImageStreamIO.c:284
int ImageStreamIO_bitpix(uint8_t atype)
Get the FITSIO BITPIX from the data type code.
Definition: ImageStreamIO.c:448
int errno_t
Definition: AOloopControl_IOtools.h:20
int ImageStreamIO_destroysem(IMAGE *image)
Destroy shmim semaphores.
Definition: ImageStreamIO.c:1299
errno_t ImageStreamIO_set_printError(errno_t(*new_printError)(const char *, const char *, int, errno_t, char *))
Set the error reporting function. The new function supplied by the pointer will be called whenever a ...
Definition: ImageStreamIO.c:109
long ImageStreamIO_sempost(IMAGE *image, long index)
Post all shmim semaphores.
Definition: ImageStreamIO.c:1448
long ImageStreamIO_sempost_loop(IMAGE *image, long index, long dtus)
Post shmim semaphores at regular time interval.
Definition: ImageStreamIO.c:1584
long ImageStreamIO_semflush(IMAGE *image, long index)
Flush all semaphores of a shmim.
Definition: ImageStreamIO.c:1736
errno_t ImageStreamIO_createIm(IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int NBkw)
Create shared memory image stream (legacy API)
Definition: ImageStreamIO.c:583
Image structure definition.
uint64_t ImageStreamIO_readLastWroteIndex(const IMAGE *image)
Definition: ImageStreamIO.h:61
errno_t ImageStreamIO_openIm(IMAGE *image, const char *name)
Connect to an existing shared memory image stream.
Definition: ImageStreamIO.c:963
errno_t init_ImageStreamIO()
Definition: ImageStreamIO.c:86
uint64_t ImageStreamIO_writeIndex(const IMAGE *image)
Definition: ImageStreamIO.h:57
int ImageStreamIO_typesize(uint8_t atype)
Get the size in bytes from the data type code.
Definition: ImageStreamIO.c:407
IMAGE_METADATA * md
Definition: ImageStruct.h:351
uint32_t size[3]
Image size along each axis.
Definition: ImageStruct.h:217
int ImageStreamIO_createsem(IMAGE *image, long NBsem)
Create shmim semaphores.
Definition: ImageStreamIO.c:1370
int ImageStreamIO_semwait(IMAGE *image, int index)
Wait for semaphore.
Definition: ImageStreamIO.c:1673
int ImageStreamIO_getsemwaitindex(IMAGE *image, int semindexdefault)
Get available semaphore index.
Definition: ImageStreamIO.c:1619
void * ImageStreamIO_get_image_d_ptr(IMAGE *image)
Definition: ImageStreamIO.c:973
int ImageStreamIO_semtrywait(IMAGE *image, int index)
Definition: ImageStreamIO.c:1688