9
9
#include < bsoncxx/builder/stream/document.hpp>
10
10
#include < chrono>
11
11
12
- CControl_Handler::CControl_Handler (MongoLog * log, std::string procname){
13
- fOptions = NULL ;
12
+ CControl_Handler::CControl_Handler (std::shared_ptr< MongoLog>& log, std::string procname){
13
+ fOptions = nullptr ;
14
14
fLog = log ;
15
15
fProcname = procname;
16
16
fCurrentRun = fBID = fBoardHandle -1 ;
17
- fV2718 = NULL ;
18
- fV1495 = NULL ;
19
- fDDC10 = NULL ;
17
+ fV2718 = nullptr ;
18
+ fV1495 = nullptr ;
19
+ fDDC10 = nullptr ;
20
20
fStatus = DAXHelpers::Idle;
21
21
}
22
22
@@ -25,7 +25,7 @@ CControl_Handler::~CControl_Handler(){
25
25
}
26
26
27
27
// Initialising various devices namely; V2718 crate controller, V1495, DDC10...
28
- int CControl_Handler::DeviceArm (int run, Options * opts){
28
+ int CControl_Handler::DeviceArm (int run, std::shared_ptr< Options>& opts){
29
29
30
30
fStatus = DAXHelpers::Arming;
31
31
@@ -52,7 +52,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
52
52
return -1 ;
53
53
}
54
54
BoardType cc_def = bv[0 ];
55
- fV2718 = new V2718 (fLog );
55
+ fV2718 = std::make_unique< V2718> (fLog );
56
56
if (fV2718 ->CrateInit (copts, cc_def.link , cc_def.crate )!=0 ){
57
57
fLog ->Entry (MongoLog::Error, " Failed to initialize V2718 crate controller" );
58
58
fStatus = DAXHelpers::Idle;
@@ -69,7 +69,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
69
69
// Init DDC10 only when included in config - only for TPC
70
70
if (dv.size () == 1 ){
71
71
if (fOptions ->GetHEVOpt (hopts) == 0 ){
72
- fDDC10 = new DDC10 ();
72
+ fDDC10 = std::make_unique< DDC10> ();
73
73
if (fDDC10 ->Initialize (hopts) != 0 ){
74
74
fLog ->Entry (MongoLog::Error, " Failed to initialise DDC10 HEV" );
75
75
fStatus = DAXHelpers::Idle;
@@ -90,7 +90,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
90
90
if (mv.size () == 1 ){
91
91
BoardType mv_def = mv[0 ];
92
92
fBID = mv_def.board ;
93
- fV1495 = new V1495 (fLog , fOptions , mv_def.board , fBoardHandle , mv_def.vme_address );
93
+ fV1495 = std::make_unique< V1495> (fLog , fOptions , mv_def.board , fBoardHandle , mv_def.vme_address );
94
94
// Writing registers to the V1495 board
95
95
for (auto regi : fOptions ->GetRegisters (fBID , true )){
96
96
unsigned int reg = DAXHelpers::StringToHex (regi.reg );
@@ -110,16 +110,13 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
110
110
111
111
} // end devicearm
112
112
113
-
114
-
115
-
116
113
// Send the start signal from crate controller
117
114
int CControl_Handler::DeviceStart (){
118
115
if (fStatus != DAXHelpers::Armed){
119
116
fLog ->Entry (MongoLog::Warning, " V2718 attempt to start without arming. Maybe unclean shutdown" );
120
117
return 0 ;
121
118
}
122
- if (fV2718 == NULL || fV2718 ->SendStartSignal ()!=0 ){
119
+ if (! fV2718 || fV2718 ->SendStartSignal ()!=0 ){
123
120
fLog ->Entry (MongoLog::Error, " V2718 either failed to start" );
124
121
fStatus = DAXHelpers::Error;
125
122
return -1 ;
@@ -135,29 +132,20 @@ int CControl_Handler::DeviceStop(){
135
132
// fLog->Entry(MongoLog::Local, "Beginning stop sequence");
136
133
137
134
// If V2718 here then send stop signal
138
- if (fV2718 != NULL ){
135
+ if (fV2718 ){
139
136
if (fV2718 ->SendStopSignal () != 0 ){
140
137
fLog ->Entry (MongoLog::Warning, " Failed to stop V2718" );
141
138
}
142
- delete fV2718 ;
143
- fV2718 = NULL ;
139
+ fV2718 .reset ();
144
140
}
145
141
// Don't need to stop the DDC10 but just clean up a bit
146
- if (fDDC10 != NULL ){
147
- delete fDDC10 ;
148
- fDDC10 = NULL ;
149
- }
150
-
151
- if (fV1495 != NULL ){
152
- delete fV1495 ;
153
- fV1495 = NULL ;
154
- }
142
+ fDDC10 .reset ();
143
+ fV1495 .reset ();
155
144
156
145
fStatus = DAXHelpers::Idle;
157
146
return 0 ;
158
147
}
159
148
160
-
161
149
// Reporting back on the status of V2718, V1495, DDC10 etc...
162
150
bsoncxx::document::value CControl_Handler::GetStatusDoc (std::string hostname){
163
151
using namespace std ::chrono;
@@ -168,7 +156,7 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
168
156
" time" << bsoncxx::types::b_date (system_clock::now ());
169
157
auto in_array = builder << " active" << bsoncxx::builder::stream::open_array;
170
158
171
- if (fV2718 != NULL ){
159
+ if (fV2718 ){
172
160
auto crate_options = fV2718 ->GetCrateOptions ();
173
161
in_array << bsoncxx::builder::stream::open_document
174
162
<< " run_number" << fCurrentRun
@@ -182,8 +170,9 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
182
170
}
183
171
auto after_array = in_array << bsoncxx::builder::stream::close_array;
184
172
return after_array << bsoncxx::builder::stream::finalize;
173
+ /*
185
174
// DDC10 parameters might change for future updates of the XENONnT HEV
186
- if (fDDC10 != NULL ){
175
+ if(fDDC10){
187
176
auto hev_options = fDDC10->GetHEVOptions();
188
177
in_array << bsoncxx::builder::stream::open_document
189
178
<< "type" << "DDC10"
@@ -207,7 +196,7 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
207
196
<< bsoncxx::builder::stream::close_document;
208
197
}
209
198
// Write the settings for the Muon Veto V1495 board into status doc
210
- if (fV1495 != NULL ){
199
+ if(fV1495){
211
200
auto registers = fOptions->GetRegisters(fBID);
212
201
in_array << bsoncxx::builder::stream::open_document
213
202
<< "type" << "V1495"
@@ -223,5 +212,5 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
223
212
224
213
after_array = in_array << bsoncxx::builder::stream::close_array;
225
214
return after_array << bsoncxx::builder::stream::finalize;
226
-
227
- }
215
+ */
216
+ }
0 commit comments