Skip to content

Commit a83d432

Browse files
committed
Time to compile
1 parent ca9cb12 commit a83d432

26 files changed

+989
-1308
lines changed

CControl_Handler.cc

+20-31
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
#include <bsoncxx/builder/stream/document.hpp>
1010
#include <chrono>
1111

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;
1414
fLog = log;
1515
fProcname = procname;
1616
fCurrentRun = fBID = fBoardHandle-1;
17-
fV2718 = NULL;
18-
fV1495 = NULL;
19-
fDDC10 = NULL;
17+
fV2718 = nullptr;
18+
fV1495 = nullptr;
19+
fDDC10 = nullptr;
2020
fStatus = DAXHelpers::Idle;
2121
}
2222

@@ -25,7 +25,7 @@ CControl_Handler::~CControl_Handler(){
2525
}
2626

2727
// 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){
2929

3030
fStatus = DAXHelpers::Arming;
3131

@@ -52,7 +52,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
5252
return -1;
5353
}
5454
BoardType cc_def = bv[0];
55-
fV2718 = new V2718(fLog);
55+
fV2718 = std::make_unique<V2718>(fLog);
5656
if (fV2718->CrateInit(copts, cc_def.link, cc_def.crate)!=0){
5757
fLog->Entry(MongoLog::Error, "Failed to initialize V2718 crate controller");
5858
fStatus = DAXHelpers::Idle;
@@ -69,7 +69,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
6969
// Init DDC10 only when included in config - only for TPC
7070
if (dv.size() == 1){
7171
if(fOptions->GetHEVOpt(hopts) == 0){
72-
fDDC10 = new DDC10();
72+
fDDC10 = std::make_unique<DDC10>();
7373
if(fDDC10->Initialize(hopts) != 0){
7474
fLog->Entry(MongoLog::Error, "Failed to initialise DDC10 HEV");
7575
fStatus = DAXHelpers::Idle;
@@ -90,7 +90,7 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
9090
if (mv.size() == 1){
9191
BoardType mv_def = mv[0];
9292
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);
9494
// Writing registers to the V1495 board
9595
for(auto regi : fOptions->GetRegisters(fBID, true)){
9696
unsigned int reg = DAXHelpers::StringToHex(regi.reg);
@@ -110,16 +110,13 @@ int CControl_Handler::DeviceArm(int run, Options *opts){
110110

111111
} // end devicearm
112112

113-
114-
115-
116113
// Send the start signal from crate controller
117114
int CControl_Handler::DeviceStart(){
118115
if(fStatus != DAXHelpers::Armed){
119116
fLog->Entry(MongoLog::Warning, "V2718 attempt to start without arming. Maybe unclean shutdown");
120117
return 0;
121118
}
122-
if(fV2718 == NULL || fV2718->SendStartSignal()!=0){
119+
if(!fV2718 || fV2718->SendStartSignal()!=0){
123120
fLog->Entry(MongoLog::Error, "V2718 either failed to start");
124121
fStatus = DAXHelpers::Error;
125122
return -1;
@@ -135,29 +132,20 @@ int CControl_Handler::DeviceStop(){
135132
//fLog->Entry(MongoLog::Local, "Beginning stop sequence");
136133

137134
// If V2718 here then send stop signal
138-
if(fV2718 != NULL){
135+
if(fV2718){
139136
if(fV2718->SendStopSignal() != 0){
140137
fLog->Entry(MongoLog::Warning, "Failed to stop V2718");
141138
}
142-
delete fV2718;
143-
fV2718 = NULL;
139+
fV2718.reset();
144140
}
145141
// 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();
155144

156145
fStatus = DAXHelpers::Idle;
157146
return 0;
158147
}
159148

160-
161149
// Reporting back on the status of V2718, V1495, DDC10 etc...
162150
bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
163151
using namespace std::chrono;
@@ -168,7 +156,7 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
168156
"time" << bsoncxx::types::b_date(system_clock::now());
169157
auto in_array = builder << "active" << bsoncxx::builder::stream::open_array;
170158

171-
if(fV2718 != NULL){
159+
if(fV2718){
172160
auto crate_options = fV2718->GetCrateOptions();
173161
in_array << bsoncxx::builder::stream::open_document
174162
<< "run_number" << fCurrentRun
@@ -182,8 +170,9 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
182170
}
183171
auto after_array = in_array << bsoncxx::builder::stream::close_array;
184172
return after_array << bsoncxx::builder::stream::finalize;
173+
/*
185174
// DDC10 parameters might change for future updates of the XENONnT HEV
186-
if(fDDC10 != NULL){
175+
if(fDDC10){
187176
auto hev_options = fDDC10->GetHEVOptions();
188177
in_array << bsoncxx::builder::stream::open_document
189178
<< "type" << "DDC10"
@@ -207,7 +196,7 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
207196
<< bsoncxx::builder::stream::close_document;
208197
}
209198
// Write the settings for the Muon Veto V1495 board into status doc
210-
if(fV1495 != NULL){
199+
if(fV1495){
211200
auto registers = fOptions->GetRegisters(fBID);
212201
in_array << bsoncxx::builder::stream::open_document
213202
<< "type" << "V1495"
@@ -223,5 +212,5 @@ bsoncxx::document::value CControl_Handler::GetStatusDoc(std::string hostname){
223212
224213
after_array = in_array << bsoncxx::builder::stream::close_array;
225214
return after_array << bsoncxx::builder::stream::finalize;
226-
227-
}
215+
*/
216+
}

CControl_Handler.hh

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ class V1495;
1313
class CControl_Handler{
1414

1515
public:
16-
CControl_Handler(MongoLog *log, std::string procname);
16+
CControl_Handler(std::shared_ptr<MongoLog>& log, std::string procname);
1717
~CControl_Handler();
1818

1919
bsoncxx::document::value GetStatusDoc(std::string hostname);
20-
int DeviceArm(int run, Options *opts);
20+
int DeviceArm(int run, std::shared_ptr<Options>& opts);
2121
int DeviceStart();
2222
int DeviceStop();
2323

2424
private:
2525

26-
V2718 *fV2718;
27-
DDC10 *fDDC10;
28-
V1495 *fV1495;
26+
std::unique_ptr<V2718> fV2718;
27+
std::unique_ptr<DDC10> fDDC10;
28+
std::unique_ptr<V1495> fV1495;
2929

3030
int fStatus;
3131
int fCurrentRun;
3232
int fBID;
3333
int fBoardHandle;
3434
std::string fProcname;
35-
Options *fOptions;
36-
MongoLog *fLog;
35+
std::shared_ptr<Options> fOptions;
36+
std::shared_ptr<MongoLog> fLog;
3737
};
3838

3939
#endif

0 commit comments

Comments
 (0)