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)
WIBBase & operator= (const WIBBase &)

Private Attributes

AddressTable * wib
AddressTable * FEMB [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.

6 : wib(NULL)
9{
10 // Make sure all pointers and NULL before any allocation
11
12 for (size_t iFEMB = 0; iFEMB < FEMB_COUNT; iFEMB++) {
13 FEMB[iFEMB] = NULL;
14 }
15
16 // Create the wib address table interface
17 wib = new AddressTable(WIBAddressTable, address, 0);
18 for (size_t iFEMB = 0; iFEMB < FEMB_COUNT; iFEMB++) {
19 FEMB[iFEMB] = new AddressTable(FEMBAddressTable, address, (iFEMB + 1) * 0x10);
20 }
21}
#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

◆ ~WIBBase()

WIBBase::~WIBBase ( )

Definition at line 23 of file WIBBase.cpp.

24{
25 if (wib != NULL) {
26 delete wib;
27 wib = NULL;
28 }
29 for (size_t iFEMB = 0; iFEMB < FEMB_COUNT; iFEMB++) {
30 if (FEMB[iFEMB] != NULL) {
31 delete FEMB[iFEMB];
32 FEMB[iFEMB] = NULL;
33 }
34 }
35}

◆ 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 268 of file WIBBase.cpp.

269{
270 if (iFEMB > 4 || iFEMB < 1) {
271 BUException::WIB_INDEX_OUT_OF_RANGE e;
272 e.Append("In WIBBase::Enable_ADC");
273 throw e;
274 }
275 if (bool(enable))
276 FEMB[iFEMB - 1]->Write(0x03, 0x00);
277 else
278 FEMB[iFEMB - 1]->Write(0x03, 0xFF);
279 usleep((useconds_t)FEMBWriteSleepTime * 1e6);
280}
void Write(uint16_t, uint32_t)

◆ GetAddress()

std::string WIBBase::GetAddress ( )

Definition at line 38 of file WIBBase.cpp.

39{
40 return wib->GetRemoteAddress();
41}
std::string GetRemoteAddress()

◆ 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 }
std::vector< std::string > GetAddresses(uint16_t lower, uint16_t upper)

◆ 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 }

◆ GetFEMBItem()

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

Definition at line 131 of file WIBBase.cpp.

132{
133 if ((iFEMB > 4) || (iFEMB < 1)) {
134 BUException::WIB_INDEX_OUT_OF_RANGE e;
135 e.Append("In WIBBase::ReadFEMB\n");
136 throw e;
137 }
138 return FEMB[iFEMB - 1]->GetItem(str);
139}
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 125 of file WIBBase.cpp.

126{
127 return wib->GetItem(str);
128}

◆ 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 }
std::vector< std::string > GetTables(std::string const &regex)

◆ 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 157 of file WIBBase.cpp.

158{
159 return wib->Read(address);
160}
uint32_t Read(uint16_t)

◆ Read() [2/2]

uint32_t WIBBase::Read ( uint16_t address)

Definition at line 147 of file WIBBase.cpp.

148{
149 return wib->Read(address);
150}

◆ ReadFEMB() [1/2]

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

Definition at line 215 of file WIBBase.cpp.

216{
217 if ((iFEMB > 4) || (iFEMB < 1)) {
218 BUException::WIB_INDEX_OUT_OF_RANGE e;
219 e.Append("In WIBBase::ReadFEMB\n");
220 throw e;
221 }
222 return FEMB[iFEMB - 1]->Read(address);
223 usleep((useconds_t)FEMBReadSleepTime * 1e6);
224}

◆ ReadFEMB() [2/2]

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

Definition at line 204 of file WIBBase.cpp.

205{
206 if ((iFEMB > 4) || (iFEMB < 1)) {
207 BUException::WIB_INDEX_OUT_OF_RANGE e;
208 e.Append("In WIBBase::ReadFEMB\n");
209 throw e;
210 }
211 return FEMB[iFEMB - 1]->Read(address);
212 usleep((useconds_t)FEMBReadSleepTime * 1e6);
213}

◆ ReadI2C()

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

Definition at line 44 of file WIBBase.cpp.

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

◆ ReadWithRetry() [1/2]

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

Definition at line 152 of file WIBBase.cpp.

153{
154 return wib->ReadWithRetry(address);
155}
uint32_t ReadWithRetry(uint16_t)

◆ ReadWithRetry() [2/2]

uint32_t WIBBase::ReadWithRetry ( uint16_t address)

Definition at line 142 of file WIBBase.cpp.

143{
144 return wib->ReadWithRetry(address);
145}

◆ Write() [1/6]

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

