MIDAS
Loading...
Searching...
No Matches
v1740CONET2 Class Reference

#include <v1740CONET2.hxx>

Collaboration diagram for v1740CONET2:

Classes

struct  V1740_CONFIG_SETTINGS
 Settings structure for this v1740 module. More...
 

Public Member Functions

 v1740CONET2 (int link, int board, int moduleID)
 Constructor for the module object.
 
 ~v1740CONET2 ()
 Destructor for the module object.
 
CAENComm_ErrorCode Connect ()
 Connect the board through the optical link.
 
CAENComm_ErrorCode Disconnect ()
 Disconnect the board through the optical link.
 
CAENComm_ErrorCode StartRun ()
 Start data acquisition.
 
CAENComm_ErrorCode StopRun ()
 Start data acquisition.
 
CAENComm_ErrorCode SetupPreset (int)
 Setup board registers using preset (see ov1720.c:ov1720_Setup())
 
CAENComm_ErrorCode AcqCtl (uint32_t)
 Control data acquisition.
 
CAENComm_ErrorCode ReadReg (DWORD, DWORD *)
 Read 32-bit register.
 
CAENComm_ErrorCode WriteReg (DWORD, DWORD)
 Write to 32-bit register.
 
CAENComm_ErrorCode ReadEvent (DWORD *, int *)
 Read event buffer.
 
CAENComm_ErrorCode SendTrigger ()
 Send a software trigger to the board.
 
int SetODBRecord (HNDLE h, void(*cb_func)(INT, INT, void *))
 Set the ODB record for this module.
 
int InitializeForAcq ()
 Initialize the hardware for data acquisition.
 
bool IsConnected ()
 Get connected status.
 
bool IsRunning ()
 Get run status.
 
std::string GetName ()
 Get short string identifying the module's board number.
 
void CheckBoardType ()
 Check board type.
 
void ShowRegs ()
 Misc reg printout, for debug purposes.
 
HNDLE GetODBHandle ()
 returns ODB handle
 
bool GetSettingsTouched ()
 
void SetSettingsTouched (bool t)
 
int GetHandle ()
 returns device handler
 
int GetModuleID ()
 returns unique module ID
 
int GetLink ()
 returns optical link number
 
int GetBoard ()
 returns board number
 

Public Attributes

int verbose
 
struct v1740CONET2::V1740_CONFIG_SETTINGS config
 instance of config structure
 

Static Public Attributes

static const charconfig_str []
 Configuration string for this module. (ODB: /Equipment/[eq_name]/Settings/[board_name]/)
 

Private Attributes

int _handle
 Device handler.
 
int _link
 Optical link number.
 
int _board
 Module/Board number.
 
int _moduleID
 Unique module ID.
 
HNDLE _odb_handle
 
bool _settings_loaded
 ODB settings loaded.
 
bool _settings_touched
 ODB settings touched.
 
bool _running
 Run in progress.
 

Detailed Description

Driver class for the v1740 module using the CAEN CONET2 (optical) interface. Contains all the methods necessary to:

  • Connect/disconnect the board through an optical connection
  • Initialize the hardware (set the registers) for data acquisition
  • Read and write to the ODB
  • Poll the hardware and read the event buffer into a midas bank
  • Send a software trigger to the board if desired

Definition at line 34 of file v1740CONET2.hxx.

Constructor & Destructor Documentation

◆ v1740CONET2()

v1740CONET2::v1740CONET2 ( int  link,
int  board,
int  moduleID 
)

Constructor for the module object.

Set the basic hardware parameters

Parameters
[in]linkOptical link number
[in]boardBoard number on the optical link
[in]moduleIDUnique ID assigned to module

Definition at line 58 of file v1740CONET2.cxx.

