MemoryNameSystem.cpp
Go to the documentation of this file.
1 #include "MemoryNameSystem.h"
2 
3 
5 {
6 
7  // dto::WaitForServerResult MemoryNameSystem::waitForServer(const dto::WaitForServerInput& input)
9  const AMD_MemoryNameSystemInterface_waitForServerPtr& future,
10  const dto::WaitForServerInput& input)
11  {
12  waitForServerFutures[input.name].push_back(future);
14  }
15 
16 
18  {
19  for (auto it = waitForServerFutures.begin(); it != waitForServerFutures.end();)
20  {
21  auto& [name, futures] = *it;
22  if (auto st = servers.find(name); st != servers.end())
23  {
24  ServerInfo& info = st->second;
25 
26  dto::WaitForServerResult result;
27  result.success = true;
28  result.server = info.server;
29 
30  // Send responses and remove entry.
31  for (auto& future : futures)
32  {
33  future->ice_response(result);
34  }
35  it = waitForServerFutures.erase(it);
36  }
37  else
38  {
39  ++it; // Skip.
40  }
41  }
42  }
43 
44  dto::RegisterServerResult MemoryNameSystem::registerServer(const dto::RegisterServerInput& input)
45  {
46  const auto result = Registry::registerServer(input);
48 
49  return result;
50  }
51 
52 
54  {
55  using namespace armarx::RemoteGui::Client;
56 
57  GridLayout grid;
58 
59  int row = 0;
60  grid.add(Label("Memory Name"), {row, 0})
61  .add(Label("Component Name"), {row, 1})
62  .add(Label("R/W/P/A"), {row, 2})
63  .add(Label("Registration Time"), {row, 3})
64  ;
65  row++;
66 
67  for (const auto& [name, info] : servers)
68  {
69  ARMARX_CHECK_EQUAL(name, info.name);
70  std::string componentName = "";
71  std::string mode = "";
72  if (info.server.reading)
73  {
74  componentName = info.server.reading->ice_getIdentity().name;
75  mode += "R";
76  }
77  if (info.server.writing)
78  {
79  componentName = info.server.writing->ice_getIdentity().name;
80  mode += "W";
81  }
82  if (info.server.prediction)
83  {
84  componentName = info.server.prediction->ice_getIdentity().name;
85  mode += "P";
86  }
87  if (info.server.actions)
88  {
89  componentName = info.server.actions->ice_getIdentity().name;
90  mode += "A";
91  }
92 
93  int col = 0;
94  grid.add(Label(name), {row, col});
95  ++col;
96 
97  grid.add(Label(componentName), {row, col});
98  ++col;
99 
100  grid.add(Label(mode), {row, col});
101  ++col;
102 
103  grid.add(Label(armem::toDateTimeMilliSeconds(info.timeRegistered, 0)), {row, col});
104  ++col;
105 
106  ++row;
107  }
108 
109  return grid;
110  }
111 
112 }
armarx::armem::mns::MemoryNameSystem::waitForServer_async
void waitForServer_async(const AMD_MemoryNameSystemInterface_waitForServerPtr &future, const dto::WaitForServerInput &input)
Store the call in a container for later response.
Definition: MemoryNameSystem.cpp:8
armarx::armem::mns::Registry::ServerInfo
Information about a memory entry.
Definition: Registry.h:58
armarx::RemoteGui::Client::GridLayout::add
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
Definition: Widgets.cpp:412
armarx::armem::mns::Registry::ServerInfo::server
mns::dto::MemoryServerInterfaces server
Definition: Registry.h:61
armarx::armem::mns::MemoryNameSystem::waitForServer_processOnce
void waitForServer_processOnce()
Definition: MemoryNameSystem.cpp:17
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
armarx::RemoteGui::Client::GridLayout
Definition: Widgets.h:186
armarx::armem::toDateTimeMilliSeconds
std::string toDateTimeMilliSeconds(const Time &time, int decimals=6)
Returns timeas e.g.
Definition: Time.cpp:35
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
MemoryNameSystem.h
armarx::armem::mns::MemoryNameSystem::RemoteGui_buildInfoGrid
armarx::RemoteGui::Client::GridLayout RemoteGui_buildInfoGrid()
Builds a RemoteGui grid containing information about registered memories.
Definition: MemoryNameSystem.cpp:53
armarx::armem::mns
Definition: MemoryNameSystem.cpp:4
armarx::armem::mns::MemoryNameSystem::registerServer
dto::RegisterServerResult registerServer(const dto::RegisterServerInput &input) override
Register a new memory server or update an existing entry.
Definition: MemoryNameSystem.cpp:44
armarx::armem::mns::MemoryNameSystem::waitForServerFutures
std::map< std::string, std::vector< WaitForServerFuturePtr > > waitForServerFutures
Queued calls to waitForServer.
Definition: MemoryNameSystem.h:44
armarx::armem::mns::Registry::registerServer
virtual dto::RegisterServerResult registerServer(const dto::RegisterServerInput &input)
Register a new memory server or update an existing entry.
Definition: Registry.cpp:22
ARMARX_CHECK_EQUAL
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
Definition: ExpressionException.h:130
armarx::RemoteGui::Client
Definition: EigenWidgets.cpp:8
armarx::armem::mns::Registry::servers
std::map< std::string, ServerInfo > servers
The registered memories.
Definition: Registry.h:66