MIDAS
Loading...
Searching...
No Matches
odb_test.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "midas.h"
Include dependency graph for odb_test.c:

Go to the source code of this file.

Functions

void run_number_changed (HNDLE hDB, HNDLE hKey, void *info)
 
int main ()
 

Variables

int run_number
 

Function Documentation

◆ main()

int main ( void  )

Definition at line 23 of file odb_test.c.

24{
25 int status, size;
26 HNDLE hDB, hKey;
27
28 /* connect to experiment */
29 status = cm_connect_experiment("", "", "ODBTest", NULL);
30 if (status != CM_SUCCESS)
31 return 1;
32
33 /* get handle to online database */
35
36 /* read key "runinfo/run number" */
37 size = sizeof(run_number);
38 status =
39 db_get_value(hDB, 0, "/runinfo/run number", &run_number, &size, TID_INT, TRUE);
40 if (status != DB_SUCCESS) {
41 printf("Cannot read run number");
42 return 0;
43 }
44
45 printf("Current run number is %d\n", run_number);
46
47 /* set new run number */
48 run_number++;
49 db_set_value(hDB, 0, "/runinfo/run number", &run_number, size, 1, TID_INT);
50
51
52 /* now open run_number with automatic updates */
53 db_find_key(hDB, 0, "/runinfo/run number", &hKey);
56
57 printf("Waiting for run number to change. Hit RETURN to abort\n");
58
59 do {
60 cm_yield(1000);
61 } while (!ss_kbhit());
62
64
65 /* disconnect from experiment */
67
68 return 1;
69}
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_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
Definition midas.cxx:2278
INT cm_disconnect_experiment(void)
Definition midas.cxx:2846
#define CM_SUCCESS
Definition midas.h:582
#define DB_SUCCESS
Definition midas.h:631
#define MODE_READ
Definition midas.h:370
#define TID_INT
Definition midas.h:338
BOOL ss_kbhit()
Definition system.cxx:3664
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_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_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_close_record(HNDLE hDB, HNDLE hKey)
Definition odb.cxx:13473
HNDLE hKey
HNDLE hDB
main ODB handle
Definition mana.cxx:207
INT HNDLE
Definition midas.h:132
#define TRUE
Definition midas.h:182
int run_number
Definition odb_test.c:16
void run_number_changed(HNDLE hDB, HNDLE hKey, void *info)
Definition odb_test.c:18
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
Here is the call graph for this function:

◆ run_number_changed()

void run_number_changed ( HNDLE  hDB,
HNDLE  hKey,
void info 
)

Definition at line 18 of file odb_test.c.

19{
20 printf("New run number: %d\n", run_number);
21}
Here is the caller graph for this function:

Variable Documentation

◆ run_number

int run_number

Definition at line 16 of file odb_test.c.