58 :
60{
61 _handle = -1;
62 _odb_handle = 0;
63 verbose = 0;
64 _settings_loaded=false;
66 _running = false;
67}
bool _settings_touched
ODB settings touched.
int _handle
Device handler.
int _moduleID
Unique module ID.
HNDLE _odb_handle
int _link
Optical link number.
bool _settings_loaded
ODB settings loaded.
int _board
Module/Board number.
bool _running
Run in progress.
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24

◆ ~v1740CONET2()

v1740CONET2::~v1740CONET2 ( )

Destructor for the module object.

Nothing to do.

Definition at line 73 of file v1740CONET2.cxx.

73{}

Member Function Documentation

◆ AcqCtl()

CAENComm_ErrorCode v1740CONET2::AcqCtl ( uint32_t  operation)

Control data acquisition.

Write to Acquisition Control reg

Parameters
[in]operationacquisition mode (see v1720.h)
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 217 of file v1740CONET2.cxx.

218{
219#if SIMULATION
220 return CAENComm_Success;
221#else
223#endif
224}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckBoardType()

void v1740CONET2::CheckBoardType ( )

Check board type.

Check if board type is v1740, if not issue a warning

Definition at line 453 of file v1740CONET2.cxx.

454{
455 // Verify Board Type
456 uint32_t version = 0;
457 const uint32_t v1740_board_type = 0x04;
459 if((version & 0xFF) != v1740_board_type)
460 cm_msg(MINFO,"feoV1740","*** WARNING *** Trying to use a v1740 frontend with another"
461 " type of board. Results will be unexpected!");
462
463 UNUSED(sCAEN);
464}
CAENComm_ErrorCode ReadReg(DWORD, DWORD *)
Read 32-bit register.
#define MINFO
Definition midas.h:560
#define UNUSED
Definition mongoose6.h:113
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
Here is the call graph for this function:

◆ Connect()

CAENComm_ErrorCode v1740CONET2::Connect ( )

Connect the board through the optical link.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 109 of file v1740CONET2.cxx.

110{
111 if (verbose) cout << "Opening device (l,b) = (" << _link << "," << _board << ")" << endl;
113
114#if SIMULATION //Simulate success opening device
116 _handle = 1; //random
117#else
119#endif
120
121 if (sCAEN != CAENComm_Success) _handle = -1;
122 return sCAEN;
123}
Here is the call graph for this function:

◆ Disconnect()

CAENComm_ErrorCode v1740CONET2::Disconnect ( )

Disconnect the board through the optical link.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 129 of file v1740CONET2.cxx.

130{
131 if (verbose) cout << "Closing device (l,b) = (" << _link << "," << _board << ")" << endl;
133
134#if SIMULATION //Simulate success closing device
136#else
138#endif
139
140
141 _handle = -1;
142 return sCAEN;
143}
Here is the call graph for this function:

◆ GetBoard()

int v1740CONET2::GetBoard ( )
inline

returns board number

Definition at line 100 of file v1740CONET2.hxx.

◆ GetHandle()

int v1740CONET2::GetHandle ( )
inline

returns device handler

Definition at line 97 of file v1740CONET2.hxx.

Here is the caller graph for this function:

◆ GetLink()

int v1740CONET2::GetLink ( )
inline

returns optical link number

Definition at line 99 of file v1740CONET2.hxx.

◆ GetModuleID()

int v1740CONET2::GetModuleID ( )
inline

returns unique module ID

Definition at line 98 of file v1740CONET2.hxx.

◆ GetName()

string v1740CONET2::GetName ( )

Get short string identifying the module's board number.

Returns
name string

Definition at line 80 of file v1740CONET2.cxx.

81{
82 stringstream txt;
83 txt << "B" << _board;
84 return txt.str();
85}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetODBHandle()

HNDLE v1740CONET2::GetODBHandle ( )
inline

returns ODB handle

Definition at line 90 of file v1740CONET2.hxx.

◆ GetSettingsTouched()

bool v1740CONET2::GetSettingsTouched ( )
inline

returns true if odb settings touched

Definition at line 91 of file v1740CONET2.hxx.

91 {
92 return _settings_touched;
93 }

◆ InitializeForAcq()

int v1740CONET2::InitializeForAcq ( )

Initialize the hardware for data acquisition.

Set the registers using a preset if setup != 0 in the config string, or set them manually otherwise.

Returns
0 on success, -1 on error

Definition at line 382 of file v1740CONET2.cxx.

383{
384 if (!_settings_loaded) {
385 cout << "Error: cannot call InitializeForAcq() without settings loaded properly" << endl;
386 return -1; }
387 if (!IsConnected()) {
388 cout << "Error: trying to call InitializeForAcq() to unconnected board" << endl;
389 return -1; }
390 if (IsRunning()) {
391 cout << "Error: trying to call InitializeForAcq() to already running board" << endl;
392 return -1; }
393
394 if (_settings_loaded && !_settings_touched) return 0; //don't do anything if settings haven't been changed
395
398
399 //use preset setting if enabled
400 if (config.setup != 0) {
402 //else use odb values
403 } else {
404
406 printf("group config 0x%x\n", config.group_config);
417 WriteReg(V1740_MONITOR_MODE, 0x3); // buffer occupancy
418 printf("group config 0x%x\n", temp);
419 /*sCAEN = ov1740_GroupConfig(GetHandle()
420 , config.trigger_positive_pulse == 1 ? V1740_TRIGGER_OVERTH : V1740_TRIGGER_UNDERTH);*/
422
423 // Set individual channel stuff
424 for (int i=0;i<8;i++) {
425 //group threshold
428 printf("Threshold[%i] = %d \n", i, temp);
429 //set DAC
431 printf("DAC[%i] = %d \n", i, temp);
432 //disable channel triggers
434 }
435
436 // Doesn't set the ID in the data stream!
439 }
440
441 _settings_touched = false;
442 UNUSED(sCAEN);
443
444 //ready to do startrun
445
446 return 0;
447}
bool IsRunning()
Get run status.
int GetHandle()
returns device handler
struct v1740CONET2::V1740_CONFIG_SETTINGS config
instance of config structure
bool IsConnected()
Get connected status.
CAENComm_ErrorCode SetupPreset(int)
Setup board registers using preset (see ov1720.c:ov1720_Setup())
CAENComm_ErrorCode WriteReg(DWORD, DWORD)
Write to 32-bit register.
CAENComm_ErrorCode AcqCtl(uint32_t)
Control data acquisition.
INT i
Definition mdump.cxx:32
INT setup
Initial board setup mode number.
DWORD post_trigger
0x8114@[31.. 0]
DWORD group_config
0x8000@[19.. 0]
DWORD trigger_output
0x8110@[31.. 0]
INT buffer_organization
0x800C@[ 3.. 0]
DWORD dac[8]
0x1n98@[15.. 0]
DWORD trigger_source
0x810C@[31.. 0]
DWORD threshold[8]
0x1n80@[11.. 0]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsConnected()

bool v1740CONET2::IsConnected ( )

Get connected status.

Returns
true if board is connected

Definition at line 91 of file v1740CONET2.cxx.

92{
93 return (_handle >= 0);
94}
Here is the caller graph for this function:

◆ IsRunning()

bool v1740CONET2::IsRunning ( )

Get run status.

Returns
true if run is started

Definition at line 100 of file v1740CONET2.cxx.

101{
102 return _running;
103}
Here is the caller graph for this function:

◆ ReadEvent()

CAENComm_ErrorCode v1740CONET2::ReadEvent ( DWORD data,
int dwords_read 
)

Read event buffer.

Read the event buffer for this module using BLT (32-bit) cycles. This function reads nothing if EVENT_SIZE register was zero.

Parameters
[out]dataWhere to write content of event buffer
[out]dwords_readNumber of DWORDs read from the buffer
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 270 of file v1740CONET2.cxx.

