|
milk
1.01
Modular Image processing Library toolKit
|
Read and Create image. More...
#include <math.h>#include <pthread.h>#include <signal.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/file.h>#include <sys/mman.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <dirent.h>#include <arpa/inet.h>#include <errno.h>#include <fcntl.h>#include <netinet/in.h>#include <netinet/tcp.h>#include <semaphore.h>#include "ImageStreamIO.h"
Functions | |
| void | __attribute__ ((constructor)) |
| errno_t | init_ImageStreamIO () |
| errno_t | ImageStreamIO_printERROR_ (const char *file, const char *func, int line, errno_t code, char *errmessage) |
| errno_t | ImageStreamIO_printWARNING (char *warnmessage) |
| errno_t | ImageStreamIO_set_default_printError () |
| Set the error reporting function to the default provided by the library. More... | |
| 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 library function reports an error. Pass NULL to turn off error reporting from within the library. More... | |
| errno_t | ImageStreamIO_write_process_log (char *msg) |
| Write entry into debug log. More... | |
| errno_t | ImageStreamIO_printERROR_ (const char *file, const char *func, int line, __attribute__((unused)) errno_t code, char *errmessage) |
| 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. More... | |
| errno_t | ImageStreamIO_shmdirname (char *shmdname) |
| errno_t | ImageStreamIO_filename (char *file_name, size_t ssz, const char *im_name) |
| Get the standard stream filename. More... | |
| int | ImageStreamIO_typesize (uint8_t datatype) |
| Get the size in bytes from the data type code. More... | |
| int | ImageStreamIO_bitpix (uint8_t datatype) |
| Get the FITSIO BITPIX from the data type code. More... | |
| uint64_t | ImageStreamIO_offset_data (IMAGE *image, void *map) |
| uint64_t | ImageStreamIO_initialize_buffer (IMAGE *image) |
| errno_t | ImageStreamIO_createIm (IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t datatype, int shared, int NBkw) |
| Create shared memory image stream (legacy API) | |
| errno_t | ImageStreamIO_createIm_gpu (IMAGE *image, const char *name, long naxis, uint32_t *size, uint8_t datatype, int8_t location, int shared, int NBsem, int NBkw, uint64_t imagetype) |
| Create shared memory image stream. | |
| errno_t | ImageStreamIO_destroyIm (IMAGE *image) |
| Deallocate and remove an IMAGE structure. More... | |
| errno_t | ImageStreamIO_openIm (IMAGE *image, const char *name) |
| Connect to an existing shared memory image stream. More... | |
| void * | ImageStreamIO_get_image_d_ptr (IMAGE *image) |
| errno_t | ImageStreamIO_read_sharedmem_image_toIMAGE (const char *name, IMAGE *image) |
| Read / connect to existing shared memory image stream. More... | |
| errno_t | ImageStreamIO_closeIm (IMAGE *image) |
| Close a shared memmory image stream. More... | |
| errno_t | ImageStreamIO_destroysem (IMAGE *image) |
| Destroy shmim semaphores. More... | |
| 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... | |
| int | ImageStreamIO_getsemwaitindex (IMAGE *image, int semindexdefault) |
| Get available semaphore index. More... | |
| int | ImageStreamIO_semwait (IMAGE *image, int index) |
| Wait for semaphore. More... | |
| int | ImageStreamIO_semtrywait (IMAGE *image, int index) |
| int | ImageStreamIO_semtimedwait (IMAGE *image, int index, const struct timespec *semwts) |
| long | ImageStreamIO_semflush (IMAGE *image, long index) |
| Flush all semaphores of a shmim. More... | |
Variables | |
| static int | INITSTATUS_ImageStreamIO = 0 |
| errno_t(* | internal_printError )(const char *, const char *, int, errno_t, char *) = &ImageStreamIO_printERROR_ |
Read and Create image.
Read and create images and streams (shared memory)
| #define DEBUG_TRACEPOINTLOG | ( | ... | ) |
| int ImageStreamIO_bitpix | ( | uint8_t | atype | ) |
Get the FITSIO BITPIX from the data type code.
| errno_t ImageStreamIO_closeIm | ( | IMAGE * | image | ) |
Close a shared memmory image stream.
For use in clients, detaches and cleans up memory used by non-owner process.
| int ImageStreamIO_createsem | ( | IMAGE * | image, |
| long | NBsem | ||
| ) |
Create shmim semaphores.
Create semaphore of a shmim
| [in] | image | IMAGE* pointer to shmim |
| [in] | NBsem | number of semaphores to be created |
| errno_t ImageStreamIO_destroyIm | ( | IMAGE * | image | ) |
Deallocate and remove an IMAGE structure.
For a shared image: Closes all semaphores, deallcoates sem pointers, and removes associated files. Unmaps the shared memory segment, and finally removes the file. Sets the metadata and keyword pointers to NULL.
For a non-shred image: Deallocates all arrays and sets pointers to NULL.
| errno_t ImageStreamIO_destroysem | ( | IMAGE * | image | ) |
Destroy shmim semaphores.
Destroy semaphore of a shmim
| [in] | image | IMAGE* pointer to shmim |
| errno_t ImageStreamIO_filename | ( | char * | file_name, |
| size_t | ssz, | ||
| const char * | im_name | ||
| ) |
Get the standard stream filename.
Fills in the file_name string with the standard shared memory image path, e.g.
produces the output:
* /milk/shm/image00.im.shm 8
| void* ImageStreamIO_get_image_d_ptr | ( | IMAGE * | image | ) |
| int ImageStreamIO_getsemwaitindex | ( | IMAGE * | image, |
| int | semindexdefault | ||
| ) |
Get available semaphore index.
Get available shmim semaphore index
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | preferred semaphore index, if available |
| uint64_t ImageStreamIO_initialize_buffer | ( | IMAGE * | image | ) |
| errno_t ImageStreamIO_openIm | ( | IMAGE * | image, |
| const char * | name | ||
| ) |
Connect to an existing shared memory image stream.
Wrapper for ImageStreamIO_read_sharedmem_image_toIMAGE
| errno_t ImageStreamIO_printERROR_ | ( | const char * | file, |
| const char * | func, | ||
| int | line, | ||
| __attribute__((unused)) errno_t | code, | ||
| char * | errmessage | ||
| ) |
Print error to stderr
| errno_t ImageStreamIO_printWARNING | ( | char * | warnmessage | ) |
Print warning to stderr
| errno_t ImageStreamIO_read_sharedmem_image_toIMAGE | ( | const char * | name, |
| IMAGE * | image | ||
| ) |
Read / connect to existing shared memory image stream.
Read shared memory image
<
| 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.
Return the raw pointer to the beginning of the slice slice_index
| [in] | image | IMAGE* pointer to shmim |
| [in] | indec | const int slice_index of the slice to read |
| [out] | buffer | void** pointer to the beginning of the slice |
| long ImageStreamIO_semflush | ( | IMAGE * | image, |
| long | index | ||
| ) |
Flush all semaphores of a shmim.
Flush shmim semaphore
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | semaphore index flush all semaphores if index<0 |
| long ImageStreamIO_sempost | ( | IMAGE * | image, |
| long | index | ||
| ) |
Post all shmim semaphores.
Posts semaphore of a shmim if index < 0, post all semaphores
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | semaphore 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.
Posts all semaphores of a shmim except one
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | semaphore index index of semaphore to be excluded |
| long ImageStreamIO_sempost_loop | ( | IMAGE * | image, |
| long | index, | ||
| long | dtus | ||
| ) |
Post shmim semaphores at regular time interval.
Posts all semaphores of a shmim at regular time intervals
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | semaphore index is =-1, post all semaphores |
| [in] | dtus | time interval [us] |
| int ImageStreamIO_semwait | ( | IMAGE * | image, |
| int | index | ||
| ) |
Wait for semaphore.
Wait on a shmim semaphore
| [in] | image | IMAGE* pointer to shmim |
| [in] | index | semaphore index |
| errno_t ImageStreamIO_set_default_printError | ( | ) |
Set the error reporting function to the default provided by the library.
| errno_t ImageStreamIO_set_printError | ( | errno_t(*)(const char *, const char *, int, errno_t, char *) | new_printError | ) |
Set the error reporting function. The new function supplied by the pointer will be called whenever a library function reports an error. Pass NULL to turn off error reporting from within the library.
| new_printError | is a pointer to the function to use for reporting errors. Can be NULL. |
| int ImageStreamIO_typesize | ( | uint8_t | atype | ) |
Get the size in bytes from the data type code.
| errno_t ImageStreamIO_write_process_log | ( | char * | msg | ) |
Write entry into debug log.