1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-26 12:22:03 +00:00

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
This commit is contained in:
Walter F.J. Mueller
2017-04-16 15:20:06 +02:00
parent 3ae2cae6d8
commit d42ab4c798
6 changed files with 124 additions and 24 deletions

View File

@@ -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 <W.F.J.Mueller@gsi.de>
//
@@ -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<const string&> ("diskscheme",
boost::bind(&Rw11VirtDisk::SetDefaultScheme, _1));
fGets.Add<Tcl_Obj*> ("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<Obj().NCpu(); i++) {
Rw11Cpu& cpu(Obj().Cpu(i));
@@ -190,10 +193,11 @@ int RtclRw11::M_default(RtclArgs& args)
<< " " << RosPrintf(cpu.Type().c_str(),"-s",4)
<< " " << RosPrintf(cpu.Base(),"x",4)
<< endl;
vector<string> list;
cpu.ListCntl(list);
for (size_t j=0; j<list.size(); j++) {
Rw11Cntl& cntl(cpu.Cntl(list[j]));
vector<string> 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<Obj().NCpu(); i++) {
string ccmd = string("cpu") + to_string(i);
RtclOPtr pele(Tcl_NewStringObj(ccmd.data(), ccmd.length()));
Tcl_ListObjAppendElement(nullptr, rlist, pele);
}
return rlist;
}
} // end namespace Retro

View File

@@ -1,4 +1,4 @@
// $Id: RtclRw11.hpp 867 2017-04-02 18:16:33Z mueller $
// $Id: RtclRw11.hpp 876 2017-04-16 08:01:37Z mueller $
//
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
@@ -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<RlinkServer> fspServ;
RtclGetList fGets;

View File

@@ -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 <W.F.J.Mueller@gsi.de>
//
@@ -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<Tcl_Obj*> ("units",
boost::bind(&RtclRw11Cntl::UnitCommands, this));
fGets.Add<const string&> ("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

View File

@@ -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 <W.F.J.Mueller@gsi.de>
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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;
};

View File

@@ -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 <W.F.J.Mueller@gsi.de>
//
@@ -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<Tcl_Obj*> ("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.size(); i++) {
Rw11Cntl& cntl(Obj().Cntl(cntlnames[i]));
for (auto& cname : cntlnames) {
Rw11Cntl& cntl(Obj().Cntl(cname));
sos << RosPrintf(cntl.Name().c_str(),"-s",4)
<< " " << RosPrintf(cntl.Type().c_str(),"-s",5)
<< " " << RosPrintf(cntl.Base(),"o",6)
@@ -1439,6 +1446,20 @@ int RtclRw11Cpu::M_default(RtclArgs& args)
<< endl;
}
sos << endl;
sos << "name attachurl" << endl;
for (auto& cname : cntlnames) {
Rw11Cntl& cntl(Obj().Cntl(cname));
for (size_t j=0; j<cntl.NUnit(); j++) {
Rw11Unit& unit(cntl.UnitBase(j));
if (unit.IsAttached()) {
sos << RosPrintf(unit.Name().c_str(),"-s",5)
<< " " << unit.AttachUrl() << endl;
}
}
}
args.AppendResultLines(sos);
return kOK;
}
@@ -1570,5 +1591,22 @@ bool RtclRw11Cpu::ClistNonEmpty(RtclArgs& args, const RlinkCommandList& clist)
}
return true;
}
//------------------------------------------+-----------------------------------
//! FIXME_docs
Tcl_Obj* RtclRw11Cpu::ControllerCommands()
{
vector<string> 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

View File

@@ -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 <W.F.J.Mueller@gsi.de>
// Copyright 2013-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// 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<std::string>& varname);
bool ClistNonEmpty(RtclArgs& args,
const RlinkCommandList& clist);
Tcl_Obj* ControllerCommands();
protected:
RtclGetList fGets;