271{
273 int tempnw = 0;
274 *dwords_read = 0;
275
276#if SIMULATION //read maximum size allowed
279#else
281#endif
282
283 if (verbose>=2) cout << "Start of ReadEvent... "
284 << "size_rem = " << size_remaining << " " << sCAEN << endl;
285
286 while (size_remaining > 0 && sCAEN == CAENComm_Success)
287 {
288#if SIMULATION //read random 32-bit integers
290 for (WORD i = 0; i < to_read; i++)
291 *data_pos++ = rand();
293 tempnw = to_read; //simulate success reading all data
294#else
297#endif
298
299 if (verbose>=2) cout << sCAEN << " = BLTRead(handle=" << _handle
300 << ", addr=" << V1740_EVENT_READOUT_BUFFER
301 << ", data_pos=" << data_pos
302 << ", to_read=" << to_read
303 << ", tempnw returned " << tempnw << ");" << endl;
306 data_pos += tempnw;
307 }
308 if (verbose>=2) cout << "End of ReadEvent... "
309 << "dwords_read = " << *dwords_read << endl;;
310
311 return sCAEN;
312}
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
void * data
Definition mana.cxx:268
#define MAX_BLT_READ_SIZE
Maximum size of data to read using BLT (32-bit) cycle.
Here is the call graph for this function:

◆ ReadReg()

CAENComm_ErrorCode v1740CONET2::ReadReg ( DWORD  address,
DWORD val 
)

Read 32-bit register.

Parameters
[in]addressaddress of the register to read
[out]valvalue read from register
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 232 of file v1740CONET2.cxx.

233{
234 if (verbose >= 2) cout << GetName() << "::ReadReg(" << hex << address << ")" << endl;
235#if SIMULATION
236 return CAENComm_Success;
237#else
238 return CAENComm_Read32(_handle, address, val);
239#endif
240}
std::string GetName()
Get short string identifying the module's board number.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendTrigger()

CAENComm_ErrorCode v1740CONET2::SendTrigger ( )

Send a software trigger to the board.

Send a software trigger to the board. May require software triggers to be enabled in register.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 321 of file v1740CONET2.cxx.

322{
323 if (verbose) cout << "Sending Trigger (l,b) = (" << _link << "," << _board << ")" << endl;
324 return WriteReg(V1740_SOFTWARE_TRIGGER, 0x1);
325}
Here is the call graph for this function:

◆ SetODBRecord()

int v1740CONET2::SetODBRecord ( HNDLE  h,
void(*)(INT, INT, void *)  cb_func 
)

Set the ODB record for this module.

Create a record for the board with settings from the configuration string (v1740CONET2::config_str) if it doesn't exist or merge with existing record. Create hotlink with callback function for when the record is updated. Get the handle to the record.

Ex: For a frontend with index number 2 and board number 0, this record will be created/merged:

/Equipment/FEv1740I2/Settings/Board0

Parameters
[in]hmain ODB handle
[in]cb_funcCallback function to call when record is updated
Returns
ODB Error Code (see midas.h)

Definition at line 343 of file v1740CONET2.cxx.

344{
345 char set_str[80];
346 int status,size;
347
348#if SIMULATION
349 sprintf(set_str, "/Equipment/FEv1740_SIM/Settings/Board%d", _board);
350#else
351 sprintf(set_str, "/Equipment/FEv1740/Settings/Board%d", _board);
352#endif
353
354 if (verbose) cout << GetName() << "::SetODBRecord(" << h << "," << set_str << ",...)" << endl;
355
356 //create record if doesn't exist and find key
359 if (status != DB_SUCCESS) cm_msg(MINFO,"FE","Key %s not found", set_str);
360
361 //hotlink
362 // size = sizeof(config_type);
363 size = sizeof(V1740_CONFIG_SETTINGS);
365
366 //get actual record
367 status = db_get_record(h, _odb_handle, &config, &size, 0);
368
369 if (status == DB_SUCCESS) _settings_loaded = true;
370 _settings_touched = true;
371
372 return status; //== DB_SUCCESS for success
373}
static const char * config_str[]
Configuration string for this module. (ODB: /Equipment/[eq_name]/Settings/[board_name]/)
#define DB_SUCCESS
Definition midas.h:631
#define MODE_READ
Definition midas.h:370
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
Definition odb.cxx:13291
INT db_get_record(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align)
Definition odb.cxx:11709
char * strcomb(const char **list)
Definition odb.cxx:571
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4079
INT db_create_record(HNDLE hDB, HNDLE hKey, const char *orig_key_name, const char *init_str)
Definition odb.cxx:12800
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:

