-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrVLSBMasterController.cc
74 lines (60 loc) · 2.31 KB
/
TrVLSBMasterController.cc
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
#include "TrVLSBMasterController.hh"
TrVLSBMasterController::TrVLSBMasterController() {}
void TrVLSBMasterController::initialise() {
TrVLSBController::initialise();
triggerModes.insert( std::pair<std::string, int> ("internal",0) );
triggerModes.insert( std::pair<std::string, int> ("external",1) );
triggerModes.insert( std::pair<std::string, int> ("internalSuppressed",2) );
triggerModes.insert( std::pair<std::string, int> ("externalSuppressed",3) );
}
void TrVLSBMasterController::setTriggerMode(std::string mode) {
try {
switch(triggerModes[mode]) {
case 0: // internal triggers
modeRegisterValue = triggerSetting["internal"];
modeRegisterValue |= triggerSetting["noZeroSuppression"];
break;
case 1: // external
modeRegisterValue = triggerSetting["external"];
modeRegisterValue |= triggerSetting["noZeroSuppression"];
modeRegisterValue |= triggerSetting["noVeto"];
modeRegisterValue |= triggerSetting["continuousSpill"];
break;
case 2:
modeRegisterValue = triggerSetting["internal"];
break;
case 3:
modeRegisterValue = triggerSetting["external"];
modeRegisterValue |= triggerSetting["noVeto"];
modeRegisterValue |= triggerSetting["continuousSpill"];
break;
default:
break; // How did this happen?
}
}
catch(...) {
std::cout << "Trigger mode exception," << std::endl;
std::cout << "Fixing by defaulting to internal mode setting" << std::endl;
modeRegisterValue = triggerSetting["internal"];
}
}
void TrVLSBMasterController::enableTrigger() {
modeRegisterValue |= triggerSetting["spillEnable"];
CAENVME_WriteCycle(0, addresses["control"], &modeRegisterValue, addressModifier, dataWidth);
}
void TrVLSBMasterController::disableTrigger() {
CAENVME_WriteCycle(0, addresses["control"], &triggerSetting["spillDisable"], addressModifier, dataWidth);
}
void TrVLSBMasterController::setTriggerWindowSettings(int windowOpen, int windowClose) {
//int windowRegisterValue = (windowOpen & 0x1F) + ((windowClose & 0x1F) << 8);
}
void TrVLSBMasterController::setTriggerRate(int period, int triggers) {
//int triggerRateRegisterValue = (period & 0xFFFF) + ((triggers & 0xFFFF) << 16);
}
int TrVLSBMasterController::getSpillDone() {
int done(0);
while (!done) {
CAENVME_ReadCycle(0, addresses[""], &done, addressModifier, dataWidth);
}
return done;
}