AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
ACQPROC
BroadcastSystemInterface.cpp
Go to the documentation of this file.
1
8
#include "
AcqSys.h
"
9
#include <assert.h>
10
#include <string.h>
11
12
13
14
class
BroadcastSystemInterface
:
public
SystemInterface
{
15
const
int
ntriggers;
/* opt: repeat trigger to instrument trigger overhead */
16
int
over;
17
const
char
* trgfile;
18
int
th_chan[2];
/* channel index to threshold */
19
int
thix;
/* threshold channel index 0|1 */
20
FILE* fp_log;
21
22
public
:
23
BroadcastSystemInterface
(
const
HBA
& hba) :
24
SystemInterface
(hba), over(0), ntriggers(::
getenv
(
"NTRIGGERS"
, 1)), thix(0), fp_log(0)
25
{
26
char
* _trgfile =
new
char
[80];
27
snprintf(_trgfile, 80,
"/dev/rtm-t.0.ctrl/com_trg"
);
28
trgfile = _trgfile;
29
th_chan[0] =
::getenv
(
"THCHAN0"
, 0);
30
th_chan[1] =
::getenv
(
"THCHAN1"
, 0);
31
if
(
getenv
(
"SILOG"
)){
32
fp_log = fopen(
getenv
(
"SILOG"
),
"w"
);
33
}
34
}
35
virtual
~BroadcastSystemInterface
() {
36
delete
[] trgfile;
37
if
(fp_log){
38
fclose(fp_log);
39
}
40
}
41
42
virtual
void
trigger
() {
43
FILE* fp = fopen(trgfile,
"w"
);
44
assert
(fp);
45
fprintf(fp,
"1\n"
);
46
fclose(fp);
47
}
48
49
virtual
void
ringDoorbell
(
int
sample){
50
int
ai =
IN
.
AI32
[th_chan[thix]];
51
52
if
(over && ai < -2000){
53
over =
false
;
54
}
else
if
(!over && ai > 2000) {
55
for
(
int
it = 0; it < ntriggers; ++it){
56
trigger
();
57
}
58
over =
true
;
59
G::verbose
&& printf(
"%s over\n"
,
PFN
);
60
}
61
62
G::verbose
> 1 && printf(
"%s[%d] %08x\n"
,
PFN
, sample,
IN
.
AI32
[0]);
63
thix = !thix;
64
65
if
(fp_log){
66
fwrite(
IN
.
AI32
,
sizeof
(
int
),
AI32_count
(), fp_log);
67
}
68
}
69
};
70
71
SystemInterface
&
SystemInterface::factory
(
const
HBA
& hba)
72
{
73
if
(
getenv
(
"HW"
) && atoi(
getenv
(
"HW"
)) > 0){
74
return
*
new
BroadcastSystemInterface
(hba);
75
}
else
{
76
return
*
new
SystemInterface
(hba);
77
}
78
}
79
HBA
Models a Host Bus Adapter like AFHBA404.
Definition:
AcqSys.h:123
BroadcastSystemInterface::~BroadcastSystemInterface
virtual ~BroadcastSystemInterface()
Definition:
BroadcastSystemInterface.cpp:35
BroadcastSystemInterface::trigger
virtual void trigger()
Definition:
BroadcastSystemInterface.cpp:42
AcqSys.h
acqproc global class interface definition.
PFN
#define PFN
Definition:
AcqSys.h:232
SystemInterface::SystemInterface
SystemInterface(const HBA &_hba)
Definition:
AcqSys.cpp:401
SystemInterface::IN
struct SystemInterface::Inputs IN
SystemInterface::Inputs::AI32
int * AI32
Definition:
AcqSys.h:171
BroadcastSystemInterface
Definition:
BroadcastSystemInterface.cpp:14
SystemInterface
Models interface with external PCS.
Definition:
AcqSys.h:161
BroadcastSystemInterface::ringDoorbell
virtual void ringDoorbell(int sample)
Definition:
BroadcastSystemInterface.cpp:49
G::verbose
int verbose
Definition:
acqproc.cpp:34
SystemInterface::AI32_count
unsigned AI32_count() const
Definition:
AcqSys.h:201
assert
#define assert(p)
Definition:
acq-fiber-hba.h:55
SystemInterface::factory
static SystemInterface & factory(const HBA &)
Definition:
BroadcastSystemInterface.cpp:71
BroadcastSystemInterface::BroadcastSystemInterface
BroadcastSystemInterface(const HBA &hba)
Definition:
BroadcastSystemInterface.cpp:23
getenv
int getenv(const char *key, int def, int(*cvt)(const char *key))
Definition:
acqproc.cpp:23
Generated by
1.8.18