MIDAS
Loading...
Searching...
No Matches
midas_c_compat.cxx
Go to the documentation of this file.
1#include "midas_c_compat.h"
2#include "midas.h"
3#include "mrpc.h"
4#include "msystem.h"
5#include <vector>
6#include <string>
7#include "string.h"
8#include "stdlib.h"
9#include "stdarg.h"
10#include "history.h"
11
12/*
13We define a simple free function to ensure that python clients can
14free any memory that was allocated by midas. We define it as part
15of this library (rather than importing libc directly in python) to
16ensure that the same version of libc is used for the alloc and free.
17*/
18void c_free(void* mem) {
19 free(mem);
20}
21
22void c_free_list(void** mem_list, int arr_len) {
23 for (int i = 0; i < arr_len; i++) {
24 free(mem_list[i]);
25 }
26
27 free(mem_list);
28}
29
30/*
31Copies the content for src to dest (at most dest_size bytes).
32dest should already have been allocated to the correct size.
33If the destination is not large enough to hold the entire src
34string, we return DB_TRUNCATED; otherwise we return SUCCESS.
35
36In general it's preferable to accept a char** from python rather than
37a buffer of a fixed size. Although python must then remember to free
38the memory we allocated.
39 */
40INT copy_string_to_c(std::string src, char* dest, DWORD dest_size) {
41 strncpy(dest, src.c_str(), dest_size);
42
43 if (src.size() > dest_size) {
44 return DB_TRUNCATED;
45 }
46
47 return SUCCESS;
48}
49
50/*
51Copies the content of vec into an array of type 'T' at dest. Will malloc the
52memory needed, so you must later call c_free() on dest. Fills dest_len with
53the size of the vector.
54 */
55template <class T> INT copy_vector_to_c(std::vector<T> vec, void** dest, int& dest_len) {
56 dest_len = vec.size();
57 *dest = malloc(sizeof(T) * dest_len);
58 std::copy(vec.begin(), vec.end(), (T*)*dest);
59 return SUCCESS;
60}
61
62/*
63Copies the content of vec into an array of char* at dest. Will malloc the
64memory needed for each string (and for the array itself), so you must later call
65c_free_list() on dest. Fills dest_len with the size of the vector.
66 */
67INT copy_vector_string_to_c(std::vector<std::string> vec, char*** dest, int& dest_len) {
68 dest_len = vec.size();
69 *dest = (char**) malloc(sizeof(char*) * dest_len);
70
71 for (int i = 0; i < dest_len; i++) {
72 (*dest)[i] = strdup(vec[i].c_str());
73 }
74
75 return SUCCESS;
76}
77
78/*
79Example of how one could wrap a midas function that returns/fills a std::string.
80In this version we accept a buffer of a specified size from the user.
81
82The python code would be:
83```
84buffer = ctypes.create_string_buffer(64)
85lib.c_example_string_c_bufsize(buffer, 64)
86py_str = buffer.value.decode("utf-8")
87```
88 */
89INT c_example_string_c_bufsize(char* buffer, DWORD buffer_size) {
90 std::string retval("My string that would come from a C++ function");
91 return copy_string_to_c(retval, buffer, buffer_size);
92}
93
94/*
95Example of how one could wrap a midas function that returns/fills a std::string.
96In this version we allocate memory for the C char array. The caller must later
97free this memory themselves.
98
99The python code would be (note the final free!):
100```
101buffer = ctypes.c_char_p()
102lib.c_example_string_c_alloc(ctypes.byref(buffer))
103py_str = buffer.value.decode("utf-8")
104lib.c_free(buffer)
105```
106 */
108 std::string retval("My string that would come from a C++ function");
109 *dest = strdup(retval.c_str());
110 return SUCCESS;
111}
112
113/*
114Example of how one could wrap a midas function that returns/fills a std::vector.
115In this version we allocate memory for the C array. The caller must later
116free this memory themselves.
117
118The python code would be (note the final free!):
119```
120import ctypes
121import midas.client
122
123client = midas.client.MidasClient("pytest")
124lib = client.lib
125
126arr = ctypes.c_void_p()
127arr_len = ctypes.c_int()
128lib.c_example_vector(ctypes.byref(arr), ctypes.byref(arr_len))
129casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_float))
130py_list = casted[:arr_len.value]
131lib.c_free(arr)
132```
133 */
135 std::vector<float> retvec;
136 for (int i = 0; i < 10; i++) {
137 retvec.push_back(i/3.);
138 }
139
141}
142
143/*
144Example of how one could wrap a midas function that returns/fills a std::vector.
145In this version we allocate memory for the C array. The caller must later
146free this memory themselves.
147
148The python code would be (note the final free!):
149```
150import ctypes
151import midas.client
152client = midas.client.MidasClient("pytest")
153lib = client.lib
154
155arr = ctypes.POINTER(ctypes.c_char_p)()
156arr_len = ctypes.c_int()
157lib.c_example_string_vector(ctypes.byref(arr), ctypes.byref(arr_len))
158casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_char_p))
159py_list = [casted[i].decode("utf-8") for i in range(arr_len.value)]
160lib.c_free_list(arr, arr_len)
161```
162 */
164 std::vector<std::string> retvec;
165 retvec.push_back("Hello");
166 retvec.push_back("world!");
167
169}
170
171INT c_al_trigger_alarm(const char *alarm_name, const char *alarm_message, const char *default_class, const char *cond_str, INT type) {
172 return al_trigger_alarm(alarm_name, alarm_message, default_class, cond_str, type);
173}
174
177}
178
179INT c_al_define_odb_alarm(const char *name, const char *condition, const char *aclass, const char *message) {
180 return al_define_odb_alarm(name, condition, aclass, message);
181}
182
183INT c_bm_flush_cache(INT buffer_handle, INT async_flag) {
184 return bm_flush_cache(buffer_handle, async_flag);
185}
186
187INT c_bm_open_buffer(const char *buffer_name, INT buffer_size, INT * buffer_handle) {
188 return bm_open_buffer(buffer_name, buffer_size, buffer_handle);
189}
190
191INT c_bm_receive_event(INT buffer_handle, void *destination, INT * buf_size, INT async_flag) {
192 return bm_receive_event(buffer_handle, destination, buf_size, async_flag);
193}
194
195INT c_bm_remove_event_request(INT buffer_handle, INT request_id) {
196 return bm_remove_event_request(buffer_handle, request_id);
197}
198
199INT c_bm_request_event(INT buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, INT * request_id) {
200 // Final argument is function pointer that python lib doesn't need.
201 return bm_request_event(buffer_handle, event_id, trigger_mask, sampling_type, request_id, 0);
202}
203
207
208INT c_cm_connect_client(const char *client_name, HNDLE * hConn) {
209 return cm_connect_client(client_name, hConn);
210}
211
212INT c_cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void (*func) (char *)) {
213 return cm_connect_experiment(host_name, exp_name, client_name, func);
214}
215
219
223
227
229 return cm_exist(name, bUnique);
230}
231
235
239
240INT c_cm_get_path(char *path, int path_size) {
241 std::string str_path = cm_get_path();
242 return copy_string_to_c(str_path, path, path_size);
243}
244
245const char* c_cm_get_revision(void) {
246 // If this changes to returning a string, do:
247 // return strdup(cm_get_revision().c_str());
248 return cm_get_revision();
249}
250
251const char* c_cm_get_version(void) {
252 // If this changes to returning a string, do:
253 // return strdup(cm_get_version().c_str());
254 return cm_get_version();
255}
256
257INT c_cm_msg(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format, ...) {
259 char message[1000];
260 va_start(argptr, format);
261 vsnprintf(message, 1000, (char *) format, argptr);
262 va_end(argptr);
263 return cm_msg1(message_type, filename, line, facility, routine, "%s", message);
264}
265
266/*
267Remember to call c_free_list on the dest afterwards. E.g.:
268```
269import ctypes
270import midas.client
271lib = midas.client.MidasClient("pytest").lib
272
273arr = ctypes.POINTER(ctypes.c_char_p)()
274arr_len = ctypes.c_int()
275lib.c_cm_msg_facilities(ctypes.byref(arr), ctypes.byref(arr_len))
276casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_char_p))
277py_list = [casted[i].decode("utf-8") for i in range(arr_len.value)]
278lib.c_free_list(arr, arr_len)
279```
280*/
282 std::vector<std::string> retvec;
284 if (retcode == SUCCESS) {
286 } else {
287 return retcode;
288 }
289}
290
292 return cm_msg_register(func);
293}
294
296 // Python ctypes doesn't know the size of time_t, so just accept a uint64_t and convert here.
297 time_t t = before;
299 return retval;
300}
301
305
309
313
314INT c_cm_register_function(INT id, INT(*func) (INT, void **)) {
315 return cm_register_function(id, func);
316}
317
318INT c_cm_register_transition(INT transition, INT(*func) (INT, char *), int sequence_number) {
319 return cm_register_transition(transition, func, sequence_number);
320}
321
323 return cm_set_transition_sequence(transition, sequence_number);
324}
325
327 return cm_shutdown(name, bUnique);
328}
329
333
337
338INT c_cm_transition(INT transition, INT run_number, char *error, INT strsize, INT async_flag, INT debug_flag) {
339 return cm_transition(transition, run_number, error, strsize, async_flag, debug_flag);
340}
341
345
349
350INT c_db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int* buffer_size, int* buffer_end) {
351 return db_copy_json_ls(hDB, hKey, buffer, buffer_size, buffer_end);
352}
353
354INT c_db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int* buffer_size, int* buffer_end) {
355 return db_copy_json_save(hDB, hKey, buffer, buffer_size, buffer_end);
356}
357
359 return db_create_key(hdb, key_handle, key_name, type);
360}
361
365
369
373
377
379 return db_find_key(hdb, hkey, name, hsubkey);
380}
381
382INT c_db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE * subhKey) {
383 return db_find_link(hDB, hKey, key_name, subhKey);
384}
385
389
391 return db_get_link_data(hdb, key_handle, data, buf_size, type);
392}
393
397
398INT c_db_get_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, void *data, INT * size, DWORD type, BOOL create) {
399 return db_get_value(hdb, hKeyRoot, key_name, data, size, type, create);
400}
401
402INT c_db_open_record(HNDLE hdb, HNDLE hkey, void *ptr, INT rec_size, WORD access, void (*dispatcher) (INT, INT, void *), void *info) {
403 return db_open_record(hdb, hkey, ptr, rec_size, access, dispatcher, info);
404}
405
407 return db_rename_key(hDB, hKey, name);
408}
409
413
414INT c_db_resize_string(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_size) {
415 return db_resize_string(hDB, hKeyRoot, key_name, num_values, max_string_size);
416}
417
418INT c_db_set_link_data(HNDLE hdb, HNDLE key_handle, void *data, INT buf_size, int num_values, DWORD type) {
419 return db_set_link_data(hdb, key_handle, data, buf_size, num_values, type);
420}
421
423 return db_set_num_values(hDB, hKey, num_values);
424}
425
426INT c_db_set_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, const void *data, INT size, INT num_values, DWORD type) {
427 return db_set_value(hdb, hKeyRoot, key_name, data, size, num_values, type);
428}
429
430INT c_db_set_value_index(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT index, DWORD type, BOOL truncate) {
431 return db_set_value_index(hDB, hKeyRoot, key_name, data, data_size, index, type, truncate);
432}
433
437
438INT c_db_watch(HNDLE hDB, HNDLE hKey, void (*dispatcher) (INT, INT, INT, void*), void* info) {
439 return db_watch(hDB, hKey, dispatcher, info);
440}
441
442INT c_jrpc_client_call(HNDLE hconn, char* cmd, char* args, char* buf, int buf_length) {
443 // Specialized version of rpc_client_call that just deals with RPC_JRPC,
444 // so we don't have to worry about variable arg lists.
445 // You must already have malloc'd buf to be big enough for buf_length.
446 return rpc_client_call(hconn, RPC_JRPC, cmd, args, buf, buf_length);
447}
448
449INT c_brpc_client_call(HNDLE hconn, char* cmd, char* args, char* buf, int& buf_length) {
450 // Specialized version of rpc_client_call that just deals with RPC_BRPC,
451 // so we don't have to worry about variable arg lists.
452 // You must already have malloc'd buf to be big enough for buf_length.
453 return rpc_client_call(hconn, RPC_BRPC, cmd, args, buf, &buf_length);
454}
455
457 return rpc_flush_event();
458}
459
461 return rpc_is_remote();
462}
463
464INT c_rpc_send_event(INT buffer_handle, const EVENT_HEADER *event, INT buf_size, INT async_flag, INT mode) {
465 return rpc_send_event(buffer_handle, event, buf_size, async_flag, mode);
466}
467
471
473 return ss_exec(cmd, child_pid);
474}
475
477
480
481 if (mh == nullptr) {
483 }
484
485 return status;
486}
487
490
491 if (status != SUCCESS) {
492 return status;
493 }
494
495 time_t t = 0;
496 std::vector<std::string> events;
497
499
500 if (status != SUCCESS) {
501 return status;
502 }
503
505}
506
507INT c_hs_get_tags(HNDLE hDB, char* event_name, char*** dest_names, void** dest_types, void** dest_n_data, int& dest_len) {
509
510 if (status != SUCCESS) {
511 return status;
512 }
513
514 time_t t = 0;
515 std::vector<TAG> tags;
516 status = mh->hs_get_tags(event_name, t, &tags);
517
518 if (status != SUCCESS) {
519 return status;
520 }
521
522 std::vector<std::string> tag_names;
523 std::vector<DWORD> tag_types;
524 std::vector<DWORD> tag_n_data;
525
526 for (auto& tag : tags) {
527 tag_names.push_back(tag.name);
528 tag_types.push_back(tag.type);
529 tag_n_data.push_back(tag.n_data);
530 }
531
535 return SUCCESS;
536}
537
539 uint32_t start_time, uint32_t end_time, uint32_t interval_secs,
540 char* event_name, char* tag_name, int idx_start, int nvars,
541 void** num_entries, void** times, void** values, void** hs_status) {
542 // Note this function varies from hs_read() for the times/tbuffer and values/vbuffer
543 // parameters! To simplify passing between python/C, we concatenate all the data for
544 // all variables into one array, rather than using a 2D array.
545 // So num_entries and hs_status are length "nvars", while
546 // times and values are length "sum of num_entries".
548
549 if (status != SUCCESS) {
550 return status;
551 }
552
553 const char** event_names = (const char**)calloc(nvars, sizeof(const char*));
554 const char** var_names = (const char**)calloc(nvars, sizeof(const char*));
555 int* indices = (int*)calloc(nvars, sizeof(int));
556
557 for (int i = 0; i < nvars; i++) {
558 event_names[i] = event_name;
559 var_names[i] = tag_name;
560 indices[i] = idx_start + i;
561 }
562
563 *num_entries = calloc(nvars, sizeof(int));
564 time_t** tbuffer_int = (time_t**)calloc(nvars, sizeof(time_t*));
565 double** vbuffer_int = (double**)calloc(nvars, sizeof(double*));
566 *hs_status = calloc(nvars, sizeof(int));
567
568 status = mh->hs_read(start_time, end_time, interval_secs, nvars, event_names, var_names, indices, (int*)*num_entries, tbuffer_int, vbuffer_int, (int*)*hs_status);
569
570 // Simplify passing back to python by concatenating timestamp buffers into
571 // a single buffer rather than 2-D array. Same for value buffers.
572 size_t tot_len = 0;
573
574 for (int i = 0; i < nvars; i++) {
575 tot_len += ((int*)(*num_entries))[i];
576 }
577
578 if (tot_len > 0) {
579 *times = calloc(tot_len, sizeof(uint32_t));
580 *values = calloc(tot_len, sizeof(double));
581
583 double* cast_vbuffer = (double*)*values;
584 size_t offset = 0;
585
586 for (int i = 0; i < nvars; i++) {
587 size_t this_n = ((int*)(*num_entries))[i];
588 for (int n = 0; n < (int) this_n; n++) {
589 // Deal with time_t vs uint32_t possibly being different sizes
590 // by manually copying values rather than doing a memcpy.
593 }
594
595 offset += this_n;
596 }
597 }
598
599 free(tbuffer_int);
600 free(vbuffer_int);
601 free(event_names);
602 free(var_names);
603 free(indices);
604
605 return status;
606}
virtual int hs_read(time_t start_time, time_t end_time, time_t interval, int num_var, const char *const event_name[], const char *const tag_name[], const int var_index[], int num_entries[], time_t *time_buffer[], double *data_buffer[], int status[])=0
see hs_read(), returns HS_SUCCESS
virtual int hs_get_events(time_t time_from, std::vector< std::string > *pevents)=0
get list of events that exist(ed) at given time and later (value 0 means "return all events from begi...
virtual int hs_get_tags(const char *event_name, time_t time_from, std::vector< TAG > *ptags)=0
get list of history variables for given event (use event names returned by hs_get_events()) that exis...
INT transition(INT run_number, char *error)
Definition consume.cxx:35
INT EXPRT al_define_odb_alarm(const char *name, const char *condition, const char *aclass, const char *message)
Definition alarm.cxx:921
INT al_reset_alarm(const char *alarm_name)
Definition alarm.cxx:525
INT al_trigger_alarm(const char *alarm_name, const char *alarm_message, const char *default_class, const char *cond_str, INT type)
Definition alarm.cxx:283
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
Definition midas.cxx:6717
INT bm_request_event(HNDLE buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, HNDLE *request_id, EVENT_HANDLER *func)
Definition midas.cxx:8465
INT bm_receive_event(INT buffer_handle, void *destination, INT *buf_size, int timeout_msec)
Definition midas.cxx:10650
INT bm_remove_event_request(INT buffer_handle, INT request_id)
Definition midas.cxx:8518
INT bm_flush_cache(int buffer_handle, int timeout_msec)
Definition midas.cxx:10207
INT cm_register_transition(INT transition, INT(*func)(INT, char *), INT sequence_number)
Definition midas.cxx:3593
INT cm_shutdown(const char *name, BOOL bUnique)
Definition midas.cxx:7400
INT cm_disconnect_client(HNDLE hConn, BOOL bShutdown)
Definition midas.cxx:2833
INT cm_yield(INT millisec)
Definition midas.cxx:5642
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
Definition midas.cxx:3011
INT cm_connect_client(const char *client_name, HNDLE *hConn)
Definition midas.cxx:2766
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
Definition midas.cxx:2278
INT cm_start_watchdog_thread()
Definition midas.cxx:7355
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
Definition midas.cxx:5286
INT cm_stop_watchdog_thread()
Definition midas.cxx:7370
INT cm_register_function(INT id, INT(*func)(INT, void **))
Definition midas.cxx:5790
INT cm_disconnect_experiment(void)
Definition midas.cxx:2846
std::string cm_get_path()
Definition midas.cxx:1537
INT cm_register_deferred_transition(INT transition, BOOL(*func)(INT, BOOL))
Definition midas.cxx:3837
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
Definition midas.cxx:2134
const char * cm_get_version()
Definition midas.cxx:1476
INT cm_deregister_transition(INT transition)
Definition midas.cxx:3669
INT cm_check_deferred_transition()
Definition midas.cxx:3889
INT cm_set_transition_sequence(INT transition, INT sequence_number)
Definition midas.cxx:3723
const char * cm_get_revision()
Definition midas.cxx:1484
INT cm_exist(const char *name, BOOL bUnique)
Definition midas.cxx:7520
#define DB_TRUNCATED
Definition midas.h:644
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
#define SUCCESS
Definition mcstd.h:54
void() EVENT_HANDLER(HNDLE buffer_handler, HNDLE request_id, EVENT_HEADER *event_header, void *event_data)
Definition midas.h:918
INT ss_daemon_init(BOOL keep_stdout)
Definition system.cxx:2001
INT ss_exec(const char *command, INT *pid)
Definition system.cxx:2132
INT cm_msg1(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
Definition midas.cxx:973
INT EXPRT cm_msg_facilities(STRING_LIST *list)
Definition midas.cxx:504
int cm_msg_open_buffer(void)
Definition midas.cxx:474
int cm_msg_close_buffer(void)
Definition midas.cxx:487
INT cm_msg_register(EVENT_HANDLER *func)
Definition midas.cxx:1051
INT cm_msg_retrieve2(const char *facility, time_t t, INT n_message, char **messages, int *num_messages)
Definition midas.cxx:1264
INT db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
Definition odb.cxx:3856
INT db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4274
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
Definition odb.cxx:5415
INT db_reorder_key(HNDLE hDB, HNDLE hKey, INT idx)
Definition odb.cxx:6361
static const KEY * db_get_parent(const DATABASE_HEADER *pheader, const KEY *pkey, int *pstatus, const char *caller, db_err_msg **msg)
Definition odb.cxx:1030
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
Definition odb.cxx:13291
INT db_set_link_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
Definition odb.cxx:7425
INT db_create_key(HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
Definition odb.cxx:3308
INT db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
Definition odb.cxx:10475
INT db_unwatch(HNDLE hDB, HNDLE hKey)
Definition odb.cxx:13887
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
Definition odb.cxx:6019
INT db_watch(HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
Definition odb.cxx:13813
INT db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
Definition odb.cxx:5725
INT db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
Definition odb.cxx:10421
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
Definition odb.cxx:5261
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4079
INT db_get_link_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
Definition odb.cxx:6656
INT db_rename_key(HNDLE hDB, HNDLE hKey, const char *name)
Definition odb.cxx:6261
INT db_set_value_index(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT idx, DWORD type, BOOL trunc)
Definition odb.cxx:5365
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
Definition odb.cxx:5586
INT EXPRT db_resize_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_length)
Definition odb.cxx:14025
INT db_close_record(HNDLE hDB, HNDLE hKey)
Definition odb.cxx:13473
INT db_set_num_values(HNDLE hDB, HNDLE hKey, INT num_values)
Definition odb.cxx:7502
INT db_create_link(HNDLE hDB, HNDLE hKey, const char *link_name, const char *destination)
Definition odb.cxx:3601
#define RPC_BRPC
Definition mrpc.h:131
INT rpc_client_call(HNDLE hConn, DWORD routine_id,...)
Definition midas.cxx:13472
#define RPC_JRPC
Definition mrpc.h:130
bool rpc_is_remote(void)
Definition midas.cxx:12761
INT rpc_flush_event()
Definition midas.cxx:14038
INT rpc_send_event(INT buffer_handle, const EVENT_HEADER *pevent, int unused, INT async_flag, INT mode)
Definition midas.cxx:13901
#define HS_GET_DEFAULT
Definition history.h:38
#define HS_GET_INACTIVE
Definition history.h:37
#define HS_GET_READER
Definition history.h:35
int hs_get_history(HNDLE hDB, HNDLE hKey, int flags, int debug_flag, MidasHistoryInterface **mh)
void ** info
Definition fesimdaq.cxx:41
HNDLE hKey
char exp_name[NAME_LENGTH]
Definition mana.cxx:243
INT run_number[2]
Definition mana.cxx:246
DWORD n[4]
Definition mana.cxx:247
INT index
Definition mana.cxx:271
void * data
Definition mana.cxx:268
BOOL debug
debug printouts
Definition mana.cxx:254
INT type
Definition mana.cxx:269
HNDLE hDB
main ODB handle
Definition mana.cxx:207
char host_name[HOST_NAME_LENGTH]
Definition mana.cxx:242
BOOL create
Definition mchart.cxx:39
KEY key
Definition mdump.cxx:34
INT i
Definition mdump.cxx:32
char buffer_name[NAME_LENGTH]
Definition mevb.cxx:45
static int offset
Definition mgd.cxx:1500
INT HNDLE
Definition midas.h:132
DWORD BOOL
Definition midas.h:105
int INT
Definition midas.h:129
INT copy_vector_string_to_c(std::vector< std::string > vec, char ***dest, int &dest_len)
INT c_db_reorder_key(HNDLE hDB, HNDLE hKey, INT index)
INT c_db_create_key(HNDLE hdb, HNDLE key_handle, const char *key_name, DWORD type)
INT c_rpc_is_remote(void)
INT c_cm_connect_client(const char *client_name, HNDLE *hConn)
INT c_bm_receive_event(INT buffer_handle, void *destination, INT *buf_size, INT async_flag)
const char * c_cm_get_version(void)
INT c_al_define_odb_alarm(const char *name, const char *condition, const char *aclass, const char *message)
INT copy_string_to_c(std::string src, char *dest, DWORD dest_size)
INT c_cm_check_deferred_transition(void)
INT c_cm_register_transition(INT transition, INT(*func)(INT, char *), int sequence_number)
INT c_al_reset_alarm(const char *alarm_name)
INT c_example_vector(void **dest, int &dest_len)
const char * c_cm_get_revision(void)
INT c_db_set_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, const void *data, INT size, INT num_values, DWORD type)
INT c_db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT c_db_set_link_data(HNDLE hdb, HNDLE key_handle, void *data, INT buf_size, int num_values, DWORD type)
INT c_cm_get_path(char *path, int path_size)
INT c_db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT c_db_get_parent(HNDLE hDB, HNDLE hKey, HNDLE *parenthKey)
INT c_db_get_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, void *data, INT *size, DWORD type, BOOL create)
INT c_cm_transition(INT transition, INT run_number, char *error, INT strsize, INT async_flag, INT debug_flag)
INT c_cm_stop_watchdog_thread(void)
INT c_db_delete_key(HNDLE database_handle, HNDLE key_handle, BOOL follow_links)
INT c_db_rename_key(HNDLE hDB, HNDLE hKey, const char *name)
INT c_cm_disconnect_experiment()
INT c_cm_msg(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
INT c_db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
INT c_rpc_flush_event(void)
INT c_db_get_key(HNDLE hdb, HNDLE key_handle, KEY *key)
INT c_db_set_value_index(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT index, DWORD type, BOOL truncate)
INT c_brpc_client_call(HNDLE hconn, char *cmd, char *args, char *buf, int &buf_length)
INT c_cm_set_transition_sequence(INT transition, INT sequence_number)
INT c_db_close_record(HNDLE hdb, HNDLE hkey)
INT c_db_set_num_values(HNDLE hDB, HNDLE hKey, INT num_values)
INT c_ss_daemon_init(BOOL keep_stdout)
MidasHistoryInterface * mh
INT c_bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
INT c_cm_msg_facilities(char ***dest, int &dest_len)
INT c_cm_msg_register(EVENT_HANDLER *func)
INT c_al_trigger_alarm(const char *alarm_name, const char *alarm_message, const char *default_class, const char *cond_str, INT type)
INT c_hs_get_tags(HNDLE hDB, char *event_name, char ***dest_names, void **dest_types, void **dest_n_data, int &dest_len)
INT c_db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
INT c_db_create_link(HNDLE hdb, HNDLE key_handle, const char *link_name, const char *destination)
INT c_cm_msg_close_buffer()
void c_free(void *mem)
INT c_cm_start_watchdog_thread(void)
INT c_cm_deregister_transition(INT transition)
INT c_example_string_c_alloc(char **dest)
INT c_cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT c_hs_get_events(HNDLE hDB, char ***dest, int &dest_len)
INT c_example_string_vector(char ***dest, int &dest_len)
INT c_example_string_c_bufsize(char *buffer, DWORD buffer_size)
INT c_bm_request_event(INT buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, INT *request_id)
INT c_cm_register_deferred_transition(INT transition, BOOL(*func)(INT, BOOL))
INT c_db_open_record(HNDLE hdb, HNDLE hkey, void *ptr, INT rec_size, WORD access, void(*dispatcher)(INT, INT, void *), void *info)
INT c_cm_msg_open_buffer()
INT c_db_unwatch(HNDLE hDB, HNDLE hKey)
INT c_db_resize_string(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_size)
INT c_db_get_link_data(HNDLE hdb, HNDLE key_handle, void *data, INT *buf_size, DWORD type)
INT c_bm_flush_cache(INT buffer_handle, INT async_flag)
INT copy_vector_to_c(std::vector< T > vec, void **dest, int &dest_len)
INT c_connect_history_if_needed(HNDLE hDB, bool debug=false)
INT c_cm_register_function(INT id, INT(*func)(INT, void **))
INT c_db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
INT c_cm_exist(const char *name, BOOL bUnique)
INT c_cm_shutdown(const char *name, BOOL bUnique)
INT c_cm_msg_retrieve2(const char *facility, uint64_t before, INT min_messages, char **messages, int *num_messages_read)
INT c_cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT c_jrpc_client_call(HNDLE hconn, char *cmd, char *args, char *buf, int buf_length)
INT c_bm_remove_event_request(INT buffer_handle, INT request_id)
INT c_ss_exec(char *cmd, INT *child_pid)
INT c_cm_yield(INT millisec)
INT c_db_find_key(HNDLE hdb, HNDLE hkey, const char *name, HNDLE *hsubkey)
INT c_cm_disconnect_client(HNDLE hConn, BOOL bShutdown)
INT c_db_watch(HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
INT c_cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
INT c_rpc_send_event(INT buffer_handle, const EVENT_HEADER *event, INT buf_size, INT async_flag, INT mode)
INT c_hs_read(HNDLE hDB, uint32_t start_time, uint32_t end_time, uint32_t interval_secs, char *event_name, char *tag_name, int idx_start, int nvars, void **num_entries, void **times, void **values, void **hs_status)
void c_free_list(void **mem_list, int arr_len)
#define trigger_mask
#define message(type, str)
HNDLE hdb
Definition midas_macro.h:21
#define event_id
#define name(x)
Definition midas_macro.h:24
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Definition midas.h:1026