Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
insite-nest-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
insite-nest-module
Commits
8e2d2be8
Commit
8e2d2be8
authored
5 years ago
by
Simon Oehrl
Browse files
Options
Downloads
Patches
Plain Diff
Change position to array
parent
add603d1
No related branches found
No related tags found
1 merge request
!10
Feature/add database
Pipeline
#163420
canceled
5 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
recording_backend_insite.cpp
+51
-37
51 additions, 37 deletions
recording_backend_insite.cpp
with
51 additions
and
37 deletions
recording_backend_insite.cpp
+
51
−
37
View file @
8e2d2be8
...
@@ -24,10 +24,13 @@ RecordingBackendInsite::RecordingBackendInsite()
...
@@ -24,10 +24,13 @@ RecordingBackendInsite::RecordingBackendInsite()
pqxx
::
work
txn
(
database_connection_
);
pqxx
::
work
txn
(
database_connection_
);
simulation_node_id_
=
txn
.
exec1
(
simulation_node_id_
=
txn
.
exec1
(
"INSERT INTO nest_simulation_node (address) "
"INSERT INTO nest_simulation_node (address) "
"VALUES ('http://insite-nest-module:"
+
get_port_string
()
+
"') "
"VALUES ('http://insite-nest-module:"
+
"RETURNING id;"
get_port_string
()
+
)[
0
].
as
<
int
>
();
"') "
std
::
cout
<<
"Simulation node registered to database. Node ID: "
<<
simulation_node_id_
<<
std
::
endl
;
"RETURNING id;"
)[
0
]
.
as
<
int
>
();
std
::
cout
<<
"Simulation node registered to database. Node ID: "
<<
simulation_node_id_
<<
std
::
endl
;
txn
.
commit
();
txn
.
commit
();
}
}
...
@@ -66,8 +69,7 @@ void RecordingBackendInsite::set_value_names(
...
@@ -66,8 +69,7 @@ void RecordingBackendInsite::set_value_names(
auto
&
multimeter
=
multimeter_infos_
.
at
(
device
.
get_node_id
());
auto
&
multimeter
=
multimeter_infos_
.
at
(
device
.
get_node_id
());
std
::
stringstream
multimeter_query
;
std
::
stringstream
multimeter_query
;
multimeter_query
multimeter_query
<<
"INSERT INTO nest_multimeter (id, attributes) "
<<
"INSERT INTO nest_multimeter (id, attributes) "
<<
"VALUES ("
<<
device
.
get_node_id
()
<<
",
\'
{"
;
<<
"VALUES ("
<<
device
.
get_node_id
()
<<
",
\'
{"
;
bool
first
=
true
;
bool
first
=
true
;
...
@@ -115,16 +117,18 @@ void RecordingBackendInsite::post_step_hook() {
...
@@ -115,16 +117,18 @@ void RecordingBackendInsite::post_step_hook() {
pqxx
::
work
txn
(
database_connection_
);
pqxx
::
work
txn
(
database_connection_
);
txn
.
exec0
(
txn
.
exec0
(
"UPDATE nest_simulation_node "
"UPDATE nest_simulation_node "
"SET current_simulation_time = "
+
std
::
to_string
(
latest_simulation_time_
)
+
""
"SET current_simulation_time = "
+
"WHERE id = "
+
std
::
to_string
(
simulation_node_id_
)
std
::
to_string
(
latest_simulation_time_
)
+
);
""
"WHERE id = "
+
std
::
to_string
(
simulation_node_id_
));
txn
.
commit
();
txn
.
commit
();
}
}
if
(
new_neuron_infos_
.
size
()
>
0
)
{
if
(
new_neuron_infos_
.
size
()
>
0
)
{
std
::
stringstream
neuron_query
;
std
::
stringstream
neuron_query
;
neuron_query
neuron_query
<<
"INSERT INTO nest_neuron (id, simulation_node_id, "
<<
"INSERT INTO nest_neuron (id, simulation_node_id, population_id, position_x, position_y, position_z
) "
"population_id, position
) "
<<
"VALUES "
;
<<
"VALUES "
;
for
(
auto
&
neuron_info
:
new_neuron_infos_
)
{
for
(
auto
&
neuron_info
:
new_neuron_infos_
)
{
const
bool
first
=
neuron_info
.
gid
==
new_neuron_infos_
[
0
].
gid
;
const
bool
first
=
neuron_info
.
gid
==
new_neuron_infos_
[
0
].
gid
;
...
@@ -133,16 +137,26 @@ void RecordingBackendInsite::post_step_hook() {
...
@@ -133,16 +137,26 @@ void RecordingBackendInsite::post_step_hook() {
}
}
uint64_t
population_id
=
0
;
uint64_t
population_id
=
0
;
for
(
const
nest
::
NodeIDTriple
&
node_id_triple
:
*
neuron_info
.
gid_collection
.
get
())
{
for
(
const
nest
::
NodeIDTriple
&
node_id_triple
:
*
neuron_info
.
gid_collection
.
get
())
{
population_id
^=
node_id_triple
.
node_id
*
938831
;
population_id
^=
node_id_triple
.
node_id
*
938831
;
}
}
neuron_query
<<
"("
<<
neuron_info
.
gid
<<
","
<<
simulation_node_id_
<<
","
<<
population_id
%
0x800000
;
neuron_query
<<
"("
<<
neuron_info
.
gid
<<
","
<<
simulation_node_id_
for
(
const
auto
position_entry
:
neuron_info
.
position
)
{
<<
","
<<
population_id
%
0x800000
;
neuron_query
<<
","
<<
position_entry
;
const
auto
position_size
=
neuron_info
.
position
.
size
();
if
(
position_size
>
0
)
{
assert
(
position_size
<=
3
);
neuron_query
<<
",
\'
{"
;
for
(
size_t
i
=
0
;
i
<
position_size
;
++
i
)
{
if
(
i
>
0
)
{
neuron_query
<<
","
;
}
neuron_query
<<
neuron_info
.
position
[
i
];
}
}
assert
(
neuron_info
.
position
.
size
()
<=
3
)
;
neuron_query
<<
"}
\'
"
;
for
(
auto
i
=
3
-
neuron_info
.
position
.
size
();
i
!=
0
;
--
i
)
{
}
else
{
neuron_query
<<
",NULL"
;
neuron_query
<<
",NULL"
;
}
}
neuron_query
<<
")"
;
neuron_query
<<
")"
;
...
@@ -162,8 +176,7 @@ void RecordingBackendInsite::post_step_hook() {
...
@@ -162,8 +176,7 @@ void RecordingBackendInsite::post_step_hook() {
// Send multimeter info
// Send multimeter info
for
(
auto
&
kvp
:
multimeter_infos_
)
{
for
(
auto
&
kvp
:
multimeter_infos_
)
{
auto
&
multimeter
=
kvp
.
second
;
auto
&
multimeter
=
kvp
.
second
;
if
(
!
multimeter
.
needs_update
)
if
(
!
multimeter
.
needs_update
)
continue
;
continue
;
multimeter
.
needs_update
=
false
;
multimeter
.
needs_update
=
false
;
if
(
multimeter
.
gids
.
size
()
>
0
)
{
if
(
multimeter
.
gids
.
size
()
>
0
)
{
...
@@ -174,7 +187,8 @@ void RecordingBackendInsite::post_step_hook() {
...
@@ -174,7 +187,8 @@ void RecordingBackendInsite::post_step_hook() {
for
(
const
auto
&
neuron_id
:
multimeter
.
gids
)
{
for
(
const
auto
&
neuron_id
:
multimeter
.
gids
)
{
const
bool
first
=
neuron_id
==
multimeter
.
gids
[
0
];
const
bool
first
=
neuron_id
==
multimeter
.
gids
[
0
];
neuron_multimeter_query
<<
(
first
?
""
:
","
)
<<
"("
<<
neuron_id
<<
","
<<
multimeter
.
device_id
<<
")"
;
neuron_multimeter_query
<<
(
first
?
""
:
","
)
<<
"("
<<
neuron_id
<<
","
<<
multimeter
.
device_id
<<
")"
;
}
}
neuron_multimeter_query
<<
" ON CONFLICT DO NOTHING;"
;
neuron_multimeter_query
<<
" ON CONFLICT DO NOTHING;"
;
...
@@ -208,12 +222,12 @@ void RecordingBackendInsite::write(const nest::RecordingDevice& device,
...
@@ -208,12 +222,12 @@ void RecordingBackendInsite::write(const nest::RecordingDevice& device,
}
}
for
(
std
::
size_t
i
=
0
;
i
<
double_values
.
size
();
++
i
)
for
(
std
::
size_t
i
=
0
;
i
<
double_values
.
size
();
++
i
)
data_storage_
.
AddMultimeterMeasurement
(
device_id
,
data_storage_
.
AddMultimeterMeasurement
(
multimeter
.
double_attributes
[
i
],
time_stamp
,
sender_gid
,
device_id
,
multimeter
.
double_attributes
[
i
],
time_stamp
,
sender_gid
,
double_values
[
i
]);
double_values
[
i
]);
for
(
std
::
size_t
i
=
0
;
i
<
long_values
.
size
();
++
i
)
for
(
std
::
size_t
i
=
0
;
i
<
long_values
.
size
();
++
i
)
data_storage_
.
AddMultimeterMeasurement
(
device_id
,
data_storage_
.
AddMultimeterMeasurement
(
multimeter
.
long_attributes
[
i
],
time_stamp
,
sender_gid
,
device_id
,
multimeter
.
long_attributes
[
i
],
time_stamp
,
sender_gid
,
double
(
long_values
[
i
]));
double
(
long_values
[
i
]));
}
}
latest_simulation_time_
=
std
::
max
(
latest_simulation_time_
,
time_stamp
);
latest_simulation_time_
=
std
::
max
(
latest_simulation_time_
,
time_stamp
);
...
...
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