MIDAS
Loading...
Searching...
No Matches
history.h
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: history.h
4 Created by: Konstantin Olchanski / TRIUMF
5
6 Contents: Interface for the MIDAS history system
7
8 $Id$
9
10\********************************************************************/
11
12#ifndef HISTORY_H
13#define HISTORY_H
14
15#include <string>
16#include <vector>
17
18#include "midas.h"
19
22
24
25// "factory" pattern
26
34
35#define HS_GET_READER 1
36#define HS_GET_WRITER 2
37#define HS_GET_INACTIVE 4
38#define HS_GET_DEFAULT 8
39
40// construct history interface class from logger history channel definition in /Logger/History/0/...
41int hs_get_history(HNDLE hDB, HNDLE hKey, int flags, int debug_flag, MidasHistoryInterface **mh);
42
43// find history reader channel, returns ODB handle to the history channel definition in /Logger/History/...
44int hs_find_reader_channel(HNDLE hDB, HNDLE* hKey, int debug_flag);
45
46// save list of active events
47int hs_save_event_list(const std::vector<std::string> *pevents);
48
49// get list of active events
50int hs_read_event_list(std::vector<std::string> *pevents);
51
52// define history panel
53int hs_define_panel(const char *group, const char *panel, const std::vector<std::string> vars);
54INT hs_define_panel2(const char *group, const char *panel, const std::vector<std::string> var,
55 const std::vector<std::string> label, const std::vector<std::string> formula = {},
56 const std::vector<std::string> color = {});
57
58// MIDAS history data buffer interface class
59
61{
62 public:
64 virtual ~MidasHistoryBufferInterface() { }; // dtor
65 public:
66 virtual void Add(time_t time, double value) = 0;
67};
68
70{
71 public:
72 int fNumBins = 0;
75
76 int fNumEntries = 0;
77 double *fSum0 = NULL;
78 double *fSum1 = NULL;
79 double *fSum2 = NULL;
80
81 public: // following arrays are owned by the caller of hs_read_binned()
82 int *fCount = NULL;
83 double *fMean = NULL;
84 double *fRms = NULL;
85 double *fMin = NULL;
86 double *fMax = NULL;
87
92
95
96 public:
99
100 public:
101 void Start();
102 void Add(time_t t, double v);
103 void Finish();
104};
105
106// MIDAS history interface class
107
109{
110 public:
113
114 public:
116 {
117 name[0] = 0;
118 type[0] = 0;
119 }
120
121 virtual ~MidasHistoryInterface() { }; // dtor
122
123 public:
124 virtual int hs_connect(const char* connect_string) = 0;
125 virtual int hs_disconnect() = 0;
126
127 virtual int hs_set_debug(int debug) = 0;
128
129 virtual int hs_clear_cache() = 0;
130
131 // functions for writing into the history, used by mlogger
132
133 virtual int hs_define_event(const char* event_name, time_t timestamp, int ntags, const TAG tags[]) = 0;
134
135 virtual int hs_write_event(const char* event_name, time_t timestamp, int data_size, const char* data) = 0;
136
137 virtual int hs_flush_buffers() = 0;
138
139 // functions for reading from the history, used by mhttpd, mhist
140
141 virtual int hs_get_events(time_t time_from, std::vector<std::string> *pevents) = 0;
142
143 virtual int hs_get_tags(const char* event_name, time_t time_from, std::vector<TAG> *ptags) = 0;
144
145 virtual int hs_get_last_written(time_t start_time,
146 int num_var, const char* const event_name[], const char* const tag_name[], const int var_index[],
147 time_t last_written[]) = 0;
148
149 virtual int hs_read_buffer(time_t start_time, time_t end_time,
150 int num_var, const char* const event_name[], const char* const tag_name[], const int var_index[],
152 int status[]) = 0;
153
154 virtual int hs_read(time_t start_time, time_t end_time, time_t interval,
155 int num_var, const char* const event_name[], const char* const tag_name[], const int var_index[],
156 int num_entries[], time_t* time_buffer[], double* data_buffer[],
157 int status[]) = 0;
158
159 virtual int hs_read_binned(time_t start_time, time_t end_time, int num_bins,
160 int num_var, const char* const event_name[], const char* const tag_name[], const int var_index[],
161 int num_entries[],
162 int* count_bins[], double* mean_bins[], double* rms_bins[], double* min_bins[], double* max_bins[],
165 time_t last_time[], double last_value[],
166 int status[]) = 0;
167};
168
169#endif
170// end
void Add(time_t t, double v)
virtual ~MidasHistoryBufferInterface()
Definition history.h:64
virtual void Add(time_t time, double value)=0
virtual int hs_set_debug(int debug)=0
set debug level, returns previous debug level
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_disconnect()=0
disconnect from history, returns HS_SUCCESS
virtual int hs_connect(const char *connect_string)=0
returns HS_SUCCESS
virtual ~MidasHistoryInterface()
Definition history.h:121
virtual int hs_flush_buffers()=0
flush buffered data to storage where it is visible to mhttpd
virtual int hs_write_event(const char *event_name, time_t timestamp, int data_size, const char *data)=0
see hs_write_event(), returns HS_SUCCESS or HS_FILE_ERROR
virtual int hs_define_event(const char *event_name, time_t timestamp, int ntags, const TAG tags[])=0
see hs_define_event(), returns HS_SUCCESS or HS_FILE_ERROR
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...
char type[NAME_LENGTH]
history channel name
Definition history.h:112
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...
char name[NAME_LENGTH]
Definition history.h:111
MidasHistoryInterface()
history type: MIDAS, ODBC, SQLITE, etc
Definition history.h:115
virtual int hs_read_buffer(time_t start_time, time_t end_time, int num_var, const char *const event_name[], const char *const tag_name[], const int var_index[], MidasHistoryBufferInterface *buffer[], int status[])=0
returns HS_SUCCESS
virtual int hs_get_last_written(time_t start_time, int num_var, const char *const event_name[], const char *const tag_name[], const int var_index[], time_t last_written[])=0
virtual int hs_clear_cache()=0
clear internal cache, returns HS_SUCCESS
virtual int hs_read_binned(time_t start_time, time_t end_time, int num_bins, int num_var, const char *const event_name[], const char *const tag_name[], const int var_index[], int num_entries[], int *count_bins[], double *mean_bins[], double *rms_bins[], double *min_bins[], double *max_bins[], time_t *bins_first_time[], double *bins_first_value[], time_t *bins_last_time[], double *bins_last_value[], time_t last_time[], double last_value[], int status[])=0
returns HS_SUCCESS
MidasHistoryInterface * MakeMidasHistory()
Definition history.cxx:3583
INT hs_define_panel2(const char *group, const char *panel, const std::vector< std::string > var, const std::vector< std::string > label, const std::vector< std::string > formula={}, const std::vector< std::string > color={})
Definition history.cxx:3530
int hs_define_panel(const char *group, const char *panel, const std::vector< std::string > vars)
Definition history.cxx:3492
MidasHistoryInterface * MakeMidasHistoryODBC()
int hs_read_event_list(std::vector< std::string > *pevents)
int hs_find_reader_channel(HNDLE hDB, HNDLE *hKey, int debug_flag)
int hs_save_event_list(const std::vector< std::string > *pevents)
MidasHistoryInterface * MakeMidasHistorySqlite()
int hs_get_history(HNDLE hDB, HNDLE hKey, int flags, int debug_flag, MidasHistoryInterface **mh)
MidasHistoryInterface * MakeMidasHistorySqlDebug()
MidasHistoryInterface * MakeMidasHistoryMysql()
MidasHistoryInterface * MakeMidasHistoryPgsql()
MidasHistoryInterface * MakeMidasHistoryFile()
HNDLE hKey
DWORD last_time
Definition mana.cxx:3070
void * data
Definition mana.cxx:268
BOOL debug
debug printouts
Definition mana.cxx:254
HNDLE hDB
main ODB handle
Definition mana.cxx:207
char color[][16]
Definition mchart.cxx:32
INT HNDLE
Definition midas.h:132
int INT
Definition midas.h:129
#define NAME_LENGTH
Definition midas.h:272
MidasHistoryInterface * mh
double value[100]
Definition odbhist.cxx:42
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:1234