-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathES.cpp
More file actions
81 lines (73 loc) · 1.52 KB
/
ES.cpp
File metadata and controls
81 lines (73 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
71
72
73
74
75
76
77
78
79
80
/*
* ES.cpp
*
* Created on: 13 Jan 2021
* Author: pgm
*/
#include <string.h>
#include "knobs.h"
#include "ES.h"
bool ISACQ480() {
char mval[80];
if (getKnob(0, "/etc/acq400/1/MODEL", mval) >= 0){
return strstr(mval, "ACQ480") != NULL ||
strstr(mval, "ACQ482") != NULL;
}
return false;
}
template <unsigned MASK, unsigned PAT, unsigned MATCHES>
class ES : public AbstractES {
bool is_es_word(unsigned word) {
return (word&MASK) == PAT;
}
public:
bool isES(unsigned *cursor){
bool is_es = false;
unsigned matches = MATCHES;
for (int ic = 0; matches != 0; ++ic, matches >>= 1){
if ((matches&0x1) != 0){
if (is_es_word(cursor[ic])){
is_es = true;
}else{
return false;
}
}
}
return is_es;
}
};
#define EV0_MASK 0xffffffff
#define EV1_MASK 0xffffffff
AbstractES* AbstractES::evX_instance() {
static AbstractES* _instance;
if (!_instance){
if (ISACQ480()){
_instance = new ES<EVX_MASK, EVX_MAGIC, 0x0a>;
}else{
_instance = new ES<EVX_MASK, EVX_MAGIC, 0x0f>;
}
}
return _instance;
}
AbstractES* AbstractES::ev0_instance() {
static AbstractES* _instance;
if (!_instance){
if (ISACQ480()){
_instance = new ES<EV0_MASK, EV0_MAGIC, 0x0a>;
}else{
_instance = new ES<EV0_MASK, EV0_MAGIC, 0x0f>;
}
}
return _instance;
}
AbstractES* AbstractES::ev1_instance() {
static AbstractES* _instance;
if (!_instance){
if (ISACQ480()){
_instance = new ES<EV1_MASK, EV1_MAGIC, 0x0a>;
}else{
_instance = new ES<EV1_MASK, EV1_MAGIC, 0x0f>;
}
}
return _instance;
}