4 #ifndef SWIG__COMMON__NDS_CHANNEL_HH
5 #define SWIG__COMMON__NDS_CHANNEL_HH
15 #include "nds_export.hh"
24 inline namespace abi_0
40 CHANNEL_TYPE_UNKNOWN = 0,
41 CHANNEL_TYPE_ONLINE = ( 1 << 0 ),
42 CHANNEL_TYPE_RAW = ( 1 << 1 ),
43 CHANNEL_TYPE_RDS = ( 1 << 2 ),
44 CHANNEL_TYPE_STREND = ( 1 << 3 ),
45 CHANNEL_TYPE_MTREND = ( 1 << 4 ),
46 CHANNEL_TYPE_TEST_POINT = ( 1 << 5 ),
47 CHANNEL_TYPE_STATIC = ( 1 << 6 )
54 DATA_TYPE_UNKNOWN = 0,
55 DATA_TYPE_INT16 = ( 1 << 0 ),
56 DATA_TYPE_INT32 = ( 1 << 1 ),
57 DATA_TYPE_INT64 = ( 1 << 2 ),
58 DATA_TYPE_FLOAT32 = ( 1 << 3 ),
59 DATA_TYPE_FLOAT64 = ( 1 << 4 ),
62 DATA_TYPE_UINT32 = ( 1 << 6 )
71 class hash_type :
private std::vector< unsigned char >
74 typedef std::vector< unsigned char > element_type;
76 using element_type::size;
80 bool compare(
const void* Buffer,
81 size_t Length = (
size_t )( -1 ) )
const;
83 const void* ref( )
const;
88 friend struct NDS::detail::conn_p_type;
90 static const unsigned char zero_hash[ 1 ];
91 static const size_t MAX_SIZE;
94 typedef double sample_rate_type;
95 typedef float signal_gain_type;
96 typedef float signal_slope_type;
97 typedef float signal_offset_type;
104 typedef std::vector< std::string > channel_names_type;
109 DLL_EXPORT
static const channel_type DEFAULT_CHANNEL_MASK =
111 CHANNEL_TYPE_ONLINE | CHANNEL_TYPE_RAW | CHANNEL_TYPE_RDS |
112 CHANNEL_TYPE_STREND | CHANNEL_TYPE_MTREND |
113 CHANNEL_TYPE_TEST_POINT | CHANNEL_TYPE_STATIC );
118 DLL_EXPORT
static const data_type DEFAULT_DATA_MASK = ( data_type )(
119 DATA_TYPE_INT16 | DATA_TYPE_INT32 | DATA_TYPE_INT64 |
120 DATA_TYPE_FLOAT32 | DATA_TYPE_FLOAT64 | DATA_TYPE_COMPLEX32 |
123 DLL_EXPORT
static const sample_rate_type
125 DLL_EXPORT
static const sample_rate_type
135 DLL_EXPORT
static channel_type convert_daq_chantype(
int ChanType );
143 DLL_EXPORT
static data_type convert_daq_datatype(
int DataType );
150 DLL_EXPORT
static const std::string&
151 ToString( channel_type ChannelType );
158 DLL_EXPORT
static const std::string& ToString( data_type DataType );
173 channel(
const channel& Source );
189 channel(
const std::string& Name,
192 sample_rate_type SampleRate,
193 signal_gain_type Gain,
194 signal_slope_type Slope,
195 signal_offset_type Offset,
202 DLL_EXPORT
const std::string& Name( )
const;
211 DLL_EXPORT std::string NameLong( )
const;
217 DLL_EXPORT channel_type Type( )
const;
223 DLL_EXPORT data_type DataType( )
const;
232 DLL_EXPORT size_type DataTypeSize( )
const;
238 DLL_EXPORT sample_rate_type SampleRate( )
const;
244 DLL_EXPORT signal_gain_type Gain( )
const;
250 DLL_EXPORT signal_slope_type Slope( )
const;
256 DLL_EXPORT signal_offset_type Offset( )
const;
262 DLL_EXPORT
const std::string& Units( )
const;
271 DLL_EXPORT
void swap( channel& Source );
278 DLL_EXPORT
static bool IsSecondTrend(
const std::string& Name );
285 DLL_EXPORT
static bool IsMinuteTrend(
const std::string& Name );
291 sample_rate_type sample_rate;
292 signal_gain_type gain;
293 signal_slope_type slope;
294 signal_offset_type offset;
298 typedef std::vector< channel > channels_type;
301 channel::hash_type::ref( )
const
303 return ( ( size( ) > 0 ) ? &( this->
operator[]( 0 ) ) : zero_hash );
306 inline const std::string&
307 channel::Name( )
const
312 inline channel::channel_type
313 channel::Type( )
const
318 inline channel::data_type
319 channel::DataType( )
const
324 inline channel::size_type
325 channel::DataTypeSize( )
const
329 case DATA_TYPE_INT16:
332 case DATA_TYPE_INT32:
333 case DATA_TYPE_FLOAT32:
334 case DATA_TYPE_UINT32:
337 case DATA_TYPE_INT64:
338 case DATA_TYPE_FLOAT64:
339 case DATA_TYPE_COMPLEX32:
347 inline channel::sample_rate_type
348 channel::SampleRate( )
const
353 inline channel::signal_gain_type
354 channel::Gain( )
const
359 inline channel::signal_slope_type
360 channel::Slope( )
const
365 inline channel::signal_offset_type
366 channel::Offset( )
const
371 inline const std::string&
372 channel::Units( )
const
378 channel::IsSecondTrend(
const std::string& Name )
380 static const std::string STREND_EXT(
",s-trend" );
382 if ( Name.size( ) <= STREND_EXT.size( ) )
386 return ( STREND_EXT.compare( Name.substr(
387 Name.size( ) - STREND_EXT.size( ) ) ) == 0 );
391 channel::IsMinuteTrend(
const std::string& Name )
393 static const std::string MTREND_EXT(
",m-trend" );
395 if ( Name.size( ) <= MTREND_EXT.size( ) )
399 return ( MTREND_EXT.compare( Name.substr(
400 Name.size( ) - MTREND_EXT.size( ) ) ) == 0 );
403 DLL_EXPORT
extern std::ostream& operator<<( std::ostream& os,
424 template <
typename T >
425 struct channel_data_type_conversion
427 static const NDS::channel::data_type value =
428 NDS::channel::DATA_TYPE_UNKNOWN;
432 struct channel_data_type_conversion< std::int16_t >
434 static const NDS::channel::data_type value =
435 NDS::channel::DATA_TYPE_INT16;
439 struct channel_data_type_conversion< std::int32_t >
441 static const NDS::channel::data_type value =
442 NDS::channel::DATA_TYPE_INT32;
446 struct channel_data_type_conversion< std::int64_t >
448 static const NDS::channel::data_type value =
449 NDS::channel::DATA_TYPE_INT64;
453 struct channel_data_type_conversion< float >
455 static const NDS::channel::data_type value =
456 ( NDS::channel::DATA_TYPE_FLOAT32 );
460 struct channel_data_type_conversion< double >
462 static const NDS::channel::data_type value =
463 NDS::channel::DATA_TYPE_FLOAT64;
467 struct channel_data_type_conversion< std::complex< float > >
469 static const NDS::channel::data_type value =
470 ( NDS::channel::DATA_TYPE_COMPLEX32 );
474 struct channel_data_type_conversion< std::uint32_t >
476 static const NDS::channel::data_type value =
477 NDS::channel::DATA_TYPE_UINT32;
480 DLL_EXPORT
const std::string&
481 channel_type_to_string( channel::channel_type ctype );
483 DLL_EXPORT
const std::string&
484 data_type_to_string( channel::data_type dtype );