25 #ifndef SWIG__COMMON__NDS_CONNECTION_HH
26 #define SWIG__COMMON__NDS_CONNECTION_HH
116 #include "nds_export.hh"
117 #include "nds_buffer.hh"
118 #include "nds_channel.hh"
119 #include "nds_data_iterator.hh"
120 #include "nds_availability.hh"
121 #include "nds_epoch.hh"
128 class parameter_block;
129 class parameter_accessor;
131 inline namespace abi_0
138 NDS::channel::sample_rate_type
140 NDS::channel::sample_rate_type
144 : minimum( NDS::
channel::MIN_SAMPLE_RATE ),
149 NDS::channel::sample_rate_type Max )
150 : minimum( Min ),
maximum( Max )
171 typedef std::vector< NDS::channel::channel_type > channel_type_list;
172 typedef std::vector< NDS::channel::data_type > data_type_list;
175 : epoch_(
"", 0, NDS::buffer::GPS_INF ), glob_( ),
176 channel_types_( ), data_types_( ), sample_rates_( )
196 return ( glob_.empty( ) ?
"*" : glob_ );
202 const channel_type_list
206 if ( channel_types_.empty( ) )
208 channel_type_list result{ all_channel_types };
211 return channel_types_;
216 NDS::channel::channel_type
219 if ( channel_types_.empty( ) )
221 return NDS::channel::DEFAULT_CHANNEL_MASK;
223 NDS::channel::channel_type result;
224 for (
const NDS::channel::channel_type val : channel_types_ )
226 result = ( NDS::channel::channel_type )( result | val );
237 if ( data_types_.empty( ) )
239 data_type_list result{ all_data_types };
247 NDS::channel::data_type
250 if ( data_types_.empty( ) )
252 return NDS::channel::DEFAULT_DATA_MASK;
254 NDS::channel::data_type result;
255 for (
const NDS::channel::data_type val : data_types_ )
257 result = ( NDS::channel::data_type )( result | val );
269 return sample_rates_;
274 NDS::channel::sample_rate_type
277 return sample_rates_.minimum;
282 NDS::channel::sample_rate_type
298 NDS::buffer::gps_second_type
301 return epoch_.gps_start;
306 NDS::buffer::gps_second_type
309 return epoch_.gps_stop;
320 glob_ = std::move( val );
343 set( NDS::channel::channel_type val )
346 for (
auto entry : all_channel_types )
347 if ( (
int)entry | (
int)val )
349 channel_types_.push_back( val );
374 set( NDS::channel::data_type val )
376 for (
auto entry : all_data_types )
378 if ( (
int)entry | (
int)val )
380 data_types_.push_back( val );
442 NDS::buffer::gps_second_type
gps_stop )
444 NDS::epoch e(
"", gps_start, gps_stop );
449 DLL_EXPORT
const static data_type_list all_data_types;
450 DLL_EXPORT
const static channel_type_list all_channel_types;
454 channel_type_list channel_types_;
455 data_type_list data_types_;
460 build_channel_predicate( channel_predicate_object& pred )
464 template <
typename T >
466 build_channel_predicate( channel_predicate_object& pred, T val )
471 template <
typename T,
typename... Args >
473 build_channel_predicate( channel_predicate_object& pred,
478 build_channel_predicate( pred, args... );
491 template <
typename... Args >
492 channel_predicate_object
493 channel_predicate( Args... args )
495 channel_predicate_object pred;
496 build_channel_predicate( pred, args... );
520 class error :
public std::runtime_error
524 error(
const std::string& What,
int ErrNo = 0 );
578 daq_error(
int daq_code,
579 const std::string& additional_information );
582 daq_error(
int daq_code,
const char* additional_information );
597 static std::string format(
int DAQCode,
598 const char* extra =
nullptr );
620 typedef std::vector< std::string > parameters_type;
653 explicit connection(
const NDS::parameters& params );
658 connection(
const NDS::connection& other ) =
delete;
759 DLL_EXPORT channels_type
830 DLL_EXPORT buffers_type
840 DLL_EXPORT NDS::parameters&
parameters( )
const;
904 DLL_EXPORT NDS::data_iterable
905 iterate( NDS::request_period period,
918 std::shared_ptr< detail::conn_p_type > p_;
921 DLL_EXPORT
extern std::ostream& operator<<( std::ostream& os,
933 DLL_EXPORT
explicit parameters(
938 DLL_EXPORT parameters(
const parameters& other );
939 DLL_EXPORT parameters( parameters&& other ) noexcept;
941 DLL_EXPORT parameters& operator=(
const parameters& other );
942 DLL_EXPORT parameters& operator=( parameters&& other ) noexcept;
944 DLL_EXPORT ~parameters( );
974 DLL_EXPORT std::string
get(
const std::string& key )
const;
1089 DLL_EXPORT
bool set(
const std::string& key,
1090 const std::string& value );
1100 friend class NDS::detail::parameter_accessor;
1101 std::unique_ptr< detail::parameter_block > p_;
std::vector< std::string > channel_names_type
A vector of channel names.
Definition: nds_channel.hh:104
NDS::channel::sample_rate_type max_sample_rate() const
return the maximum sample rate to be selected. This is also available through the sample_rates method...
Definition: nds_connection.hh:283
NDS::buffer::gps_second_type gps_stop() const
Return the gps stop time that constrains this query. Note this is available via the time_span method...
Definition: nds_connection.hh:307
Signal that the connection has already been closed.
Definition: nds_connection.hh:530
DLL_EXPORT availability_list_type get_availability(const epoch &time_span, const channel_names_type &channel_names)
Given a list of channels return their availability over the current epoch.
Definition: nds_connection.cc:222
A list of availabilitys (channels, availability segments)
Definition: nds_availability.hh:126
DLL_EXPORT ~connection()
Destroy the connection.
Base class for NDS errors.
Definition: nds_connection.hh:520
static const port_type DEFAULT_PORT
Default NDS2 port number.
Definition: nds_connection.hh:622
const frequency_range & sample_rates() const
return the range of sample rates that are to be allowed in the query. defaults to (NDS::channel::MIN_...
Definition: nds_connection.hh:267
DLL_EXPORT void close()
Close the connection.
Definition: nds_connection.cc:216
Unknown or invalid connection.
Definition: nds_connection.hh:606
DLL_EXPORT bool check(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const channel_names_type &channel_names)
Check to see if data is avaiable.
Definition: nds_connection.cc:230
std::string host_type
Host name type.
Definition: nds_connection.hh:612
void set_channel_type_mask(NDS::channel::channel_type val)
Set the channel type mask.
Definition: nds_connection.hh:361
void set_frequency_range(NDS::channel::sample_rate_type min_sample_rate, NDS::channel::sample_rate_type max_sample_rate)
Set the [min, max) frequency range that limits this query.
Definition: nds_connection.hh:415
A transfer is already in progress.
Definition: nds_connection.hh:551
A predicate object to be used in limiting the number of channels returned when searching for channels...
Definition: nds_connection.hh:168
const data_type_list data_types() const
return a container of distinct data types that are to be matched (defaults to an expansion of NDS::ch...
Definition: nds_connection.hh:235
DLL_EXPORT channels_type find_channels(const channel_predicate_object &pred)
Retrieve a list of channels.
Definition: nds_connection.cc:272
channel_predicate_object & set(std::string val)
Set the glob string used in channel matching.
Definition: nds_connection.hh:318
NDS::channel::channel_type channel_type_mask() const
return a compact mask of the channel types selected. this is mainly provided for the SWIG language bi...
Definition: nds_connection.hh:217
DLL_EXPORT bool set(const std::string &key, const std::string &value)
Change the default behavior of the connection.
Definition: nds_connection.cc:144
frequency_range()
The maximum frequency in this range.
Definition: nds_connection.hh:143
Signals that a minute trend has been requested but the start/stop times are not divisible by 60...
Definition: nds_connection.hh:541
NDS::channel::sample_rate_type min_sample_rate() const
return the minimum sample rate to be selected. This is also available through the sample_rates method...
Definition: nds_connection.hh:275
channel_predicate_object & set(NDS::channel::channel_type val)
Set a channel type to search for.
Definition: nds_connection.hh:343
DLL_EXPORT buffers_type fetch(buffer::gps_second_type gps_start, buffer::gps_second_type gps_stop, const channel_names_type &channel_names)
Retreive data from the server.
Definition: nds_connection.cc:240
DLL_EXPORT NDS::data_iterable iterate(NDS::request_period period, const channel_names_type &channel_names)
Retreive data in segments.
long gps_second_type
Type second portion of a gps time.
Definition: nds_buffer.hh:33
channel_predicate_object & set(epoch val)
Definition: nds_connection.hh:428
DLL_EXPORT connection::parameters_type parameter_list() const
Return a list of supported parameters.
Definition: nds_connection.cc:150
NDS::channel::sample_rate_type maximum
The minimum frequency in this range.
Definition: nds_connection.hh:141
int port_type
Host port number type.
Definition: nds_connection.hh:613
std::string glob() const
Return the channel name glob (defaults to "*")
Definition: nds_connection.hh:194
DLL_EXPORT connection::host_type host() const
Return the host that is currently connected/configured.
Definition: nds_connection.cc:120
A simple range for sample rates.
Definition: nds_connection.hh:136
channel_predicate_object & set(frequency_range val)
Definition: nds_connection.hh:403
Connect with NDS1 protocol.
Definition: nds_connection.hh:607
size_t count_type
Generic count time.
Definition: nds_connection.hh:614
NDS::channel::data_type data_type_mask() const
return a compact mask of the data types selected. this is mainly provided for the SWIG language bindi...
Definition: nds_connection.hh:248
an error state was returned by the NDS server
Definition: nds_connection.hh:571
The hash_type represents a channel hash. The channel hash is an hash of the NDS2 channel list...
Definition: nds_channel.hh:71
DLL_EXPORT const channel::hash_type & hash() const
Return the NDS2 channel hash.
Definition: nds_connection.cc:290
An unexpected channel or data was received.
Definition: nds_connection.hh:561
DLL_EXPORT epochs_type get_epochs()
Return a list of epochs.
Definition: nds_connection.cc:298
DLL_EXPORT NDS::parameters & parameters() const
Return the parameter/configuration object.
Definition: nds_connection.cc:284
DLL_EXPORT bool request_in_progress() const
Query the connection to see if a request is in progress.
Definition: nds_connection.cc:318
channel::channel_names_type channel_names_type
A list of channel names.
Definition: nds_connection.hh:619
void set_timespan(NDS::buffer::gps_second_type gps_start, NDS::buffer::gps_second_type gps_stop)
Set the [gps_start, gps_stop) time range that limits this query.
Definition: nds_connection.hh:441
DLL_EXPORT connection::port_type port() const
Return the port number that is currently connected/configured.
Definition: nds_connection.cc:126
NDS::buffer::gps_second_type gps_start() const
Return the gps start time that constrains this query. Note this is available via the time_span method...
Definition: nds_connection.hh:299
void set_data_type_mask(NDS::channel::data_type val)
Set the data type mask.
Definition: nds_connection.hh:392
channel_predicate_object & set(NDS::channel::data_type val)
Set a data type to search for.
Definition: nds_connection.hh:374
A connection to the NDS/NDS2 server.
Definition: nds_connection.hh:514
Represents a LIGO data channel.
Definition: nds_channel.hh:33
const channel_type_list channel_types() const
return a container of distinct channel types that are to be matched (defaults to an expansion of NDS:...
Definition: nds_connection.hh:203
The parameters class holds the configuration for a connection. This includes gap handling strategy an...
Definition: nds_connection.hh:929
const epoch & time_span() const
return the timespan/epoch that should constrain the query defaults to [0, NDS::buffer::GPS_INF) ...
Definition: nds_connection.hh:291
Autodetect server protocol.
Definition: nds_connection.hh:609
protocol_type
Connection constants.
Definition: nds_connection.hh:604
DLL_EXPORT connection::protocol_type protocol() const
Return the protocol version configured/in use.
Definition: nds_connection.cc:132
void set_glob(std::string val)
Set the glob string to match on.
Definition: nds_connection.hh:330
Connect with NDS2 protocol.
Definition: nds_connection.hh:608
DLL_EXPORT connection()=delete
Default constructor.
connection & operator=(const NDS::connection &other)=delete
Connection objects are not copyable.
DLL_EXPORT count_type count_channels(const channel_predicate_object &pred)
Return the count of channels matching the given predicate.
Definition: nds_connection.cc:250