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

#include <v1720CONET2.hxx>

Collaboration diagram for v1720CONET2:

Classes

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

Public Member Functions

 v1720CONET2 (int feindex, int link, int board, int moduleID)
 Constructor for the module object.
 
 ~v1720CONET2 ()
 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 ChannelConfig (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.
 
CAENComm_ErrorCode Poll (DWORD *)
 Poll Event Stored register.
 
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 index, link and board number.
 
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
 
int GetFEIndex ()
 returns frontend index
 
void getChannelConfig (DWORD aChannelConfig)
 Get data type and ZLE configuration.
 
BOOL IsZLEData ()
 Get ZLE setting.
 
void fillQtBank (char *aDest, uint32_t *aZLEData, int aModule)
 Fill Qt Bank.
 

Public Attributes

int verbose
 
struct v1720CONET2::V1720_CONFIG_SETTINGS config
 instance of config structure
 
BOOL mZLE
 true if ZLE (Zero-length encoding) is enabled on all channels
 
int mDataType
 

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 _feindex
 Frontend index number.
 
int _link
 Optical link number.
 
int _board
 Module/Board number.
 
int _moduleID
 Unique module ID.
 
HNDLE _odb_handle
 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 v1720 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
  • Handle ZLE data
  • Send a software trigger to the board if desired

Definition at line 35 of file v1720CONET2.hxx.

Constructor & Destructor Documentation

◆ v1720CONET2()

v1720CONET2::v1720CONET2 ( int  feindex,
int  link,
int  board,
int  moduleID 
)

Constructor for the module object.

Set the basic hardware parameters

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

Definition at line 111 of file v1720CONET2.cxx.

113{
114 _handle = -1;
115 _odb_handle = 0;
116 verbose = 0;
117 _settings_loaded=false;
118 _settings_touched=false;
119 _running=false;
120 mZLE=false;
121 mDataType = 0;
122}
int _link
Optical link number.
bool _settings_loaded
ODB settings loaded.
int _handle
Device handler.
int _moduleID
Unique module ID.
bool _settings_touched
ODB settings touched.
BOOL mZLE
true if ZLE (Zero-length encoding) is enabled on all channels
int _feindex
Frontend index number.
HNDLE _odb_handle
ODB handle.
bool _running
Run in progress.
int _board
Module/Board number.
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24

◆ ~v1720CONET2()

v1720CONET2::~v1720CONET2 ( )

Destructor for the module object.

Nothing to do.

Definition at line 129 of file v1720CONET2.cxx.

130{
131}

Member Function Documentation

◆ AcqCtl()

CAENComm_ErrorCode v1720CONET2::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 297 of file v1720CONET2.cxx.

298{
299#if SIMULATION
300 return CAENComm_Success;
301#else
303#endif
304}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChannelConfig()

CAENComm_ErrorCode v1720CONET2::ChannelConfig ( 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 313 of file v1720CONET2.cxx.

314{
315#if SIMULATION
316 return CAENComm_Success;
317#else
319#endif
320}
Here is the call graph for this function:

◆ Connect()

CAENComm_ErrorCode v1720CONET2::Connect ( )

Connect the board through the optical link.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 171 of file v1720CONET2.cxx.

172{
173 if (verbose) cout << GetName() << "::Connect()\n";
174 if (IsConnected()) { cout << "Error: trying to connect already connected board" << endl;
175 return (CAENComm_ErrorCode) 1; }
176#if SIMULATION
177 if (verbose) cout << "Opening device " << _board << endl;
178#else
179 if (verbose) cout << "Opening device (i,l,b) = (" << _feindex << "," << _link << "," << _board << ")" << endl;
180#endif
181
183
184#if SIMULATION
186 _handle = 1; //random
187#else
189#endif
190
191 if (sCAEN != CAENComm_Success) _handle = -1;
192 return sCAEN;
193}
std::string GetName()
Get short string identifying the module's index, link and board number.
bool IsConnected()
Get connected status.
Here is the call graph for this function:

◆ Disconnect()

CAENComm_ErrorCode v1720CONET2::Disconnect ( )

Disconnect the board through the optical link.

Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 199 of file v1720CONET2.cxx.

200{
201 if (verbose) cout << GetName() << "::Disconnect()\n";
202 if (!IsConnected()) { cout << "Error: trying to disconnect already disconnected board" << endl; return (CAENComm_ErrorCode)1; }
203 if (IsRunning()) { cout << "Error: trying to disconnect running board" << endl; return (CAENComm_ErrorCode)1; }
204#if SIMULATION
205 if (verbose) cout << "Closing device " << _board << endl;
206#else
207 if (verbose) cout << "Closing device (i,l,b) = (" << _feindex << "," << _link << "," << _board << ")" << endl;
208#endif
209
211
212#if SIMULATION
214#else
216#endif
217
218 _handle = -1;
219 return sCAEN;
220}
bool IsRunning()
Get run status.
Here is the call graph for this function:

◆ fillQtBank()

void v1720CONET2::fillQtBank ( char pevent,
uint32_t pZLEData,
int  moduleID 
)

Fill Qt Bank.

Parameters
[in]peventpointer to event buffer
[in]pZLEDatapointer to the data area of the bank
[in]moduleIDunique module/board ID

Definition at line 719 of file v1720CONET2.cxx.

719 {
720 // >>> Create bank.
721 // QtData is the pointer to the memory location hodling the Qt data
722 // Content
723 // V1720 event counter
724 // V1720 Trigger time tag
725 // Number of Qt
726 // QT format: channel 28 time 16 charge 0
727 char tBankName[5];
728 sprintf(tBankName,"QT%02d",moduleID);
731
732
733 // >>> copy some header words
734 *QtData = *(pZLEData+2); // event counter QtData[0]
735 QtData++;
736 *QtData = *(pZLEData+3); // trigger time tag QtData[1]
737 QtData++;
738
739 // >>> Figure out channel mapping
740 //if(mNCh==0){
741 int mNCh=0;
742 uint32_t mChMap[8];
743 uint32_t chMask = pZLEData[1] & 0xFF;
744 for(int iCh=0; iCh<8; iCh++){
745 if(chMask & (1<<iCh)){
746 mChMap[mNCh] = iCh;
747 mNCh++;
748 }
749 }
750 if(mNCh==0){
751 // printf("No channels found for module %i! Something wrong with channel mask\n", aModule);
752 }
753 //}
754
755 // >>> Skip location QtData[2]. Will be used for number of QT;
757 *(nQt) = 0;
758 QtData++;
759 //std::cout << QtData[0] << " " << *(QtData-2) << " " << QtData[1] << " " << *nQt << " " << *(QtData-1)<< " ";
760 // >>> Loop over ZLE data and fill up Qt data bank
761
762 uint32_t iPtr=4;
763 for(int iCh=0; iCh<mNCh; iCh++){
765 uint32_t iChPtr = 1;// The chSize space is included in chSize
766 uint32_t iBin=0;
767 iPtr++;
768 //std::cout << "--------------- Channel: " << aModule << "-" << iCh << " size=" << chSize << " " << std::endl;
770 while(iChPtr<chSize){
771 uint32_t goodData = ((pZLEData[iPtr]>>31) & 0x1);
772 uint32_t nWords = (pZLEData[iPtr] & 0xFFFFF);
773 if(prevGoodData==0 && goodData==0){ // consecutive skip. Bad
774 /* std::cout << "consecutive skip: V1720=" << aModule
775 << " | ch=" << iCh
776 << " | prev word=" << pZLEData[iPtr-1]
777 << " | cur word=" << pZLEData[iPtr] << std::endl;
778 */}
780 if(goodData){
782 uint32_t min=4096;
783 uint32_t baseline = (pZLEData[iPtr+1]&0xFFF);
784 for(uint32_t iWord=0; iWord<nWords; iWord++){
785 iPtr++;
786 iChPtr++;
787 if(min > (pZLEData[iPtr]&0xFFF) ){
788 iMin = iBin+iWord*2;
789 min = (pZLEData[iPtr]&0xFFF);
790 }
791 if(min > ((pZLEData[iPtr]>>16)&0xFFF) ){
792 iMin = iBin+iWord*2+1;
793 min = ((pZLEData[iPtr]>>16)&0xFFF);
794 }
795 }
796 // package channel | iMin | min in one 32 bit word
797 // don't bother for now. Temporary!!!!
798 (*nQt)++; // increment number of Qt
799 min = baseline-min; // turn it into a positive number
800 *QtData = (((mChMap[iCh]<<28) & 0xF0000000) |
801 ((iMin<<16) & 0x0FFF0000) |
802 (min & 0x0000FFFF));
803 QtData++;
804 //std::cout << aModule << " " << mChMap[iCh] << " " << iMin << " " << min << " " << *(QtData-1) << std::endl;
805 }
806 else{ // skip
807 iBin += (nWords*2);
808 }
809
810 iChPtr++;
811 iPtr++;
812 }
813 }
814 //std::cout << " | " << *nQt << std::endl;
815 bk_close(pevent, QtData);
816}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:16561
#define TID_DWORD
Definition midas.h:336
Here is the call graph for this function:

◆ GetBoard()

int v1720CONET2::GetBoard ( )
inline

returns board number

Definition at line 125 of file v1720CONET2.hxx.

◆ getChannelConfig()

void v1720CONET2::getChannelConfig ( DWORD  aChannelConfig)

Get data type and ZLE configuration.

Takes the channel configuration (0x8000) as parameter and checks against the fields for data type (pack 2 or pack 2.5) and for ZLE (Zero-length encoding). Puts the results in fields mDataType and mZLE.

Parameters
[in]aChannelConfigChannel configuration (32-bit)

Definition at line 666 of file v1720CONET2.cxx.

666 {
667
668 // Set Device, data type and packing for QT calculation later
669 int dataType = ((aChannelConfig >> 11) & 0x1);
670 if(((aChannelConfig >> 16) & 0xF) == 0) {
671 if(dataType == 1) {
672 // 2.5 pack, full data
673 mDataType = 1;
674 mZLE=0;
675 cm_msg(MINFO,"FE","Data Type: Full data with 2.5 Packing");
676 }
677 else{
678 // 2 pack, full data
679 mZLE=0;
680 mDataType = 0;
681 cm_msg(MINFO,"FE","Data Type: Full data with 2 Packing");
682 }
683 }
684 else if(((aChannelConfig >> 16) & 0xF) == 2) {
685 if(dataType == 1) {
686 // 2.5 pack, ZLE data
687 mDataType = 3;
688 cm_msg(MINFO,"FE","Data Type: ZLE data with 2.5 Packing");
689 mZLE=1;
690 }
691 else{
692 // 2 pack, ZLE data
693 mDataType = 2;
694 cm_msg(MINFO,"FE","Data Type: ZLE data with 2 Packing");
695 mZLE=1;
696 }
697 }
698 else{
699 cm_msg(MERROR,"FE","V1720 Data format Unrecognised reg: 0x%04x", 0x8000);
700 }
701}
#define MINFO
Definition midas.h:560
#define MERROR
Definition midas.h:559
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:
Here is the caller graph for this function:

◆ GetFEIndex()

int v1720CONET2::GetFEIndex ( )
inline

returns frontend index

Definition at line 126 of file v1720CONET2.hxx.

◆ GetHandle()

int v1720CONET2::GetHandle ( )
inline

returns device handler

Definition at line 118 of file v1720CONET2.hxx.

◆ GetLink()

int v1720CONET2::GetLink ( )
inline

returns optical link number

Definition at line 124 of file v1720CONET2.hxx.

◆ GetModuleID()

int v1720CONET2::GetModuleID ( )
inline

returns unique module ID

Definition at line 123 of file v1720CONET2.hxx.

◆ GetName()

string v1720CONET2::GetName ( )

Get short string identifying the module's index, link and board number.

Returns
name string

Definition at line 138 of file v1720CONET2.cxx.

139{
140 stringstream txt;
141#if SIMULATION
142 txt << "B" << _board;
143#else
144 txt << "F" << _feindex << _link << _board;
145#endif
146 return txt.str();
147}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetODBHandle()

HNDLE v1720CONET2::GetODBHandle ( )
inline

returns ODB handle

Definition at line 111 of file v1720CONET2.hxx.

◆ GetSettingsTouched()

bool v1720CONET2::GetSettingsTouched ( )
inline

returns true if odb settings touched

Definition at line 112 of file v1720CONET2.hxx.

112 {
113 return _settings_touched;
114 }

◆ InitializeForAcq()

int v1720CONET2::InitializeForAcq ( )

Initialize the hardware for data acquisition.

Initial setup:

  • Set FP I/O Ctrl (0x811C) to default settings (output trigger).
  • Do software reset + clear.
  • Set up busy daisy chaining
  • Put acquisition on stop.

Checks

  • AMC firmware version (and check that each channel has the same AMC firmware)
  • ROC firmware version
  • board type

Set registers

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

Returns
0 on success, -1 on error

Definition at line 514 of file v1720CONET2.cxx.

515{
516 if (verbose) cout << GetName() << "::InitializeForAcq()" << endl;
517
518 if (!_settings_loaded) {
519 cout << "Error: cannot call InitializeForAcq() without settings loaded properly" << endl;
520 return -1; }
521 if (!IsConnected()) {
522 cout << "Error: trying to call InitializeForAcq() to unconnected board" << endl;
523 return -1; }
524 if (IsRunning()) {
525 cout << "Error: trying to call InitializeForAcq() to already running board" << endl;
526 return -1; }
527
528 //don't do anything if settings haven't been changed
529 if (_settings_loaded && !_settings_touched) return 0;
530
532
533 // Set register V1720_FP_IO_CONTROL (0x811C) to default settings
534 // (output trigger) will set the board that output the clock latter
535 sCAEN = WriteReg(V1720_FP_IO_CONTROL, 0x00000000);
536
537 // Clear the board
540
541 // Setup Busy daisy chaining
542 printf("\nBusy daisy chaining \n\n");
544 //sCAEN = WriteReg(V1720_FP_LVDS_IO_CRTL, 0x22);
546
547#if SIMULATION
548 cm_msg(MINFO,"feoV1720","Simulation, no firmware check");
549#else
550 // Firmware version check
551 // read each AMC firmware version
552 // [31:16] Revision date Y/M/DD
553 // [15:8] Firmware Revision (X)
554 // [7:0] Firmware Revision (Y)
555 // eg 0x760C0103 is 12th June 07, revision 1.3
556 int addr = 0;
557 uint32_t version = 0;
559 // Hardcode correct firmware verisons
560 // Current release 3.4_0.11 Feb 2012
561 const uint32_t amc_fw_ver = 0xc102000b;
562 const uint32_t roc_fw_ver = 0xc2080304;
563 const uint32_t roc_fw_ver_test = 0xc5250306; //new version we're testing
564
565 for(int iCh=0;iCh<8;iCh++) {
566 addr = 0x108c | (iCh << 8);
567 sCAEN = ReadReg(addr, &version);
568 if((iCh != 0) && (prev_chan != version)) {
569 cm_msg(MERROR, "feoV1720","Error AMC Channels have different Firmware \n");
570 }
571 prev_chan = version;
572 }
573 cm_msg(MINFO,"feoV1720","Format: YMDD:XX.YY");
574 if(version != amc_fw_ver) {
575 cm_msg(MERROR,"feoV1720","Incorrect AMC Firmware Version: 0x%08x", version);
576 }
577 else {
578 cm_msg(MINFO,"feoV1720","AMC Firmware Version: 0x%08x", version);
579 }
580
581 // read ROC firmware revision
582 // Format as above
584 switch (version)
585 {
586 case roc_fw_ver:
587 cm_msg(MINFO,"feoV1720","ROC Firmware Version: 0x%08x", version);
588 break;
589 case roc_fw_ver_test:
590 cm_msg(MINFO,"feoV1720","*** WARNING *** using new ROC Firmware Version: 0x%08x", version);
591 break;
592 default:
593 cm_msg(MERROR,"feoV1720","Incorrect ROC Firmware Version: 0x%08x", version);
594 break;
595 }
596
597 // Verify Board Type
598 const uint32_t v1720_board_type = 0x03;
599 sCAEN = ReadReg(V1720_BOARD_INFO, &version);
600 if((version & 0xFF) != v1720_board_type)
601 cm_msg(MINFO,"feoV1720","*** WARNING *** Trying to use a v1720 frontend with another"
602 " type of board. Results will be unexpected!");
603
604#endif //SIMULATION
605
607
608 //use preset setting if enabled
610 //else use odb values
611 else
612 {
613 //already reset/clear earlier this function, so skip here
623 //WriteReg(V1720_ALMOST_FULL_LEVEL, 850);
627
628 //set specfic channel values
629 for (int iChan=0; iChan<8; iChan++)
630 {
636 //NB: in original frontend, zst and zsn regs were set via a short calculation in the
637 //frontend, not the exact values as in odb. it was not clear that this was done
638 //without looking at source code, so i have changed it to just take values direct
639 //from ODB.
640 //On my todo list is to figure out a better way of setting up ODB settings
641 //for the frontends.
642
643 }
644 //could do Status here
645 }
646
647 //todo: some kind of check to make sure stuff is set correctly???
648
649 _settings_touched = false;
650 UNUSED(sCAEN);
651
652 //ready to do startrun
653
654 return 0;
655}
CAENComm_ErrorCode WriteReg(DWORD, DWORD)
Write to 32-bit register.
CAENComm_ErrorCode SetupPreset(int)
Setup board registers using preset (see ov1720.c:ov1720_Setup())
CAENComm_ErrorCode ReadReg(DWORD, DWORD *)
Read 32-bit register.
CAENComm_ErrorCode AcqCtl(uint32_t)
Control data acquisition.
void getChannelConfig(DWORD aChannelConfig)
Get data type and ZLE configuration.
struct v1720CONET2::V1720_CONFIG_SETTINGS config
instance of config structure
#define UNUSED
Definition mongoose6.h:113
char addr[128]
Definition mcnaf.cxx:104
DWORD threshold[8]
0x1n80@[11.. 0]
DWORD nbouthreshold[8]
0x1n84@[11.. 0]
INT zs_threshold[8]
0x1n24@[31.. 0]
DWORD channel_config
0x8000@[19.. 0]
DWORD zs_nsamp[8]
0x1n28@[31.. 0]
DWORD dac[8]
0x1n98@[15.. 0]
DWORD channel_mask
0x8120@[ 7.. 0]
INT buffer_organization
0x800C@[ 3.. 0]
DWORD trigger_source
0x810C@[31.. 0]
DWORD trigger_output
0x8110@[31.. 0]
DWORD post_trigger
0x8114@[31.. 0]
INT setup
Initial board setup mode number.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsConnected()

bool v1720CONET2::IsConnected ( )

Get connected status.

Returns
true if board is connected

Definition at line 153 of file v1720CONET2.cxx.

154{
155 return (_handle >= 0);
156}
Here is the caller graph for this function:

◆ IsRunning()

bool v1720CONET2::IsRunning ( )

Get run status.

Returns
true if run is started

Definition at line 162 of file v1720CONET2.cxx.

163{
164 return _running;
165}
Here is the caller graph for this function:

◆ IsZLEData()

BOOL v1720CONET2::IsZLEData ( )

Get ZLE setting.

Get the current ZLE setting from the channel configuration.

Returns
true if data is ZLE

Definition at line 709 of file v1720CONET2.cxx.

709 {
710 return mZLE;
711}

◆ Poll()

CAENComm_ErrorCode v1720CONET2::Poll ( DWORD val)

Poll Event Stored register.

Check Event Stored register for any event stored

Parameters
[out]valNumber of events stored
Returns
CAENComm Error Code (see CAENComm.h)

Definition at line 361 of file v1720CONET2.cxx.

362{
363#if SIMULATION
364 return CAENComm_Success;
365#else
367#endif
368}
Here is the call graph for this function:

◆ ReadEvent()

CAENComm_ErrorCode v1720CONET2::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 382 of file v1720CONET2.cxx.

383{
384 if (!IsConnected()) {
385 cout << "Error: trying to ReadEvent disconnected board" << endl;
386 return (CAENComm_ErrorCode)1;
387 }
389 int tempnw = 0;
390 *dwords_read = 0;
391
392 //read size of event to be read
393#if SIMULATION
396#else
398#endif
399
400 while (size_remaining > 0 && sCAEN == CAENComm_Success)
401 {
402#if SIMULATION
404 for (WORD i = 0; i < to_read; i++)
405 *data_pos++ = rand();
407 tempnw = to_read; //simulate success reading all data
408#else
409 //calculate amount of data to be read in this iteration
412#endif
413
414 if (verbose >= 2) cout << sCAEN << " = BLTRead(handle=" << _handle
415 << ", addr=" << V1720_EVENT_READOUT_BUFFER
416 << ", data_pos=" << data_pos
417 << ", to_read=" << to_read
418 << ", tempnw returned " << tempnw << ");" << endl;
419
420 //increment pointers/counters
423 data_pos += tempnw;
424 }
425 return sCAEN;
426}
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
void * data
Definition mana.cxx:268
INT i
Definition mdump.cxx:32
#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 v1720CONET2::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 328 of file v1720CONET2.cxx.

329{
330 if (verbose >= 2) cout << GetName() << "::ReadReg(" << hex << address << ")" << endl;
331#if SIMULATION
332 return CAENComm_Success;
333#else
334 return CAENComm_Read32(_handle, address, val);
335#endif
336}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendTrigger()

CAENComm_ErrorCode v1720CONET2::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 435 of file v1720CONET2.cxx.

436{
437 if (verbose) cout << GetName() << "::SendTrigger()" << endl;
438 if (!IsConnected()) { cout << "Error: trying to SendTrigger disconnected board" << endl; return (CAENComm_ErrorCode)1; }
439#if SIMULATION
440 if (verbose) cout << "Sending Trigger " << _board << endl;
441#else
442 if (verbose) cout << "Sending Trigger (l,b) = (" << _link << "," << _board << ")" << endl;
443#endif
444
445 return WriteReg(V1720_SW_TRIGGER, 0x1);
446}
Here is the call graph for this function:

◆ SetODBRecord()

int v1720CONET2::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 (v1720CONET2::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/FEv1720I2/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 464 of file v1720CONET2.cxx.

465{
466 char set_str[200];
467
468#if SIMULATION
469 sprintf(set_str, "/Equipment/FEv1720_SIM/Settings/Board%d", _board);
470#else
471 if(_feindex == -1)
472 sprintf(set_str, "/Equipment/FEv1720I/Settings/Board%d", _moduleID);
473 else
474 sprintf(set_str, "/Equipment/FEv1720I%0d/Settings/Board%d", _feindex, _moduleID);
475#endif
476
477 if (verbose) cout << GetName() << "::SetODBRecord(" << h << "," << set_str << ",...)" << endl;
478 int status,size;
479 //create record if doesn't exist and find key
482 if (status != DB_SUCCESS) cm_msg(MINFO,"FE","Key %s not found", set_str);
483
484 //hotlink
485 size = sizeof(V1720_CONFIG_SETTINGS);
487
488 //get actual record
489 status = db_get_record(h, _odb_handle, &config, &size, 0);
490 if (status == DB_SUCCESS) _settings_loaded = true;
491 _settings_touched = true;
492
493 return status; //== DB_SUCCESS for success
494}
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 v1720CONET2::SetSettingsTouched ( bool  t)
inline

set _settings_touched

Definition at line 115 of file v1720CONET2.hxx.

115 {
117 }

◆ SetupPreset()

CAENComm_ErrorCode v1720CONET2::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 281 of file v1720CONET2.cxx.

282{
283#if SIMULATION
284 return CAENComm_Success;
285#else
286 return ov1720_Setup(_handle, mode);
287#endif
288}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartRun()

CAENComm_ErrorCode v1720CONET2::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 230 of file v1720CONET2.cxx.

231{
232 if (verbose) cout << GetName() << "::StartRun()\n";
233 if (IsRunning()) {
234 cout << "Error: trying to start already started board" << endl;
235 return (CAENComm_ErrorCode)1;
236 }
237 if (!IsConnected()) {
238 cout << "Error: trying to start disconnected board" << endl;
239 return (CAENComm_ErrorCode)1;
240 }
242 {
243 cm_msg(MINFO, "feoV1720", "Note: settings on board %s touched. Re-initializing board.",
244 GetName().c_str());
245 cout << "reinitializing" << endl;
247 }
248
250 if (e == CAENComm_Success) _running=true;
251 return e;
252}
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 v1720CONET2::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 261 of file v1720CONET2.cxx.

262{
263 if (verbose) cout << GetName() << "::StopRun()\n";
264 if (!IsRunning()) { cout << "Error: trying to stop already stopped board" << endl; return (CAENComm_ErrorCode)1; }
265 if (!IsConnected()) { cout << "Error: trying to stop disconnected board" << endl; return (CAENComm_ErrorCode)1; }
267 if (e == CAENComm_Success) _running=false;
268 return e;
269}
Here is the call graph for this function:

◆ WriteReg()

CAENComm_ErrorCode v1720CONET2::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 344 of file v1720CONET2.cxx.

345{
346 if (verbose >= 2) cout << GetName() << "::WriteReg(" << hex << address << "," << val << ")" << endl;
347#if SIMULATION
348 return CAENComm_Success;
349#else
350 return CAENComm_Write32(_handle, address, val);
351#endif
352}
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _board

int v1720CONET2::_board
private

Module/Board number.

Definition at line 44 of file v1720CONET2.hxx.

◆ _feindex

int v1720CONET2::_feindex
private

Frontend index number.

Definition at line 42 of file v1720CONET2.hxx.

◆ _handle

int v1720CONET2::_handle
private

Device handler.

Definition at line 41 of file v1720CONET2.hxx.

◆ _link

int v1720CONET2::_link
private

Optical link number.

Definition at line 43 of file v1720CONET2.hxx.

◆ _moduleID

int v1720CONET2::_moduleID
private

Unique module ID.

Definition at line 45 of file v1720CONET2.hxx.

◆ _odb_handle

HNDLE v1720CONET2::_odb_handle
private

ODB handle.

Definition at line 48 of file v1720CONET2.hxx.

◆ _running

bool v1720CONET2::_running
private

Run in progress.

Definition at line 51 of file v1720CONET2.hxx.

◆ _settings_loaded

bool v1720CONET2::_settings_loaded
private

ODB settings loaded.

Definition at line 49 of file v1720CONET2.hxx.

◆ _settings_touched

bool v1720CONET2::_settings_touched
private

ODB settings touched.

Definition at line 50 of file v1720CONET2.hxx.

◆ config

instance of config structure

◆ config_str

const char * v1720CONET2::config_str
static

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

Definition at line 18 of file v1720CONET2.hxx.

18 {
19#include "CAENComm.h"
20#include "ov1720drv.h"
21}
22#include "midas.h"
23
35class v1720CONET2
36{
37private:
38#if SIMULATION
39 int _handle, _board;
40#else
41 int _handle,
42 _feindex,
43 _link,
44 _board,
45 _moduleID;
46#endif
47
49 bool _settings_loaded,
51 _running;
52
53public:
54 int verbose;
58
59
61 struct V1720_CONFIG_SETTINGS {
62 INT setup;
71 // Hard code the two fp_* settings to alway on (Alex 21/2/13)
72 // DWORD fp_io_ctrl; //!< 0x811C@[31.. 0]
74 // DWORD fp_lvds_io_ctrl; //!< 0x81A0@[31.. 0]
75 // BOOL trigger_positive_pulse; //!< 0x8000@[ 6]
76 // WORD pre_record_zs; //!< 0x1n24@[31..16]
77 // WORD post_record_zs; //!< 0x1n24@[15.. 0]
78 DWORD threshold[8];
INT HNDLE
Definition midas.h:132
int INT
Definition midas.h:129

◆ mDataType

int v1720CONET2::mDataType

Data type for all channels:

  • 0: Full data, 2 packing
  • 1: Full data, 2.5 packing
  • 2: ZLE data, 2 packing
  • 3: ZLE data, 2.5 packing

Definition at line 139 of file v1720CONET2.hxx.

◆ mZLE

BOOL v1720CONET2::mZLE

true if ZLE (Zero-length encoding) is enabled on all channels

Definition at line 132 of file v1720CONET2.hxx.

◆ verbose

int v1720CONET2::verbose

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

Definition at line 54 of file v1720CONET2.hxx.


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