File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4242LIBRARIES = -lcurses \
4343 -lToolException \
4444 -lBUTool_IPBusIO \
45+ -lBUTool_IPBusRegHelpers \
4546 -lBUTool_IPBusStatus \
47+ -lBUTool_IPBusRegHelpers \
4648 -lBUTool_BUTextIO \
4749 -lboost_regex \
4850 -lboost_filesystem
Original file line number Diff line number Diff line change 22#define __GENERIC_IPBUS_HH__
33
44#include < IPBusIO/IPBusConnection.hh>
5+ #include < IPBusIO/IPBusIO.hh>
56#include < BUException/ExceptionBase.hh>
67
78
1011
1112#include < stdint.h>
1213
13- class GenericIPBus : public IPBusConnection {
14+ class GenericIPBus : public IPBusConnection ,
15+ public IPBusIO{
1416public:
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.
Original file line number Diff line number Diff line change 1818#include < GenericIPBus/GenericIPBus.hh>
1919
2020namespace 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 ();
Original file line number Diff line number Diff line change 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
712GenericIPBus::~GenericIPBus (){
Original file line number Diff line number Diff line change 55
66void 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;
Original file line number Diff line number Diff line change @@ -21,24 +21,15 @@ using namespace BUTool;
2121
2222GenericIPBusDevice::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
3832GenericIPBusDevice::~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 " \
You can’t perform that action at this time.
0 commit comments