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 &)
 
AddressTableoperator= (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_UDPio
 

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 10 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)
void Setup(std::string const &address, uint16_t port_offset=0)
Definition BNL_UDP.cpp:96
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 24 of file AddressTable_item.cpp.

24 {
25 //Check for null item
26 if(item == NULL){
27 BUException::NULL_POINTER e;
28 e.Append("Null Item pointer passed to AddEntry\n");
29 throw e;
30 }
31 //Check for invalid Mode
32 if((item->mode & Item::WRITE) &&
33 (item->mode & Item::ACTION)){
34 BUException::BAD_MODE e;
35 e.Append("AddEntry called with both WRITE and ACTION modes\n");
36 throw e;
37 }
38
39 //This function now owns the memory at item
40
41
42
43 //Add the item to the address map and check that it doesn't conflict with
44 std::map<uint32_t,std::vector<Item*> >::iterator itAddressItem = addressItemMap.find(item->address);
45 if(itAddressItem == addressItemMap.end()){
46 //This is the first entry at this address.
47 //Create the entry in addressItemMap and then push_back with our item.
48 addressItemMap[item->address].push_back(item);
49 //Update the iterator to the newly inserted item
50 itAddressItem = addressItemMap.find(item->address);
51 }else{
52 std::vector<Item*> & addressItems = itAddressItem->second;
53 //Check each entry for an overlap in masks. This is only ok if one is a subset, via it's name, of the other
54 for(size_t iItem = 0; iItem < addressItems.size();iItem++){
55 if(addressItems[iItem]->mask & item->mask){
56 //free for all now
57
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",
114 convstring.c_str());
115 item->sc_conv = ItemConversion::FromString("pass");
116 }
117 } else {
118 item->sc_conv = ItemConversion::FromString("pass");
119 }
120
121 //Everything is good, we've added it
122}
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.

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

◆ GetItem()

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

Definition at line 11 of file AddressTable_item.cpp.

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

◆ GetNames() [1/2]

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

Definition at line 10 of file AddressTable_search.cpp.

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

◆ GetNames() [2/2]

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

Definition at line 28 of file AddressTable_search.cpp.

