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

#include <AddressTable.hh>

Collaboration diagram for AddressTable:
[legend]

Public Member Functions

 AddressTable (std::string const &addressTableName, std::string const &deviceAddress, uint16_t offset)
uint32_t Read (uint16_t)
uint32_t Read (std::string registerName)
uint32_t ReadWithRetry (uint16_t)
uint32_t ReadWithRetry (std::string registerName)
void Write (uint16_t, uint32_t)
void Write (std::string registerName, uint32_t val)
void WriteWithRetry (uint16_t, uint32_t)
void WriteWithRetry (std::string registerName, uint32_t val)
void Write (uint16_t, std::vector< uint32_t > const &values)
void Write (std::string registerName, std::vector< uint32_t > const &values)
void Write (uint16_t, uint32_t const *values, size_t word_count)
void Write (std::string registerName, uint32_t const *values, size_t word_count)
Item const * GetItem (std::string const &)
std::vector< Item const * > GetTagged (std::string const &tag)
std::vector< std::string > GetNames ()
std::vector< std::string > GetNames (std::string const &regex)
std::vector< std::string > GetAddresses (uint16_t lower, uint16_t upper)
std::string GetRemoteAddress ()
std::vector< std::string > GetTables (std::string const &regex)
uint64_t GetRetryCount ()

Private Member Functions

 AddressTable ()
 AddressTable (const AddressTable &)
AddressTable & operator= (const AddressTable &)
void LoadFile (std::string const &, std::string const &prefix="", uint16_t offset=0)
void ProcessLine (std::string const &, size_t, std::string const &prefix="", uint16_t offset=0)
void AddEntry (Item *)

Private Attributes

int fileLevel
std::map< uint32_t, std::vector< Item * > > addressItemMap
std::map< std::string, Item * > nameItemMap
BNL_UDP * io

Detailed Description

Definition at line 26 of file AddressTable.hh.

Constructor & Destructor Documentation

◆ AddressTable() [1/3]

AddressTable::AddressTable ( std::string const & addressTableName,
std::string const & deviceAddress,
uint16_t offset )

Definition at line 9 of file AddressTable.cpp.

10{
11 fileLevel = 0;
12 io = new BNL_UDP;
13 io->Setup(deviceAddress, offset);
14 io->SetWriteAck(true);
15 LoadFile(addressTableName);
16}
void LoadFile(std::string const &, std::string const &prefix="", uint16_t offset=0)
BNL_UDP * io
void SetWriteAck(bool val)
Definition BNL_UDP.hh:22
void Setup(std::string const &address, uint16_t port_offset=0)
Definition BNL_UDP.cpp:104
double offset

◆ AddressTable() [2/3]

AddressTable::AddressTable ( )
private

◆ AddressTable() [3/3]

AddressTable::AddressTable ( const AddressTable & )
private

Member Function Documentation

◆ AddEntry()

void AddressTable::AddEntry ( Item * item)
private

Definition at line 27 of file AddressTable_item.cpp.