Definition at line 188 of file WIBBase.cpp.

189{
190 wib->Write(address, values);
191}

◆ Write() [2/6]

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

Definition at line 198 of file WIBBase.cpp.

199{
200 wib->Write(address, values, word_count);
201}

◆ Write() [3/6]

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

Definition at line 178 of file WIBBase.cpp.

179{
180 wib->Write(address, value);
181}

◆ Write() [4/6]

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

Definition at line 183 of file WIBBase.cpp.

184{
185 wib->Write(address, values);
186}

◆ Write() [5/6]

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

Definition at line 193 of file WIBBase.cpp.

194{
195 wib->Write(address, values, word_count);
196}

◆ Write() [6/6]

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

Definition at line 168 of file WIBBase.cpp.

169{
170 wib->Write(address, value);
171}

◆ WriteFEMB() [1/2]

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

Definition at line 238 of file WIBBase.cpp.

239{
240 if ((iFEMB > 4) || (iFEMB < 1)) {
241 BUException::WIB_INDEX_OUT_OF_RANGE e;
242 e.Append("In WIBBase::WriteFEMB\n");
243 throw e;
244 }
245 FEMB[iFEMB - 1]->WriteWithRetry(address, value);
246 usleep((useconds_t)FEMBWriteSleepTime * 1e6);
247}
void WriteWithRetry(uint16_t, uint32_t)

◆ WriteFEMB() [2/2]

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

Definition at line 227 of file WIBBase.cpp.

228{
229 if ((iFEMB > 4) || (iFEMB < 1)) {
230 BUException::WIB_INDEX_OUT_OF_RANGE e;
231 e.Append("In WIBBase::WriteFEMB\n");
232 throw e;
233 }
234 FEMB[iFEMB - 1]->WriteWithRetry(address, value);
235 usleep((useconds_t)FEMBWriteSleepTime * 1e6);
236}

◆ WriteFEMBBits()

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

Definition at line 250 of file WIBBase.cpp.

251{
252 if ((iFEMB > 4) || (iFEMB < 1)) {
253 BUException::WIB_INDEX_OUT_OF_RANGE e;
254 e.Append("In WIBBase::WriteFEMB\n");
255 throw e;
256 }
257
258 uint32_t shiftVal = value & mask;
259 uint32_t regMask = (mask << pos);
260 uint32_t initVal = FEMB[iFEMB - 1]->Read(address);
261 uint32_t newVal = ((initVal & ~(regMask)) | (shiftVal << pos));
262
263 FEMB[iFEMB - 1]->WriteWithRetry(address, newVal);
264 usleep((useconds_t)FEMBWriteSleepTime * 1e6);
265}

◆ 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 81 of file WIBBase.cpp.

86{
87 // This is an incredibly inefficient version of this function since it does a dozen or so UDP transactions.
88 // This is done to be generic, but it could be hard-coded by assuming address offsets and bit maps and done in one
89 // write and one read.
90
91 // Set type of read
92 WriteWithRetry(base_address + ".RW", 0);
93 // Set address
94 WriteWithRetry(base_address + ".ADDR", address);
95 // Set read size
96 WriteWithRetry(base_address + ".BYTE_COUNT", byte_count);
97 // Send data to write
98 WriteWithRetry(base_address + ".WR_DATA", data);
99 // Wait for the last transaction to be done
100 while (ReadWithRetry(base_address + ".DONE") == 0x0) {
101 usleep(1000);
102 }
103 // Run transaction
104 WriteWithRetry(base_address + ".RUN", 0x1);
105
106 // Wait for the last transaction to be done
107 while (ReadWithRetry(base_address + ".DONE") == 0x0) {
108 usleep(1000);
109 }
110
111 if (!ignore_error && ReadWithRetry(base_address + ".ERROR")) {
112 // Reset the I2C firmware
113 WriteWithRetry(base_address + ".RESET", 1);
114 char trans_info[] = "wr 0xFFFFFFFF @ 0xFFFF";
115 sprintf(trans_info, "wr 0x%08X @ 0x%04X", data, address & 0xFFFF);
116 BUException::WIB_ERROR e;
117 e.Append("I2C Error on ");
118 e.Append(base_address.c_str());
119 e.Append(trans_info);
120 throw e;
121 }
122}

◆ WriteWithRetry() [1/2]

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

Definition at line 173 of file WIBBase.cpp.

174{
175 wib->WriteWithRetry(address, value);
176}

◆ WriteWithRetry() [2/2]

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

Definition at line 163 of file WIBBase.cpp.

164{
165 wib->WriteWithRetry(address, value);
166}

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: