Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
bd3828ca
Commit
bd3828ca
authored
4 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Add introspection to MemoryRemoteGui
parent
88dbf774
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!95
Add introspection in RemoteGui
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/libraries/armem/component/MemoryRemoteGui.cpp
+361
-10
361 additions, 10 deletions
...ce/RobotAPI/libraries/armem/component/MemoryRemoteGui.cpp
source/RobotAPI/libraries/armem/component/MemoryRemoteGui.h
+6
-0
6 additions, 0 deletions
source/RobotAPI/libraries/armem/component/MemoryRemoteGui.h
with
367 additions
and
10 deletions
source/RobotAPI/libraries/armem/component/MemoryRemoteGui.cpp
+
361
−
10
View file @
bd3828ca
#include
"MemoryRemoteGui.h"
#include
<stack>
#include
<ArmarXCore/core/exceptions/local/ExpressionException.h>
#include
<RobotAPI/libraries/aron/aroncore/navigators/datanavigator/AronAllDataNavigators.h>
#include
<SimoxUtility/meta/type_name.h>
namespace
armarx
::
armem
{
...
...
@@ -9,8 +15,12 @@ namespace armarx::armem
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
Memory
&
memory
)
const
{
GroupBox
group
;
group
.
setLabel
(
"Memory
'"
+
memory
.
name
+
"'"
);
group
.
setLabel
(
makeGroupLabel
(
"Memory
"
,
memory
.
name
,
memory
.
coreSegments
.
size
())
);
if
(
memory
.
coreSegments
.
empty
())
{
group
.
addChild
(
Label
(
makeNoItemsMessage
(
"core segments"
)));
}
for
(
const
auto
&
[
name
,
coreSegment
]
:
memory
.
coreSegments
)
{
group
.
addChild
(
makeGroupBox
(
*
coreSegment
));
...
...
@@ -24,8 +34,12 @@ namespace armarx::armem
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
CoreSegment
&
coreSegment
)
const
{
GroupBox
group
;
group
.
setLabel
(
"Core Segment
'"
+
coreSegment
.
name
+
"'"
);
group
.
setLabel
(
makeGroupLabel
(
"Core Segment
"
,
coreSegment
.
name
,
coreSegment
.
providerSegments
.
size
())
);
if
(
coreSegment
.
providerSegments
.
empty
())
{
group
.
addChild
(
Label
(
makeNoItemsMessage
(
"provider segments"
)));
}
for
(
const
auto
&
[
name
,
providerSegment
]
:
coreSegment
.
providerSegments
)
{
group
.
addChild
(
makeGroupBox
(
*
providerSegment
));
...
...
@@ -39,8 +53,12 @@ namespace armarx::armem
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
ProviderSegment
&
providerSegment
)
const
{
GroupBox
group
;
group
.
setLabel
(
"Provider Segment
'"
+
providerSegment
.
name
+
"'"
);
group
.
setLabel
(
makeGroupLabel
(
"Provider Segment
"
,
providerSegment
.
name
,
providerSegment
.
entities
.
size
())
);
if
(
providerSegment
.
entities
.
empty
())
{
group
.
addChild
(
Label
(
makeNoItemsMessage
(
"entities"
)));
}
for
(
const
auto
&
[
name
,
entity
]
:
providerSegment
.
entities
)
{
group
.
addChild
(
makeGroupBox
(
*
entity
));
...
...
@@ -54,8 +72,12 @@ namespace armarx::armem
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
Entity
&
entity
)
const
{
GroupBox
group
;
group
.
setLabel
(
"Entity
'"
+
entity
.
name
+
"'"
);
group
.
setLabel
(
makeGroupLabel
(
"Entity
"
,
entity
.
name
,
entity
.
history
.
size
())
);
if
(
entity
.
history
.
empty
())
{
group
.
addChild
(
Label
(
makeNoItemsMessage
(
"snapshots"
)));
}
if
(
int
(
entity
.
history
.
size
())
<=
maxHistorySize
)
{
for
(
const
auto
&
[
time
,
snapshot
]
:
entity
.
history
)
...
...
@@ -80,6 +102,7 @@ namespace armarx::armem
group
.
addChild
(
makeGroupBox
(
*
rit
->
second
));
}
}
group
.
setCollapsed
(
true
);
return
group
;
}
...
...
@@ -89,19 +112,347 @@ namespace armarx::armem
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
EntitySnapshot
&
snapshot
)
const
{
GroupBox
group
;
std
::
stringstream
ss
;
ss
<<
"t = "
<<
armem
::
toDateTimeMilliSeconds
(
snapshot
.
time
);
group
.
setLabel
(
ss
.
str
());
group
.
setLabel
(
makeGroupLabel
(
"t"
,
armem
::
toDateTimeMilliSeconds
(
snapshot
.
time
),
snapshot
.
instances
.
size
(),
" = "
,
""
));
if
(
snapshot
.
instances
.
empty
())
{
group
.
addChild
(
Label
(
makeNoItemsMessage
(
"instances"
)));
}
for
(
const
auto
&
instance
:
snapshot
.
instances
)
{
group
.
addChild
(
makeGroupBox
(
*
instance
));
}
group
.
setCollapsed
(
true
);
return
group
;
}
}
namespace
armarx
::
aron
::
datanavigator
{
struct
AronDataNavigatorVisitor
{
virtual
~
AronDataNavigatorVisitor
()
{}
virtual
bool
visitEnter
(
AronDictDataNavigator
&
dict
)
{
(
void
)
dict
;
return
true
;
}
virtual
bool
visitExit
(
AronDictDataNavigator
&
dict
)
{
(
void
)
dict
;
return
true
;
}
virtual
bool
visitEnter
(
AronListDataNavigator
&
list
)
{
(
void
)
list
;
return
true
;
}
virtual
bool
visitExit
(
AronListDataNavigator
&
list
)
{
(
void
)
list
;
return
true
;
}
virtual
bool
visit
(
AronBoolDataNavigator
&
b
)
{
(
void
)
b
;
return
true
;
}
virtual
bool
visit
(
AronDoubleDataNavigator
&
d
)
{
(
void
)
d
;
return
true
;
}
virtual
bool
visit
(
AronFloatDataNavigator
&
f
)
{
(
void
)
f
;
return
true
;
}
virtual
bool
visit
(
AronIntDataNavigator
&
i
)
{
(
void
)
i
;
return
true
;
}
virtual
bool
visit
(
AronLongDataNavigator
&
l
)
{
(
void
)
l
;
return
true
;
}
virtual
bool
visit
(
AronNDArrayDataNavigator
&
array
)
{
(
void
)
array
;
return
true
;
}
virtual
bool
visit
(
AronStringDataNavigator
&
string
)
{
(
void
)
string
;
return
true
;
}
};
struct
AronDataNavigatorAcceptor
{
bool
accept
(
AronDataNavigator
&
navigator
,
AronDataNavigatorVisitor
&
visitor
)
{
if
(
auto
n
=
dynamic_cast
<
AronDictDataNavigator
*>
(
&
navigator
))
{
if
(
!
visitor
.
visitEnter
(
*
n
))
{
return
false
;
}
if
(
!
visitChildren
(
*
n
,
visitor
))
{
return
false
;
}
if
(
!
visitor
.
visitExit
(
*
n
))
{
return
false
;
}
return
true
;
}
else
if
(
auto
n
=
dynamic_cast
<
AronListDataNavigator
*>
(
&
navigator
))
{
if
(
!
visitor
.
visitEnter
(
*
n
))
{
return
false
;
}
if
(
!
visitChildren
(
*
n
,
visitor
))
{
return
false
;
}
if
(
!
visitor
.
visitExit
(
*
n
))
{
return
false
;
}
return
true
;
}
ARMARX_CHECK_EQUAL
(
navigator
.
childrenSize
(),
0
)
<<
simox
::
meta
::
get_type_name
(
navigator
);
if
(
auto
n
=
dynamic_cast
<
AronBoolDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronDoubleDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronFloatDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronIntDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronLongDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronNDArrayDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
else
if
(
auto
n
=
dynamic_cast
<
AronStringDataNavigator
*>
(
&
navigator
))
{
return
visitor
.
visit
(
*
n
);
}
ARMARX_CHECK
(
false
)
<<
"Unhandled AronDataNavigatorType '"
<<
simox
::
meta
::
get_type_name
(
navigator
)
<<
"'."
;
}
bool
visitChildren
(
AronDataNavigator
&
navigator
,
AronDataNavigatorVisitor
&
visitor
)
{
for
(
auto
&
child
:
navigator
.
getChildren
())
{
if
(
child
)
{
if
(
!
accept
(
*
child
,
visitor
))
{
return
false
;
}
}
}
return
true
;
}
};
}
namespace
armarx
::
armem
{
struct
MyVisitor
:
aron
::
datanavigator
::
AronDataNavigatorVisitor
{
using
GroupBox
=
armarx
::
RemoteGui
::
Client
::
GroupBox
;
using
Label
=
armarx
::
RemoteGui
::
Client
::
Label
;
MyVisitor
()
{
}
virtual
~
MyVisitor
()
override
;
std
::
stack
<
GroupBox
>
groups
;
GroupBox
result
;
bool
visitEnter
(
aron
::
datanavigator
::
AronDictDataNavigator
&
dict
)
override
{
ARMARX_INFO
<<
"- Dict Enter (path: '"
<<
dict
.
getPath
().
toString
()
<<
"')"
;
groups
.
push
(
GroupBox
());
return
true
;
}
bool
visitExit
(
aron
::
datanavigator
::
AronDictDataNavigator
&
dict
)
override
{
ARMARX_INFO
<<
"- Dict Exit (path: '"
<<
dict
.
getPath
().
toString
()
<<
"')"
;
GroupBox
group
=
groups
.
top
();
groups
.
pop
();
if
(
groups
.
size
()
>
0
)
{
groups
.
top
().
addChild
(
group
);
}
else
{
result
=
group
;
}
return
true
;
}
bool
visitEnter
(
aron
::
datanavigator
::
AronListDataNavigator
&
list
)
override
{
ARMARX_INFO
<<
"- List Enter (path: '"
<<
list
.
getPath
().
toString
()
<<
"')"
;
return
true
;
}
bool
visitExit
(
aron
::
datanavigator
::
AronListDataNavigator
&
list
)
override
{
ARMARX_INFO
<<
"- List Exit (path: '"
<<
list
.
getPath
().
toString
()
<<
"')"
;
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronBoolDataNavigator
&
b
)
override
{
this
->
addValueLabel
(
b
,
"bool"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronDoubleDataNavigator
&
d
)
override
{
this
->
addValueLabel
(
d
,
"double"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronFloatDataNavigator
&
f
)
override
{
this
->
addValueLabel
(
f
,
"float"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronIntDataNavigator
&
i
)
override
{
this
->
addValueLabel
(
i
,
"int"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronLongDataNavigator
&
l
)
override
{
this
->
addValueLabel
(
l
,
"long"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronStringDataNavigator
&
string
)
override
{
this
->
addValueLabel
(
string
,
"string"
);
return
true
;
}
bool
visit
(
aron
::
datanavigator
::
AronNDArrayDataNavigator
&
array
)
override
{
ARMARX_INFO
<<
"- NdArray (path: '"
<<
array
.
getPath
().
toString
()
<<
"')"
;
return
true
;
}
template
<
class
Navigator
>
void
addValueLabel
(
Navigator
&
n
,
const
std
::
string
&
typeName
)
{
groups
.
top
().
addChild
(
Label
(
this
->
makeValueLabelText
(
n
,
typeName
)));
}
template
<
class
Navigator
>
std
::
string
makeValueLabelText
(
Navigator
&
n
,
const
std
::
string
&
typeName
)
{
std
::
stringstream
ss
;
ss
<<
"Instance #"
<<
instance
->
index
;
Label
instanceLabel
(
ss
.
str
());
group
.
addChild
(
instanceLabel
);
ss
<<
n
.
getPath
().
getLastElement
()
<<
": "
<<
typeName
<<
" = "
;
makeValueText
(
n
,
ss
);
return
ss
.
str
();
}
template
<
class
Navigator
>
void
makeValueText
(
Navigator
&
n
,
std
::
stringstream
&
ss
)
{
ss
<<
n
.
getValue
();
}
void
makeValueText
(
aron
::
datanavigator
::
AronStringDataNavigator
&
n
,
std
::
stringstream
&
ss
)
{
ss
<<
"'"
<<
n
.
getValue
()
<<
"'"
;
}
};
MyVisitor
::~
MyVisitor
()
{}
MemoryRemoteGui
::
GroupBox
MemoryRemoteGui
::
makeGroupBox
(
const
EntityData
&
instance
)
const
{
GroupBox
group
;
if
(
instance
.
dataNavigator
)
{
ARMARX_IMPORTANT
<<
"Starting acceptor"
;
MyVisitor
visitor
;
aron
::
datanavigator
::
AronDataNavigatorAcceptor
acceptor
;
acceptor
.
accept
(
*
instance
.
dataNavigator
,
visitor
);
group
=
visitor
.
result
;
ARMARX_IMPORTANT
<<
"Ending acceptor"
;
}
else
{
group
.
addChild
(
Label
(
"(No introspection available.)"
));
}
std
::
stringstream
ss
;
ss
<<
"Instance #"
<<
instance
.
index
;
group
.
setLabel
(
ss
.
str
());
group
.
setCollapsed
(
true
);
return
group
;
}
std
::
string
MemoryRemoteGui
::
makeGroupLabel
(
const
string
&
term
,
const
string
&
name
,
size_t
size
,
const
std
::
string
&
namePrefix
,
const
std
::
string
&
nameSuffix
)
const
{
std
::
stringstream
ss
;
ss
<<
term
<<
namePrefix
<<
name
<<
nameSuffix
<<
" ("
<<
size
<<
")"
;
return
ss
.
str
();
}
std
::
string
MemoryRemoteGui
::
makeNoItemsMessage
(
const
std
::
string
&
term
)
const
{
std
::
stringstream
ss
;
ss
<<
"(no "
<<
term
<<
")"
;
return
ss
.
str
();
}
}
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/armem/component/MemoryRemoteGui.h
+
6
−
0
View file @
bd3828ca
...
...
@@ -22,6 +22,12 @@ namespace armarx::armem
GroupBox
makeGroupBox
(
const
ProviderSegment
&
providerSegment
)
const
;
GroupBox
makeGroupBox
(
const
Entity
&
entity
)
const
;
GroupBox
makeGroupBox
(
const
EntitySnapshot
&
entitySnapshot
)
const
;
GroupBox
makeGroupBox
(
const
EntityData
&
instance
)
const
;
std
::
string
makeGroupLabel
(
const
std
::
string
&
term
,
const
std
::
string
&
name
,
size_t
size
,
const
std
::
string
&
namePrefix
=
": '"
,
const
std
::
string
&
nameSuffix
=
"'"
)
const
;
std
::
string
makeNoItemsMessage
(
const
std
::
string
&
term
)
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment