w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RtclRw11CntlDEUNA.cpp
Go to the documentation of this file.
1// $Id: RtclRw11CntlDEUNA.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2014-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-02-23 1114 1.0.2 use std::bind instead of lambda
8// 2018-12-15 1082 1.0.1 use lambda instead of boost::bind
9// 2017-04-16 878 1.0 Initial version
10// 2014-06-09 561 0.1 First draft
11// ---------------------------------------------------------------------------
12
17#include <sstream>
18#include <functional>
19
21
22#include "RtclRw11CntlDEUNA.hpp"
23#include "RtclRw11UnitDEUNA.hpp"
24
25using namespace std;
26using namespace std::placeholders;
27
33// all method definitions in namespace Retro
34namespace Retro {
35
36//------------------------------------------+-----------------------------------
38
40 : RtclRw11CntlBase<Rw11CntlDEUNA>("Rw11CntlDEUNA","ether")
41{
42 Rw11CntlDEUNA* pobj = &Obj();
43
44 fGets.Add<string> ("dpa", bind(&Rw11CntlDEUNA::MacDefault, pobj));
45 fGets.Add<const Rtime&> ("rxpoll", bind(&Rw11CntlDEUNA::RxPollTime, pobj));
46 fGets.Add<size_t> ("rxqlim", bind(&Rw11CntlDEUNA::RxQueLimit, pobj));
47 fGets.Add<bool> ("run", bind(&Rw11CntlDEUNA::Running, pobj));
48
49 fSets.Add<const string&> ("type",
50 bind(&Rw11CntlDEUNA::SetType,pobj, _1));
51 fSets.Add<const string&> ("dpa",
52 bind(&Rw11CntlDEUNA::SetMacDefault,pobj, _1));
53 fSets.Add<const Rtime&> ("rxpoll",
54 bind(&Rw11CntlDEUNA::SetRxPollTime,pobj, _1));
55 fSets.Add<size_t> ("rxqlim",
56 bind(&Rw11CntlDEUNA::SetRxQueLimit,pobj, _1));
57}
58
59//------------------------------------------+-----------------------------------
61
63{}
64
65//------------------------------------------+-----------------------------------
67
69{
70 static RtclNameSet optset("-base|-lam");
71
72 string cntlname(cpu.Obj().NextCntlName("xu"));
73 string cntlcmd = cpu.CommandName() + cntlname;
74
75 uint16_t base = Rw11CntlDEUNA::kIbaddr;
76 int lam = Rw11CntlDEUNA::kLam;
77
78 string opt;
79 while (args.NextOpt(opt, optset)) {
80 if (opt == "-base") {
81 if (!args.GetArg("base", base, 0177776, 0160000)) return kERR;
82 } else if (opt == "-lam") {
83 if (!args.GetArg("lam", lam, 0, 15)) return kERR;
84 }
85 }
86 if (!args.AllDone()) return kERR;
87
88 // configure controller
89 Obj().Config(cntlname, base, lam);
90
91 // install in CPU
92 cpu.Obj().AddCntl(dynamic_pointer_cast<Rw11Cntl>(ObjSPtr()));
93
94 // finally create tcl command
95 CreateObjectCmd(args.Interp(), cntlcmd.c_str());
96
97 // and create unit commands
98 for (size_t i=0; i<Obj().NUnit(); i++) {
99 string unitcmd = cpu.CommandName() + Obj().UnitName(i);
100 new RtclRw11UnitDEUNA(args.Interp(), unitcmd, Obj().UnitSPtr(i));
101 }
102
103 return kOK;
104}
105
106//------------------------------------------+-----------------------------------
108
110{
111 ostringstream sos;
112 sos << "to come\n";
113 args.AppendResultLines(sos);
114 return kOK;
115}
116
117} // end namespace Retro
FIXME_docs.
Definition: RtclArgs.hpp:41
bool NextOpt(std::string &val)
FIXME_docs.
Definition: RtclArgs.cpp:368
void AppendResultLines(const std::string &str)
FIXME_docs.
Definition: RtclArgs.cpp:484
bool GetArg(const char *name, Tcl_Obj *&pval)
FIXME_docs.
Definition: RtclArgs.cpp:114
Tcl_Interp * Interp() const
FIXME_docs.
Definition: RtclArgs.ipp:28
bool AllDone()
FIXME_docs.
Definition: RtclArgs.cpp:447
void Add(const std::string &name, get_uptr_t &&upget)
FIXME_docs.
Definition: RtclGetList.cpp:52
void CreateObjectCmd(Tcl_Interp *interp, const char *name)
FIXME_docs.
std::string CommandName() const
FIXME_docs.
Implemenation (all inline) of RtclRw11CntlBase.
virtual Rw11CntlDEUNA & Obj()
FIXME_docs.
const std::shared_ptr< Rw11CntlDEUNA > & ObjSPtr()
FIXME_docs.
virtual int FactoryCmdConfig(RtclArgs &args, RtclRw11Cpu &cpu)
FIXME_docs.
virtual int M_default(RtclArgs &args)
FIXME_docs.
virtual Rw11Cpu & Obj()=0
void Add(const std::string &name, set_uptr_t &&upset)
FIXME_docs.
Definition: RtclSetList.cpp:52
FIXME_docs.
Definition: Rtime.hpp:25
virtual size_t NUnit() const
FIXME_docs.
void Config(const std::string &name, uint16_t base, int lam)
FIXME_docs.
void SetRxQueLimit(size_t rxqlim)
FIXME_docs.
std::string MacDefault() const
FIXME_docs.
void SetType(const std::string &type)
FIXME_docs.
bool Running() const
FIXME_docs.
static const uint16_t kIbaddr
DEUNA default address.
size_t RxQueLimit() const
FIXME_docs.
void SetRxPollTime(const Rtime &time)
FIXME_docs.
void SetMacDefault(const std::string &mac)
FIXME_docs.
const Rtime & RxPollTime() const
FIXME_docs.
static const int kLam
DEUNA default lam.
std::string UnitName(size_t index) const
FIXME_docs.
Definition: Rw11Cntl.cpp:122
std::string NextCntlName(const std::string &base) const
FIXME_docs.
Definition: Rw11Cpu.cpp:331
void AddCntl(const std::shared_ptr< Rw11Cntl > &spcntl)
FIXME_docs.
Definition: Rw11Cpu.cpp:266
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47
static const int kERR
Definition: RtclBvi.cpp:38
static const int kOK
Definition: RtclBvi.cpp:37