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 "mjsonrpc.h"
6#include <vector>
7#include <string>
8#include "string.h"
9#include "stdlib.h"
10#include "stdarg.h"
11#include "history.h"
12
13/*
14We define a simple free function to ensure that python clients can
15free any memory that was allocated by midas. We define it as part
16of this library (rather than importing libc directly in python) to
17ensure that the same version of libc is used for the alloc and free.
18*/
19void c_free(void* mem) {
20 free(mem);
21}
22
23void c_free_list(void** mem_list, int arr_len) {
24 for (int i = 0; i < arr_len; i++) {
25 free(mem_list[i]);
26 }
27
28 free(mem_list);
29}
30
31/*
32Copies the content for src to dest (at most dest_size bytes).
33dest should already have been allocated to the correct size.
34If the destination is not large enough to hold the entire src
35string, we return DB_TRUNCATED; otherwise we return SUCCESS.
36
37In general it's preferable to accept a char** from python rather than
38a buffer of a fixed size. Although python must then remember to free
39the memory we allocated.
40 */
41INT copy_string_to_c(std::string src, char* dest, DWORD dest_size) {
42 strncpy(dest, src.c_str(), dest_size);
43
44 if (src.size() > dest_size) {
45 return DB_TRUNCATED;
46 }
47
48 return SUCCESS;
49}
50
51/*
52Copies the content of vec into an array of type 'T' at dest. Will malloc the
53memory needed, so you must later call c_free() on dest. Fills dest_len with
54the size of the vector.
55 */
56template <class T> INT copy_vector_to_c(std::vector<T> vec, void** dest, int& dest_len) {
57 dest_len = vec.size();
58 *dest = malloc(sizeof(T) * dest_len);
59 std::copy(vec.begin(), vec.end(), (T*)*dest);
60 return SUCCESS;
61}
62
63/*
64Copies the content of vec into an array of char* at dest. Will malloc the
65memory needed for each string (and for the array itself), so you must later call
66c_free_list() on dest. Fills dest_len with the size of the vector.
67 */
68INT copy_vector_string_to_c(std::vector<std::string> vec, char*** dest, int& dest_len) {
69 dest_len = vec.size();
70 *dest = (char**) malloc(sizeof(char*) * dest_len);
71
72 for (int i = 0; i < dest_len; i++) {
73 (*dest)[i] = strdup(vec[i].c_str());
74 }
75
76 return SUCCESS;
77}
78
79/*
80Example of how one could wrap a midas function that returns/fills a std::string.
81In this version we accept a buffer of a specified size from the user.
82
83The python code would be:
84```
85buffer = ctypes.create_string_buffer(64)
86lib.c_example_string_c_bufsize(buffer, 64)
87py_str = buffer.value.decode("utf-8")
88```
89 */
90INT c_example_string_c_bufsize(char* buffer, DWORD buffer_size) {
91 std::string retval("My string that would come from a C++ function");
92 return copy_string_to_c(retval, buffer, buffer_size);
93}
94
95/*
96Example of how one could wrap a midas function that returns/fills a std::string.
97In this version we allocate memory for the C char array. The caller must later
98free this memory themselves.
99
100The python code would be (note the final free!):
101```
102buffer = ctypes.c_char_p()
103lib.c_example_string_c_alloc(ctypes.byref(buffer))
104py_str = buffer.value.decode("utf-8")
105lib.c_free(buffer)
106```
107 */
109 std::string retval("My string that would come from a C++ function");
110 *dest = strdup(retval.c_str());
111 return SUCCESS;
112}
113
114/*
115Example of how one could wrap a midas function that returns/fills a std::vector.
116In this version we allocate memory for the C array. The caller must later
117free this memory themselves.
118
119The python code would be (note the final free!):
120```
121import ctypes
122import midas.client
123
124client = midas.client.MidasClient("pytest")
125lib = client.lib
126
127arr = ctypes.c_void_p()
128arr_len = ctypes.c_int()
129lib.c_example_vector(ctypes.byref(arr), ctypes.byref(arr_len))
130casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_float))
131py_list = casted[:arr_len.value]
132lib.c_free(arr)
133```
134 */
135INT c_example_vector(void** dest, int& dest_len) {
136 std::vector<float> retvec;
137 for (int i = 0; i < 10; i++) {
138 retvec.push_back(i/3.);
139 }
140
141 return copy_vector_to_c(retvec, dest, dest_len);
142}
143
144/*
145Example of how one could wrap a midas function that returns/fills a std::vector.
146In this version we allocate memory for the C array. The caller must later
147free this memory themselves.
148
149The python code would be (note the final free!):
150```
151import ctypes
152import midas.client
153client = midas.client.MidasClient("pytest")
154lib = client.lib
155
156arr = ctypes.POINTER(ctypes.c_char_p)()
157arr_len = ctypes.c_int()
158lib.c_example_string_vector(ctypes.byref(arr), ctypes.byref(arr_len))
159casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_char_p))
160py_list = [casted[i].decode("utf-8") for i in range(arr_len.value)]
161lib.c_free_list(arr, arr_len)
162```
163 */
164INT c_example_string_vector(char*** dest, int& dest_len) {
165 std::vector<std::string> retvec;
166 retvec.push_back("Hello");
167 retvec.push_back("world!");
168
169 return copy_vector_string_to_c(retvec, dest, dest_len);
170}
171
172INT c_al_trigger_alarm(const char *alarm_name, const char *alarm_message, const char *default_class, const char *cond_str, INT type) {
173 return al_trigger_alarm(alarm_name, alarm_message, default_class, cond_str, type);
174}
175
176INT c_al_reset_alarm(const char *alarm_name) {
177 return al_reset_alarm(alarm_name);
178}
179
180INT c_al_define_odb_alarm(const char *name, const char *condition, const char *aclass, const char *message) {
181 return al_define_odb_alarm(name, condition, aclass, message);
182}
183
184INT c_bm_flush_cache(INT buffer_handle, INT async_flag) {
185 return bm_flush_cache(buffer_handle, async_flag);
186}
187
188INT c_bm_open_buffer(const char *buffer_name, INT buffer_size, INT * buffer_handle) {
189 return bm_open_buffer(buffer_name, buffer_size, buffer_handle);
190}
191
192INT c_bm_receive_event(INT buffer_handle, void *destination, INT * buf_size, INT async_flag) {
193 return bm_receive_event(buffer_handle, destination, buf_size, async_flag);
194}
195
196INT c_bm_remove_event_request(INT buffer_handle, INT request_id) {
197 return bm_remove_event_request(buffer_handle, request_id);
198}
199
200INT c_bm_request_event(INT buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, INT * request_id) {
201 // Final argument is function pointer that python lib doesn't need.
202 return bm_request_event(buffer_handle, event_id, trigger_mask, sampling_type, request_id, 0);
203}
204
208
209INT c_cm_connect_client(const char *client_name, HNDLE * hConn) {
210 return cm_connect_client(client_name, hConn);
211}
212
213INT c_cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void (*func) (char *)) {
214 return cm_connect_experiment(host_name, exp_name, client_name, func);
215}
216
220
222 return cm_disconnect_client(hConn, bShutdown);
223}
224
228
229INT c_cm_exist(const char *name, BOOL bUnique) {
230 return cm_exist(name, bUnique);
231}
232
233INT c_cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size) {
234 return cm_get_environment(host_name, host_name_size, exp_name, exp_name_size);
235}
236
238 return cm_get_experiment_database(hDB, hKeyClient);
239}
240
241INT c_cm_get_path(char *path, int path_size) {
242 std::string str_path = cm_get_path();
243 return copy_string_to_c(str_path, path, path_size);
244}
245
246const char* c_cm_get_revision(void) {
247 // If this changes to returning a string, do:
248 // return strdup(cm_get_revision().c_str());
249 return cm_get_revision();
250}
251
252const char* c_cm_get_version(void) {
253 // If this changes to returning a string, do:
254 // return strdup(cm_get_version().c_str());
255 return cm_get_version();
256}
257
258INT c_cm_msg(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format, ...) {
259 va_list argptr;
260 char message[1000];
261 va_start(argptr, format);
262 vsnprintf(message, 1000, (char *) format, argptr);
263 va_end(argptr);
264 return cm_msg1(message_type, filename, line, facility, routine, "%s", message);
265}
266
267/*
268Remember to call c_free_list on the dest afterwards. E.g.:
269```
270import ctypes
271import midas.client
272lib = midas.client.MidasClient("pytest").lib
273
274arr = ctypes.POINTER(ctypes.c_char_p)()
275arr_len = ctypes.c_int()
276lib.c_cm_msg_facilities(ctypes.byref(arr), ctypes.byref(arr_len))
277casted = ctypes.cast(arr, ctypes.POINTER(ctypes.c_char_p))
278py_list = [casted[i].decode("utf-8") for i in range(arr_len.value)]
279lib.c_free_list(arr, arr_len)
280```
281*/
282INT c_cm_msg_facilities(char*** dest, int& dest_len) {
283 std::vector<std::string> retvec;
284 INT retcode = cm_msg_facilities(&retvec);
285 if (retcode == SUCCESS) {
286 return copy_vector_string_to_c(retvec, dest, dest_len);
287 } else {
288 return retcode;
289 }
290}
291
293 return cm_msg_register(func);
294}
295
296INT c_cm_msg_retrieve2(const char *facility, uint64_t before, INT min_messages, char **messages, int *num_messages_read) {
297 // Python ctypes doesn't know the size of time_t, so just accept a uint64_t and convert here.
298 time_t t = before;
299 INT retval = cm_msg_retrieve2(facility, t, min_messages, messages, num_messages_read);
300 return retval;
301}
302
306
310
314
315INT c_cm_register_function(INT id, INT(*func) (INT, void **)) {
316 return cm_register_function(id, func);
317}
318
319INT c_cm_register_transition(INT transition, INT(*func) (INT, char *), int sequence_number) {
320 return cm_register_transition(transition, func, sequence_number);
321}
322
324 return cm_set_transition_sequence(transition, sequence_number);
325}
326
327INT c_cm_shutdown(const char *name, BOOL bUnique) {
328 return cm_shutdown(name, bUnique);
329}
330
334
338
339INT c_cm_transition(INT transition, INT run_number, char *error, INT strsize, INT async_flag, INT debug_flag) {
340 return cm_transition(transition, run_number, error, strsize, async_flag, debug_flag);
341}
342
343INT c_cm_yield(INT millisec) {
344 return cm_yield(millisec);
345}
346
348 return db_close_record(hdb, hkey);
349}
350
351INT c_db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int* buffer_size, int* buffer_end) {
352 return db_copy_json_ls(hDB, hKey, buffer, buffer_size, buffer_end);
353}
354
355INT c_db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int* buffer_size, int* buffer_end) {
356 return db_copy_json_save(hDB, hKey, buffer, buffer_size, buffer_end);
357}
358
359INT c_db_create_key(HNDLE hdb, HNDLE key_handle, const char *key_name, DWORD type) {
360 return db_create_key(hdb, key_handle, key_name, type);
361}
362
363INT c_db_create_link(HNDLE hdb, HNDLE key_handle, const char *link_name, const char *destination) {
364 return db_create_link(hdb, key_handle, link_name, destination);
365}
366
367INT c_db_delete_key(HNDLE database_handle, HNDLE key_handle) {
368 return db_delete_key(database_handle, key_handle);
369}
370
371INT c_db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE * subkey_handle) {
372 return db_enum_key(hDB, hKey, idx, subkey_handle);
373}
374
375INT c_db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE * subkey_handle) {
376 return db_enum_link(hDB, hKey, idx, subkey_handle);
377}
378
379INT c_db_find_key(HNDLE hdb, HNDLE hkey, const char *name, HNDLE * hsubkey) {
380 return db_find_key(hdb, hkey, name, hsubkey);
381}
382
383INT c_db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE * subhKey) {
384 return db_find_link(hDB, hKey, key_name, subhKey);
385}
386
388 return db_get_key(hdb, key_handle, key);
389}
390
391INT c_db_get_link_data(HNDLE hdb, HNDLE key_handle, void *data, INT * buf_size, DWORD type) {
392 return db_get_link_data(hdb, key_handle, data, buf_size, type);
393}
394
396 return db_get_parent(hDB, hKey, parenthKey);
397}
398
399INT c_db_get_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, void *data, INT * size, DWORD type, BOOL create) {
400 return db_get_value(hdb, hKeyRoot, key_name, data, size, type, create);
401}
402
403INT c_db_open_record(HNDLE hdb, HNDLE hkey, void *ptr, INT rec_size, WORD access, void (*dispatcher) (INT, INT, void *), void *info) {
404 return db_open_record(hdb, hkey, ptr, rec_size, access, dispatcher, info);
405}
406
408 return db_rename_key(hDB, hKey, name);
409}
410
414
415INT c_db_resize_string(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_size) {
416 return db_resize_string(hDB, hKeyRoot, key_name, num_values, max_string_size);
417}
418
419INT c_db_set_link_data(HNDLE hdb, HNDLE key_handle, void *data, INT buf_size, int num_values, DWORD type) {
420 return db_set_link_data(hdb, key_handle, data, buf_size, num_values, type);
421}
422
423INT c_db_set_mode(HNDLE hdb, HNDLE key_handle, WORD mode, BOOL recurse) {
424 return db_set_mode(hdb, key_handle, mode, recurse);
425}
426
428 return db_set_num_values(hDB, hKey, num_values);
429}
430
431INT c_db_set_data(HNDLE hdb, HNDLE hKeyRoot, const void *data, INT size, INT num_values, DWORD type) {
432 return db_set_data(hdb, hKeyRoot, data, size, num_values, type);
433}
434
435INT c_db_set_value(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, const void *data, INT size, INT num_values, DWORD type) {
436 return db_set_value(hdb, hKeyRoot, key_name, data, size, num_values, type);
437}
438
439INT 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) {
440 return db_set_value_index(hDB, hKeyRoot, key_name, data, data_size, index, type, truncate);
441}
442
446
447INT c_db_watch(HNDLE hDB, HNDLE hKey, void (*dispatcher) (INT, INT, INT, void*), void* info) {
448 return db_watch(hDB, hKey, dispatcher, info);
449}
450
451INT c_jrpc_client_call(HNDLE hconn, char* cmd, char* args, char* buf, int buf_length) {
452 // Specialized version of rpc_client_call that just deals with RPC_JRPC,
453 // so we don't have to worry about variable arg lists.
454 // You must already have malloc'd buf to be big enough for buf_length.
455 return rpc_client_call(hconn, RPC_JRPC, cmd, args, buf, buf_length);
456}
457
458INT c_brpc_client_call(HNDLE hconn, char* cmd, char* args, char* buf, int& buf_length) {
459 // Specialized version of rpc_client_call that just deals with RPC_BRPC,
460 // so we don't have to worry about variable arg lists.
461 // You must already have malloc'd buf to be big enough for buf_length.
462 return rpc_client_call(hconn, RPC_BRPC, cmd, args, buf, &buf_length);
463}
464
466 // Specialized version of rpc_client_call that just deals with RPC_MANUAL_TRIG,
467 // so we don't have to worry about variable arg lists.
469}
470
471INT c_mjsonrpc_get_schema(char** json_str) {
473 MJsonNode* s = mjsonrpc_get_schema();
474 std::string reply = s->Stringify();
475 *json_str = strdup(reply.c_str());
476 return SUCCESS;
477}
478
480 return rpc_flush_event();
481}
482
484 return rpc_is_remote();
485}
486
487INT c_rpc_send_event(INT buffer_handle, const EVENT_HEADER *event, INT buf_size, INT async_flag, INT mode) {
488 return rpc_send_event(buffer_handle, event, buf_size, async_flag, mode);
489}
490
494
496 return ss_daemon_init(keep_stdout);
497}
498
499INT c_ss_exec(char* cmd, INT* child_pid) {
500 return ss_exec(cmd, child_pid);
501}
502
506
508
511
512 if (mh == nullptr) {
514 }
515
516 return status;
517}
518
519INT c_hs_get_events(HNDLE hDB, char*** dest, int& dest_len) {
521
522 if (status != SUCCESS) {
523 return status;
524 }
525
526 time_t t = 0;
527 std::vector<std::string> events;
528
529 status = mh->hs_get_events(t, &events);
530
531 if (status != SUCCESS) {
532 return status;
533 }
534
535 return copy_vector_string_to_c(events, dest, dest_len);
536}
537
538INT c_hs_get_tags(HNDLE hDB, char* event_name, char*** dest_names, void** dest_types, void** dest_n_data, int& dest_len) {
540
541 if (status != SUCCESS) {
542 return status;
543 }
544
545 time_t t = 0;
546 std::vector<TAG> tags;
547 status = mh->hs_get_tags(event_name, t, &tags);
548
549 if (status != SUCCESS) {
550 return status;
551 }
552
553 std::vector<std::string> tag_names;
554 std::vector<DWORD> tag_types;
555 std::vector<DWORD> tag_n_data;
556
557 for (auto& tag : tags) {
558 tag_names.push_back(tag.name);
559 tag_types.push_back(tag.type);
560 tag_n_data.push_back(tag.n_data);
561 }
562
563 copy_vector_string_to_c(tag_names, dest_names, dest_len);
564 copy_vector_to_c(tag_types, dest_types, dest_len);
565 copy_vector_to_c(tag_n_data, dest_n_data, dest_len);
566 return SUCCESS;
567}
568
570 uint32_t start_time, uint32_t end_time, uint32_t interval_secs,
571 char* event_name, char* tag_name, int idx_start, int nvars,
572 void** num_entries, void** times, void** values, void** hs_status) {
573 // Note this function varies from hs_read() for the times/tbuffer and values/vbuffer
574 // parameters! To simplify passing between python/C, we concatenate all the data for
575 // all variables into one array, rather than using a 2D array.
576 // So num_entries and hs_status are length "nvars", while
577 // times and values are length "sum of num_entries".
579
580 if (status != SUCCESS) {
581 return status;
582 }
583
584 const char** event_names = (const char**)calloc(nvars, sizeof(const char*));
585 const char** var_names = (const char**)calloc(nvars, sizeof(const char*));
586 int* indices = (int*)calloc(nvars, sizeof(int));
587
588 for (int i = 0; i < nvars; i++) {
589 event_names[i] = event_name;
590 var_names[i] = tag_name;
591 indices[i] = idx_start + i;
592 }
593
594 *num_entries = calloc(nvars, sizeof(int));
595 time_t** tbuffer_int = (time_t**)calloc(nvars, sizeof(time_t*));
596 double** vbuffer_int = (double**)calloc(nvars, sizeof(double*));
597 *hs_status = calloc(nvars, sizeof(int));
598
599 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);
600
601 // Simplify passing back to python by concatenating timestamp buffers into
602 // a single buffer rather than 2-D array. Same for value buffers.
603 size_t tot_len = 0;
604
605 for (int i = 0; i < nvars; i++) {
606 tot_len += ((int*)(*num_entries))[i];
607 }
608
609 if (tot_len > 0) {
610 *times = calloc(tot_len, sizeof(uint32_t));
611 *values = calloc(tot_len, sizeof(double));
612
613 uint32_t* cast_tbuffer = (uint32_t*)*times;
614 double* cast_vbuffer = (double*)*values;
615 size_t offset = 0;
616
617 for (int i = 0; i < nvars; i++) {
618 size_t this_n = ((int*)(*num_entries))[i];
619 for (int n = 0; n < (int) this_n; n++) {
620 // Deal with time_t vs uint32_t possibly being different sizes
621 // by manually copying values rather than doing a memcpy.
622 cast_tbuffer[offset+n] = tbuffer_int[i][n];
623 cast_vbuffer[offset+n] = vbuffer_int[i][n];
624 }
625
626 offset += this_n;
627 }
628 }
629
630 free(tbuffer_int);
631 free(vbuffer_int);
632 free(event_names);
633 free(var_names);
634 free(indices);
635
636 return status;
637}
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:939
INT al_reset_alarm(const char *alarm_name)
Definition alarm.cxx:519
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:6728
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:8476
INT bm_receive_event(INT buffer_handle, void *destination, INT *buf_size, int timeout_msec)
Definition midas.cxx:10789
INT bm_remove_event_request(INT buffer_handle, INT request_id)
Definition midas.cxx:8529
INT bm_flush_cache(int buffer_handle, int timeout_msec)
Definition midas.cxx:10233
INT cm_register_transition(INT transition, INT(*func)(INT, char *), INT sequence_number)
Definition midas.cxx:3617
INT cm_shutdown(const char *name, BOOL bUnique)
Definition midas.cxx:7411
INT cm_disconnect_client(HNDLE hConn, BOOL bShutdown)
Definition midas.cxx:2849
INT cm_yield(INT millisec)
Definition midas.cxx:5660
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
Definition midas.cxx:3027
INT cm_connect_client(const char *client_name, HNDLE *hConn)
Definition midas.cxx:2782
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
Definition midas.cxx:2294
INT cm_start_watchdog_thread()
Definition midas.cxx:7366
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
Definition midas.cxx:5304
INT cm_stop_watchdog_thread()
Definition midas.cxx:7381
INT cm_register_function(INT id, INT(*func)(INT, void **))
Definition midas.cxx:5808
INT cm_disconnect_experiment(void)
Definition midas.cxx:2862
std::string cm_get_path()
Definition midas.cxx:1553
INT cm_register_deferred_transition(INT transition, BOOL(*func)(INT, BOOL))
Definition midas.cxx:3861
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
Definition midas.cxx:2150
const char * cm_get_version()
Definition midas.cxx:1492
INT cm_deregister_transition(INT transition)
Definition midas.cxx:3693
INT cm_check_deferred_transition()
Definition midas.cxx:3913
INT cm_set_transition_sequence(INT transition, INT sequence_number)
Definition midas.cxx:3747
const char * cm_get_revision()
Definition midas.cxx:1500
INT cm_exist(const char *name, BOOL bUnique)
Definition midas.cxx:7531
#define DB_TRUNCATED
Definition midas.h:645
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
#define SUCCESS
Definition mcstd.h:54
void mjsonrpc_init()
MJsonNode * mjsonrpc_get_schema()
void() EVENT_HANDLER(HNDLE buffer_handler, HNDLE request_id, EVENT_HEADER *event_header, void *event_data)
Definition midas.h:919
INT ss_suspend_set_server_acceptions(RPC_SERVER_ACCEPTION_LIST *acceptions)
Definition system.cxx:4370
INT ss_daemon_init(BOOL keep_stdout)
Definition system.cxx:2073
INT ss_exec(const char *command, INT *pid)
Definition system.cxx:2204
INT cm_msg1(INT message_type, const char *filename, INT line, const char *facility, const char *routine, const char *format,...)
Definition midas.cxx:989
INT EXPRT cm_msg_facilities(STRING_LIST *list)
Definition midas.cxx:518
int cm_msg_open_buffer(void)
Definition midas.cxx:488
int cm_msg_close_buffer(void)
Definition midas.cxx:501
INT cm_msg_register(EVENT_HANDLER *func)
Definition midas.cxx:1067
INT cm_msg_retrieve2(const char *facility, time_t t, INT n_message, char **messages, int *num_messages)
Definition midas.cxx:1280
INT db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
Definition odb.cxx:3933
INT db_find_link(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4293
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
Definition odb.cxx:5185
INT db_reorder_key(HNDLE hDB, HNDLE hKey, INT idx)
Definition odb.cxx:6385
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:1057
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:13322
INT db_set_link_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
Definition odb.cxx:7449
INT db_create_key(HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
Definition odb.cxx:3392
INT db_copy_json_save(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
Definition odb.cxx:10496
INT db_unwatch(HNDLE hDB, HNDLE hKey)
Definition odb.cxx:13920
INT db_set_mode(HNDLE hDB, HNDLE hKey, WORD mode, BOOL recurse)
Definition odb.cxx:8040
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
Definition odb.cxx:6043
INT db_watch(HNDLE hDB, HNDLE hKey, void(*dispatcher)(INT, INT, INT, void *), void *info)
Definition odb.cxx:13845
INT db_set_data(HNDLE hDB, HNDLE hKey, const void *data, INT buf_size, INT num_values, DWORD type)
Definition odb.cxx:7239
INT db_enum_link(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
Definition odb.cxx:5495
INT db_copy_json_ls(HNDLE hDB, HNDLE hKey, char **buffer, int *buffer_size, int *buffer_end)
Definition odb.cxx:10442
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:5028
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4256
INT db_get_link_data(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, DWORD type)
Definition odb.cxx:6680
INT db_rename_key(HNDLE hDB, HNDLE hKey, const char *name)
Definition odb.cxx:6285
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:5135
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
Definition odb.cxx:5357
INT EXPRT db_resize_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int num_values, int max_string_length)
Definition odb.cxx:14058
INT db_close_record(HNDLE hDB, HNDLE hKey)
Definition odb.cxx:13505
INT db_set_num_values(HNDLE hDB, HNDLE hKey, INT num_values)
Definition odb.cxx:7523
INT db_create_link(HNDLE hDB, HNDLE hKey, const char *link_name, const char *destination)
Definition odb.cxx:3688
#define RPC_BRPC
Definition mrpc.h:135
INT rpc_client_call(HNDLE hConn, DWORD routine_id,...)
Definition midas.cxx:13926
#define RPC_JRPC
Definition mrpc.h:134
bool rpc_is_remote(void)
Definition midas.cxx:12892
INT rpc_flush_event()
Definition midas.cxx:14486
INT rpc_server_shutdown(void)
Definition midas.cxx:17572
INT rpc_send_event(INT buffer_handle, const EVENT_HEADER *pevent, int unused, INT async_flag, INT mode)
Definition midas.cxx:14349
#define RPC_MANUAL_TRIG
Definition mrpc.h:132
#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_db_delete_key(HNDLE database_handle, HNDLE key_handle)
INT c_db_set_mode(HNDLE hdb, HNDLE key_handle, WORD mode, BOOL recurse)
INT c_rpc_is_remote(void)
INT c_db_set_data(HNDLE hdb, HNDLE hKeyRoot, const void *data, INT size, INT num_values, DWORD type)
INT c_cm_connect_client(const char *client_name, HNDLE *hConn)
INT c_rpc_server_shutdown()
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_mjsonrpc_get_schema(char **json_str)
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_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)
INT c_manualtrig_rpc_client_call(HNDLE hconn, int event_id)
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_ss_suspend_reset_server_acceptions()
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
Definition midas.h:1027