DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIBBase Class Reference

#include <WIBBase.hh>

Inheritance diagram for WIBBase:
[legend]
Collaboration diagram for WIBBase:
[legend]

Public Member Functions

 WIBBase (std::string const &address, std::string const &WIBAddressTable, std::string const &FEMBAddressTable)
 
 ~WIBBase ()
 
std::string GetAddress ()
 
uint32_t Read (uint16_t address)
 
uint32_t ReadWithRetry (uint16_t address)
 
uint32_t Read (std::string const &address)
 
uint32_t ReadWithRetry (std::string const &address)
 
void Write (uint16_t address, uint32_t value)
 
void WriteWithRetry (uint16_t address, uint32_t value)
 
void Write (std::string const &address, uint32_t value)
 
void WriteWithRetry (std::string const &address, uint32_t value)
 
void Write (uint16_t address, std::vector< uint32_t > const &values)
 
void Write (std::string const &address, std::vector< uint32_t > const &values)
 
void Write (uint16_t address, uint32_t const *values, size_t word_count)
 
void Write (std::string const &address, uint32_t const *values, size_t word_count)
 
uint32_t ReadI2C (std::string const &base_address, uint16_t I2C_aaddress, uint8_t byte_count=4)
 
void WriteI2C (std::string const &base_address, uint16_t I2C_address, uint32_t data, uint8_t byte_count=4, bool ignore_error=false)
 
std::vector< std::string > GetNames (std::string const &regex)
 
std::vector< std::string > GetFEMBNames (std::string const &regex)
 
std::vector< std::string > GetAddresses (uint16_t lower, uint16_t upper)
 
std::vector< std::string > GetFEMBAddresses (uint16_t lower, uint16_t upper)
 
std::vector< std::string > GetTableNames (std::string const &regex)
 
std::vector< Item const * > GetTagged (std::string const &tag)
 
std::vector< Item const * > GetFEMBTagged (std::string const &tag)
 
uint32_t ReadFEMB (int iFEMB, uint16_t address)
 
uint32_t ReadFEMB (int iFEMB, std::string const &address)
 
void WriteFEMB (int iFEMB, uint16_t address, uint32_t value)
 
void WriteFEMB (int iFEMB, std::string const &address, uint32_t value)
 
void WriteFEMBBits (int iFEMB, uint16_t address, uint32_t pos, uint32_t mask, uint32_t value)
 
void EnableADC (uint64_t iFEMB, uint64_t enable)
 
Item const * GetItem (std::string const &)
 
Item const * GetFEMBItem (int iFEMB, std::string const &)
 
int GetSVNVersion ()
 

Private Member Functions

 WIBBase ()
 
 WIBBase (const WIBBase &other)
 
WIBBaseoperator= (const WIBBase &)
 

Private Attributes

AddressTablewib
 
AddressTableFEMB [FEMB_COUNT]
 
const float FEMBReadSleepTime
 
const float FEMBWriteSleepTime
 

Static Private Attributes

static const int Version
 

Detailed Description

Definition at line 11 of file WIBBase.hh.

Constructor & Destructor Documentation

◆ WIBBase() [1/3]

WIBBase::WIBBase ( std::string const & address,
std::string const & WIBAddressTable,
std::string const & FEMBAddressTable )

Definition at line 5 of file WIBBase.cpp.

5 :
6 wib(NULL), FEMBReadSleepTime(0.01), FEMBWriteSleepTime(0.01) {
7 //Make sure all pointers and NULL before any allocation
8
9 for(size_t iFEMB = 0; iFEMB < FEMB_COUNT;iFEMB++){
10 FEMB[iFEMB] = NULL;
11 }
12
13 //Create the wib address table interface
14 wib = new AddressTable(WIBAddressTable,address,0);
15 for(size_t iFEMB = 0; iFEMB < FEMB_COUNT;iFEMB++){
16 FEMB[iFEMB] = new AddressTable(FEMBAddressTable,address,(iFEMB+1)*0x10);
17 }
18}
#define FEMB_COUNT
Definition WIBBase.hh:9
AddressTable * wib
Definition WIBBase.hh:77
AddressTable * FEMB[FEMB_COUNT]
Definition WIBBase.hh:78
const float FEMBWriteSleepTime
Definition WIBBase.hh:81
const float FEMBReadSleepTime
Definition WIBBase.hh:80
Definition wib.pb.cc:23

◆ ~WIBBase()

WIBBase::~WIBBase ( )

Definition at line 20 of file WIBBase.cpp.

20 {
21 if(wib != NULL){
22 delete wib;
23 wib = NULL;
24 }
25 for(size_t iFEMB = 0; iFEMB < FEMB_COUNT;iFEMB++){
26 if(FEMB[iFEMB] != NULL){
27 delete FEMB[iFEMB];
28 FEMB[iFEMB] = NULL;
29 }
30 }
31}

◆ WIBBase() [2/3]

WIBBase::WIBBase ( )
private

◆ WIBBase() [3/3]

WIBBase::WIBBase ( const WIBBase & other)
private

Member Function Documentation

◆ EnableADC()

void WIBBase::EnableADC ( uint64_t iFEMB,
uint64_t enable )

Definition at line 209 of file WIBBase.cpp.

209 {
210 if(iFEMB > 4 || iFEMB < 1){
211 BUException::WIB_INDEX_OUT_OF_RANGE e;
212 e.Append("In WIBBase::Enable_ADC");
213 throw e;
214 }
215 if(bool(enable))FEMB[iFEMB-1]->Write(0x03,0x00);
216 else FEMB[iFEMB-1]->Write(0x03,0xFF);
217 usleep((useconds_t) FEMBWriteSleepTime * 1e6);
218}
void Write(uint16_t, uint32_t)

◆ GetAddress()

std::string WIBBase::GetAddress ( )

Definition at line 34 of file WIBBase.cpp.

34 {
35 return wib->GetRemoteAddress();
36}

◆ GetAddresses()

std::vector< std::string > WIBBase::GetAddresses ( uint16_t lower,
uint16_t upper )
inline

Definition at line 41 of file WIBBase.hh.

41 {
42 return wib->GetAddresses(lower,upper);
43 }

◆ GetFEMBAddresses()

std::vector< std::string > WIBBase::GetFEMBAddresses ( uint16_t lower,
uint16_t upper )
inline

Definition at line 44 of file WIBBase.hh.

44 {
45 return FEMB[0]->GetAddresses(lower,upper);
46 }
std::vector< std::string > GetAddresses(uint16_t lower, uint16_t upper)

◆ GetFEMBItem()

Item const * WIBBase::GetFEMBItem ( int iFEMB,
std::string const & str )

Definition at line 107 of file WIBBase.cpp.

107 {
108 if((iFEMB > 4) || (iFEMB <1)){
109 BUException::WIB_INDEX_OUT_OF_RANGE e;
110 e.Append("In WIBBase::ReadFEMB\n");
111 throw e;
112 }
113 return FEMB[iFEMB-1]->GetItem(str);
114}
Item const * GetItem(std::string const &)

◆ GetFEMBNames()

std::vector< std::string > WIBBase::GetFEMBNames ( std::string const & regex)
inline

Definition at line 38 of file WIBBase.hh.

38 {
39 return FEMB[0]->GetNames(regex);
40 }
std::vector< std::string > GetNames()

◆ GetFEMBTagged()

std::vector< Item const * > WIBBase::GetFEMBTagged ( std::string const & tag)
inline

Definition at line 55 of file WIBBase.hh.

55 {
56 return FEMB[0]->GetTagged(tag);
57 }
std::vector< Item const * > GetTagged(std::string const &tag)

◆ GetItem()

Item const * WIBBase::GetItem ( std::string const & str)

Definition at line 103 of file WIBBase.cpp.

103 {
104 return wib->GetItem(str);
105}

◆ GetNames()

std::vector< std::string > WIBBase::GetNames ( std::string const & regex)
inline

Definition at line 35 of file WIBBase.hh.

35 {
36 return wib->GetNames(regex);
37 }

◆ GetSVNVersion()

int WIBBase::GetSVNVersion ( )
inline

Definition at line 70 of file WIBBase.hh.

70{return Version;}
static const int Version
Definition WIBBase.hh:79

◆ GetTableNames()

std::vector< std::string > WIBBase::GetTableNames ( std::string const & regex)
inline

Definition at line 47 of file WIBBase.hh.

47 {
48 return wib->GetTables(regex);
49 }

◆ GetTagged()

std::vector< Item const * > WIBBase::GetTagged ( std::string const & tag)
inline

Definition at line 51 of file WIBBase.hh.

51 {
52 return wib->GetTagged(tag);
53 }

◆ operator=()

WIBBase & WIBBase::operator= ( const WIBBase & )
private

◆ Read() [1/2]

uint32_t WIBBase::Read ( std::string const & address)

Definition at line 125 of file WIBBase.cpp.

125 {
126 return wib->Read(address);
127}

◆ Read() [2/2]

uint32_t WIBBase::Read ( uint16_t address)

Definition at line 119 of file WIBBase.cpp.

119 {
120 return wib->Read(address);
121}

◆ ReadFEMB() [1/2]

uint32_t WIBBase::ReadFEMB ( int iFEMB,
std::string const & address )

Definition at line 164 of file WIBBase.cpp.

