McStas Readout Master 0.3.3
Loading...
Searching...
No Matches
readout_capi.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <stdint.h>
14#include <stddef.h>
15
17#ifdef WIN32
18// Export symbols if compile flags "READOUT_SHARED" and "READOUT_EXPORT" are set on Windows.
19 #ifdef READOUT_SHARED
20 #ifdef READOUT_EXPORT
21 #define RL_API __declspec(dllexport)
22 #else
23 #define RL_API __declspec(dllimport)
24 #endif
25 #else
26 // Disable definition if linking statically.
27 #define RL_API
28 #endif
29#else
30// Disable definition for non-Win32 systems.
31#define RL_API
32#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
41#define READOUT_CAPI_ABI_VERSION 1
42
44RL_API int readout_capi_abi_version(void);
45
47RL_API const char * readout_version(void);
48
54RL_API const char * readout_last_error(void);
55
62
63/* ---- replay --------------------------------------------------------------- */
64
66typedef struct readout_replay readout_replay_t;
67
72
73/* Configuration setters mirroring ReplayConfig (replay.h). Each returns
74 * READOUT_OK or READOUT_ERROR (NULL handle, invalid value, or bad JSON). */
75
77RL_API int readout_replay_set_counting_time(readout_replay_t * handle, double seconds);
81RL_API int readout_replay_set_seed(readout_replay_t * handle, uint32_t seed);
83RL_API int readout_replay_set_random_order(readout_replay_t * handle, int enable);
85RL_API int readout_replay_set_default_endpoint(readout_replay_t * handle, const char * address, int port);
87RL_API int readout_replay_set_chunk_size(readout_replay_t * handle, uint64_t chunk);
89RL_API int readout_replay_set_subset(readout_replay_t * handle, uint64_t first, uint64_t number, uint64_t every);
93RL_API int readout_replay_set_pulse_rate(readout_replay_t * handle, double hz);
95RL_API int readout_replay_set_fold_tof(readout_replay_t * handle, int enable);
97RL_API int readout_replay_set_senders_json(readout_replay_t * handle, const char * json_text);
98
106typedef int (*readout_publish_cb)(void * user_data, uint64_t point,
107 const char * name, const char * value,
108 const char * unit_or_null);
110typedef int (*readout_point_ready_cb)(void * user_data, uint64_t point);
111
118RL_API int readout_replay_run(readout_replay_t * handle, const char * filename,
119 readout_publish_cb publish,
120 readout_point_ready_cb point_ready,
121 void * user_data);
122
134
135/* ---- combine --------------------------------------------------------------- */
136
141RL_API int64_t readout_validate_collector_file(const char * filename);
142
150RL_API int readout_append_collector_files(const char * out_filename,
151 const char * const * in_filenames, size_t n_in,
152 int reset_datasets);
153
160RL_API int readout_concatenate_collector_files(const char * out_filename,
161 const char * const * in_filenames, size_t n_in);
162
169RL_API int readout_combine_collector_files(const char * out_filename,
170 const char * const * in_filenames, size_t n_in);
171
172#ifdef __cplusplus
173} // extern "C"
174#endif
RL_API int readout_capi_abi_version(void)
The READOUT_CAPI_ABI_VERSION the library was compiled with.
RL_API int readout_replay_set_chunk_size(readout_replay_t *handle, uint64_t chunk)
Number of stored readouts per HDF5 read (default 65536); also the mid-point cancellation granularity.
int(* readout_point_ready_cb)(void *user_data, uint64_t point)
Per-point publisher callback (ParameterPublisher::point_ready); same return convention.
RL_API int readout_replay_clear_subset(readout_replay_t *handle)
Remove a previously set subset restriction.
RL_API readout_replay_t * readout_replay_create(void)
Create a replay handle with default configuration; NULL on allocation failure.
RL_API int readout_replay_set_default_endpoint(readout_replay_t *handle, const char *address, int port)
EFU address and UDP port for collector groups without explicit or file-embedded routing.
RL_API int readout_replay_set_random_order(readout_replay_t *handle, int enable)
Nonzero shuffles events within each (point, collector group) before sending.
RL_API int readout_replay_set_counting_time(readout_replay_t *handle, double seconds)
Counting time in seconds: a stored readout with rate-weight w is sent n ~ Poisson(w * seconds) times.
RL_API int readout_replay_set_pulse_rate(readout_replay_t *handle, double hz)
Pulse (reference time) repetition rate in Hz (default 14, the ESS source frequency).
int(* readout_publish_cb)(void *user_data, uint64_t point, const char *name, const char *value, const char *unit_or_null)
Per-parameter publisher callback (ParameterPublisher::publish).
RL_API int readout_append_collector_files(const char *out_filename, const char *const *in_filenames, size_t n_in, int reset_datasets)
Combine same-point collector files (identical parameters) by appending readouts.
struct readout_replay readout_replay_t
Opaque replay handle: a ReplayConfig plus a thread-safe stop flag.
RL_API int readout_replay_run(readout_replay_t *handle, const char *filename, readout_publish_cb publish, readout_point_ready_cb point_ready, void *user_data)
Replay a collector file; blocking.
RL_API void readout_replay_destroy(readout_replay_t *handle)
Destroy a replay handle; must not be called while readout_replay_run is blocking on it.
RL_API void readout_replay_reset_stop(readout_replay_t *handle)
Clear a previous stop request so the handle can be reused.
RL_API int readout_combine_collector_files(const char *out_filename, const char *const *in_filenames, size_t n_in)
Combine collector files, choosing append or concatenate per their parameters.
RL_API const char * readout_last_error(void)
Message describing the most recent failure on the calling thread; never NULL.
RL_API int readout_replay_stop_requested(const readout_replay_t *handle)
1 when a stop has been requested on the handle, else 0.
RL_API const char * readout_version(void)
The library version string, e.g. "0.4.0".
RL_API void readout_replay_request_stop(readout_replay_t *handle)
Request that a running replay stop at the next point or chunk boundary.
RL_API int readout_replay_set_seed(readout_replay_t *handle, uint32_t seed)
Sampling/shuffling generator seed; 0 (the default) selects a non-deterministic seed.
RL_API int readout_replay_set_fold_tof(readout_replay_t *handle, int enable)
Nonzero stamps events at pulse + (tof %% period), wrapping long-flight events into their detection fr...
RL_API int readout_concatenate_collector_files(const char *out_filename, const char *const *in_filenames, size_t n_in)
Combine different-point collector files into one multi-point cue-based file.
readout_status
Status codes returned by the C API entry points.
@ READOUT_STOPPED
replay stopped early via request_stop or a nonzero callback return
@ READOUT_ERROR
failed; see readout_last_error()
@ READOUT_OK
completed successfully
RL_API int64_t readout_validate_collector_file(const char *filename)
Validate a collector file.
RL_API int readout_replay_clear_counting_time(readout_replay_t *handle)
Unset the counting time so every stored readout is sent exactly once (the default).
RL_API int readout_replay_set_senders_json(readout_replay_t *handle, const char *json_text)
Explicit EFU routing as a JSON document (see SenderConfigs); READOUT_ERROR with a parse message on in...
RL_API int readout_replay_set_subset(readout_replay_t *handle, uint64_t first, uint64_t number, uint64_t every)
Restrict replay to stored readouts with global index first + k * every, for k in [0,...