◆ SetSettingsTouched()

void v1740CONET2::SetSettingsTouched ( bool  t)
inline

set _settings_touched

Definition at line 94 of file v1740CONET2.hxx.

94 {
96 }

◆ SetupPreset()

CAENComm_ErrorCode v1740CONET2::SetupPreset ( int  mode)

Setup board registers using preset (see ov1720.c:ov1720_Setup())

Setup board registers using a preset defined in the midas file ov1720.c

  • Mode 0x0: "Setup Skip\n"
  • Mode 0x1: "Trigger from FP, 8ch, 1Ks, postTrigger 800\n"
  • Mode 0x2: "Trigger from LEMO\n"
Parameters
[in]modeConfiguration mode number
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 201 of file v1740CONET2.cxx.

202{
203#if SIMULATION
204 return CAENComm_Success;
205#else
206 return ov1740_Setup(_handle, mode);
207#endif
208}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowRegs()

void v1740CONET2::ShowRegs ( )

Misc reg printout, for debug purposes.

Definition at line 468 of file v1740CONET2.cxx.

469{
470#if !SIMULATION
471 DWORD temp;
473 cout << " *** regs: ";
474 sCAEN = CAENComm_Read32(_handle, V1740_EVENT_SIZE, &temp); cout << "E_SIZE=0x" << hex << temp << " ";
475 sCAEN = CAENComm_Read32(_handle, V1740_EVENT_STORED, &temp); cout << "E_STORED=0x" << hex << temp << " ";
476 sCAEN = CAENComm_Read32(_handle, V1740_GROUP_BUFFER_OCCUPANCY, &temp); cout << "GRP_BUFF_OCC[0]=0x" << temp << " ";
477 sCAEN = CAENComm_Read32(_handle, V1740_ACQUISITION_STATUS, &temp); cout << "ACQ_STATUS=0x" << temp << " lam=" << (temp & 0x4);
478 //sCAEN = CAENComm_Read32(_handle, V1740_BLT_EVENT_NB, &temp); cout << "BLT_EVENT_NB=0x" << temp << " ";
479 //sCAEN = CAENComm_Read32(_handle, V1740_GROUP_CONFIG, &temp); cout << "GROUP_CONFIG= " << temp << " ";
480 //sCAEN = CAENComm_Read32(_handle, V1740_GROUP_EN_MASK, &temp); cout << "GROUP_EN_MASK= " << temp << " ";
481 cout << dec << endl;
482 UNUSED(sCAEN);
483#endif
484}
Here is the call graph for this function:

◆ StartRun()

CAENComm_ErrorCode v1740CONET2::StartRun ( )

Start data acquisition.

Write to Acquisition Control reg to put board in RUN mode. If ODB settings have been changed, re-initialize the board with the new settings. Set _running flag true.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 153 of file v1740CONET2.cxx.

154{
155 if (verbose) cout << GetName() << "::StartRun()\n";
156 if (IsRunning()) {
157 cout << "Error: trying to start already started board" << endl;
158 return (CAENComm_ErrorCode)1;
159 }
160 if (!IsConnected()) {
161 cout << "Error: trying to start disconnected board" << endl;
162 return (CAENComm_ErrorCode)1;
163 }
165 {
166 cm_msg(MINFO, "feoV1740", "Note: settings on board %s touched. Re-initializing board.",
167 GetName().c_str());
168 cout << "reinitializing" << endl;
170 }
171
173 if (e == CAENComm_Success) _running=true;
174 return e;
175}
int InitializeForAcq()
Initialize the hardware for data acquisition.
static double e(void)
Definition tinyexpr.c:136
Here is the call graph for this function:

