ICP  1
selogger.h
Go to the documentation of this file.
1 // The following ifdef block is the standard way of creating macros which make exporting
2 // from a DLL simpler. All files within this DLL are compiled with the SELOGGER_EXPORTS
3 // symbol defined on the command line. this symbol should not be defined on any project
4 // that uses this DLL. This way any other project whose source files include this file see
5 // SELOGGER_API functions as being imported from a DLL, whereas this DLL sees symbols
6 // defined with this macro as being exported.
7 
8 #ifndef SELOGGER_H
9 #define SELOGGER_H
10 
11 #ifdef SELOGGER_EXPORTS
12 #define SELOGGER_API __declspec(dllexport)
13 #else
14 #define SELOGGER_API __declspec(dllimport)
15 #endif
16 
17 //#include "ci_string.h"
18 
19 enum BlockOptions { Enabled=0x1, RunControl=0x2, LogAtBegin=0x4, LogAtEnd=0x8 };
20 
21 #include <Poco/Tuple.h>
22 
23 typedef Poco::Tuple<std::string, std::string, std::string, std::string,
24  std::string, std::string, int, std::string,
25  float, float, std::string, std::string,
26  int, std::string, std::string, std::string> SEBLOCK_DETAILS_tuple;
27 
29 {
30 public:
31  SEBLOCK_DETAILS_tuple& tuple() { return *this; }
32  std::string& block_name() { return this->get<0>(); }
33  std::string& setpoint_value() { return this->get<1>(); }
34  std::string& vi_name() { return this->get<2>(); }
35  std::string& read_control() { return this->get<3>(); }
36  std::string& set_control() { return this->get<4>(); }
37  std::string& button_control() { return this->get<5>(); }
38  int& options() { return this->get<6>(); }
39  std::string& nexus_name() { return this->get<7>(); }
40  float& low_limit() { return this->get<8>(); }
41  float& high_limit() { return this->get<9>(); }
42  std::string& units() { return this->get<10>(); }
43  std::string& block_value() { return this->get<11>(); }
44  int& is_real() { return this->get<12>(); }
45  std::string& source() { return this->get<13>(); }
46  std::string& setpoint_time() { return this->get<14>(); }
47  std::string& value_time() { return this->get<15>(); }
48  SEBLOCK_DETAILS(const std::string& block_name, const std::string& setpoint_value,
49  const std::string& vi_name, const std::string& read_control, const std::string& set_control,
50  const std::string& button_control, int options, const std::string& nexus_name,
51  float low_limit, float high_limit, const std::string& units, const std::string& block_value,
52  int is_real, const std::string& source, const std::string& setpoint_time, const std::string& value_time)
53  : SEBLOCK_DETAILS_tuple(block_name, setpoint_value, vi_name, read_control, set_control,
54  button_control, options, nexus_name, low_limit, high_limit, units, block_value,
55  is_real, source, setpoint_time, value_time)
56  {
57  }
59  {
60  }
62  {
63  }
65  {
66  if (this != &block)
67  {
68  SEBLOCK_DETAILS_tuple::operator=(block);
69  }
70  return *this;
71  }
72 };
73 
74 struct SEBLOCK
75 {
76  time_t ref_time;
77  std::vector<std::string> setpoint_value;
78  std::vector<float> fsetpoint_value;
79  std::vector<float> fsetpoint_spread;
80  std::string vi_name;
81  std::string read_control;
82  std::string set_control;
83  std::string button_control;
84  unsigned options;
85  std::string nexus_name;
86  float low_limit;
87  float high_limit;
88  std::string units;
89  std::vector<std::string> current_value;
90  std::vector<float> fcurrent_value;
91  std::vector<float> fcurrent_spread;
92  bool is_real;
93 
94  std::vector<float> time;
95  std::vector<float> fvalues;
96  std::vector<std::string> svalues;
97  SEBLOCK() : ref_time(0), is_real(false), options(0), nexus_name(""), low_limit(0.0), high_limit(0.0) {}
98 };
99 
100 struct RUNBLOCK
101 {
102  time_t ref_time;
103  std::vector<float> time;
104  std::vector<int> period;
105  std::vector<int> run_status;
106  std::vector<int> is_running;
107  std::vector<int> is_waiting;
108  std::vector<int> good_frames;
109  std::vector<int> raw_frames;
110  std::vector<float> good_uamps;
111  std::vector<float> raw_uamps;
112  std::vector<int64_t> monitor1_sum;
113  std::vector<float> dae_beam_current;
114  std::vector<int64_t> total_counts;
115  std::vector<float> count_rate;
116  std::vector<float> np_ratio;
117  RUNBLOCK() : ref_time(0) {}
118 };
119 
121 {
123  char* inst_name;
125  unsigned lastread_nano;
126 };
127 
128 typedef std::map<std::string, SEBLOCK> seblock_map_t;
129 
130 // all routines return 0 on success, -1 on error
131 // if there is an error, call se_get_errmsg() to retrieve the text of the error message
132 //
133 // the database is opened automatically on a se_log_value()
134 // if possible you should call se_close() during a shutdown
135 extern "C" {
149  SELOGGER_API int __stdcall se_log_value(long run_number, const char* source, const char* iso_time, const char* block_name, const char* block_value);
154 
155  SELOGGER_API int __stdcall se_close();
156 
164  SELOGGER_API const char* __stdcall se_get_errmsg();
165 
183  SELOGGER_API int __stdcall se_set_block_details(const char* block_name, const char* setpoint_value,
184  const char* vi_name, const char* read_control_label, const char* set_control_label, const char* button_control_label,
185  unsigned options, const char* nexus_name, float low_limit, float high_limit,
186  const char* units, const char* current_value);
187 
188 
189  SELOGGER_API int __stdcall se_get_block_details(const char* block_name, SEBLOCK_DETAILS& details);
190 
195  SELOGGER_API int __stdcall se_new_seci_config(const char* config_name);
196 
200  SELOGGER_API int __stdcall se_log_run(int run_number, const char* source, const char* iso_time, int period,
201  int run_status, int is_running, int is_waiting,
202  int good_frames, int raw_frames,
203  float good_uamph, float raw_uamph,
204  int64_t monitor_sum0, float dae_beam_current, int64_t total_counts,
205  float count_rate, float npratio_current);
206 
207  SELOGGER_API int __stdcall se_get_num_blocks();
208 
209  SELOGGER_API int __stdcall se_get_seci_config(std::string& seci_config);
210 
214  SELOGGER_API int __stdcall se_set_block_value(const char* block_name, const char* block_value);
215 
216  SELOGGER_API int __stdcall se_get_blocks(int run_number, time_t ref_time, seblock_map_t& blocks);
217 
218  SELOGGER_API int __stdcall se_get_run_status(int run_number, time_t ref_time, RUNBLOCK& blocks);
219 
220  SELOGGER_API int __stdcall se_set_run_state(int run_number, const char* state, int is_start);
221 
222  SELOGGER_API int __stdcall se_set_run_state_async(int run_number, const char* state, int is_start);
223 
224  SELOGGER_API int __stdcall se_set_run_number(int run_number);
225 
226  SELOGGER_API int __stdcall se_set_period(int period);
227 
228  SELOGGER_API int __stdcall se_set_period_async(int period);
229 
230  SELOGGER_API int __stdcall se_new_measurement(const char* label, std::string& res);
231 
232  SELOGGER_API int __stdcall se_get_measurement_label(const char* measurement_id, std::string& res);
233 
234  SELOGGER_API int __stdcall se_set_measurement_label(const char* measurement_id, const char* label);
235 
236  SELOGGER_API int __stdcall se_get_measurement_id(const char* label, std::string& measurement_id);
237 
238  SELOGGER_API int __stdcall se_clear_values(int run_start, int run_finish);
239 
240  SELOGGER_API int __stdcall se_profile(const char* filename);
241 
242  SELOGGER_API int __stdcall se_log_values(long run_number, const char* source, const std::vector<std::string>& iso_times, const std::vector<std::string>& block_names, const std::vector<std::string>& block_values);
243 
244  SELOGGER_API int __stdcall se_log_fvalues(long run_number, const char* source, const std::vector<std::string>& iso_times, const std::vector<std::string>& block_names, const std::vector<float>& block_values);
245 
246  SELOGGER_API int __stdcall se_set_block_values(const std::vector<std::string>& block_names, const std::vector<std::string>& block_values);
247 
248  SELOGGER_API int __stdcall se_log_value_async(long run_number, const char* source, const char* iso_time, const char* block_name, const char* block_value);
249 
250  SELOGGER_API int __stdcall se_log_values_async(long run_number, const char* source, const std::vector<std::string>& iso_times, const std::vector<std::string>& block_names, const std::vector<std::string>& block_values);
251 
252  SELOGGER_API int __stdcall se_wait_for_async();
253 
254  SELOGGER_API int __stdcall se_get_measurement_first_run(const char* measurement_id, long& run_number);
255 
256  SELOGGER_API int __stdcall se_get_block_values(seblock_map_t& blocks);
257 
258  SELOGGER_API int __stdcall se_set_block_setpoint(const char* block_name, const char* block_setpoint);
259 
260  SELOGGER_API int __stdcall se_set_block_setpoints(const std::vector<std::string>& block_names, const std::vector<std::string>& block_setpoints);
261 
262  SELOGGER_API const char* __stdcall se_version();
263 
264  SELOGGER_API int __stdcall se_get_values(long run_number, const char* source, const char* block_name, std::vector<std::string>& iso_times, std::vector<std::string>& block_values);
265 
266  SELOGGER_API int __stdcall se_exec_sql(const char* sql, std::string& result);
267 };
268 
269 #endif /* SELOGGER_H */
int & is_real()
Definition: selogger.h:44
SELOGGER_API int __stdcall se_log_run(int run_number, const char *source, const char *iso_time, int period, int run_status, int is_running, int is_waiting, int good_frames, int raw_frames, float good_uamph, float raw_uamph, int64_t monitor_sum0, float dae_beam_current, int64_t total_counts, float count_rate, float npratio_current)
Definition: selogger.cpp:701
SELOGGER_API int __stdcall se_new_seci_config(const char *config_name)
Definition: selogger.cpp:764
std::vector< int > raw_frames
Definition: selogger.h:109
float high_limit
Definition: selogger.h:87
float & high_limit()
Definition: selogger.h:41
std::vector< int64_t > total_counts
Definition: selogger.h:114
std::vector< float > count_rate
Definition: selogger.h:115
int & options()
Definition: selogger.h:38
SELOGGER_API int __stdcall se_new_measurement(const char *label, std::string &res)
Definition: selogger.cpp:872
SELOGGER_API int __stdcall se_get_run_status(int run_number, time_t ref_time, RUNBLOCK &blocks)
Definition: selogger.cpp:1248
SELOGGER_API int __stdcall se_get_block_values(seblock_map_t &blocks)
Definition: selogger.cpp:1388
SELOGGER_API int __stdcall se_get_measurement_id(const char *label, std::string &measurement_id)
Definition: selogger.cpp:947
std::string units
Definition: selogger.h:88
bool is_real
Definition: selogger.h:92
SELOGGER_API int __stdcall se_set_run_state_async(int run_number, const char *state, int is_start)
Definition: selogger.cpp:1382
SELOGGER_API int __stdcall se_start_epics_thread(epics_thread_data_t *arg)
Definition: selogger.cpp:469
std::vector< float > fcurrent_spread
per period
Definition: selogger.h:91
SELOGGER_API int __stdcall se_get_num_blocks()
std::string set_control
Definition: selogger.h:82
std::string & source()
Definition: selogger.h:45
std::vector< float > fsetpoint_value
per period
Definition: selogger.h:78
std::map< std::string, SEBLOCK > seblock_map_t
Definition: selogger.h:128
std::string & block_name()
Definition: selogger.h:32
std::vector< std::string > setpoint_value
per period
Definition: selogger.h:77
std::string & units()
Definition: selogger.h:42
std::vector< float > raw_uamps
Definition: selogger.h:111
std::vector< float > good_uamps
Definition: selogger.h:110
SEBLOCK_DETAILS(const SEBLOCK_DETAILS &block)
Definition: selogger.h:61
SELOGGER_API int __stdcall se_log_values(long run_number, const char *source, const std::vector< std::string > &iso_times, const std::vector< std::string > &block_names, const std::vector< std::string > &block_values)
Definition: selogger.cpp:589
SELOGGER_API const char *__stdcall se_get_errmsg()
Definition: selogger.cpp:696
SELOGGER_API int __stdcall se_set_period(int period)
Definition: selogger.cpp:734
std::vector< std::string > current_value
per period
Definition: selogger.h:89
Poco::Tuple< std::string, std::string, std::string, std::string, std::string, std::string, int, std::string, float, float, std::string, std::string, int, std::string, std::string, std::string > SEBLOCK_DETAILS_tuple
Definition: selogger.h:26
SELOGGER_API int __stdcall se_log_value(long run_number, const char *source, const char *iso_time, const char *block_name, const char *block_value)
Definition: selogger.cpp:525
std::string & set_control()
Definition: selogger.h:36
std::vector< float > np_ratio
Definition: selogger.h:116
std::string & value_time()
Definition: selogger.h:47
SELOGGER_API int __stdcall se_profile(const char *filename)
Definition: selogger.cpp:1328
std::vector< float > time
Definition: selogger.h:103
std::string button_control
Definition: selogger.h:83
std::string read_control
Definition: selogger.h:81
std::vector< int > period
Definition: selogger.h:104
const char *__stdcall se_version()
Definition: selogger.cpp:345
std::string & setpoint_time()
Definition: selogger.h:46
SELOGGER_API int __stdcall se_get_block_details(const char *block_name, SEBLOCK_DETAILS &block)
Definition: selogger.cpp:1481
SELOGGER_API int __stdcall se_get_measurement_label(const char *measurement_id, std::string &res)
Definition: selogger.cpp:905
float low_limit
Definition: selogger.h:86
SELOGGER_API int __stdcall se_log_fvalues(long run_number, const char *source, const std::vector< std::string > &iso_times, const std::vector< std::string > &block_names, const std::vector< float > &block_values)
Definition: selogger.cpp:578
SELOGGER_API int __stdcall se_set_block_setpoints(const std::vector< std::string > &block_names, const std::vector< std::string > &block_setpoints)
Definition: selogger.cpp:1413
SEBLOCK_DETAILS_tuple & tuple()
Definition: selogger.h:31
SELOGGER_API int __stdcall se_set_run_number(int run_number)
Definition: selogger.cpp:729
BlockOptions
Definition: selogger.h:19
SELOGGER_API int __stdcall se_set_period_async(int period)
Definition: selogger.cpp:1356
SELOGGER_API int __stdcall se_close()
Definition: selogger.cpp:691
SELOGGER_API int __stdcall se_get_values(long run_number, const char *source, const char *block_name, std::vector< std::string > &iso_times, std::vector< std::string > &block_values)
Definition: selogger.cpp:1446
std::vector< float > fvalues
Definition: selogger.h:95
std::vector< float > fcurrent_value
per period
Definition: selogger.h:90
SELOGGER_API int __stdcall se_get_seci_config(std::string &seci_config)
Definition: selogger.cpp:739
std::vector< float > dae_beam_current
Definition: selogger.h:113
SEBLOCK_DETAILS & operator=(const SEBLOCK_DETAILS &block)
Definition: selogger.h:64
RUNBLOCK()
Definition: selogger.h:117
std::vector< int > is_waiting
Definition: selogger.h:107
std::vector< float > fsetpoint_spread
per period
Definition: selogger.h:79
std::string & vi_name()
Definition: selogger.h:34
SELOGGER_API int __stdcall se_get_measurement_first_run(const char *measurement_id, long &run_number)
Definition: selogger.cpp:974
std::vector< int > is_running
Definition: selogger.h:106
SEBLOCK_DETAILS(const std::string &block_name, const std::string &setpoint_value, const std::string &vi_name, const std::string &read_control, const std::string &set_control, const std::string &button_control, int options, const std::string &nexus_name, float low_limit, float high_limit, const std::string &units, const std::string &block_value, int is_real, const std::string &source, const std::string &setpoint_time, const std::string &value_time)
Definition: selogger.h:48
SELOGGER_API int __stdcall se_exec_sql(const char *sql, std::string &result)
Definition: selogger.cpp:1503
std::vector< std::string > svalues
Definition: selogger.h:96
SELOGGER_API int __stdcall se_get_blocks(int run_number, time_t ref_time, seblock_map_t &blocks)
Definition: selogger.cpp:1060
SELOGGER_API int __stdcall se_set_run_state(int run_number, const char *state, int is_start)
Definition: selogger.cpp:744
std::vector< float > time
Definition: selogger.h:94
unsigned lastread_nano
Definition: selogger.h:125
SELOGGER_API int __stdcall se_set_block_setpoint(const char *block_name, const char *block_setpoint)
Definition: selogger.cpp:1404
SELOGGER_API int __stdcall se_clear_values(int run_start, int run_finish)
Definition: selogger.cpp:1040
SELOGGER_API int __stdcall se_set_block_value(const char *block_name, const char *block_value)
Definition: selogger.cpp:475
std::string nexus_name
Definition: selogger.h:85
std::string & read_control()
Definition: selogger.h:35
SELOGGER_API int __stdcall se_set_measurement_label(const char *measurement_id, const char *label)
Definition: selogger.cpp:931
std::string & button_control()
Definition: selogger.h:37
SELOGGER_API int __stdcall se_set_block_values(const std::vector< std::string > &block_names, const std::vector< std::string > &block_values)
Definition: selogger.cpp:484
time_t ref_time
Definition: selogger.h:76
SELOGGER_API int __stdcall se_log_value_async(long run_number, const char *source, const char *iso_time, const char *block_name, const char *block_value)
Definition: selogger.cpp:567
#define SELOGGER_API
Definition: selogger.h:12
SELOGGER_API int __stdcall se_set_block_details(const char *block_name, const char *setpoint_value, const char *vi_name, const char *read_control_label, const char *set_control_label, const char *button_control_label, unsigned options, const char *nexus_name, float low_limit, float high_limit, const char *units, const char *current_value)
Definition: selogger.cpp:784
SELOGGER_API int __stdcall se_wait_for_async()
Definition: selogger.cpp:537
float & low_limit()
Definition: selogger.h:40
std::string & block_value()
Definition: selogger.h:43
unsigned options
Definition: selogger.h:84
std::vector< int > run_status
Definition: selogger.h:105
std::string & setpoint_value()
Definition: selogger.h:33
time_t ref_time
Definition: selogger.h:102
std::string & nexus_name()
Definition: selogger.h:39
std::string vi_name
Definition: selogger.h:80
std::vector< int > good_frames
Definition: selogger.h:108
SELOGGER_API int __stdcall se_log_values_async(long run_number, const char *source, const std::vector< std::string > &iso_times, const std::vector< std::string > &block_names, const std::vector< std::string > &block_values)
Definition: selogger.cpp:572
std::vector< int64_t > monitor1_sum
Definition: selogger.h:112
SEBLOCK()
Definition: selogger.h:97