164 {
165 if((iFEMB > 4) || (iFEMB <1)){
166 BUException::WIB_INDEX_OUT_OF_RANGE e;
167 e.Append("In WIBBase::ReadFEMB\n");
168 throw e;
169 }
170 return FEMB[iFEMB-1]->Read(address);
171 usleep((useconds_t) FEMBReadSleepTime * 1e6);
172}
uint32_t Read(uint16_t)

◆ ReadFEMB() [2/2]

uint32_t WIBBase::ReadFEMB ( int iFEMB,
uint16_t address )

Definition at line 155 of file WIBBase.cpp.

155 {
156 if((iFEMB > 4) || (iFEMB <1)){
157 BUException::WIB_INDEX_OUT_OF_RANGE e;
158 e.Append("In WIBBase::ReadFEMB\n");
159 throw e;
160 }
161 return FEMB[iFEMB-1]->Read(address);
162 usleep((useconds_t) FEMBReadSleepTime * 1e6);
163}

◆ ReadI2C()

uint32_t WIBBase::ReadI2C ( std::string const & base_address,
uint16_t I2C_aaddress,
uint8_t byte_count = 4 )

Definition at line 39 of file WIBBase.cpp.

39 {
40 //This is an incredibly inefficient version of this function since it does a dozen or so UDP transactions.
41 //This is done to be generic, but it could be hard-coded by assuming address offsets and bit maps and done in one write and one read.
42
43 //Set type of read
44 WriteWithRetry(base_address+".RW",1);
45 //Set address
46 WriteWithRetry(base_address+".ADDR",address);
47 //Set read size
48 WriteWithRetry(base_address+".BYTE_COUNT",byte_count);
49 //Wait for the last transaction to be done
50 while(ReadWithRetry(base_address+".DONE") == 0x0){usleep(1000);}
51 //Run transaction
52 WriteWithRetry(base_address+".RUN",0x1);
53 //Wait for the last transaction to be done
54 while(ReadWithRetry(base_address+".DONE") == 0x0){usleep(1000);}
55 if(ReadWithRetry(base_address+".ERROR")){
56 printf("%s 0x%08X\n",(base_address+".ERROR").c_str(),ReadWithRetry(base_address+".ERROR"));
57 //Reset the I2C firmware
58 WriteWithRetry(base_address+".RESET",1);
59 char trans_info[] = "rd @ 0xFFFF";
60 sprintf(trans_info,"rd @ 0x%04X",address&0xFFFF);
61 BUException::WIB_ERROR e;
62 e.Append("I2C Error on ");
63 e.Append(base_address.c_str());
64 e.Append(trans_info);
65 throw e;
66 }
67 return ReadWithRetry(base_address+".RD_DATA");
68}
void WriteWithRetry(uint16_t address, uint32_t value)
Definition WIBBase.cpp:129
uint32_t ReadWithRetry(uint16_t address)
Definition WIBBase.cpp:116

◆ ReadWithRetry() [1/2]

uint32_t WIBBase::ReadWithRetry ( std::string const & address)

Definition at line 122 of file WIBBase.cpp.

122 {
123 return wib->ReadWithRetry(address);
124}

◆ ReadWithRetry() [2/2]

uint32_t WIBBase::ReadWithRetry ( uint16_t address)

Definition at line 116 of file WIBBase.cpp.

116 {
117 return wib->ReadWithRetry(address);
118}

◆ Write() [1/6]

void WIBBase::Write ( std::string const & address,
std::vector< uint32_t > const & values )

Definition at line 144 of file WIBBase.cpp.

144 {
145 wib->Write(address,values);
146}

◆ Write() [2/6]

void WIBBase::Write ( std::string const & address,
uint32_t const * values,
size_t word_count )

Definition at line 150 of file WIBBase.cpp.

150 {
151 wib->Write(address,values,word_count);
152}

◆ Write() [3/6]

void WIBBase::Write ( std::string const & address,
uint32_t value )

Definition at line 138 of file WIBBase.cpp.

138 {
139 wib->Write(address,value);
140}

◆ Write() [4/6]

void WIBBase::Write ( uint16_t address,
std::vector< uint32_t > const & values )

Definition at line 141 of file WIBBase.cpp.

141 {
142 wib->Write(address,values);
143}

◆ Write() [5/6]

void WIBBase::Write ( uint16_t address,
uint32_t const * values,
size_t word_count )

Definition at line 147 of file WIBBase.cpp.

147 {
148 wib->Write(address,values,word_count);
149}

◆ Write() [6/6]

void WIBBase::Write ( uint16_t address,
uint32_t value )

Definition at line 132 of file WIBBase.cpp.

132 {
133 wib->Write(address,value);
134}

◆ WriteFEMB() [1/2]

void WIBBase::WriteFEMB ( int iFEMB,
std::string const & address,
uint32_t value )

Definition at line 183 of file WIBBase.cpp.

