coffee
Coronagraph Optimization For Fast Exoplanet Exploration
ImageStreamIO.c File Reference

Read and Create image. More...

Functions

void __attribute__ ((constructor))
 
int_fast8_t init_ImageStreamIO ()
 
int ImageStreamIO_printERROR (const char *file, const char *func, int line, char *errmessage)
 
1. READ / WRITE STREAM
int ImageStreamIO_createIm (IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t atype, int shared, int NBkw)
 Create shared memory image stream. More...
 
long ImageStreamIO_read_sharedmem_image_toIMAGE (const char *name, IMAGE *image)
 Read / connect to existing shared memory image stream. More...
 
2. MANAGE SEMAPHORES
int ImageStreamIO_createsem (IMAGE *image, long NBsem)
 Create shmim semaphores. More...
 
long ImageStreamIO_sempost (IMAGE *image, long index)
 Post all shmim semaphores. More...
 
long ImageStreamIO_sempost_excl (IMAGE *image, long index)
 Post all shmim semaphores except one. More...
 
long ImageStreamIO_sempost_loop (IMAGE *image, long index, long dtus)
 Post shmim semaphores at regular time interval. More...
 
long ImageStreamIO_semwait (IMAGE *image, long index)
 Wait for semaphore. More...
 
long ImageStreamIO_semflush (IMAGE *image, long index)
 Flush all semaphores of a shmim. More...
 

Detailed Description

Read and Create image.

Read and create images and streams (shared memory)

Author
O. Guyon
Bug:
No known bugs.

Function Documentation

void __attribute__ ( (constructor)  )
int ImageStreamIO_createIm ( IMAGE image,
const char *  name,
long  naxis,
uint32_t *  size,
uint8_t  atype,
int  shared,
int  NBkw 
)

Create shared memory image stream.

Parameters
[out]imageIMAGE structure which will have its members allocated and initialized.
[in]namethe name of the shared memory file will be SHAREDMEMDIR/<name>_im.shm
[in]naxisnumber of axes in the image.
[in]sizethe size of the image along each axis. Must have naxis elements.
[in]atypedata type code
[in]sharedif true then a shared memory buffer is allocated. If false, only local storage is used.
[in]NBkwthe number of keywords to allocate.
int ImageStreamIO_createsem ( IMAGE image,
long  NBsem 
)

Create shmim semaphores.

Purpose

Create semaphore of a shmim

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]NBsemnumber of semaphores to be created
int ImageStreamIO_printERROR ( const char *  file,
const char *  func,
int  line,
char *  errmessage 
)
long ImageStreamIO_read_sharedmem_image_toIMAGE ( const char *  name,
IMAGE image 
)

Read / connect to existing shared memory image stream.

Parameters
[in]namethe name of the shared memory file to access, as in SHAREDMEMDIR/<name>_im.shm
[out]imagethe IMAGE structure to connect to the stream
long ImageStreamIO_semflush ( IMAGE image,
long  index 
)

Flush all semaphores of a shmim.

Purpose

Flush shmim semaphore

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]indexsemaphore index flush all semaphores if index<0
long ImageStreamIO_sempost ( IMAGE image,
long  index 
)

Post all shmim semaphores.

Purpose

Posts semaphore of a shmim if index < 0, post all semaphores

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]indexsemaphore index index of semaphore to be posted if index=-1, post all semaphores
long ImageStreamIO_sempost_excl ( IMAGE image,
long  index 
)

Post all shmim semaphores except one.

Purpose

Posts all semaphores of a shmim except one

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]indexsemaphore index index of semaphore to be excluded
long ImageStreamIO_sempost_loop ( IMAGE image,
long  index,
long  dtus 
)

Post shmim semaphores at regular time interval.

Purpose

Posts all semaphores of a shmim at regular time intervals

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]indexsemaphore index is =-1, post all semaphores
[in]dtustime interval [us]
long ImageStreamIO_semwait ( IMAGE image,
long  index 
)

Wait for semaphore.

Purpose

Wait on a shmim semaphore

Arguments

Parameters
[in]imageIMAGE* pointer to shmim
[in]indexsemaphore index
int_fast8_t init_ImageStreamIO ( )