Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nest-streaming-module
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LuFG VR VIS
VR-Group
In Situ Pipeline
nest-streaming-module
Commits
26230fd6
Commit
26230fd6
authored
6 years ago
by
Simon Oehrl
Browse files
Options
Downloads
Patches
Plain Diff
Use new nesci API
#7
parent
42abf07c
No related branches found
No related tags found
2 merge requests
!5
Feature/#7 remove conan
,
!3
Feature/#7 remove conan
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
streaming_recording_backend.cpp
+91
-11
91 additions, 11 deletions
streaming_recording_backend.cpp
streaming_recording_backend.h
+9
-1
9 additions, 1 deletion
streaming_recording_backend.h
with
100 additions
and
12 deletions
streaming_recording_backend.cpp
+
91
−
11
View file @
26230fd6
...
...
@@ -27,33 +27,113 @@
#include
<iostream>
#include
<memory>
#include
<sstream>
#include
<thread>
namespace
streamingnest
{
StreamingRecordingBackend
::
StreamingRecordingBackend
()
{}
void
StreamingRecordingBackend
::
initialize
()
{
// Called once
std
::
cout
<<
"initialize()"
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
enroll
(
const
nest
::
RecordingDevice
&
device
,
const
std
::
vector
<
Name
>
&
double_value_names
,
const
std
::
vector
<
Name
>
&
long_value_names
)
{
std
::
cout
<<
"double value names:"
<<
std
::
endl
;
// Called per thread
std
::
lock_guard
<
std
::
mutex
>
lock_guard
(
enroll_mutex_
);
std
::
vector
<
std
::
string
>
double_parameter_names
;
double_parameter_names
.
reserve
(
double_value_names
.
size
());
for
(
const
auto
&
value_name
:
double_value_names
)
{
double_parameter_names
.
push_back
(
value_name
.
toString
());
}
std
::
vector
<
std
::
string
>
long_parameter_names
;
long_parameter_names
.
reserve
(
long_value_names
.
size
());
for
(
const
auto
&
value_name
:
long_value_names
)
{
long_parameter_names
.
push_back
(
value_name
.
toString
());
}
if
(
device
.
get_type
()
==
nest
::
RecordingDevice
::
Type
::
MULTIMETER
)
{
devices_
[
std
::
this_thread
::
get_id
()][
device
.
get_name
()]
=
std
::
make_unique
<
nesci
::
producer
::
NestMultimeter
>
(
device
.
get_name
(),
double_parameter_names
,
long_parameter_names
);
}
std
::
cout
<<
std
::
this_thread
::
get_id
()
<<
' '
;
std
::
cout
<<
device
.
get_name
()
<<
' '
;
std
::
cout
<<
"double_value_names: "
;
for
(
const
auto
&
name
:
double_value_names
)
{
std
::
cout
<<
name
<<
std
::
endl
;
std
::
cout
<<
name
<<
' '
;
}
std
::
cout
<<
"
\n
long
value
names:"
<<
std
::
endl
;
std
::
cout
<<
"
,
long
_
value
_
names:
"
;
for
(
const
auto
&
name
:
long_value_names
)
{
std
::
cout
<<
name
<<
std
::
endl
;
std
::
cout
<<
name
<<
' '
;
}
std
::
cout
<<
std
::
endl
;
}
void
StreamingRecordingBackend
::
initialize
()
{}
void
StreamingRecordingBackend
::
write
(
const
nest
::
RecordingDevice
&
device
,
const
nest
::
Event
&
event
,
const
std
::
vector
<
double
>
&
double_values
,
const
std
::
vector
<
long
>
&
long_values
)
{
// Called per thread
// std::lock_guard<std::mutex> lock_guard(write_mutex_);
// std::cout << std::this_thread::get_id() << ' ';
// std::cout << device.get_name() << ' ';
// std::cout << event.get_sender_gid() << ' ';
// std::cout << event.get_stamp() << ' ';
// for (const auto value : double_values) {
// std::cout << value << ' ';
// }
// std::cout << ' ';
// for (const auto value : long_values) {
// std::cout << value << ' ';
// }
// std::cout << std::endl;
void
StreamingRecordingBackend
::
finalize
()
{}
const
auto
thread_devices
=
devices_
.
find
(
std
::
this_thread
::
get_id
());
if
(
thread_devices
==
devices_
.
end
())
{
// std::cout << "Error: no devices assigned to this thread!" << std::endl;
return
;
}
void
StreamingRecordingBackend
::
synchronize
()
{}
const
auto
thread_device
=
thread_devices
->
second
.
find
(
device
.
get_name
());
if
(
thread_device
==
thread_devices
->
second
.
end
())
{
// std::cout << "Error: device not found in this thread (device = "
// << device.get_name() << ")" << std::endl;
void
StreamingRecordingBackend
::
write
(
const
nest
::
RecordingDevice
&
,
const
nest
::
Event
&
,
const
std
::
vector
<
double
>
&
,
const
std
::
vector
<
long
>
&
)
{}
return
;
}
auto
&
nesci_device
=
thread_device
->
second
;
if
(
device
.
get_type
()
==
nest
::
RecordingDevice
::
Type
::
MULTIMETER
)
{
auto
multimeter
=
static_cast
<
nesci
::
producer
::
NestMultimeter
*>
(
nesci_device
.
get
());
multimeter
->
Record
(
event
.
get_stamp
().
get_ms
(),
event
.
get_sender_gid
(),
double_values
.
data
(),
long_values
.
data
());
}
}
void
StreamingRecordingBackend
::
synchronize
()
{
// Called per thread
for
(
const
auto
&
device
:
devices_
.
at
(
std
::
this_thread
::
get_id
()))
{
{
std
::
lock_guard
<
std
::
mutex
>
lock_guard
(
relay_mutex_
);
relay_
.
Send
(
device
.
second
->
node
(),
false
);
}
static_cast
<
nesci
::
producer
::
NestMultimeter
*>
(
device
.
second
.
get
())
->
Clear
();
}
}
void
StreamingRecordingBackend
::
finalize
()
{
// Called once
std
::
cout
<<
"finalize()"
<<
std
::
endl
;
}
}
// namespace streamingnest
This diff is collapsed.
Click to expand it.
streaming_recording_backend.h
+
9
−
1
View file @
26230fd6
...
...
@@ -25,6 +25,7 @@
#include
<map>
#include
<memory>
#include
<mutex>
#include
<string>
#include
<vector>
...
...
@@ -55,8 +56,15 @@ class StreamingRecordingBackend : public nest::RecordingBackend {
const
std
::
vector
<
double
>
&
,
const
std
::
vector
<
long
>
&
)
override
;
private
:
std
::
mutex
relay_mutex_
;
contra
::
Relay
<
contra
::
SharedMemoryTransport
>
relay_
;
std
::
map
<
nest
::
index
,
std
::
unique_ptr
<
nesci
::
producer
::
Device
>>
recorders_
;
std
::
mutex
write_mutex_
;
std
::
map
<
std
::
thread
::
id
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
nesci
::
producer
::
Device
>>>
devices_
;
std
::
mutex
enroll_mutex_
;
};
}
// namespace streamingnest
...
...
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