◆ StopRun()

CAENComm_ErrorCode v1740CONET2::StopRun ( )

Start data acquisition.

Write to Acquisition Control reg to put board in STOP mode. Set _running flag false.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 184 of file v1740CONET2.cxx.

185{
187 if (e == CAENComm_Success) _running=false;
188 return e;
189}
Here is the call graph for this function:

◆ WriteReg()

CAENComm_ErrorCode v1740CONET2::WriteReg ( DWORD  address,
DWORD  val 
)

Write to 32-bit register.

Parameters
[in]addressaddress of the register to write to
[in]valvalue to write to the register
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 248 of file v1740CONET2.cxx.

249{
250 if (verbose >= 2) cout << GetName() << "::WriteReg(" << hex << address << "," << val << ")" << endl;
251#if SIMULATION
252 return CAENComm_Success;
253#else
254 return CAENComm_Write32(_handle, address, val);
255#endif
256}
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _board

int v1740CONET2::_board
private

Module/Board number.

Definition at line 39 of file v1740CONET2.hxx.

◆ _handle

int v1740CONET2::_handle
private

Device handler.

Definition at line 37 of file v1740CONET2.hxx.

◆ _link

int v1740CONET2::_link
private

Optical link number.

Definition at line 38 of file v1740CONET2.hxx.

◆ _moduleID

int v1740CONET2::_moduleID
private

Unique module ID.

Definition at line 40 of file v1740CONET2.hxx.

◆ _odb_handle

HNDLE v1740CONET2::_odb_handle
private

Definition at line 42 of file v1740CONET2.hxx.

◆ _running

bool v1740CONET2::_running
private

Run in progress.

Definition at line 45 of file v1740CONET2.hxx.

◆ _settings_loaded

bool v1740CONET2::_settings_loaded
private

ODB settings loaded.

Definition at line 43 of file v1740CONET2.hxx.

◆ _settings_touched

bool v1740CONET2::_settings_touched
private

ODB settings touched.

Definition at line 44 of file v1740CONET2.hxx.

◆ config

instance of config structure

◆ config_str

const char * v1740CONET2::config_str
static
Initial value:
= {
"setup = INT : 0",
"Acq mode = INT : 1",
"Group Configuration = DWORD : 0",
"Buffer organization = INT : 8",
"Custom size = INT : 0",
"Group Mask = DWORD : 0xFF",
"Trigger Source = DWORD : 0x40000000",
"Trigger Output = DWORD : 0x40000000",
"Post Trigger = DWORD : 200",
"Threshold = DWORD[8] :",
"[0] 2080",
"[1] 1900",
"[2] 2080",
"[3] 9",
"[4] 9",
"[5] 9",
"[6] 9",
"[7] 9",
"DAC = DWORD[8] :",
"[0] 35000",
"[1] 35000",
"[2] 35000",
"[3] 35000",
"[4] 35000",
"[5] 35000",
"[6] 9190",
"[7] 9190",
}

Configuration string for this module. (ODB: /Equipment/[eq_name]/Settings/[board_name]/)

Definition at line 18 of file v1740CONET2.hxx.

35{
36private:
37 int _handle,
38 _link,
39 _board,
40 _moduleID;
41
43 bool _settings_loaded,
45 _running;
46public:
47 int verbose;
INT HNDLE
Definition midas.h:132

◆ verbose

int v1740CONET2::verbose

Make the driver verbose 0: off 1: normal 2: very verbose

Definition at line 47 of file v1740CONET2.hxx.


The documentation for this class was generated from the following files: