Skip to content

Commit fc7b34e

Browse files
authored
Merge pull request #8 from BU-Tools/releases/v1.0
Releases/v1.0
2 parents 645fcdb + 3f6ce9e commit fc7b34e

6 files changed

Lines changed: 42 additions & 22 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ endif
4242
LIBRARIES = -lcurses \
4343
-lToolException \
4444
-lBUTool_IPBusIO \
45+
-lBUTool_IPBusRegHelpers \
4546
-lBUTool_IPBusStatus \
47+
-lBUTool_IPBusRegHelpers \
4648
-lBUTool_BUTextIO \
4749
-lboost_regex \
4850
-lboost_filesystem

include/GenericIPBus/GenericIPBus.hh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __GENERIC_IPBUS_HH__
33

44
#include <IPBusIO/IPBusConnection.hh>
5+
#include <IPBusIO/IPBusIO.hh>
56
#include <BUException/ExceptionBase.hh>
67

78

@@ -10,9 +11,10 @@
1011

1112
#include <stdint.h>
1213

13-
class GenericIPBus : public IPBusConnection{
14+
class GenericIPBus : public IPBusConnection,
15+
public IPBusIO{
1416
public:
15-
GenericIPBus(); //User should call Connect inhereted from IPBusConnection
17+
GenericIPBus(std::vector<std::string> const & args);
1618
~GenericIPBus();
1719

1820
//The IPBus connection and read/write functions come from the IPBusConnection class.

include/GenericIPBus_device/GenericIPBus_device.hh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@
1818
#include <GenericIPBus/GenericIPBus.hh>
1919

2020
namespace BUTool{
21+
22+
//This holder class is used to force the GenericIPBus class that would normally
23+
//be in the GenericIPBusDevice class to be initialized before the IPBusRegHelper
24+
//so that it can be past to the IPBusRegHelper's constructor.
25+
class GenericIPBusHolder{
26+
public:
27+
GenericIPBusHolder(std::vector<std::string> const & arg){
28+
SM = std::make_shared<GenericIPBus>(arg);
29+
};
30+
protected:
31+
std::shared_ptr<GenericIPBus> SM;
32+
private:
33+
GenericIPBusHolder();
34+
};
35+
2136

22-
class GenericIPBusDevice: public CommandList<GenericIPBusDevice>, public IPBusRegHelper{
37+
class GenericIPBusDevice: public CommandList<GenericIPBusDevice>,
38+
public GenericIPBusHolder,
39+
public IPBusRegHelper{
2340
public:
2441
GenericIPBusDevice(std::vector<std::string> arg);
2542
~GenericIPBusDevice();
@@ -28,7 +45,6 @@ namespace BUTool{
2845

2946

3047
private:
31-
GenericIPBus * SM;
3248

3349
//Here is where you update the map between string and function
3450
void LoadCommandList();

src/GenericIPBus/GenericIPBus.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#include <GenericIPBus/GenericIPBus.hh>
22
#include <fstream> //std::ofstream
33

4-
GenericIPBus::GenericIPBus():IPBusConnection("GenericIPBus"){
4+
GenericIPBus::GenericIPBus(std::vector<std::string> const & args):
5+
IPBusConnection("GenericIPBus",args),
6+
IPBusIO( ((IPBusConnection*)this)->GetHWInterface()){
7+
//Set case sensistive
8+
SetCase(RegisterHelperIO::RegisterNameCase::CASE_SENSITIVE);
9+
510
}
611

712
GenericIPBus::~GenericIPBus(){

src/GenericIPBus/GenericIPBus_debug.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
void GenericIPBus::DebugDump(std::ostream & output){
77
//Get all the register names
8-
std::vector<std::string> registers = myMatchRegex("*");
8+
std::vector<std::string> registers = GetRegsRegex("*");
99
int sleepLength=1;
1010

1111
//read out each
@@ -17,7 +17,7 @@ void GenericIPBus::DebugDump(std::ostream & output){
1717
output << std::setw(60) << std::setfill(' ') << std::right << *itReg;
1818
output << " : ";
1919
try{
20-
val = RegReadRegister(*itReg);
20+
val = ReadRegister(*itReg);
2121
output << "0x" << std::setfill('0') << std::setw(8) << std::hex << val << std::endl;
2222
}catch(BUException::REG_READ_DENIED & e){
2323
output << "Write Only" << std::endl;
@@ -37,7 +37,7 @@ void GenericIPBus::DebugDump(std::ostream & output){
3737
output << std::setw(60) << std::setfill(' ') << std::right << *itReg;
3838
output << " : ";
3939
try{
40-
val = RegReadRegister(*itReg);
40+
val = ReadRegister(*itReg);
4141
output << "0x" << std::setfill('0') << std::setw(8) << std::hex << val << std::endl;
4242
}catch(BUException::REG_READ_DENIED & e){
4343
output << "Write Only" << std::endl;

src/GenericIPBus_device/GenericIPBus_device.cc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,15 @@ using namespace BUTool;
2121

2222
GenericIPBusDevice::GenericIPBusDevice(std::vector<std::string> arg)
2323
: CommandList<GenericIPBusDevice>("GenericIPBus"),
24-
IPBusRegHelper(){
25-
//Set case sensistive
26-
SetCase(RegisterHelper::RegisterNameCase::CASE_SENSITIVE);
27-
SM = new GenericIPBus();
28-
SM->Connect(arg);
29-
SetHWInterface(SM->GetHWInterface()); //Pass the inherited version of IPBusIO inside of IPBusREgHelper a pointer to the real hw interface
30-
31-
// setup RegisterHelper's BUTextIO pointer
32-
SetupTextIO();
33-
24+
GenericIPBusHolder(arg),
25+
IPBusRegHelper(std::static_pointer_cast<IPBusIO>(SM),
26+
BUTool::CommandListBase::TextIO){
27+
3428
//setup commands
3529
LoadCommandList();
3630
}
3731

3832
GenericIPBusDevice::~GenericIPBusDevice(){
39-
if(NULL != SM){
40-
delete SM;
41-
}
4233
}
4334

4435

@@ -68,7 +59,11 @@ void GenericIPBusDevice::LoadCommandList(){
6859
&GenericIPBusDevice::RegisterAutoComplete);
6960
AddCommandAlias("ro","readoffset");
7061

71-
62+
AddCommand("readconvert",&GenericIPBusDevice::ReadConvert,
63+
"Read and convert register\n" \
64+
"Usage: \n" \
65+
" readconvert reg\n",
66+
&GenericIPBusDevice::RegisterAutoComplete);
7267

7368
AddCommand("write",&GenericIPBusDevice::Write,
7469
"Write to GenericIPBus\n" \

0 commit comments

Comments
 (0)