AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
AcqSys.h
Go to the documentation of this file.
1 
8 #ifndef ACQPROC_ACQSYS_H_
9 #define ACQPROC_ACQSYS_H_
10 
11 #include <vector>
12 #include <string>
13 
14 #include <string.h>
15 
16 using namespace std;
17 
18 int getenv(const char* key, int def, int (*cvt)(const char* key) = atoi);
19 
20 
24 struct VI {
25  int len(void) const;
26  VI& operator+= (const VI& right);
27  VI offsets(void) const;
28  int AI16;
29  int AI32;
30  int DI32;
31  int SP32;
32  VI();
33 };
34 
36 enum SPIX {
37  TLATCH = 0,
38  USECS = 1,
39  POLLCOUNT = 2,
40 };
41 
42 #define PW32LEN 32
43 typedef unsigned PW32V[PW32LEN];
44 
48 struct VO {
49  int len(void) const;
50  int hwlen(void) const;
51  VO& operator+= (const VO& right);
52  VO offsets(void) const;
53  int AO16;
54  int DO32;
55  int PW32;
56  int CC32;
57  VO();
58 };
59 
60 
61 struct SystemInterface;
62 
64 class IO {
65 
66  string name;
67  string* _string;
68 public:
69  const VI vi;
70  const VO vo;
71 
72  IO(string _name, VI _vi, VO _vo);
73  virtual ~IO();
74  virtual string toString();
75  string getName() {
76  return name;
77  }
78 };
79 
80 
82 class ACQ: public IO
83 {
84 protected:
85  ACQ(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets, VO _vo_offsets, VI& sys_vi_cursor, VO& sys_vo_cursor);
86  virtual ~ACQ();
87 
88  bool nowait;
89  unsigned wd_mask;
90  int pollcount;
91  int devnum;
92 public:
93  const VI vi_offsets;
94  const VO vo_offsets;
95  const VI vi_cursor;
96  const VO vo_cursor;
98  virtual string toString();
99 
100  virtual bool newSample(int sample);
101  /*< checks host buffer for new sample, if so copies to lbuf and reports true */
102  virtual void action(SystemInterface& systemInterface) {}
103  /*< early stage action */
104  virtual void action2(SystemInterface& systemInterface) {}
105  /*< second stage action */
106  virtual unsigned tlatch(void);
108  virtual void arm(int nsamples);
110  static ACQ* factory(int devnum, string _name, VI _vi, VO _vo, VI _vi_offsets,
111  VO _vo_offsets, VI& sys_vi_cursor, VO& sys_vo_cursor);
112 
113  friend class HBA;
114 };
115 
117 struct Dev;
118 
119 
120 
122 class HBA: public IO
123 {
124  HBA(vector <ACQ*> _uuts, VI _vi, VO _vo);
125  static HBA* the_hba;
126 public:
127  virtual ~HBA();
128  int devnum;
129  vector<ACQ*> uuts;
130  vector<int> devs;
131  const VI vi;
132  const VO vo;
133  static int maxsam;
135  static HBA& create(const char* json_def, int _maxsam);
136  static HBA& instance() { return *the_hba; }
137 
138  virtual void start_shot();
139  virtual void processSample(SystemInterface& systemInterface, int sample);
142  void dump_config();
144  void dump_data(const char* basename);
147  virtual string toString();
148 };
149 
150 namespace G {
151  extern int nsamples;
152  extern int verbose;
153  extern int dummy_first_loop;
154  extern int samples_buffer;
155  extern int maxpoll;
156 };
157 
162 private:
163  const HBA& hba;
164 
165 public:
169  struct Inputs {
170  short *AI16;
171  int *AI32;
172  unsigned *DI32;
173  unsigned *SP32;
174  } IN;
177  struct Outputs {
178  short* AO16;
179  unsigned *DO32;
181  unsigned *CC32;
182  } OUT;
183 
184  SystemInterface(const HBA& _hba);
185  virtual ~SystemInterface();
186  virtual void trigger()
187  {}
188  virtual void ringDoorbell(int sample)
191  {}
192 
193  static SystemInterface& factory(const HBA&);
194 
195  unsigned tlatch() {
196  return IN.SP32[0];
197  }
198  unsigned AI16_count() const {
199  return hba.vi.AI16;
200  }
201  unsigned AI32_count() const {
202  return hba.vi.AI32;
203  }
204  unsigned DI32_count() const {
205  return hba.vi.DI32;
206  }
207  unsigned SP32_count() const {
208  return hba.vi.SP32;
209  }
210  unsigned AO16_count() const {
211  return hba.vo.AO16;
212  }
213  unsigned DO32_count() const {
214  return hba.vo.DO32;
215  }
216  unsigned PW32_count() const {
217  return hba.vo.PW32;
218  }
219  unsigned CC32_count() const {
220  return hba.vo.CC32;
221  }
222 };
223 
224 template <class T>
225 T* new_zarray(int nelems)
226 {
227  T* nz_array = new T[nelems];
228  memset(nz_array, 0, nelems*sizeof(T));
229  return nz_array;
230 }
231 
232 #define PFN __PRETTY_FUNCTION__
233 
234 
235 #endif /* ACQPROC_ACQSYS_H_ */
HBA
Models a Host Bus Adapter like AFHBA404.
Definition: AcqSys.h:123
SystemInterface::Outputs::CC32
unsigned * CC32
calc values from PCS .
Definition: AcqSys.h:181
ACQ::vi_cursor
const VI vi_cursor
index for each Input type in System Interface
Definition: AcqSys.h:95
VI
Models Vector Input.
Definition: AcqSys.h:24
USECS
@ USECS
microseconds since trigger
Definition: AcqSys.h:38
TLATCH
@ TLATCH
Sample Number.
Definition: AcqSys.h:37
SystemInterface::Outputs::AO16
short * AO16
Definition: AcqSys.h:178
SPIX
SPIX
SPIX: defined fields in SP32 array.
Definition: AcqSys.h:36
ACQ::vo_offsets
const VO vo_offsets
byte offset for each Output type in Local Vector Out
Definition: AcqSys.h:94
SystemInterface::AO16_count
unsigned AO16_count() const
Definition: AcqSys.h:210
ACQ::devnum
int devnum
AFHBA404 device numbers 0..N.
Definition: AcqSys.h:91
SystemInterface::PW32_count
unsigned PW32_count() const
Definition: AcqSys.h:216
SystemInterface::Outputs::DO32
unsigned * DO32
Definition: AcqSys.h:179
HBA::vi
const VI vi
total system size each Input type.
Definition: AcqSys.h:131
SystemInterface::DI32_count
unsigned DI32_count() const
Definition: AcqSys.h:204
HBA::uuts
vector< ACQ * > uuts
vector of ACQ UUT's
Definition: AcqSys.h:129
G::maxpoll
int maxpoll
Definition: acqproc.cpp:39
HBA::instance
static HBA & instance()
Definition: AcqSys.h:136
getenv
int getenv(const char *key, int def, int(*cvt)(const char *key)=atoi)
Definition: acqproc.cpp:23
PW32V
unsigned PW32V[PW32LEN]
Definition: AcqSys.h:43
POLLCOUNT
@ POLLCOUNT
pollcount: number of times SW polled for incoming.
Definition: AcqSys.h:39
VI::AI32
int AI32
AI32 values from the HW.
Definition: AcqSys.h:29
SystemInterface::SP32_count
unsigned SP32_count() const
Definition: AcqSys.h:207
ACQ::action
virtual void action(SystemInterface &systemInterface)
Definition: AcqSys.h:102
ACQ::wd_mask
unsigned wd_mask
watchdog mask.
Definition: AcqSys.h:89
VO::PW32
int PW32
PW32 values from the algorithm.
Definition: AcqSys.h:55
VI::SP32
int SP32
SP32 values from the HW.
Definition: AcqSys.h:31
PW32LEN
#define PW32LEN
Definition: AcqSys.h:42
VO::AO16
int AO16
AO16 values from the algorithm.
Definition: AcqSys.h:53
VO::CC32
int CC32
#CALC values from the algorithm.
Definition: AcqSys.h:56
SystemInterface::ringDoorbell
virtual void ringDoorbell(int sample)
Definition: AcqSys.h:188
Dev
struct Dev : interface to AFHBA404 device driver.
Definition: AcqHw.cpp:35
G::dummy_first_loop
int dummy_first_loop
possible speed up by filling cache first loop
Definition: acqproc.cpp:35
SystemInterface::AI16_count
unsigned AI16_count() const
Definition: AcqSys.h:198
HBA::maxsam
static int maxsam
max samples in shot (for raw memory alloc)
Definition: AcqSys.h:133
SystemInterface::Outputs::PW32
PW32V * PW32
32 demand values packed into shorts
Definition: AcqSys.h:180
IO::vi
const VI vi
Definition: AcqSys.h:69
VO
Models Vector Output.
Definition: AcqSys.h:48
SystemInterface::Outputs
ONE vector each type, scatter each type to appropriate VO all UUTS.
Definition: AcqSys.h:177
ACQ
abstract model of an ACQ2106 box.
Definition: AcqSys.h:83
HBA::devnum
int devnum
Definition: AcqSys.h:128
verbose
int verbose
Definition: InlineDataHandlerMuxAO_LLC.cpp:59
IO
Base Class.
Definition: AcqSys.h:64
SystemInterface::Inputs::AI32
int * AI32
Definition: AcqSys.h:171
VO::DO32
int DO32
DO32 values from the algorithm.
Definition: AcqSys.h:54
ACQ::vi_offsets
const VI vi_offsets
byte offset for each Input type in Local Vector In
Definition: AcqSys.h:93
SystemInterface::CC32_count
unsigned CC32_count() const
Definition: AcqSys.h:219
SystemInterface::trigger
virtual void trigger()
Definition: AcqSys.h:186
SystemInterface::Inputs::AI16
short * AI16
Definition: AcqSys.h:170
VI::AI16
int AI16
AI16 values from the HW.
Definition: AcqSys.h:28
SystemInterface
Models interface with external PCS.
Definition: AcqSys.h:161
SystemInterface::AI32_count
unsigned AI32_count() const
Definition: AcqSys.h:201
HBA::devs
vector< int > devs
AFHBA devnum.
Definition: AcqSys.h:130
HBA::vo
const VO vo
total system size each Output type.
Definition: AcqSys.h:132
SystemInterface::DO32_count
unsigned DO32_count() const
Definition: AcqSys.h:213
IO::getName
string getName()
Definition: AcqSys.h:75
SystemInterface::Inputs::SP32
unsigned * SP32
Definition: AcqSys.h:173
VI::DI32
int DI32
DI32 values from the HW.
Definition: AcqSys.h:30
SystemInterface::tlatch
unsigned tlatch()
Definition: AcqSys.h:195
IO::vo
const VO vo
Definition: AcqSys.h:70
SystemInterface::Inputs
ONE vector each type, all VI from all UUTS are split into types and aggregated in the appropriate vec...
Definition: AcqSys.h:169
SystemInterface::Inputs::DI32
unsigned * DI32
Definition: AcqSys.h:172
G
Definition: acqproc.cpp:33
G::samples_buffer
int samples_buffer
number of samples in each VI buffer (default:1)
Definition: acqproc.cpp:37
new_zarray
T * new_zarray(int nelems)
Definition: AcqSys.h:225
ACQ::action2
virtual void action2(SystemInterface &systemInterface)
Definition: AcqSys.h:104
ACQ::vo_cursor
const VO vo_cursor
index for each Output type in System Interface
Definition: AcqSys.h:96
G::nsamples
int nsamples
samples to capture (default:2, typ 200000)
Definition: acqproc.cpp:38
ACQ::nowait
bool nowait
newSample doesn't block for new Tlatch (eg bolo in set with non bolo uuts).
Definition: AcqSys.h:88
ACQ::pollcount
int pollcount
Definition: AcqSys.h:90