w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11.cpp
Go to the documentation of this file.
1// $Id: Rw11.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2018 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.1.5 use std::bind instead of lambda
8// 2018-12-19 1090 1.1.4 use RosPrintf(bool)
9// 2018-12-15 1082 1.1.3 use lambda instead of boost::bind
10// 2018-12-09 1080 1.1.2 use std::shared_ptr instead of boost and range loop
11// 2017-04-07 868 1.1.1 Dump(): add detail arg
12// 2014-12-30 625 1.1 adopt to Rlink V4 attn logic
13// 2013-03-06 495 1.0 Initial version
14// 2013-01-27 478 0.1 First draft
15// ---------------------------------------------------------------------------
16
21#include <functional>
22
24#include "librtools/RosFill.hpp"
26#include "Rw11Cpu.hpp"
27
28#include "Rw11.hpp"
29
30using namespace std;
31using namespace std::placeholders;
32
38// all method definitions in namespace Retro
39namespace Retro {
40
41//------------------------------------------+-----------------------------------
42// constants definitions
43
44const int Rw11::kLam;
45
46//------------------------------------------+-----------------------------------
48
50 : fspServ(),
51 fNCpu(0),
52 fStarted(false)
53{}
54
55//------------------------------------------+-----------------------------------
57
59{}
60
61//------------------------------------------+-----------------------------------
63
64void Rw11::SetServer(const std::shared_ptr<RlinkServer>& spserv)
65{
66 fspServ = spserv;
67 fspServ->AddAttnHandler(bind(&Rw11::AttnHandler, this, _1),
68 uint16_t(1)<<kLam, this);
69 return;
70}
71
72//------------------------------------------+-----------------------------------
74
75void Rw11::AddCpu(const std::shared_ptr<Rw11Cpu>& spcpu)
76{
77 if (fNCpu >= 4)
78 throw Rexception("Rw11::AddCpu", "Bad state: already 4 cpus registered");
79 if (fNCpu > 0 && fspCpu[0]->Type() != spcpu->Type())
80 throw Rexception("Rw11::AddCpu", "Bad state: type mismatch, new is "
81 + spcpu->Type() + " first was " + fspCpu[0]->Type());
82
83 fspCpu[fNCpu] = spcpu;
84 fNCpu += 1;
85 spcpu->Setup(this);
86
87 return;
88}
89
90//------------------------------------------+-----------------------------------
92
93Rw11Cpu& Rw11::Cpu(size_t ind) const
94{
95 return *fspCpu[ind];
96}
97
98//------------------------------------------+-----------------------------------
100
102{
103 if (fStarted)
104 throw Rexception("Rw11::Start()","alread started");
105
106 for (size_t i=0; i<fNCpu; i++) fspCpu[i]->Start();
107
108 if (!Server().IsActive()) Server().Start();
109
110 fStarted = true;
111 return;
112}
113
114//------------------------------------------+-----------------------------------
116
117void Rw11::Dump(std::ostream& os, int ind, const char* text, int /*detail*/) const
118{
119 RosFill bl(ind);
120 os << bl << (text?text:"--") << "Rw11 @ " << this << endl;
121
122 os << bl << " fspServ: " << fspServ.get() << endl;
123 os << bl << " fNCpu: " << fNCpu << endl;
124 os << bl << " fspCpu[4]: ";
125 for (auto& o: fspCpu) os << o.get() << " ";
126 os << endl;
127 os << bl << " fStarted: " << RosPrintf(fStarted) << endl;
128 return;
129}
130
131//------------------------------------------+-----------------------------------
133
135{
136 Server().GetAttnInfo(args);
137
138 for (size_t i=0; i<fNCpu; i++) fspCpu[i]->W11AttnHandler();
139 return 0;
140}
141
142} // end namespace Retro
FIXME_docs.
Definition: Rexception.hpp:29
void GetAttnInfo(AttnArgs &args, RlinkCommandList &clist)
FIXME_docs.
void Start()
FIXME_docs.
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24
FIXME_docs.
Definition: Rw11Cpu.hpp:66
std::shared_ptr< RlinkServer > fspServ
Definition: Rw11.hpp:63
int AttnHandler(RlinkServer::AttnArgs &args)
FIXME_docs.
Definition: Rw11.cpp:134
Rw11Cpu & Cpu(size_t ind) const
FIXME_docs.
Definition: Rw11.cpp:93
RlinkServer & Server() const
FIXME_docs.
Definition: Rw11.ipp:30
void Start()
FIXME_docs.
Definition: Rw11.cpp:101
static const int kLam
W11 CPU cluster lam.
Definition: Rw11.hpp:57
virtual ~Rw11()
Destructor.
Definition: Rw11.cpp:58
Rw11()
Default constructor.
Definition: Rw11.cpp:49
void AddCpu(const std::shared_ptr< Rw11Cpu > &spcpu)
FIXME_docs.
Definition: Rw11.cpp:75
void SetServer(const std::shared_ptr< RlinkServer > &spserv)
FIXME_docs.
Definition: Rw11.cpp:64
size_t fNCpu
Definition: Rw11.hpp:64
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rw11.cpp:117
bool fStarted
true if Start() called
Definition: Rw11.hpp:66
std::shared_ptr< Rw11Cpu > fspCpu[4]
Definition: Rw11.hpp:65
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Definition: RosPrintf.ipp:38
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47