183 {
184 if((iFEMB > 4) || (iFEMB <1)){
185 BUException::WIB_INDEX_OUT_OF_RANGE e;
186 e.Append("In WIBBase::WriteFEMB\n");
187 throw e;
188 }
189 FEMB[iFEMB-1]->WriteWithRetry(address,value);
190 usleep((useconds_t) FEMBWriteSleepTime * 1e6);
191}
void WriteWithRetry(uint16_t, uint32_t)

◆ WriteFEMB() [2/2]

void WIBBase::WriteFEMB ( int iFEMB,
uint16_t address,
uint32_t value )

Definition at line 174 of file WIBBase.cpp.

174 {
175 if((iFEMB > 4) || (iFEMB <1)){
176 BUException::WIB_INDEX_OUT_OF_RANGE e;
177 e.Append("In WIBBase::WriteFEMB\n");
178 throw e;
179 }
180 FEMB[iFEMB-1]->WriteWithRetry(address,value);
181 usleep((useconds_t) FEMBWriteSleepTime * 1e6);
182}

◆ WriteFEMBBits()

void WIBBase::WriteFEMBBits ( int iFEMB,
uint16_t address,
uint32_t pos,
uint32_t mask,
uint32_t value )

Definition at line 193 of file WIBBase.cpp.

193 {
194 if((iFEMB > 4) || (iFEMB <1)){
195 BUException::WIB_INDEX_OUT_OF_RANGE e;
196 e.Append("In WIBBase::WriteFEMB\n");
197 throw e;
198 }
199
200 uint32_t shiftVal = value & mask;
201 uint32_t regMask = (mask << pos);
202 uint32_t initVal = FEMB[iFEMB -1]->Read(address);
203 uint32_t newVal = ( (initVal & ~(regMask)) | (shiftVal << pos) );
204
205 FEMB[iFEMB -1]->WriteWithRetry(address,newVal);
206 usleep((useconds_t) FEMBWriteSleepTime * 1e6);
207}

◆ WriteI2C()

void WIBBase::WriteI2C ( std::string const & base_address,
uint16_t I2C_address,
uint32_t data,
uint8_t byte_count = 4,
bool ignore_error = false )

Definition at line 69 of file WIBBase.cpp.

69 {
70 //This is an incredibly inefficient version of this function since it does a dozen or so UDP transactions.
71 //This is done to be generic, but it could be hard-coded by assuming address offsets and bit maps and done in one write and one read.
72
73 //Set type of read
74 WriteWithRetry(base_address+".RW",0);
75 //Set address
76 WriteWithRetry(base_address+".ADDR",address);
77 //Set read size
78 WriteWithRetry(base_address+".BYTE_COUNT",byte_count);
79 //Send data to write
80 WriteWithRetry(base_address+".WR_DATA",data);
81 //Wait for the last transaction to be done
82 while(ReadWithRetry(base_address+".DONE") == 0x0){usleep(1000);}
83 //Run transaction
84 WriteWithRetry(base_address+".RUN",0x1);
85
86 //Wait for the last transaction to be done
87 while(ReadWithRetry(base_address+".DONE") == 0x0){usleep(1000);}
88
89 if(!ignore_error && ReadWithRetry(base_address+".ERROR")){
90 //Reset the I2C firmware
91 WriteWithRetry(base_address+".RESET",1);
92 char trans_info[] = "wr 0xFFFFFFFF @ 0xFFFF";
93 sprintf(trans_info,"wr 0x%08X @ 0x%04X",data,address&0xFFFF);
94 BUException::WIB_ERROR e;
95 e.Append("I2C Error on ");
96 e.Append(base_address.c_str());
97 e.Append(trans_info);
98 throw e;
99 }
100}

◆ WriteWithRetry() [1/2]

void WIBBase::WriteWithRetry ( std::string const & address,
uint32_t value )

Definition at line 135 of file WIBBase.cpp.

135 {
136 wib->WriteWithRetry(address,value);
137}

◆ WriteWithRetry() [2/2]

void WIBBase::WriteWithRetry ( uint16_t address,
uint32_t value )

Definition at line 129 of file WIBBase.cpp.

129 {
130 wib->WriteWithRetry(address,value);
131}

Member Data Documentation

◆ FEMB

AddressTable* WIBBase::FEMB[FEMB_COUNT]
private

Definition at line 78 of file WIBBase.hh.

◆ FEMBReadSleepTime

const float WIBBase::FEMBReadSleepTime
private

Definition at line 80 of file WIBBase.hh.

◆ FEMBWriteSleepTime

const float WIBBase::FEMBWriteSleepTime
private

Definition at line 81 of file WIBBase.hh.

◆ Version

const int WIBBase::Version
staticprivate

Definition at line 79 of file WIBBase.hh.

◆ wib

AddressTable* WIBBase::wib
private

Definition at line 77 of file WIBBase.hh.


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