CFEL - ASG Software Suite  2.5.0
CASS
channel.hpp
Go to the documentation of this file.
1 //Copyright (C) 2009,2010, 2015 Lutz Foucar
2 
3 /**
4  * @file channel.hpp file contains the classes that describe an acqiris channel
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _CHANNEL_HPP_
10 #define _CHANNEL_HPP_
11 
12 
13 #include <stdint.h>
14 #include <iostream>
15 #include <vector>
16 
17 #include "serializer.hpp"
18 #include "serializable.hpp"
19 
20 namespace cass
21 {
22 namespace ACQIRIS
23 {
24 /** A Channel of an Acqiris Instrument.
25  *
26  * contains all information that an Acqiris instrument will provide about
27  * a channel
28  *
29  * @author Lutz Foucar
30  */
31 class Channel : public Serializable
32 {
33 public:
34  /** define the waveform */
35  typedef std::vector<int16_t> waveform_t;
36 
37  /** constructor that will set the serialize version*/
39  : Serializable(1),
40  _chNbr(0),
41  _horpos(0),
42  _offset(0),
43  _gain(0),
45  {}
46 
47  /** construct this from the stream
48  *
49  * @param in the input stream to read this class from
50  */
52  : Serializable(1)
53  {
54  deserialize(in);
55  }
56 
57 public:
58  /** will serialize this channel to the serializer
59  *
60  * @param out the stream to serialze this class to
61  */
62  void serialize(SerializerBackend &out)const
63  {
64  writeVersion(out);
65  /** output all variables obtained from the acqiris */
66  out.add(_horpos);
67  out.add(_offset);
68  out.add(_gain);
69  out.add(_sampleInterval);
70  /** write the length of the waveform */
71  out.add(static_cast<size_t>(_waveform.size()));
72  /** the waveform itselve */
73  for (waveform_t::const_iterator it=_waveform.begin();it!=_waveform.end();++it)
74  out.add(*it);
75  }
76 
77  /** deserialize this channel from the serializer
78  *
79  * @param in the stream to serialze this class from
80  */
82  {
83  checkVersion(in);
84  /** read all variables and then the waveform from the input stream */
85  _horpos = in.retrieve<double>();
86  _offset = in.retrieve<double>();
87  _gain = in.retrieve<double>();
88  _sampleInterval = in.retrieve<double>();
89  /** read the length of the waveform */
90  size_t nSamples(in.retrieve<size_t>());
91  /** clear the wavefrom */
92  _waveform.clear();
93  for (size_t i(0);i<nSamples;++i)
94  _waveform.push_back(in.retrieve<waveform_t::value_type>());
95  return true;
96  }
97 
98 public:
99  //@{
100  /** setter */
101  double &horpos() {return _horpos;}
102  double &offset() {return _offset;}
103  double &sampleInterval() {return _sampleInterval;}
104  double &gain() {return _gain;}
105  waveform_t &waveform() {return _waveform;}
106  size_t &channelNbr() {return _chNbr;}
107  //@}
108  //@{
109  /** getter */
110  double horpos()const {return _horpos;}
111  double offset()const {return _offset;}
112  double gain()const {return _gain;}
113  double sampleInterval()const {return _sampleInterval;}
114  const waveform_t &waveform()const {return _waveform;}
115  size_t channelNbr()const {return _chNbr;}
116  //@}
117 
118  /** getter
119  *
120  * will calculate the fullscale from the gain value, provided by the
121  * instrument
122  */
123  double fullscale()const {return _gain*0xffff;}
124 
125 private:
126  /** This Channels Number in the Acqiris Instrument*/
127  size_t _chNbr;
128 
129  /** Horizontal position of first data point with respect to the trigger*/
130  double _horpos;
131 
132  /** the vertical offset of this channel (in V)*/
133  double _offset;
134 
135  /** Vertical gain in Volts/LSB. (V = vGain * data - vOffset)*/
136  double _gain;
137 
138  /** the time between two consecutive datapoints in seconds*/
140 
141  /** the waveform of this channel*/
142  waveform_t _waveform;
143 };
144 
145 }//end namespace ACQIRIS
146 }//end namespace cass
147 
148 #endif
std::vector< int16_t > waveform_t
define the waveform
Definition: channel.hpp:35
Channel(SerializerBackend &in)
construct this from the stream
Definition: channel.hpp:51
double horpos() const
getter
Definition: channel.hpp:110
waveform_t & waveform()
setter
Definition: channel.hpp:105
Channel()
constructor that will set the serialize version
Definition: channel.hpp:38
virtual void writeVersion(SerializerBackend &out) const
write the version to the stream
double & sampleInterval()
setter
Definition: channel.hpp:103
void serialize(SerializerBackend &out) const
will serialize this channel to the serializer
Definition: channel.hpp:62
file contains classes for serializing objects
double _offset
the vertical offset of this channel (in V)
Definition: channel.hpp:133
double fullscale() const
getter
Definition: channel.hpp:123
size_t _chNbr
This Channels Number in the Acqiris Instrument.
Definition: channel.hpp:127
double _horpos
Horizontal position of first data point with respect to the trigger.
Definition: channel.hpp:130
double _sampleInterval
the time between two consecutive datapoints in seconds
Definition: channel.hpp:139
file contains base class all serializable classes
double & horpos()
setter
Definition: channel.hpp:101
virtual void checkVersion(SerializerBackend &in) const
check the version
double & offset()
setter
Definition: channel.hpp:102
A Channel of an Acqiris Instrument.
Definition: channel.hpp:31
double sampleInterval() const
getter
Definition: channel.hpp:113
double offset() const
getter
Definition: channel.hpp:111
bool deserialize(SerializerBackend &in)
deserialize this channel from the serializer
Definition: channel.hpp:81
size_t channelNbr() const
getter
Definition: channel.hpp:115
double & gain()
setter
Definition: channel.hpp:104
Type retrieve()
read arbitrary value from stream
Definition: serializer.hpp:169
waveform_t _waveform
the waveform of this channel
Definition: channel.hpp:142
size_t & channelNbr()
setter
Definition: channel.hpp:106
const waveform_t & waveform() const
getter
Definition: channel.hpp:114
Serializable.
void add(const Type &value)
add arbitrary value to the stream
Definition: serializer.hpp:158
double _gain
Vertical gain in Volts/LSB.
Definition: channel.hpp:136
double gain() const
getter
Definition: channel.hpp:112