From d42ab4c798dcacf4a97e728f310a171c73e96936 Mon Sep 17 00:00:00 2001 From: "Walter F.J. Mueller" Date: Sun, 16 Apr 2017 15:20:06 +0200 Subject: [PATCH] make list cpus,cntls,units command gettable; make controller class gettable - RtclRw11: add CpuCommands() and cpus getter - RtclRw11Cntl: add UnitCommands() and uints and class getter - RtclRw11Cpu: add ControllerCommands() and cntls getter --- tools/src/librwxxtpp/RtclRw11.cpp | 33 +++++++++++++++---- tools/src/librwxxtpp/RtclRw11.hpp | 7 ++-- tools/src/librwxxtpp/RtclRw11Cntl.cpp | 37 +++++++++++++++++++-- tools/src/librwxxtpp/RtclRw11Cntl.hpp | 16 +++++++--- tools/src/librwxxtpp/RtclRw11Cpu.cpp | 46 ++++++++++++++++++++++++--- tools/src/librwxxtpp/RtclRw11Cpu.hpp | 9 ++++-- 6 files changed, 124 insertions(+), 24 deletions(-) diff --git a/tools/src/librwxxtpp/RtclRw11.cpp b/tools/src/librwxxtpp/RtclRw11.cpp index 772d6773..b95dd53b 100644 --- a/tools/src/librwxxtpp/RtclRw11.cpp +++ b/tools/src/librwxxtpp/RtclRw11.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11.cpp 868 2017-04-07 20:09:33Z mueller $ +// $Id: RtclRw11.cpp 876 2017-04-16 08:01:37Z mueller $ // // Copyright 2013-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-16 876 1.0.4 add CpuCommands() // 2017-04-07 868 1.0.3 M_dump: use GetArgsDump and Dump detail // 2017-04-02 866 1.0.2 add M_set; handle default disk scheme // 2015-03-28 660 1.0.1 add M_get @@ -23,7 +24,7 @@ /*! \file - \version $Id: RtclRw11.cpp 868 2017-04-07 20:09:33Z mueller $ + \version $Id: RtclRw11.cpp 876 2017-04-16 08:01:37Z mueller $ \brief Implemenation of class RtclRw11. */ @@ -76,6 +77,8 @@ RtclRw11::RtclRw11(Tcl_Interp* interp, const char* name) fSets.Add ("diskscheme", boost::bind(&Rw11VirtDisk::SetDefaultScheme, _1)); + fGets.Add ("cpus", + boost::bind(&RtclRw11::CpuCommands, this)); } //------------------------------------------+----------------------------------- @@ -182,7 +185,7 @@ int RtclRw11::M_default(RtclArgs& args) if (!args.AllDone()) return kERR; ostringstream sos; - sos << "cpu type base : cntl type ibbase probe lam boot" << endl; + sos << "cpu type base : cntl type ibbase probe lam boot" << endl; for (size_t i=0; i list; - cpu.ListCntl(list); - for (size_t j=0; j cntlnames; + cpu.ListCntl(cntlnames); + for (auto& cname : cntlnames) { + Rw11Cntl& cntl(cpu.Cntl(cname)); const Rw11Probe& pstat(cntl.ProbeStatus()); sos << " " << RosPrintf(cntl.Name().c_str(),"-s",4) << " " << RosPrintf(cntl.Type().c_str(),"-s",5) @@ -213,5 +217,20 @@ int RtclRw11::M_default(RtclArgs& args) args.AppendResultLines(sos); return kOK; } + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Tcl_Obj* RtclRw11::CpuCommands() +{ + Tcl_Obj* rlist = Tcl_NewListObj(0,nullptr); + for (size_t i=0; i // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-16 876 1.0.3 add CpuCommands() // 2017-04-02 866 1.0.2 add M_set // 2015-03-28 660 1.0.1 add M_get // 2013-03-06 495 1.0 Initial version @@ -21,7 +22,7 @@ /*! \file - \version $Id: RtclRw11.hpp 867 2017-04-02 18:16:33Z mueller $ + \version $Id: RtclRw11.hpp 876 2017-04-16 08:01:37Z mueller $ \brief Declaration of class RtclRw11. */ @@ -56,6 +57,8 @@ namespace Retro { int M_dump(RtclArgs& args); int M_default(RtclArgs& args); + Tcl_Obj* CpuCommands(); + protected: boost::shared_ptr fspServ; RtclGetList fGets; diff --git a/tools/src/librwxxtpp/RtclRw11Cntl.cpp b/tools/src/librwxxtpp/RtclRw11Cntl.cpp index 457359ce..a8f776ee 100644 --- a/tools/src/librwxxtpp/RtclRw11Cntl.cpp +++ b/tools/src/librwxxtpp/RtclRw11Cntl.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Cntl.cpp 865 2017-04-02 16:45:06Z mueller $ +// $Id: RtclRw11Cntl.cpp 877 2017-04-16 10:13:56Z mueller $ // // Copyright 2013-2017 by Walter F.J. Mueller // @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-16 877 1.1.2 add UnitCommands(); add Class() // 2017-04-02 865 1.0.2 M_dump: use GetArgsDump and Dump detail // 2015-03-27 660 1.0.1 add M_start // 2013-03-06 495 1.0 Initial version @@ -21,7 +22,7 @@ /*! \file - \version $Id: RtclRw11Cntl.cpp 865 2017-04-02 16:45:06Z mueller $ + \version $Id: RtclRw11Cntl.cpp 877 2017-04-16 10:13:56Z mueller $ \brief Implemenation of RtclRw11Cntl. */ @@ -29,6 +30,7 @@ #include "boost/bind.hpp" #include "librtcltools/RtclStats.hpp" +#include "librtcltools/RtclOPtr.hpp" #include "RtclRw11Cntl.hpp" @@ -45,8 +47,10 @@ namespace Retro { //------------------------------------------+----------------------------------- //! Constructor -RtclRw11Cntl::RtclRw11Cntl(const std::string& type) +RtclRw11Cntl::RtclRw11Cntl(const std::string& type, + const std::string& cclass) : RtclProxyBase(type), + fClass(cclass), fGets(), fSets() { @@ -57,6 +61,11 @@ RtclRw11Cntl::RtclRw11Cntl(const std::string& type) AddMeth("stats", boost::bind(&RtclRw11Cntl::M_stats, this, _1)); AddMeth("dump", boost::bind(&RtclRw11Cntl::M_dump, this, _1)); AddMeth("$default", boost::bind(&RtclRw11Cntl::M_default, this, _1)); + + fGets.Add ("units", + boost::bind(&RtclRw11Cntl::UnitCommands, this)); + fGets.Add ("class", + boost::bind(&RtclRw11Cntl::Class, this)); } //------------------------------------------+----------------------------------- @@ -144,4 +153,26 @@ int RtclRw11Cntl::M_default(RtclArgs& args) return kOK; } +//------------------------------------------+----------------------------------- +//! FIXME_docs + +Tcl_Obj* RtclRw11Cntl::UnitCommands() +{ + Tcl_Obj* rlist = Tcl_NewListObj(0,nullptr); + for (size_t i = 0; i < Obj().NUnit(); i++) { + string ucmd = CommandName() + to_string(i); + RtclOPtr pele(Tcl_NewStringObj(ucmd.data(), ucmd.length())); + Tcl_ListObjAppendElement(nullptr, rlist, pele); + } + return rlist; +} + +//------------------------------------------+----------------------------------- +//! FIXME_docs + +const std::string& RtclRw11Cntl::Class() const +{ + return fClass; +} + } // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Cntl.hpp b/tools/src/librwxxtpp/RtclRw11Cntl.hpp index 9914ed61..6001793c 100644 --- a/tools/src/librwxxtpp/RtclRw11Cntl.hpp +++ b/tools/src/librwxxtpp/RtclRw11Cntl.hpp @@ -1,6 +1,6 @@ -// $Id: RtclRw11Cntl.hpp 660 2015-03-29 22:10:16Z mueller $ +// $Id: RtclRw11Cntl.hpp 878 2017-04-16 12:28:15Z mueller $ // -// Copyright 2013-2015 by Walter F.J. Mueller +// Copyright 2013-2017 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-16 878 1.1.2 add UnitCommands(); add Class(); M_default virtual // 2015-03-27 660 1.1.1 add M_start // 2015-01-03 627 1.1 M_stats now virtual // 2013-03-06 495 1.0 Initial version @@ -22,7 +23,7 @@ /*! \file - \version $Id: RtclRw11Cntl.hpp 660 2015-03-29 22:10:16Z mueller $ + \version $Id: RtclRw11Cntl.hpp 878 2017-04-16 12:28:15Z mueller $ \brief Declaration of class RtclRw11Cntl. */ @@ -44,7 +45,8 @@ namespace Retro { class RtclRw11Cntl : public RtclProxyBase { public: - explicit RtclRw11Cntl(const std::string& type); + RtclRw11Cntl(const std::string& type, + const std::string& cclass); virtual ~RtclRw11Cntl(); virtual Rw11Cntl& Obj() = 0; @@ -57,9 +59,13 @@ namespace Retro { int M_start(RtclArgs& args); virtual int M_stats(RtclArgs& args); int M_dump(RtclArgs& args); - int M_default(RtclArgs& args); + virtual int M_default(RtclArgs& args); + + Tcl_Obj* UnitCommands(); + const std::string& Class() const; protected: + std::string fClass; RtclGetList fGets; RtclSetList fSets; }; diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.cpp b/tools/src/librwxxtpp/RtclRw11Cpu.cpp index 15fa9dcc..e2b51f0e 100644 --- a/tools/src/librwxxtpp/RtclRw11Cpu.cpp +++ b/tools/src/librwxxtpp/RtclRw11Cpu.cpp @@ -1,4 +1,4 @@ -// $Id: RtclRw11Cpu.cpp 868 2017-04-07 20:09:33Z mueller $ +// $Id: RtclRw11Cpu.cpp 876 2017-04-16 08:01:37Z mueller $ // // Copyright 2013-2017 by Walter F.J. Mueller // @@ -13,6 +13,8 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-15 876 1.2.16 add ControllerCommands() +// 2017-04-15 875 1.2.15 M_default: add attached units summary // 2017-04-07 868 1.2.14 M_dump: use GetArgsDump and Dump detail // 2017-02-26 857 1.2.13 use kCPAH_M_UBM22 for cp -wa -ubm // 2017-02-19 853 1.2.12 use Rtime @@ -43,7 +45,7 @@ /*! \file - \version $Id: RtclRw11Cpu.cpp 868 2017-04-07 20:09:33Z mueller $ + \version $Id: RtclRw11Cpu.cpp 876 2017-04-16 08:01:37Z mueller $ \brief Implemenation of RtclRw11Cpu. */ @@ -70,6 +72,8 @@ #include "librtcltools/RtclNameSet.hpp" #include "librlink/RlinkCommandList.hpp" +#include "librw11/Rw11Unit.hpp" + #include "RtclRw11.hpp" #include "RtclRw11CntlFactory.hpp" @@ -112,6 +116,9 @@ RtclRw11Cpu::RtclRw11Cpu(const std::string& type) AddMeth("show", boost::bind(&RtclRw11Cpu::M_show, this, _1)); AddMeth("dump", boost::bind(&RtclRw11Cpu::M_dump, this, _1)); AddMeth("$default", boost::bind(&RtclRw11Cpu::M_default, this, _1)); + + fGets.Add ("cntls", + boost::bind(&RtclRw11Cpu::ControllerCommands, this)); } //------------------------------------------+----------------------------------- @@ -1425,8 +1432,8 @@ int RtclRw11Cpu::M_default(RtclArgs& args) sos << "name type ibbase lam probe ena on" << endl; - for (size_t i=0; i cntlnames; + Obj().ListCntl(cntlnames); + + Tcl_Obj* rlist = Tcl_NewListObj(0,nullptr); + for (auto& cname : cntlnames) { + string ccmd = CommandName() + cname; + RtclOPtr pele(Tcl_NewStringObj(ccmd.data(), ccmd.length())); + Tcl_ListObjAppendElement(nullptr, rlist, pele); + } + return rlist; +} } // end namespace Retro diff --git a/tools/src/librwxxtpp/RtclRw11Cpu.hpp b/tools/src/librwxxtpp/RtclRw11Cpu.hpp index e8906767..cec141ca 100644 --- a/tools/src/librwxxtpp/RtclRw11Cpu.hpp +++ b/tools/src/librwxxtpp/RtclRw11Cpu.hpp @@ -1,6 +1,6 @@ -// $Id: RtclRw11Cpu.hpp 661 2015-04-03 18:28:41Z mueller $ +// $Id: RtclRw11Cpu.hpp 876 2017-04-16 08:01:37Z mueller $ // -// Copyright 2013-2015 by Walter F.J. Mueller +// Copyright 2013-2017 by Walter F.J. Mueller // // This program is free software; you may redistribute and/or modify it under // the terms of the GNU General Public License as published by the Free @@ -13,6 +13,7 @@ // // Revision History: // Date Rev Version Comment +// 2017-04-16 876 1.0.5 add ControllerCommands() // 2015-04-03 661 1.0.4 add ClistNonEmpty() // 2015-03-21 659 1.0.3 rename M_amap->M_imap; add M_rmap; add GetRAddr() // 2014-12-25 621 1.0.2 add M_amap @@ -24,7 +25,7 @@ /*! \file - \version $Id: RtclRw11Cpu.hpp 661 2015-04-03 18:28:41Z mueller $ + \version $Id: RtclRw11Cpu.hpp 876 2017-04-16 08:01:37Z mueller $ \brief Declaration of class RtclRw11Cpu. */ @@ -82,6 +83,8 @@ namespace Retro { size_t nind, std::vector& varname); bool ClistNonEmpty(RtclArgs& args, const RlinkCommandList& clist); + + Tcl_Obj* ControllerCommands(); protected: RtclGetList fGets;