-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdamTriggerHandler.cc
More file actions
70 lines (52 loc) · 1.52 KB
/
damTriggerHandler.cc
File metadata and controls
70 lines (52 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "damTriggerHandler.h"
#include <iostream>
#include <iomanip>
#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
using namespace std;
int damTriggerHandler::enable()
{
return 0;
}
int damTriggerHandler::wait_for_trigger( const int moreinfo)
{
struct timeval timeout;
int sel;
timeout.tv_sec = 2;
timeout.tv_usec = 0;
FD_ZERO(&_read_flags);
if ( _dam_fd0 > 0)
{
//cout << __LINE__ << " " << __FILE__ << " setting 1st fd" << endl;
FD_SET(_dam_fd0, &_read_flags);
}
if ( _dam_fd1 > 0)
{
//cout << __LINE__ << " " << __FILE__ << " setting 2nd fd" << endl;
FD_SET(_dam_fd1, &_read_flags);
}
sel = select(_maxfd, &_read_flags, NULL, (fd_set*)0, &timeout);
if (sel < 0)
{
perror("select()");
}
// cout << __LINE__ << " " << __FILE__ << " fds: " << _dam_fd0 << " " << _dam_fd1
// << " " << FD_ISSET(_dam_fd0, &_read_flags) << " " << FD_ISSET(_dam_fd1, &_read_flags) << endl;
if (FD_ISSET(_dam_fd0, &_read_flags) || FD_ISSET(_dam_fd1, &_read_flags) )
{
//cout << __LINE__ << " " << __FILE__ << " trigger after " << _poll_count << " polls" << endl;
//_poll_count = 0;
return _etype;
}
return 0;
}
int damTriggerHandler::set_damfd( const int dam_fd0, const int dam_fd1)
{
_dam_fd0 = dam_fd0;
_dam_fd1 = dam_fd1;
_maxfd = max (_dam_fd0, _dam_fd1)+1;
//cout << __FILE__ << " " << __LINE__ << " fds, ndfs" << _dam_fd0 << " " << _dam_fd1 << " " << _maxfd << endl;
return 0;
}