#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <map>
#include "midas.h"
#include "msystem.h"
#include "history.h"
#include "mstrlcpy.h"
Go to the source code of this file.
◆ hs_event_list_filename()
static std::string hs_event_list_filename |
( |
| ) |
|
|
static |
Definition at line 389 of file history_common.cxx.
390{
392 return path + ".LOGGER_HISTORY_EVENTS.TXT";
393}
std::string cm_get_path()
◆ hs_find_reader_channel()
Definition at line 337 of file history_common.cxx.
338{
340 int size;
344
346
349 cm_msg(
MERROR,
"hs_find_reader_channel",
"Cannot find /Logger/History, db_find_key() status %d",
status);
351 }
352
353
354
357
361 cm_msg(
MERROR,
"hs_find_reader_channel",
"Misconfigured history: history channel name in /History/LoggerHistoryChannel is \'%s\', not present in /Logger/History, db_find_key() status %d",
hschanname.c_str(),
status);
363 }
367 }
368
369
370
374 break;
375
376 int active = 0;
377 size = sizeof(active);
382 }
383 }
384
385 cm_msg(
MERROR,
"hs_find_reader_channel",
"Cannot find default history: /History/LoggerHistoryChannel is empty and there are no active history channels in /Logger/History");
387}
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT EXPRT db_get_value_string(HNDLE hdb, HNDLE hKeyRoot, const char *key_name, int index, std::string *s, BOOL create, int create_string_length)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
◆ hs_get_history()
Definition at line 22 of file history_common.cxx.
23{
26 int active;
29
31
36 }
37
40
42 if (debug_flag)
43 cm_msg(
MINFO,
"hs_get_history",
"History channel \'IMAGE\' handled by image facility");
45 }
46
47 active = 0;
48 size = sizeof(active);
51
54
59
60 if (debug_flag)
61 printf(
"hs_get_history: see channel hkey %d, name \'%s\', active %d, type [%s], debug %d\n",
hKey,
key.
name, active,
type.c_str(),
debug);
62
64
66
68
70
72
77 cm_msg(
MERROR,
"hs_get_history",
"mlogger ODB setting /Logger/WriteFileHistory is obsolete, please delete it. Use /Logger/History/MIDAS/Active instead");
79 active = 0;
80 }
81
85
86 (*mh)->hs_set_debug(
debug);
87
88 status = (*mh)->hs_connect(path.c_str());
90 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to MIDAS history, status %d",
status);
92 }
93
94 if (debug_flag)
95 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type MIDAS history in \"%s\"",
key.
name, path.c_str());
96 }
97
99
100 if (1) {
102
107 cm_msg(
MERROR,
"hs_get_history",
"mlogger ODB setting /Logger/ODBC_Debug is obsolete, please delete it. Use /Logger/History/ODBC/Debug instead");
108 }
109
112 cm_msg(
MERROR,
"hs_get_history",
"mhttpd ODB setting /History/ODBC_Debug is obsolete, please delete it. Use /Logger/History/ODBC/Debug instead");
113 }
114
116
119 cm_msg(
MERROR,
"hs_get_history",
"mlogger ODB setting /Logger/ODBC_DSN is obsolete, please delete it. Use /Logger/History/ODBC/Writer_ODBC_DSN instead");
120 }
121
124 cm_msg(
MERROR,
"hs_get_history",
"mhttpd ODB setting /History/ODBC_DSN is obsolete, please delete it. Use /Logger/History/ODBC/Reader_ODBC_DSN instead");
125 }
126 }
127
130
133
136
138
143
147 }
else if (
dsn.length() > 1) {
149 }
150
153
154 (*mh)->hs_set_debug(
debug);
155
158 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to ODBC SQL driver \'%s\', status %d. Check .odbc.ini and MIDAS documentation",
dsn.c_str(),
status);
160 }
161
162 if (debug_flag)
163 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type ODBC (MySQL), DSN \'%s\'",
key.
name,
dsn.c_str());
164 }
166
168
170
172
177
178 (*mh)->hs_set_debug(
debug);
179
180 status = (*mh)->hs_connect(path.c_str());
182 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to SQLITE history, status %d, see messages",
status);
184 }
185
186 if (debug_flag)
187 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type SQLITE in \'%s\'",
key.
name, path.c_str());
188 }
190
192
194
196
197
198
203
204 (*mh)->hs_set_debug(
debug);
205
206 status = (*mh)->hs_connect(path.c_str());
208 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to FILE history, status %d, see messages",
status);
210 }
211
212 if (debug_flag)
213 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type FILE in \'%s\'",
key.
name, path.c_str());
214 }
216
219
222
225
227
232
233 std::string path;
234
237 else {
239
241
245 }
246
251
252 (*mh)->hs_set_debug(
debug);
253
254 status = (*mh)->hs_connect(path.c_str());
256 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to MYSQL history, status %d",
status);
258 }
259
260 if (debug_flag)
261 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type MYSQL at \'%s\'",
key.
name,
262 path.c_str());
263 }
265
268
271
274
276
281
282 std::string path;
283
286 else {
288
290
294 }
295
300
305
306 (*mh)->hs_set_debug(
debug);
307
308
309 status = (*mh)->hs_connect(path.c_str());
311 cm_msg(
MERROR,
"hs_get_history",
"Cannot connect to PGSQL history, status %d",
status);
313 }
314
315 if (debug_flag)
316 cm_msg(
MINFO,
"hs_get_history",
"Connected history channel \'%s\' type PGSQL at \'%s\'",
key.
name,
317 path.c_str());
318 }
320 if (debug_flag)
321 cm_msg(
MINFO,
"hs_get_history",
"History channel \'IMAGE\' handled by image facility");
322 } else {
323 cm_msg(
MERROR,
"hs_get_history",
"Logger history channel /Logger/History/%s/Type has invalid value \'%s\', valid values are MIDAS, ODBC, SQLITE, MYSQL, FILE and IMAGE",
key.
name,
type.c_str());
325 }
326
329
331 mstrlcpy((*mh)->type,
type.c_str(),
sizeof((*mh)->type));
332
334}
std::string cm_get_history_path(const char *history_channel)
MidasHistoryInterface * MakeMidasHistory()
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
int hs_find_reader_channel(HNDLE hDB, HNDLE *hKeyOut, int debug_flag)
MidasHistoryInterface * MakeMidasHistoryODBC()
MidasHistoryInterface * MakeMidasHistorySqlDebug()
MidasHistoryInterface * MakeMidasHistorySqlite()
MidasHistoryInterface * MakeMidasHistoryMysql()
MidasHistoryInterface * MakeMidasHistoryPgsql()
MidasHistoryInterface * MakeMidasHistoryFile()
BOOL debug
debug printouts
#define DIR_SEPARATOR_STR
MidasHistoryInterface * mh
◆ hs_read_event_list()
int hs_read_event_list |
( |
std::vector< std::string > * |
pevents | ) |
|
Definition at line 426 of file history_common.cxx.
427{
429
434 }
435
436 while (1) {
437 char buf[256];
438 char *s =
fgets(buf,
sizeof(buf),
fp);
439 if (!s)
440 break;
441
443 if (s)
444 *s = 0;
446 if (s)
447 *s = 0;
449 }
450
453}
static std::string hs_event_list_filename()
◆ hs_save_event_list()
int hs_save_event_list |
( |
const std::vector< std::string > * |
pevents | ) |
|
Definition at line 396 of file history_common.cxx.
397{
401
403
408 }
409
410 const char* s =
ss.c_str();
412
414
419 }
420
423}
#define write(n, a, f, d)