1 #ifndef NDS_CONNECTION_DETAIL_PTYPE_HH
2 #define NDS_CONNECTION_DETAIL_PTYPE_HH
12 #include "daq_config.h"
41 channel::sample_rate_type min_sample_rate,
42 channel::sample_rate_type max_sample_rate )
49 operator( )(
const channel& ch )
75 operator( )(
const channel& ch )
94 operator( )(
const channel& ch )
119 : gps_start( gps_start ), gps_stop( gps_stop ){};
123 const channel& channel_info )
const;
148 struct conn_p_type :
public std::enable_shared_from_this< conn_p_type >
160 typedef std::map< std::string, daq_channel_t >
183 explicit conn_p_type(
const NDS::parameters& params );
191 const epoch& time_span,
192 const connection::channel_names_type& channel_names );
194 buffer::gps_second_type gps_start,
195 buffer::gps_second_type gps_stop,
196 const connection::channel_names_type& channel_names );
198 bool check( buffer::gps_second_type gps_start,
199 buffer::gps_second_type gps_stop,
200 const connection::channel_names_type& channel_names );
203 has_gaps( buffer::gps_second_type gps_start,
204 buffer::gps_second_type gps_stop,
205 const connection::channel_names_type& channel_names );
208 fetch( buffer::gps_second_type gps_start,
209 buffer::gps_second_type gps_stop,
210 const connection::channel_names_type& channel_names,
214 std::string channel_glob,
215 channel_type channel_type_mask = channel::DEFAULT_CHANNEL_MASK,
216 data_type data_type_mask = channel::DEFAULT_DATA_MASK,
221 std::string channel_glob,
222 channel_type channel_type_mask = channel::DEFAULT_CHANNEL_MASK,
223 data_type data_type_mask = channel::DEFAULT_DATA_MASK,
229 std::string channel_glob,
230 channel_type channel_type_mask = channel::DEFAULT_CHANNEL_MASK,
231 data_type data_type_mask = channel::DEFAULT_DATA_MASK,
235 if (
protocol == connection::protocol_type::PROTOCOL_ONE )
251 const NDS::channel_predicate_object& pred );
255 std::string channel_glob,
256 channel_type channel_type_mask = channel::DEFAULT_CHANNEL_MASK,
257 data_type data_type_mask = channel::DEFAULT_DATA_MASK,
263 std::string channel_glob,
264 channel_type channel_type_mask = channel::DEFAULT_CHANNEL_MASK,
265 data_type data_type_mask = channel::DEFAULT_DATA_MASK,
272 bool set_epoch(
const std::string& epoch_name );
274 bool set_epoch( buffer::gps_second_type gps_start,
275 buffer::gps_second_type gps_stop );
279 const channel::hash_type&
hash( )
const;
282 buffer::gps_second_type gps_start,
283 buffer::gps_second_type gps_stop,
284 buffer::gps_second_type stride,
285 const connection::channel_names_type& channel_names );
288 buffer::gps_second_type gps_start,
289 buffer::gps_second_type gps_stop,
290 buffer::gps_second_type stride,
291 const connection::channel_names_type& channel_names,
292 std::vector< NDS::channel >* final_channel_list =
nullptr );
306 channel::size_type DataSizeType,
307 unsigned char* start,
308 unsigned char* end );
353 NDS::buffer::gps_second_type
355 NDS::buffer::gps_second_type gps_stop,
368 (
protocol == connection::protocol_type::PROTOCOL_ONE ) )
377 throw connection::daq_error( rc );
398 std::vector< std::string >& queryTypes );
404 buffer::gps_second_type gps_start,
405 buffer::gps_second_type gps_stop,
406 const channel::channel_names_type& names );
410 buffer::gps_second_type gps_stop,
411 const connection::channel_names_type& channel_names,
422 paccess( ).max_nds1_command_count( ) );
431 buffer::gps_second_type gps_start,
432 const connection::channel_names_type& channel_names,
433 bool& have_minute_trends,
434 double& bytes_per_sample,
435 std::vector< NDS::channel >* final_channel_list =
nullptr );
441 bool buffers_initialized );
444 buffer::gps_second_type gps_start,
445 buffer::gps_second_type gps_stop,
446 const connection::channel_names_type& channel_names );
462 template <
typename Filter,
typename Function >
464 const std::vector< std::string >& types,
465 const std::string& channel_glob,
470 buffer::gps_second_type gps_start,
471 buffer::gps_second_type gps_stop,
472 buffer::gps_second_type stride,
473 const connection::channel_names_type& channel_names );
475 std::shared_ptr< detail::iterate_handler >
477 buffer::gps_second_type gps_stop,
478 buffer::gps_second_type stride,
479 const connection::channel_names_type& channel_names );
482 buffer::gps_second_type gps_start,
483 buffer::gps_second_type gps_stop,
484 buffer::gps_second_type stride,
485 const connection::channel_names_type& channel_names );
487 std::shared_ptr< detail::iterate_handler >
489 buffer::gps_second_type gps_stop,
490 buffer::gps_second_type stride,
491 const connection::channel_names_type& channel_names );
497 template <
typename Filter,
typename Function >
500 const std::vector< std::string >& types,
501 const std::string& channel_glob,
505 std::vector< char > lineBuffer;
506 lineBuffer.resize( 512 );
508 for ( std::vector< std::string >::const_iterator cur =
516 std::ostringstream cmdBuf;
527 cmdBuf <<
"get-channels 0 ";
530 if ( channel_glob.compare(
"*" ) != 0 )
532 cmdBuf <<
" {" << channel_glob <<
"}";
546 throw connection::unexpected_channels_received_error( );
557 throw connection::unexpected_channels_received_error( );
559 if ( line_size < lineBuffer.size( ) )
561 lineBuffer.resize( line_size );
564 &( lineBuffer[ 0 ] ),
567 throw connection::unexpected_channels_received_error( );
571 if ( filter( curCh ) )
582 #endif // NDS_CONNECTION_DETAIL_PTYPE_HH
std::shared_ptr< detail::iterate_handler > iterate_full(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:1839
unsigned int uint4_type
Definition: daqc.h:17
A basic channel filter.
Definition: nds_connection_ptype.hh:37
connection::protocol_type protocol
Definition: nds_connection_ptype.hh:169
time_type request_start_time() const
Definition: nds_connection_ptype.hh:311
channel::data_type data_type_mask_
Definition: nds_connection_ptype.hh:59
long time_type
Definition: nds_connection_ptype.hh:163
void request_start_time(time_type Value)
Definition: nds_connection_ptype.hh:317
Definition: nds_iterate_handler.hh:19
size_t count_
Definition: nds_connection_ptype.hh:106
channel::data_type data_type
Definition: nds_connection_ptype.hh:157
epochs_type epoch_cache_
Definition: nds_connection_ptype.hh:450
std::shared_ptr< detail::iterate_handler > iterate_available(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:1812
epoch current_epoch_
Definition: nds_connection_ptype.hh:451
channel::sample_rate_type sample_rate_type
Definition: nds_connection_ptype.hh:158
Definition: nds_channel_cache.hh:30
void next_raw_buffer(buffers_type &output)
Definition: nds_connection_ptype.cc:2130
Definition: nds_connection_ptype.hh:113
channel::sample_rate_type min_sample_rate_
Definition: nds_connection_ptype.hh:60
NDS::buffer::gps_second_type cur_nds1_gpstime()
Definition: nds_connection_ptype.cc:2240
void find_channels_nds2(channels_type &output, std::string channel_glob, channel_type channel_type_mask=channel::DEFAULT_CHANNEL_MASK, data_type data_type_mask=channel::DEFAULT_DATA_MASK, sample_rate_type min_sample_rate=channel::MIN_SAMPLE_RATE, sample_rate_type max_sample_rate=channel::MAX_SAMPLE_RATE)
Definition: nds_connection_ptype.cc:1344
bool has_gaps(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:2041
daq_t handle
Definition: nds_connection_ptype.hh:170
void validate() const
Definition: nds_connection_ptype.cc:2267
buffer::gps_second_type gps_stop
Definition: nds_connection_ptype.hh:127
size_t count_channels_nds1(std::string channel_glob, channel_type channel_type_mask=channel::DEFAULT_CHANNEL_MASK, data_type data_type_mask=channel::DEFAULT_DATA_MASK, sample_rate_type min_sample_rate=channel::MIN_SAMPLE_RATE, sample_rate_type max_sample_rate=channel::MAX_SAMPLE_RATE)
Definition: nds_connection_ptype.cc:1201
#define DAQD_NOT_FOUND
Definition: daqc_response.h:62
std::vector< channel > & buffer_
Definition: nds_connection_ptype.hh:81
size_t count_channels(std::string channel_glob, channel_type channel_type_mask=channel::DEFAULT_CHANNEL_MASK, data_type data_type_mask=channel::DEFAULT_DATA_MASK, sample_rate_type min_sample_rate=channel::MIN_SAMPLE_RATE, sample_rate_type max_sample_rate=channel::MAX_SAMPLE_RATE)
Definition: nds_connection_ptype.hh:228
std::ostream & dout()
Definition: debug_stream.cc:23
void validate_daq(int RetCode) const
Definition: nds_connection_ptype.cc:2276
Definition: nds_connection_ptype.hh:130
void find_channels_nds1(channels_type &output, std::string channel_glob, channel_type channel_type_mask=channel::DEFAULT_CHANNEL_MASK, data_type data_type_mask=channel::DEFAULT_DATA_MASK, sample_rate_type min_sample_rate=channel::MIN_SAMPLE_RATE, sample_rate_type max_sample_rate=channel::MAX_SAMPLE_RATE)
Definition: nds_connection_ptype.cc:1054
A functor that counts the number of calls.
Definition: nds_connection_ptype.hh:87
void request_in_progress(bool Value)
Definition: nds_connection_ptype.hh:341
void retreive_channels_from_nds2(const std::vector< std::string > &types, const std::string &channel_glob, Filter &filt, Function &fn)
Definition: nds_connection_ptype.hh:499
daq_accessor(daq_t &handle)
Definition: nds_connection_ptype.hh:133
size_t count() const
Definition: nds_connection_ptype.hh:100
nds_socket_type socket_t
Definition: nds_connection_ptype.hh:165
channel::hash_type hash_
Definition: nds_connection_ptype.hh:452
epoch resolve_epoch(const std::string &epoch_name)
Definition: nds_connection_ptype.cc:1483
Channel description structure.
Definition: daqc.h:303
size_t max_command_count
Definition: daqc_private.h:46
daq_t & handle_
Definition: nds_connection_ptype.hh:139
buffers_type fetch(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const connection::channel_names_type &channel_names, channels_type *reference_channels=nullptr)
Definition: nds_connection_ptype.cc:728
channel _parse_nds2_get_channel_line(char *buffer)
Definition: nds_connection_ptype.cc:1091
buffer::gps_second_type gps_start
Definition: nds_connection_ptype.hh:126
std::string err_msg_unexpected_no_data_found(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const channel::channel_names_type &names)
Definition: nds_connection_ptype.cc:869
std::map< std::string, daq_channel_t > channel_mem_cache_type
Definition: nds_connection_ptype.hh:161
nds_socket_type sockfd
DAQD server socket.
Definition: daqc_private.h:36
#define DLL_EXPORT
Definition: channel.h:12
DLL_EXPORT ~conn_p_type()
Definition: nds_connection_ptype.cc:266
bool set_epoch(const std::string &epoch_name)
Definition: nds_connection_ptype.cc:1533
daq_accessor accesor_
Definition: nds_connection_ptype.hh:171
std::weak_ptr< detail::iterate_handler > iterate_handler_
Definition: nds_connection_ptype.hh:448
void process_check_data_result(int result, bool gaps_ok)
Definition: nds_connection_ptype.cc:617
void infer_daq_channel_info(const std::string &channel_name, daq_channel_t &channel, time_type gps)
Definition: nds_connection_ptype.cc:775
std::string get_last_message() const
Definition: nds_connection_ptype.cc:846
void load_epochs_to_cache()
Definition: nds_connection_ptype.cc:1398
std::vector< request_fragment > request_fragments_type
Definition: nds_request_fragment.hh:36
void fill_gap(data_type DataType, channel::size_type DataSizeType, unsigned char *start, unsigned char *end)
Definition: nds_connection_ptype.cc:766
size_t count_channels_nds2(std::string channel_glob, channel_type channel_type_mask=channel::DEFAULT_CHANNEL_MASK, data_type data_type_mask=channel::DEFAULT_DATA_MASK, sample_rate_type min_sample_rate=channel::MIN_SAMPLE_RATE, sample_rate_type max_sample_rate=channel::MAX_SAMPLE_RATE)
Definition: nds_connection_ptype.cc:1233
struct daq_private_ * conceal
Definition: daqc.h:293
availability_list_type get_availability(const epoch &time_span, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:333
void shutdown()
Definition: nds_connection_ptype.cc:2224
void fetch_fragment(request_fragment &fragment, const buffer_initializer &initializer, bool buffers_initialized)
Definition: nds_connection_ptype.cc:889
void find_channels(channels_type &output, const NDS::channel_predicate_object &pred)
Definition: nds_connection_ptype.cc:1309
channel::channel_type channel_type
Definition: nds_connection_ptype.hh:156
bool request_in_progress_
Definition: nds_connection_ptype.hh:178
time_type request_start_time_
Definition: nds_connection_ptype.hh:176
bool check(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:705
std::shared_ptr< detail::iterate_handler > iterate_simple_gaps(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:1753
basic_channel_filter(channel::data_type data_type_mask, channel::sample_rate_type min_sample_rate, channel::sample_rate_type max_sample_rate)
Definition: nds_connection_ptype.hh:40
bool _read_uint4(socket_t fd, uint4_type *dest)
Definition: nds_connection_ptype.cc:1147
const channel::hash_type & hash() const
Definition: nds_connection_ptype.cc:1581
NDS::detail::channel_cache_nds1 channel_cache_type
Definition: nds_connection_ptype.hh:162
void termination_block()
Definition: nds_connection_ptype.hh:359
connection::host_type host
Definition: nds_connection_ptype.hh:167
std::vector< epoch > epochs_type
Definition: nds_epoch.hh:56
NDS1/2 client status structure.
Definition: daqc.h:232
bool _read_buffer(socket_t fd, void *dest, size_t size)
Definition: nds_connection_ptype.cc:1128
count_channels()
Definition: nds_connection_ptype.hh:90
time_type request_end_time() const
Definition: nds_connection_ptype.hh:323
DLL_EXPORT int daq_send(daq_t *daq, const char *command)
send a command string.
Definition: daqc_access.c:335
NDS::parameters parameters_
Definition: nds_connection_ptype.hh:180
std::vector< channel > channels_type
Definition: nds_channel.hh:298
DLL_EXPORT void reset_buffer(buffer *cur_buffer, const channel &channel_info) const
Definition: nds_connection_ptype.cc:204
channel_mem_cache_type channel_mem_cache_
Definition: nds_connection_ptype.hh:174
A parameter_accessor allows internal code to access the detail::parameter_block in a NDS::connection:...
Definition: nds_parameter_block.hh:177
epoch current_epoch() const
Definition: nds_connection_ptype.cc:1575
bool request_in_progress() const
Definition: nds_connection_ptype.hh:335
std::vector< buffers_type > fetch_available(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:965
time_type request_end_time_
Definition: nds_connection_ptype.hh:177
static bool initialized
Definition: nds_connection_ptype.hh:494
int nds_socket_type
Definition: daqc_private.h:12
channel_cache_type channel_cache_
Definition: nds_connection_ptype.hh:173
std::shared_ptr< detail::iterate_handler > iterate_fast(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:1786
void issue_iterate(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names, std::vector< NDS::channel > *final_channel_list=nullptr)
Definition: nds_connection_ptype.cc:1612
DLL_EXPORT int daq_recv_next(daq_t *daq)
Receive a data block.
Definition: daqc_access.c:592
void setup_daq_chanlist(buffer::gps_second_type gps_start, const connection::channel_names_type &channel_names, bool &have_minute_trends, double &bytes_per_sample, std::vector< NDS::channel > *final_channel_list=nullptr)
Definition: nds_connection_ptype.cc:547
bool connected
Definition: nds_connection_ptype.hh:172
Definition: nds_request_fragment.hh:12
std::vector< buffer > buffers_type
Definition: nds_buffer.hh:356
Provide a functor to push channels onto a vector.
Definition: nds_connection_ptype.hh:67
NDS::buffer::gps_second_type calculate_stride(NDS::buffer::gps_second_type gps_start, NDS::buffer::gps_second_type gps_stop, NDS::channels_type &selected_channels) const
Definition: nds_connection_ptype.cc:2058
void request_end_time(time_type Value)
Definition: nds_connection_ptype.hh:329
iterate_finalize_reason
Definition: nds_connection_ptype.hh:150
Definition: nds_connection_ptype.hh:148
channel::sample_rate_type max_sample_rate_
Definition: nds_connection_ptype.hh:61
void finalize_iterate(detail::iterate_handler *handler, iterate_finalize_reason reason)
Definition: nds_connection_ptype.cc:1724
void connect()
Definition: nds_connection_ptype.cc:272
DLL_EXPORT buffer_initializer(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop)
Definition: nds_connection_ptype.hh:117
bool set_epoch_if_changed(const epoch &time_span)
Definition: nds_connection_ptype.cc:1514
void cycle_nds1_connection()
Definition: nds_connection_ptype.cc:2287
void channel_mask_to_query_type_strings(channel_type channel_type_mask, std::vector< std::string > &queryTypes)
Given a channel_type mask convert it into a vector of nds2 type strings.
Definition: nds_connection_ptype.cc:1165
void sync_parameters()
Definition: nds_connection_ptype.hh:416
void plan_fetches(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const connection::channel_names_type &channel_names, buffers_type &dest_buffers, request_fragments_type &retval)
Definition: nds_connection_ptype.cc:633
push_back_channel(std::vector< channel > &buffer)
Definition: nds_connection_ptype.hh:70
DLL_EXPORT conn_p_type(const NDS::parameters ¶ms)
Definition: nds_connection_ptype.cc:235
connection::port_type port
Definition: nds_connection_ptype.hh:168
std::shared_ptr< detail::iterate_handler > dispatch_iterate(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, buffer::gps_second_type stride, const connection::channel_names_type &channel_names)
Definition: nds_connection_ptype.cc:1952
epochs_type get_epochs()
Definition: nds_connection_ptype.cc:1468