AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
acqproc.cpp
Go to the documentation of this file.
1 
10 extern "C" {
11 #include "afhba-llcontrol.h"
12 extern int sched_fifo_priority;
13 }
14 
15 #include <iostream>
16 #include <iomanip>
17 #include <fstream>
18 #include <sstream>
19 
20 #include "AcqSys.h"
21 
22 
23 int getenv(const char* key, int def, int (*cvt)(const char* key))
24 {
25  const char* value = getenv(key);
26  if (value){
27  return cvt(value);
28  }else{
29  return def;
30  }
31 }
32 
33 namespace G {
34  int verbose = ::getenv("VERBOSE", 0);
35  int dummy_first_loop= ::getenv("DUMMY_FIRST_LOOP", 0);
36  int MAXLOG = ::getenv("MAXLOG", 1000000);
37  int samples_buffer = 1;
38  int nsamples = 2;
39  int maxpoll = 0;
40 };
41 
42 
43 
44 const char* ui(int argc, char* argv[])
45 {
46  const char* config_file;
47  const char* key;
48 
49  if ((key = getenv("RTPRIO"))){
50  sched_fifo_priority = atoi(key);
51  }
52  if ((key = getenv("AFFINITY")) && strtol(key, 0, 0) != 0){
53  setAffinity(strtol(key, 0, 0));
54  }
55  if ((key = getenv("MAXPOLL")) && strtol(key, 0, 0) != 0){
56  G::maxpoll = strtol(key, 0, 0);
57  }
58 
59  if (argc > 1){
60  config_file = argv[1];
61  }else{
62  fprintf(stderr, "USAGE acqproc_th CONFIG_FILE NSAMPLES [SAMPLES_BUFFER]\n");
63  exit(1);
64  }
65  if (argc > 2){
66  G::nsamples = atoi(argv[2]);
67  fprintf(stderr, "nsamples set %d\n", G::nsamples);
68  }
69  if (argc > 3){
70  G::samples_buffer = atoi(argv[3]);
71  }
72  return config_file;
73 }
74 
75 int main(int argc, char* argv[])
76 {
77  const char* config_file = ui(argc, argv);
78 
79  HBA hba = HBA::create(config_file, G::nsamples==0? 100: G::nsamples>G::MAXLOG? G::MAXLOG: G::nsamples);
80 
81 
82  hba.dump_config();
83 
84 
86 
87  hba.start_shot();
88 
89  si.trigger();
90 
91  try {
92  for (int sample = 0; G::nsamples == 0 || sample < G::nsamples; ++sample){
93  hba.processSample(si, sample);
94  }
95  } catch (int error) {
96  fprintf(stderr, "ERROR:%d\n", error);
97  }
98 }
99 
100 
101 
HBA
Models a Host Bus Adapter like AFHBA404.
Definition: AcqSys.h:123
G::MAXLOG
int MAXLOG
avoid oom
Definition: acqproc.cpp:36
afhba-llcontrol.h
main
int main(int argc, char *argv[])
Definition: acqproc.cpp:75
AcqSys.h
acqproc global class interface definition.
HBA::create
static HBA & create(const char *json_def, int _maxsam)
HBA::Create() factory function.
Definition: AcqSys.cpp:329
G::maxpoll
int maxpoll
Definition: acqproc.cpp:39
ui
const char * ui(int argc, char *argv[])
Definition: acqproc.cpp:44
HBA::start_shot
virtual void start_shot()
Definition: AcqHw.cpp:64
G::dummy_first_loop
int dummy_first_loop
possible speed up by filling cache first loop
Definition: acqproc.cpp:35
HBA::processSample
virtual void processSample(SystemInterface &systemInterface, int sample)
core run time function, processSample.
Definition: AcqSys.cpp:184
sched_fifo_priority
int sched_fifo_priority
Definition: afhba-llcontrol.c:136
SystemInterface::trigger
virtual void trigger()
Definition: AcqSys.h:186
setAffinity
void setAffinity(unsigned cpu_mask)
Definition: afhba-llcontrol.c:113
SystemInterface
Models interface with external PCS.
Definition: AcqSys.h:161
G::verbose
int verbose
Definition: acqproc.cpp:34
HBA::dump_config
void dump_config()
output complete configuration with calculated offsets
Definition: AcqSys.cpp:100
G
Definition: acqproc.cpp:33
G::samples_buffer
int samples_buffer
number of samples in each VI buffer (default:1)
Definition: acqproc.cpp:37
SystemInterface::factory
static SystemInterface & factory(const HBA &)
Definition: BroadcastSystemInterface.cpp:71
getenv
int getenv(const char *key, int def, int(*cvt)(const char *key))
Definition: acqproc.cpp:23
G::nsamples
int nsamples
samples to capture (default:2, typ 200000)
Definition: acqproc.cpp:38