28{
29 // Check for null item
30 if (item == NULL) {
31 BUException::NULL_POINTER e;
32 e.Append("Null Item pointer passed to AddEntry\n");
33 throw e;
34 }
35 // Check for invalid Mode
36 if ((item->mode & Item::WRITE) && (item->mode & Item::ACTION)) {
37 BUException::BAD_MODE e;
38 e.Append("AddEntry called with both WRITE and ACTION modes\n");
39 throw e;
40 }
41
42 // This function now owns the memory at item
43
44 // Add the item to the address map and check that it doesn't conflict with
45 std::map<uint32_t, std::vector<Item*>>::iterator itAddressItem = addressItemMap.find(item->address);
46 if (itAddressItem == addressItemMap.end()) {
47 // This is the first entry at this address.
48 // Create the entry in addressItemMap and then push_back with our item.
49 addressItemMap[item->address].push_back(item);
50 // Update the iterator to the newly inserted item
51 itAddressItem = addressItemMap.find(item->address);
52 } else {
53 std::vector<Item*>& addressItems = itAddressItem->second;
54 // Check each entry for an overlap in masks. This is only ok if one is a subset, via it's name, of the other
55 for (size_t iItem = 0; iItem < addressItems.size(); iItem++) {
56 if (addressItems[iItem]->mask & item->mask) {
57 // free for all now
58
59 // These items overlap in mask
60 // CHeck that one or the other contains the other starting at pos 0.
61 // in other words, that they are the same up until the end of the shorter one
62 // if( (addressItems[iItem]->name.find(item->name) != 0) &&
63 // (item->name.find(addressItems[iItem]->name) != 0) ) {
64 // BUException::BAD_MODE e;
65 // e.Append("Entry: ");
66 // e.Append(item->name.c_str());
67 // e.Append(" conflicts with entry ");
68 // e.Append(addressItems[iItem]->name.c_str());
69 // e.Append("\n");
70 // throw e;
71 // }
72 }
73 }
74 addressItems.push_back(item);
75 }
76
77 // Add the item to the list of addresses
78 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(item->name);
79 if (itNameItem == nameItemMap.end()) {
80 // Add this entry and everything is good.
81 nameItemMap[item->name] = item;
82 } else {
83 // There was a collision in entry name, remote the newly added element and throw an exception
84
85 // delete the addition to the vector
86 std::vector<Item*>& addressItems = itAddressItem->second;
87 for (size_t iItem = 0; iItem < addressItems.size(); iItem++) {
88 if (addressItems[iItem] == item) {
89 // Found what we just added, removing
90 addressItems.erase(addressItems.begin() + iItem);
91 }
92 }
93 // throw exception about collission
94 BUException::NAME_COLLISION e;
95 e.Append("Item ");
96 e.Append(item->name.c_str());
97 e.Append(" already existed\n");
98
99 // delete the item
100 delete item;
101
102 throw e;
103 }
104
105 // Create Slow Control ItemConversion for this item
106
107 item->sc_conv = (ItemConversion*)0x0;
108
109 if (item->user.count(SC_key_conv)) {
110 std::string convstring = item->user.at(SC_key_conv);
111 item->sc_conv = ItemConversion::FromString(convstring);
112 if (!item->sc_conv) {
113 fprintf(stderr, "Warning: Unknown item conversion \"%s\"\n", convstring.c_str());
114 item->sc_conv = ItemConversion::FromString("pass");
115 }
116 } else {
117 item->sc_conv = ItemConversion::FromString("pass");
118 }
119
120 // Everything is good, we've added it
121}
static const char * SC_key_conv
std::map< uint32_t, std::vector< Item * > > addressItemMap
std::map< std::string, Item * > nameItemMap
static ItemConversion * FromString(std::string convstring)
std::string name
boost::unordered_map< std::string, std::string > user
uint16_t address
uint32_t mask
ItemConversion * sc_conv
uint8_t mode

◆ GetAddresses()

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

Definition at line 66 of file AddressTable_search.cpp.

67{
68 std::vector<std::string> names;
69 // Get an iterator into our map of addresses to vectors of items that is the first entry that is not less than lower
70 std::map<uint32_t, std::vector<Item*>>::iterator itAddress = addressItemMap.lower_bound(lower);
71 for (; itAddress != addressItemMap.end(); itAddress++) {
72 // loop over all following address keys
73
74 if (itAddress->first < upper) {
75 // Address key is less than uppper, so add its entries to names
76 std::vector<Item*>& items = itAddress->second;
77 for (size_t iItem = 0; iItem < items.size(); iItem++) {
78 names.push_back(items[iItem]->name);
79 }
80 } else {
81 // address key is greater than or equal to upper, so stop
82 break;
83 }
84 }
85 return names;
86}

◆ GetItem()

Item const * AddressTable::GetItem ( std::string const & registerName)

Definition at line 12 of file AddressTable_item.cpp.

13{
14 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
15 if (itNameItem == nameItemMap.end()) {
16 BUException::INVALID_NAME e;
17 e.Append("Can't find item with name \"");
18 e.Append(registerName.c_str());
19 e.Append("\"");
20 throw e;
21 }
22 Item* item = itNameItem->second;
23 return item;
24}

◆ GetNames() [1/2]

std::vector< std::string > AddressTable::GetNames ( )

Definition at line 10 of file AddressTable_search.cpp.

11{
12 std::vector<std::string> names;
13 for (std::map<std::string, Item*>::iterator it = nameItemMap.begin(); it != nameItemMap.end(); it++) {
14 names.push_back(it->first);
15 }
16 return names;
17}

◆ GetNames() [2/2]

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

Definition at line 29 of file AddressTable_search.cpp.

30{
31 std::vector<std::string> names;
32 // Fix regex
33 std::string rx = regex;
34 std::transform(rx.begin(), rx.end(), rx.begin(), ::toupper);
35 if (rx.size() > 6 && rx.substr(0, 5) == "PERL:") {
36 printf("Using PERL-style regex unchanged\n");
37 rx = rx.substr(5);
38 } else {
39 ReplaceStringInPlace(rx, ".", "#");
40 ReplaceStringInPlace(rx, "*", ".*");
41 ReplaceStringInPlace(rx, "#", "\\.");
42 }
43
44 // Create regex match
45 boost::regex re;
46 try {
47 re = boost::regex(rx);
48 } catch (std::exception& e) {
49 BUException::BAD_REGEX e2;
50 e2.Append("In GetNames: (");
51 e2.Append(rx.c_str());
52 e2.Append(") ");
53 e2.Append(regex.c_str());
54 throw e2;
55 }
56 boost::cmatch match;
57 for (std::map<std::string, Item*>::iterator it = nameItemMap.begin(); it != nameItemMap.end(); it++) {
58 if (regex_match(it->first.c_str(), match, re)) {
59 names.push_back(it->first);
60 }
61 }
62 return names;
63}
void ReplaceStringInPlace(std::string &subject, const std::string &search, const std::string &replace)
dunedaq::conffwk::relationship_t match(T const &, T const &)

◆ GetRemoteAddress()

std::string AddressTable::GetRemoteAddress ( )
inline

Definition at line 46 of file AddressTable.hh.

46{return io->GetAddress();};
std::string GetAddress()
Definition BNL_UDP.hh:32

◆ GetRetryCount()

uint64_t AddressTable::GetRetryCount ( )
inline

Definition at line 48 of file AddressTable.hh.

48{return io->GetRetryCount();};
uint64_t GetRetryCount()
Definition BNL_UDP.hh:34

◆ GetTables()

std::vector< std::string > AddressTable::GetTables ( std::string const & regex)

Definition at line 89 of file AddressTable_search.cpp.

90{
91
92 // Fix regex
93 std::string rx = regex;
94 // std::transform( rx.begin(), rx.end(), rx.begin(), ::toupper);
95 if (rx.size() > 6 && rx.substr(0, 5) == "PERL:") {
96 printf("Using PERL-style regex unchanged\n");
97 rx = rx.substr(5);
98 } else {
99 ReplaceStringInPlace(rx, ".", "#");
100 ReplaceStringInPlace(rx, "*", ".*");
101 ReplaceStringInPlace(rx, "#", "\\.");
102 }
103
104 // Create regex match
105 boost::regex re;
106 try {
107 re = boost::regex(rx);
108 } catch (std::exception& e) {
109 BUException::BAD_REGEX e2;
110 e2.Append("In GetTables: (");
111 e2.Append(rx.c_str());
112 e2.Append(") ");
113 e2.Append(regex.c_str());
114 throw e2;
115 }
116 std::set<std::string> tableSearch;
117 boost::cmatch match;
118 for (std::map<std::string, Item*>::iterator it = nameItemMap.begin(); it != nameItemMap.end(); it++) {
119 // Check if this item has a table entry
120 if (it->second->user.find("Table") != it->second->user.end()) {
121 std::string const& tableName = it->second->user.find("Table")->second;
122 // check if this table isn't already in the set
123 if (tableSearch.find(tableName) == tableSearch.end()) {
124 // Check if we should add it
125 if (regex_match(tableName.c_str(), match, re)) {
126 // Add this table to the set
127 tableSearch.insert(tableName);
128 }
129 }
130 }
131 }
132 std::vector<std::string> tables(tableSearch.begin(), tableSearch.end());
133 return tables;
134}

◆ GetTagged()

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

Definition at line 137 of file AddressTable_search.cpp.

138{
139 std::vector<const Item*> matches;
140 for (std::map<std::string, Item*>::iterator it = nameItemMap.begin(); it != nameItemMap.end(); it++) {
141 // Check if this item has the tag as an entry
142 if (it->second->user.find(tag) != it->second->user.end()) {
143 matches.push_back(it->second);
144 }
145 }
146 return matches;
147}

◆ LoadFile()

void AddressTable::LoadFile ( std::string const & fileName,
std::string const & prefix = "",
uint16_t offset = 0 )
private

Definition at line 12 of file AddressTable_fileIO.cpp.

13{
14
15 std::ifstream inFile(fileName.c_str());
16 if (!inFile.is_open()) {
17 std::string envBasedFileName = fileName;
18 // Try to use address table path if it exists
19 if (getenv("WIBMOD_SHARE") != NULL) {
20 envBasedFileName = getenv("WIBMOD_SHARE");
21 envBasedFileName += "/config/WIB1/tables/";
22 envBasedFileName += fileName;
23 inFile.open(envBasedFileName.c_str());
24 }
25 if (!inFile.is_open()) {
26 BUException::BAD_FILE e;
27 e.Append("File not found: ");
28 e.Append(envBasedFileName.c_str());
29 throw e;
30 }
31 }
32 const size_t bufferSize = 1000;
33 char buffer[bufferSize + 1];
34 memset(buffer, 0, bufferSize + 1);
35 uint32_t lineNumber = 1;
36 while (!inFile.eof()) {
37 inFile.getline(buffer, bufferSize);
38 ProcessLine(std::string(buffer), lineNumber, prefix, offset);
39 lineNumber++;
40 }
41}
void ProcessLine(std::string const &, size_t, std::string const &prefix="", uint16_t offset=0)

◆ operator=()

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

◆ ProcessLine()

void AddressTable::ProcessLine ( std::string const & line,
size_t lineNumber,
std::string const & prefix = "",
uint16_t offset = 0 )
private

Definition at line 44 of file AddressTable_fileIO.cpp.

45{
46 // First, ignore commments
47 std::string activeLine = line.substr(0, line.find('#'));
48
49 // Tokenize the activeLine
50 boost::char_separator<char> sep(" ");
51 boost::tokenizer<boost::char_separator<char>> tokens(activeLine, sep);
52 boost::tokenizer<boost::char_separator<char>>::iterator itToken = tokens.begin();
53
54 // crate a new Item;
55 Item* item = new Item;
56 size_t iToken = 0;
57 for (; itToken != tokens.end(); itToken++) {
58 switch (iToken) {
59 case 0: { // keep name out of everyone else's scope
60 // Assign name
61
62 std::string name(*itToken);
63 if (!prefix.empty()) {
64 // we have a prefix to add on to the name
65 name = prefix + std::string(".") + name;
66 }
67
68 while ((name.size() > 0) && ('.' == name[name.size() - 1])) {
69 // If the trailing entry is a dot (level marker) drop it as this entry just means the prefix
70 name.erase(name.size() - 1);
71 }
72
73 if (name.size() == 0) {
74 // We have an emtpy name, this is bad and we should throw
75 BUException::INVALID_NAME e;
76 e.Append("Empty name");
77 throw e;
78 }
79
80 boost::to_upper(name);
81
82 // Assign the name to this item
83 item->name.assign(name);
84 iToken++;
85 } break;
86 case 1:
87 // Assign address and apply any offset
88 // itToken means we don't have to check for size of string
89 item->address = strtoul(itToken->c_str(), NULL, 0) + offset;
90 iToken++;
91 break;
92 case 2:
93
94 // Check if this is an include line
95 if (!isdigit((itToken->c_str()[0]))) {
96 // we have an include file, append all following tokens together to use as the filename.
97 std::string filename(*itToken);
98 itToken++;
99 while (itToken != tokens.end()) {
100 filename += " ";
101 filename += *itToken;
102 itToken++;
103 }
104 fileLevel++;
105 if (fileLevel <= MAX_FILE_LEVEL) {
106 LoadFile(filename, item->name, item->address);
107 } else {
108 BUException::MAX_INCLUDE_FILE_DEPTH e;
109 e.Append("File: ");
110 e.Append(filename);
111 e.Append(" at prefix ");
112 e.Append(item->name);
113 e.Append(" is too deep\n");
114 throw e;
115 }
116 fileLevel--;
117 // Delete fake partial item
118 delete item;
119 // return to move on to the next line of the main file
120 return;
121 }
122
123 // Assign mask
124 item->mask = strtoul(itToken->c_str(), NULL, 0);
125 // stolen from https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel
126 // Find the bitshift offset
127 {
128 unsigned int v = item->mask; // 32-bit word input to count zero bits on right
129 unsigned int c = 32; // c will be the number of zero bits on the right
130 v &= -signed(v);
131 if (v) {
132 c--;
133 }
134 if (v & 0x0000FFFF) {
135 c -= 16;
136 }
137 if (v & 0x00FF00FF) {
138 c -= 8;
139 }
140 if (v & 0x0F0F0F0F) {
141 c -= 4;
142 }
143 if (v & 0x33333333) {
144 c -= 2;
145 }
146 if (v & 0x55555555) {
147 c -= 1;
148 }
149 item->offset = c;
150 }
151
152 iToken++;
153 break;
154 case 3:
155 // Assign mode
156 item->mode = 0;
157
158 // Read
159 if (itToken->find('r') != std::string::npos) {
160 item->mode |= Item::READ;
161 } else if (itToken->find('R') != std::string::npos) {
162 item->mode |= Item::READ;
163 }
164
165 // Write
166 if (itToken->find('w') != std::string::npos) {
167 item->mode |= Item::WRITE;
168 } else if (itToken->find('W') != std::string::npos) {
169 item->mode |= Item::WRITE;
170 }
171
172 // Action
173 if (itToken->find('a') != std::string::npos) {
174 item->mode |= Item::ACTION;
175 } else if (itToken->find('A') != std::string::npos) {
176 item->mode |= Item::ACTION;
177 }
178
179 iToken++;
180 break;
181 default:
182 // parse user arguments
183 // repeated arguments will be over-written
184
185 // Find if this is an argument or a flag, flags have no equal signs
186 if (itToken->find('=') == std::string::npos) {
187 // Create an entry for this with no data
188 item->user[*itToken];
189 iToken++;
190 } else {
191 // Get the name of the user value
192 size_t equalSignPos = itToken->find('=');
193 // make sure there isn't a """ before the =
194 if (itToken->find('"') != std::string::npos) {
195 if (itToken->find('"') < equalSignPos) {
196 BUException::BAD_TOKEN e;
197 e.Append("Malformed token : ");
198 e.Append(itToken->c_str());
199 e.Append(" on line ");
200 char numberBuffer[14] = "\0\0\0\0\0\0\0\0\0\0\0\0";
201 snprintf(numberBuffer, 12, "%zu\n", lineNumber);
202 e.Append(numberBuffer);
203 e.Append("Bad line: ");
204 e.Append(activeLine);
205 e.Append("\n");
206 throw e;
207 }
208 }
209 // cache the name of the user field
210 std::string name = itToken->substr(0, equalSignPos);
211 // Parse the rest of the user value if there is more size
212 if (itToken->size() - 1 == equalSignPos) {
213 BUException::BAD_TOKEN e;
214 e.Append("Malformed token : ");
215 e.Append(itToken->c_str());
216 e.Append(" on line ");
217 char numberBuffer[14] = "\0\0\0\0\0\0\0\0\0\0\0\0";
218 snprintf(numberBuffer, 12, "%zu\n", lineNumber);
219 e.Append(numberBuffer);
220 throw e;
221 }
222 // star this user field's data (data after the '=' char)
223 std::string val = itToken->substr(equalSignPos + 1);
224 if (val[0] != '"') {
225 // We have a simple entry that has no quotes
226 item->user[name] = val;
227 iToken++;
228 } else {
229 // We have a quoted value
230 val.erase(0, 1); // remove the quote
231
232 // Check if this is still a simple entry, but with quotes
233 if (val.find('"') != std::string::npos) {
234 // We have another quote, remove it and everything after it
235 val = val.substr(0, val.find('"'));
236 } else {
237 // We have a complicated value
238 itToken++;
239 while (itToken != tokens.end()) {
240 val.append(" ");
241 val.append(*itToken);
242 if ((*itToken)[itToken->size() - 1] == '"') {
243 // stop now that we've reached the closing quote
244 // remove it from the string
245 val.erase(val.size() - 1);
246 break;
247 }
248 iToken++;
249 itToken++;
250 }
251 }
252 // convert "\n" to '\n'
253 while (val.find("\\n") != std::string::npos) {
254 val.replace(val.find("\\n"), 2, std::string("\n"));
255 }
256 item->user[name] = val;
257 }
258 }
259 break;
260 }
261 if (itToken == tokens.end()) {
262 break;
263 }
264 }
265
266 if (iToken >= 4) {
267 AddEntry(item);
268 } else {
269 delete item;
270 }
271}
#define MAX_FILE_LEVEL
void AddEntry(Item *)
uint8_t offset
default char v[0]

◆ Read() [1/2]

uint32_t AddressTable::Read ( std::string registerName)

Definition at line 43 of file AddressTable_IO.cpp.

44{
45 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
46 if (itNameItem == nameItemMap.end()) {
47 BUException::INVALID_NAME e;
48 e.Append("Can't find item with name \"");
49 e.Append(registerName.c_str());
50 e.Append("\"");
51 throw e;
52 }
53 Item* item = itNameItem->second;
54 uint32_t val = io->Read(item->address);
55 val &= (item->mask);
56 val >>= item->offset;
57
58 return val;
59}
uint32_t Read(uint16_t address)
Definition BNL_UDP.cpp:411

◆ Read() [2/2]

uint32_t AddressTable::Read ( uint16_t address)

Definition at line 10 of file AddressTable_IO.cpp.

11{
12 return io->Read(address);
13}

◆ ReadWithRetry() [1/2]

uint32_t AddressTable::ReadWithRetry ( std::string registerName)

Definition at line 62 of file AddressTable_IO.cpp.

63{
64 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
65 if (itNameItem == nameItemMap.end()) {
66 BUException::INVALID_NAME e;
67 e.Append("Can't find item with name \"");
68 e.Append(registerName.c_str());
69 e.Append("\"");
70 throw e;
71 }
72 Item* item = itNameItem->second;
73 uint32_t val = io->ReadWithRetry(item->address);
74 val &= (item->mask);
75 val >>= item->offset;
76
77 return val;
78}
uint32_t ReadWithRetry(uint16_t address, uint8_t retry_count=10)
Definition BNL_UDP.cpp:388

◆ ReadWithRetry() [2/2]

uint32_t AddressTable::ReadWithRetry ( uint16_t address)

Definition at line 15 of file AddressTable_IO.cpp.

16{
17 return io->ReadWithRetry(address);
18}

◆ Write() [1/6]

void AddressTable::Write ( std::string registerName,
std::vector< uint32_t > const & values )

Definition at line 127 of file AddressTable_IO.cpp.

128{
129 Write(registerName, values.data(), values.size());
130}
void Write(uint16_t, uint32_t)

◆ Write() [2/6]

void AddressTable::Write ( std::string registerName,
uint32_t const * values,
size_t word_count )

Definition at line 132 of file AddressTable_IO.cpp.

133{
134 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
135 if (itNameItem == nameItemMap.end()) {
136 BUException::INVALID_NAME e;
137 e.Append("Can't find item with name \"");
138 e.Append(registerName.c_str());
139 e.Append("\"");
140 throw e;
141 }
142 Item* item = itNameItem->second;
143 // Check if this entry controls all the bits
144 if (item->mask != 0xFFFFFFFF) {
145 BUException::BAD_BLOCK_WRITE e;
146 e.Append("Mask is not 0xFFFFFFFF\n");
147 throw e;
148 }
149 io->Write(item->address, values, word_count);
150}
void Write(uint16_t address, uint32_t value)
Definition BNL_UDP.cpp:230

◆ Write() [3/6]

void AddressTable::Write ( std::string registerName,
uint32_t val )

Definition at line 81 of file AddressTable_IO.cpp.

82{
83 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
84 if (itNameItem == nameItemMap.end()) {
85 BUException::INVALID_NAME e;
86 e.Append("Can't find item with name \"");
87 e.Append(registerName.c_str());
88 e.Append("\"");
89 throw e;
90 }
91 Item* item = itNameItem->second;
92 // Check if this entry controls all the bits
93 uint32_t buildingVal = 0;
94 if (item->mask != 0xFFFFFFFF) {
95 // Since there are bits this register we don't control, we need to see what they currently are
96 buildingVal = io->Read(item->address);
97 buildingVal &= ~(item->mask);
98 }
99 buildingVal |= (item->mask & (val << item->offset));
100 io->Write(item->address, buildingVal);
101}

◆ Write() [4/6]

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

Definition at line 32 of file AddressTable_IO.cpp.

33{
34 io->Write(address, values);
35}

◆ Write() [5/6]

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

Definition at line 37 of file AddressTable_IO.cpp.

38{
39 io->Write(address, values, word_count);
40}

◆ Write() [6/6]

void AddressTable::Write ( uint16_t address,
uint32_t data )

Definition at line 21 of file AddressTable_IO.cpp.

22{
23 io->Write(address, data);
24}

◆ WriteWithRetry() [1/2]

void AddressTable::WriteWithRetry ( std::string registerName,
uint32_t val )

Definition at line 104 of file AddressTable_IO.cpp.

105{
106 std::map<std::string, Item*>::iterator itNameItem = nameItemMap.find(registerName);
107 if (itNameItem == nameItemMap.end()) {
108 BUException::INVALID_NAME e;
109 e.Append("Can't find item with name \"");
110 e.Append(registerName.c_str());
111 e.Append("\"");
112 throw e;
113 }
114 Item* item = itNameItem->second;
115 // Check if this entry controls all the bits
116 uint32_t buildingVal = 0;
117 if (item->mask != 0xFFFFFFFF) {
118 // Since there are bits this register we don't control, we need to see what they currently are
119 buildingVal = io->ReadWithRetry(item->address);
120 buildingVal &= ~(item->mask);
121 }
122 buildingVal |= (item->mask & (val << item->offset));
123 io->WriteWithRetry(item->address, buildingVal);
124}
void WriteWithRetry(uint16_t address, uint32_t value, uint8_t retry_count=10)
Definition BNL_UDP.cpp:208

◆ WriteWithRetry() [2/2]

void AddressTable::WriteWithRetry ( uint16_t address,
uint32_t data )

Definition at line 26 of file AddressTable_IO.cpp.

27{
28 io->WriteWithRetry(address, data);
29}

Member Data Documentation

◆ addressItemMap

std::map<uint32_t,std::vector<Item*> > AddressTable::addressItemMap
private

Definition at line 64 of file AddressTable.hh.

◆ fileLevel

int AddressTable::fileLevel
private

Definition at line 56 of file AddressTable.hh.

◆ io

BNL_UDP* AddressTable::io
private

Definition at line 68 of file AddressTable.hh.

◆ nameItemMap

std::map<std::string,Item*> AddressTable::nameItemMap
private

Definition at line 66 of file AddressTable.hh.


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