28 {
29 std::vector<std::string > names;
30 //Fix regex
31 std::string rx = regex;
32 std::transform( rx.begin(), rx.end(), rx.begin(), ::toupper);
33 if( rx.size() > 6 && rx.substr(0,5) == "PERL:") {
34 printf("Using PERL-style regex unchanged\n");
35 rx = rx.substr( 5);
36 } else {
37 ReplaceStringInPlace( rx, ".", "#");
38 ReplaceStringInPlace( rx, "*",".*");
39 ReplaceStringInPlace( rx, "#","\\.");
40 }
41
42 //Create regex match
43 boost::regex re;
44 try{
45 re = boost::regex(rx);
46 }catch(std::exception &e){
47 BUException::BAD_REGEX e2;
48 e2.Append("In GetNames: (");
49 e2.Append(rx.c_str());
50 e2.Append(") ");
51 e2.Append(regex.c_str());
52 throw e2;
53 }
54 boost::cmatch match;
55 for(std::map<std::string,Item*>::iterator it = nameItemMap.begin();
56 it != nameItemMap.end();
57 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();};

◆ GetRetryCount()

uint64_t AddressTable::GetRetryCount ( )
inline

Definition at line 48 of file AddressTable.hh.

48{return io->GetRetryCount();};

◆ GetTables()

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

Definition at line 87 of file AddressTable_search.cpp.

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

◆ GetTagged()

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

Definition at line 135 of file AddressTable_search.cpp.

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

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

◆ Read() [1/2]

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

Definition at line 33 of file AddressTable_IO.cpp.

33 {
34 std::map<std::string,Item *>::iterator itNameItem = nameItemMap.find(registerName);
35 if(itNameItem == nameItemMap.end()){
36 BUException::INVALID_NAME e;
37 e.Append("Can't find item with name \"");
38 e.Append(registerName.c_str());
39 e.Append("\"");
40 throw e;
41 }
42 Item * item = itNameItem->second;
43 uint32_t val = io->Read(item->address);
44 val &= (item->mask);
45 val >>= item->offset;
46
47 return val;
48}

◆ Read() [2/2]

uint32_t AddressTable::Read ( uint16_t address)

Definition at line 10 of file AddressTable_IO.cpp.

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

◆ ReadWithRetry() [1/2]

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

Definition at line 50 of file AddressTable_IO.cpp.

50 {
51 std::map<std::string,Item *>::iterator itNameItem = nameItemMap.find(registerName);
52 if(itNameItem == nameItemMap.end()){
53 BUException::INVALID_NAME e;
54 e.Append("Can't find item with name \"");
55 e.Append(registerName.c_str());
56 e.Append("\"");
57 throw e;
58 }
59 Item * item = itNameItem->second;
60 uint32_t val = io->ReadWithRetry(item->address);
61 val &= (item->mask);
62 val >>= item->offset;
63
64 return val;
65}

◆ ReadWithRetry() [2/2]

uint32_t AddressTable::ReadWithRetry ( uint16_t address)

Definition at line 13 of file AddressTable_IO.cpp.

13 {
14 return io->ReadWithRetry(address);
15}

◆ Write() [1/6]

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

Definition at line 110 of file AddressTable_IO.cpp.

110 {
111 Write(registerName,values.data(),values.size());
112}
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 113 of file AddressTable_IO.cpp.

113 {
114 std::map<std::string,Item *>::iterator itNameItem = nameItemMap.find(registerName);
115 if(itNameItem == nameItemMap.end()){
116 BUException::INVALID_NAME e;
117 e.Append("Can't find item with name \"");
118 e.Append(registerName.c_str());
119 e.Append("\"");
120 throw e;
121 }
122 Item * item = itNameItem->second;
123 //Check if this entry controls all the bits
124 if(item->mask != 0xFFFFFFFF){
125 BUException::BAD_BLOCK_WRITE e;
126 e.Append("Mask is not 0xFFFFFFFF\n");
127 throw e;
128 }
129 io->Write(item->address,values,word_count);
130}

◆ Write() [3/6]

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

Definition at line 67 of file AddressTable_IO.cpp.

67 {
68 std::map<std::string,Item *>::iterator itNameItem = nameItemMap.find(registerName);
69 if(itNameItem == nameItemMap.end()){
70 BUException::INVALID_NAME e;
71 e.Append("Can't find item with name \"");
72 e.Append(registerName.c_str());
73 e.Append("\"");
74 throw e;
75 }
76 Item * item = itNameItem->second;
77 //Check if this entry controls all the bits
78 uint32_t buildingVal =0;
79 if(item->mask != 0xFFFFFFFF){
80 //Since there are bits this register we don't control, we need to see what they currently are
81 buildingVal = io->Read(item->address);
82 buildingVal &= ~(item->mask);
83 }
84 buildingVal |= (item->mask & (val << item->offset));
85 io->Write(item->address,buildingVal);
86}

◆ Write() [4/6]

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

Definition at line 25 of file AddressTable_IO.cpp.

25 {
26 io->Write(address,values);
27}

◆ Write() [5/6]

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

Definition at line 28 of file AddressTable_IO.cpp.

28 {
29 io->Write(address,values,word_count);
30}

◆ Write() [6/6]

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

Definition at line 18 of file AddressTable_IO.cpp.

18 {
19 io->Write(address,data);
20}

◆ WriteWithRetry() [1/2]

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

Definition at line 88 of file AddressTable_IO.cpp.

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

◆ WriteWithRetry() [2/2]

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

Definition at line 21 of file AddressTable_IO.cpp.

21 {
22 io->WriteWithRetry(address,data);
23}

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: