Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add infrastructure for generic input backends to feed devices #1456

Merged
merged 178 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 171 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
9739cc2
Added infrastructure for the input part of NESTIO
sdiazpier Mar 6, 2020
50eba3a
Added input infrastructure to cmake
sdiazpier Mar 6, 2020
c244c5f
Formatting
sdiazpier Mar 6, 2020
bacee11
Added the mpi recording backend and did some formatting
sdiazpier Mar 6, 2020
a7f63d9
Fixed copyright headers
sdiazpier Mar 6, 2020
f479262
Vera fixes
sdiazpier Mar 6, 2020
3b74650
Fixing bug with set parameters
sdiazpier Mar 16, 2020
8aa0c74
Some more corrections
sdiazpier Mar 16, 2020
ea6a3a7
Fixed registration of new devices when changing number of threads
sdiazpier Mar 24, 2020
5a0555c
Cleaned the finalize function of the input backend
sdiazpier Mar 24, 2020
4af28b4
Add documents and fix some comments
lionelkusch Mar 31, 2020
34a5830
Fix some requests from hakonsbm
lionelkusch Mar 31, 2020
9b5a67a
Update nestkernel/input_backend_internal.cpp
sdiazpier Apr 1, 2020
f8df294
Fix all the request
lionelkusch Apr 1, 2020
8a629ad
Small changes to comments and format
sdiazpier Apr 1, 2020
c1aaf1d
Fix bug in the log
lionelkusch Apr 1, 2020
61bfc8c
Fix one syntaxe
lionelkusch Apr 1, 2020
aa7075b
Add override in spike generator and io-manager
lionelkusch Apr 1, 2020
deb8aed
Add exception adn change LOG message
lionelkusch Apr 2, 2020
b8e29da
Fix syntaxe
lionelkusch Apr 2, 2020
29727cd
Fix syntax
lionelkusch Apr 2, 2020
ccde0e9
Fix syntax
lionelkusch Apr 2, 2020
ffea7e6
Add the missing device
lionelkusch Apr 2, 2020
6502efa
Fix syntax
lionelkusch Apr 2, 2020
d2fe2dd
Syntax fix
sdiazpier Apr 2, 2020
1550bab
Fix request
lionelkusch Apr 9, 2020
2007d22
Changed dynamic array allocation
sdiazpier Apr 14, 2020
7887583
Format fixes
sdiazpier Apr 14, 2020
e26161f
Fix bug of dynamical array
lionelkusch Apr 14, 2020
fa93cee
Fix syntax
lionelkusch Apr 14, 2020
7645d75
Change communication pattern
lionelkusch Apr 21, 2020
8fa3b17
Rename of input backends to stimulating backends refactoring started
sdiazpier Apr 21, 2020
bdde0bb
Fix syntaxe
lionelkusch Apr 22, 2020
10716c9
other changes for stimulating_device
sdiazpier Apr 22, 2020
9eb5884
further corrections for input to stimulating backend
sdiazpier Apr 22, 2020
9c558b7
solving omp and mpi errors
sdiazpier Apr 22, 2020
b71f7a8
finalized change of name from input backend to stimulating backend
sdiazpier Apr 22, 2020
6aabd86
First step in refactoring base class for spike generator
sdiazpier Apr 22, 2020
fafd946
Refactored all generators to inherit from StimulatingDevice instead o…
sdiazpier Apr 23, 2020
3a8e7b3
format corrections
sdiazpier Apr 23, 2020
c5b26e5
Refactor integration of InputDevice funtionality into StimulatingDevice
sdiazpier Apr 23, 2020
ffaa23d
compiled after the stimulating device merge with input device
sdiazpier Sep 2, 2020
40b2bd1
Corrections after rebase on master
sdiazpier Sep 2, 2020
5252f87
Solved the kernel access error
sdiazpier Oct 27, 2020
7b0246f
Fixed parameter propagation
sdiazpier Oct 28, 2020
2eb6867
format fixes
sdiazpier Oct 28, 2020
b68d7a5
Correction of spike detector to spike recorder
sdiazpier Oct 28, 2020
80d25b6
Last name changes
sdiazpier Oct 28, 2020
1f1018e
Format fix to stimulating device
sdiazpier Oct 28, 2020
82f4aea
Merging with master
sdiazpier Nov 23, 2020
32dda88
Fixed format in server code
sdiazpier Nov 23, 2020
742dd55
Changed the SpikeParameters to Parameters in the spike generator
sdiazpier Nov 23, 2020
cb0f06a
format fix
sdiazpier Nov 24, 2020
0dc3179
Merged with nest-io-dev-2-mpi-th
sdiazpier Nov 24, 2020
9b03f50
Fix small bug
lionelkusch Nov 24, 2020
b1c3891
fixed format
sdiazpier Nov 24, 2020
7110974
small modification
lionelkusch Nov 24, 2020
b80faca
Merge branch 'nest-i' of https://github.com/sdiazpier/nest-simulator …
lionelkusch Nov 24, 2020
53977e1
removed templating from stimulating device
sdiazpier Nov 26, 2020
95e21eb
compiles without the template
sdiazpier Nov 26, 2020
f404913
Working setup without templating in the stimulating device and type b…
sdiazpier Nov 26, 2020
9c20f1a
Add function for update the stimulted generator
lionelkusch Dec 3, 2020
31c6166
Fix issue for copying parameter different than default
lionelkusch Dec 9, 2020
ba0c9d6
Remove the variable ofr special mpi
lionelkusch Dec 15, 2020
7d4506a
format changes
sdiazpier Jan 11, 2021
335103b
Merge branch 'nest-i' of github.com:sdiazpier/nest-simulator into nest-i
sdiazpier Jan 11, 2021
a86c2bd
solved current generator problem
sdiazpier Jan 11, 2021
1ec54cd
Fixed formatting issues
sdiazpier Jan 12, 2021
b438038
Remove unused variable
lionelkusch Jan 15, 2021
969fca5
Avoid MPI in parallel context for recording
lionelkusch Jan 15, 2021
c1b4191
Fix syntax issues
lionelkusch Jan 15, 2021
ad4e93d
Fix syntax
lionelkusch Jan 15, 2021
753abdc
Fix syntaxe
lionelkusch Jan 16, 2021
6877216
Add override qualification
lionelkusch Jan 16, 2021
4bb1a5e
Fix override
lionelkusch Jan 16, 2021
d86dd65
Remove unecessary function
lionelkusch Feb 2, 2021
a365821
Fix comment of the reviews
lionelkusch Feb 2, 2021
7283d7d
Fix syntax
lionelkusch Feb 2, 2021
ef46907
Update models/spike_generator.cpp
lionelkusch Feb 2, 2021
3e42d8c
Fix syntax
lionelkusch Feb 2, 2021
d824738
Fix syntax
lionelkusch Feb 2, 2021
7aee72b
Remove name stimuling_backends
lionelkusch Feb 2, 2021
5ecd8f3
Remove warning
lionelkusch Feb 3, 2021
9632c22
Update models/inhomogeneous_poisson_generator.cpp
lionelkusch Feb 3, 2021
e2dbd24
Update models/pulsepacket_generator.cpp
lionelkusch Feb 3, 2021
d9ee5b0
remove unnecesarry function
lionelkusch Feb 3, 2021
064ecc2
Changes in documentation to make evident the data which is transfered…
sdiazpier Feb 9, 2021
2c6952d
Changed datum format
sdiazpier Feb 9, 2021
81d96a5
removed device type restrictions to MPI backend
sdiazpier Feb 9, 2021
d9c5969
Small fix in the precise conditions when updating from backend in the…
sdiazpier Feb 10, 2021
d350b2a
Update models/inhomogeneous_poisson_generator.cpp
sdiazpier Mar 29, 2021
43ebb6c
Update models/gamma_sup_generator.h
sdiazpier Mar 29, 2021
2323c31
Update models/poisson_generator_ps.cpp
sdiazpier Mar 29, 2021
0b79b56
Update models/pulsepacket_generator.cpp
sdiazpier Mar 29, 2021
68ac471
Update models/sinusoidal_gamma_generator.cpp
sdiazpier Mar 29, 2021
2457401
Update models/sinusoidal_poisson_generator.cpp
sdiazpier Mar 29, 2021
ce6fdd7
Update models/spike_generator.cpp
sdiazpier Mar 29, 2021
bae52ea
Update models/spike_generator.cpp
sdiazpier Mar 29, 2021
5ceb0a0
Update nestkernel/recording_backend_mpi.cpp
sdiazpier Mar 29, 2021
228acf2
Update nestkernel/recording_backend_mpi.h
sdiazpier Mar 29, 2021
d2689da
Update nestkernel/stimulating_backend.h
sdiazpier Mar 29, 2021
bbea772
Update nestkernel/stimulating_backend.h
sdiazpier Mar 29, 2021
63b2c81
Update nestkernel/stimulating_backend.h
sdiazpier Mar 29, 2021
79ca936
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
776d302
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
885ed78
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
d857920
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
a4be114
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
61f0bc9
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
7642872
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
6244286
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
1b5e218
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
cc88137
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
201fd58
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
db69db3
Update nestkernel/stimulating_backend_mpi.cpp
sdiazpier Mar 29, 2021
69a7571
Update nestkernel/stimulating_backend_mpi.h
sdiazpier Mar 29, 2021
1898de9
Update nestkernel/stimulating_backend_mpi.h
sdiazpier Mar 29, 2021
536fa5d
Update nestkernel/stimulating_backend_mpi.h
sdiazpier Mar 29, 2021
310cd4f
Update nestkernel/stimulating_backend_mpi.h
sdiazpier Mar 29, 2021
4c7678c
Update nestkernel/stimulating_device.cpp
sdiazpier Mar 29, 2021
856e58a
Update nestkernel/stimulating_device.cpp
sdiazpier Mar 29, 2021
b05b95c
Update models/noise_generator.h
sdiazpier Mar 30, 2021
ce4706d
resolving comments in PR
sdiazpier Mar 30, 2021
1341d90
Merge branch 'nest-i' of github.com:sdiazpier/nest-simulator into nest-i
sdiazpier Mar 30, 2021
8c67e36
Update nestkernel/stimulating_device.cpp
sdiazpier Mar 30, 2021
df5e9c6
More fixes addressing comments in the PR
sdiazpier Mar 30, 2021
f0d705d
Merge branch 'nest-i' of github.com:sdiazpier/nest-simulator into nest-i
sdiazpier Mar 30, 2021
ffcc4b0
Addressed last comments in the PR
sdiazpier Mar 30, 2021
edc12e3
Update nestkernel/recording_backend_mpi.h
lionelkusch Apr 23, 2021
fd4e8cf
Update nestkernel/recording_backend_mpi.h
lionelkusch Apr 23, 2021
d8a988e
Update nestkernel/stimulating_backend.h
lionelkusch Apr 23, 2021
ba8ae91
Update nestkernel/stimulating_backend_mpi.h
lionelkusch Apr 23, 2021
7a07944
Changed string formatting back to f-strings
sdiazpier Apr 23, 2021
bc311cf
Update models/ac_generator.cpp
lionelkusch May 6, 2021
3d3b9de
Update models/ac_generator.h
lionelkusch May 6, 2021
5d5fbb6
Update models/dc_generator.h
lionelkusch May 6, 2021
ed3f322
Update models/gamma_sup_generator.h
lionelkusch May 6, 2021
bf74873
Update models/inhomogeneous_poisson_generator.cpp
lionelkusch May 6, 2021
0fbe260
Update models/inhomogeneous_poisson_generator.h
lionelkusch May 6, 2021
b78ddce
Update models/mip_generator.cpp
lionelkusch May 6, 2021
e614cee
Update models/mip_generator.h
lionelkusch May 6, 2021
9d24c02
Update models/noise_generator.cpp
lionelkusch May 6, 2021
f91fb5e
Update models/noise_generator.h
lionelkusch May 6, 2021
a26c230
Update models/poisson_generator.h
lionelkusch May 6, 2021
7f974cc
Update models/poisson_generator_ps.h
lionelkusch May 6, 2021
678ff47
Update models/ppd_sup_generator.h
lionelkusch May 6, 2021
e8a58bd
Update models/pulsepacket_generator.h
lionelkusch May 6, 2021
b4d61dc
Apply suggestions from code review
lionelkusch May 6, 2021
765d50c
Apply suggestions from code review
lionelkusch May 6, 2021
704f823
Replace internal by an empty string
lionelkusch May 7, 2021
f030b65
Start to modify comments of the file
lionelkusch May 7, 2021
0a8040f
Modification of the documentation
lionelkusch May 7, 2021
988b14e
Change makefile for removing a file
lionelkusch May 7, 2021
416b601
Improve documentation
lionelkusch May 10, 2021
989fa06
Update nestkernel/stimulating_backend_mpi.h
sdiazpier May 17, 2021
63164a8
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
ed82958
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
2f996bf
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
785ce73
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
2a2af51
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
d731011
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
e1aaf95
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
bfb9bf2
Update nestkernel/stimulating_backend.h
sdiazpier May 17, 2021
c508cc2
Update nestkernel/recording_backend_mpi.h
sdiazpier May 17, 2021
2c6f9ed
Update nestkernel/stimulating_backend_mpi.h
sdiazpier May 17, 2021
f66d9db
Update nestkernel/recording_backend_mpi.h
sdiazpier May 17, 2021
0bbf518
Update nestkernel/recording_backend_mpi.h
sdiazpier May 17, 2021
988b8b3
Merge to master, addressed some documentation details and removed pos…
sdiazpier May 17, 2021
e567d2e
Deleted call to post_step_hook from io manager
sdiazpier May 17, 2021
f357f21
removed old random deviate
sdiazpier May 17, 2021
d12aac8
Fix format
sdiazpier May 17, 2021
9ffb9a3
Solved some issues with documentation
sdiazpier May 17, 2021
abe745b
Merge branch 'master' of https://github.com/nest/nest-simulator into …
lionelkusch Jun 2, 2021
3f8b344
Documentation of MPI
lionelkusch Jun 3, 2021
8f7594c
Add the documentation for Nest_3 feature.
lionelkusch Jun 3, 2021
5198a5d
Small changes in documentation
sdiazpier Jun 8, 2021
1284bb7
Rework user level documentation for NESTio/Input (#6)
jougs Jun 8, 2021
4a0f2a1
Merge branch 'master' into nest-i
jougs Jun 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/userdoc/guides/recording_from_simulations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ properties can be obtained from the kernel's status dictionary.
nest.GetKernelStatus("recording_backends")
{u'ascii': {},
u'memory': {},
u'mpi': {},
u'screen': {},
u'sionlib': {u'buffer_size': 1024,
u'filename': u'',
Expand All @@ -118,3 +119,4 @@ NEST:
- :ref:`recording_backend_ascii`
- :ref:`recording_backend_screen`
- :ref:`recording_backend_sionlib`
- :ref:`recording_backend_mpi`
31 changes: 28 additions & 3 deletions doc/userdoc/guides/stimulating_the_network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ stimulating devices (origin is just a global offset):
recorded at the earliest at time start+h. The last interval during
which the current affects the target's dynamics is (stop-h, stop].


.. doxygengroup:: generator
:content-only:
Common recorder properties
--------------------------
.. glossary::

stimulus_source
A string (default: `""`) containing the name of the stimulating
backend, where to get the data for updating the stimulating device.
By default the device uses only its parameters for updating this stimulus.

label
A string (default: `""`) specifying an arbitrary textual label for
the device.
The `mpi` use this label to localize the file which contains port description.

How to update stimulating devices with MPI communication?
---------------------------------------------------------

The stimulating device can be updated between each run of Nest.
Currently, only `mpi` communication can be used to receive data which can replace the default signals
generated internally by stimulating devices.
The 'mpi' mackend backend makes use of the label of the device in order to find the port description
for the connection with the external software.
The format of the data received by Nest for updating the stimulating devices depends on the type of device.
For more information, please look at the documentation of each device.

For more information on the internal protocol used by the 'mpi' backend for stimulating devices please
refer to:
- :ref:`stimulating_backend_mpi`
43 changes: 35 additions & 8 deletions models/ac_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ nest::ac_generator::Parameters_::set( const DictionaryDatum& d, Node* node )
* ---------------------------------------------------------------- */

nest::ac_generator::ac_generator()
: DeviceNode()
, device_()
: StimulatingDevice()
, P_()
, S_()
, B_( *this )
Expand All @@ -149,8 +148,7 @@ nest::ac_generator::ac_generator()
}

nest::ac_generator::ac_generator( const ac_generator& n )
: DeviceNode( n )
, device_( n.device_ )
: StimulatingDevice( n )
, P_( n.P_ )
, S_( n.S_ )
, B_( n.B_, *this )
Expand All @@ -167,14 +165,14 @@ nest::ac_generator::init_state_( const Node& proto )
{
const ac_generator& pr = downcast< ac_generator >( proto );

device_.init_state( pr.device_ );
StimulatingDevice::init_state( pr );
S_ = pr.S_;
}

void
nest::ac_generator::init_buffers_()
{
device_.init_buffers();
StimulatingDevice::init_buffers();
B_.logger_.reset();
}

Expand All @@ -183,7 +181,7 @@ nest::ac_generator::calibrate()
{
B_.logger_.init();

device_.calibrate();
StimulatingDevice::calibrate();

const double h = Time::get_resolution().get_ms();
const double t = kernel().simulation_manager.get_time().get_ms();
Expand Down Expand Up @@ -221,7 +219,7 @@ nest::ac_generator::update( Time const& origin, const long from, const long to )
S_.y_1_ = V_.A_10_ * y_0 + V_.A_11_ * S_.y_1_;

S_.I_ = 0.0;
if ( device_.is_active( Time::step( start + lag ) ) )
if ( StimulatingDevice::is_active( Time::step( start + lag ) ) )
{
S_.I_ = S_.y_1_ + P_.offset_;
ce.set_current( S_.I_ );
Expand All @@ -236,3 +234,32 @@ nest::ac_generator::handle( DataLoggingRequest& e )
{
B_.logger_.handle( e );
}

/* ----------------------------------------------------------------
* Other functions
* ---------------------------------------------------------------- */

void
nest::ac_generator::set_data_from_stimulating_backend( std::vector< double >& input_param )
{
Parameters_ ptmp = P_; // temporary copy in case of errors

// For the input backend
if ( not input_param.empty() )
{
if ( input_param.size() != 4 )
{
throw BadParameterValue(
"The size of the data for the ac_generator needs to be 4 [amplitude, offset, frequency, phase]." );
}
DictionaryDatum d = DictionaryDatum( new Dictionary );
( *d )[ names::amplitude ] = DoubleDatum( input_param[ 0 ] );
( *d )[ names::offset ] = DoubleDatum( input_param[ 1 ] );
( *d )[ names::frequency ] = DoubleDatum( input_param[ 2 ] );
( *d )[ names::phase ] = DoubleDatum( input_param[ 3 ] );
ptmp.set( d, this );
}

// if we get here, temporary contains consistent set of properties
P_ = ptmp;
}
81 changes: 44 additions & 37 deletions models/ac_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ Parameters
Setting start and stop only windows the current as defined above. It does not shift
the time axis. See :doc:`stimulating_the_network` for details.

Update from stimulating backend
+++++++++++++++++++++++++++++++

The parameters in this stimulating device can be updated with input
coming from a stimulating backend. The data structure used for the update
holds one value for each of the parameters mentioned in the section above.
The indexing is as follows:
amplitude = input_param[ 0 ]
offset = input_param[ 1 ]
frequency = input_param[ 2 ]
phase = input_param[ 3 ]

References
++++++++++

Expand All @@ -83,57 +95,44 @@ CurrentEvent
See also
++++++++

dc_generator, noise_generator, step_current_generator
dc_generator, noise_generator, step_current_generator, StimulatingDevice,
Device

EndUserDocs */

namespace nest
{

class ac_generator : public DeviceNode
class ac_generator : public StimulatingDevice
{

public:
ac_generator();
ac_generator( const ac_generator& );

bool
has_proxies() const
{
return false;
}

//! Allow multimeter to connect to local instances
bool
local_receiver() const
{
return true;
}

Name
get_element_type() const
{
return names::stimulator;
}
bool local_receiver() const override;

port send_test_event( Node&, rport, synindex, bool );
port send_test_event( Node&, rport, synindex, bool ) override;

using Node::handle;
using Node::handles_test_event;

void handle( DataLoggingRequest& );
void handle( DataLoggingRequest& ) override;

port handles_test_event( DataLoggingRequest&, rport ) override;

port handles_test_event( DataLoggingRequest&, rport );
void get_status( DictionaryDatum& ) const override;
void set_status( const DictionaryDatum& ) override;

void get_status( DictionaryDatum& ) const;
void set_status( const DictionaryDatum& );
StimulatingDevice::Type get_type() const override;
void set_data_from_stimulating_backend( std::vector< double >& input_param ) override;

private:
void init_state_( const Node& );
void init_buffers_();
void calibrate();
void init_state_( const Node& ) override;
void init_buffers_() override;
void calibrate() override;

void update( Time const&, const long, const long );
void update( Time const&, const long, const long ) override;


// ------------------------------------------------------------
Expand Down Expand Up @@ -180,7 +179,7 @@ class ac_generator : public DeviceNode
*/
struct Buffers_
{
Buffers_( ac_generator& );
explicit Buffers_( ac_generator& );
Buffers_( const Buffers_&, ac_generator& );
UniversalDataLogger< ac_generator > logger_;
};
Expand All @@ -189,9 +188,6 @@ class ac_generator : public DeviceNode

struct Variables_
{
double omega_; //!< Angelfrequency i rad/s
double phi_rad_; //!< Phase of sine current (0-2Pi rad)

// The exact integration matrix
double A_00_;
double A_01_;
Expand All @@ -207,7 +203,6 @@ class ac_generator : public DeviceNode

// ------------------------------------------------------------

StimulatingDevice< CurrentEvent > device_;
static RecordablesMap< ac_generator > recordablesMap_;
Parameters_ P_;
State_ S_;
Expand All @@ -218,7 +213,7 @@ class ac_generator : public DeviceNode
inline port
ac_generator::send_test_event( Node& target, rport receptor_type, synindex syn_id, bool )
{
device_.enforce_single_syn_type( syn_id );
StimulatingDevice::enforce_single_syn_type( syn_id );

CurrentEvent e;
e.set_sender( *this );
Expand All @@ -241,7 +236,7 @@ ac_generator::get_status( DictionaryDatum& d ) const
{
P_.get( d );
S_.get( d );
device_.get_status( d );
StimulatingDevice::get_status( d );

( *d )[ names::recordables ] = recordablesMap_.get_list();
}
Expand All @@ -257,12 +252,24 @@ ac_generator::set_status( const DictionaryDatum& d )
// We now know that ptmp is consistent. We do not write it back
// to P_ before we are also sure that the properties to be set
// in the parent class are internally consistent.
device_.set_status( d );
StimulatingDevice::set_status( d );

// if we get here, temporaries contain consistent set of properties
P_ = ptmp;
}

inline bool
ac_generator::local_receiver() const
{
return true;
}

inline StimulatingDevice::Type
ac_generator::get_type() const
{
return StimulatingDevice::Type::CURRENT_GENERATOR;
}

} // namespace

#endif // AC_GENERATOR_H
36 changes: 27 additions & 9 deletions models/dc_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ nest::dc_generator::Parameters_::set( const DictionaryDatum& d, Node* node )
* ---------------------------------------------------------------- */

nest::dc_generator::dc_generator()
: DeviceNode()
, device_()
: StimulatingDevice()
, P_()
, S_()
, B_( *this )
Expand All @@ -122,8 +121,7 @@ nest::dc_generator::dc_generator()
}

nest::dc_generator::dc_generator( const dc_generator& n )
: DeviceNode( n )
, device_( n.device_ )
: StimulatingDevice( n )
, P_( n.P_ )
, S_( n.S_ )
, B_( n.B_, *this )
Expand All @@ -140,14 +138,14 @@ nest::dc_generator::init_state_( const Node& proto )
{
const dc_generator& pr = downcast< dc_generator >( proto );

device_.init_state( pr.device_ );
StimulatingDevice::init_state( pr );
S_ = pr.S_;
}

void
nest::dc_generator::init_buffers_()
{
device_.init_buffers();
StimulatingDevice::init_buffers();
B_.logger_.reset();
}

Expand All @@ -156,7 +154,7 @@ nest::dc_generator::calibrate()
{
B_.logger_.init();

device_.calibrate();
StimulatingDevice::calibrate();
}


Expand All @@ -177,8 +175,7 @@ nest::dc_generator::update( Time const& origin, const long from, const long to )
for ( long offs = from; offs < to; ++offs )
{
S_.I_ = 0.0;

if ( device_.is_active( Time::step( start + offs ) ) )
if ( StimulatingDevice::is_active( Time::step( start + offs ) ) )
{
S_.I_ = P_.amp_;
kernel().event_delivery_manager.send( *this, ce, offs );
Expand All @@ -192,3 +189,24 @@ nest::dc_generator::handle( DataLoggingRequest& e )
{
B_.logger_.handle( e );
}

void
nest::dc_generator::set_data_from_stimulating_backend( std::vector< double >& input_param )
{
Parameters_ ptmp = P_; // temporary copy in case of errors

// For the input backend
if ( not input_param.empty() )
{
if ( input_param.size() != 1 )
{
throw BadParameterValue( "The size of the data for the dc_generator needs to be 1 [amplitude]." );
}
DictionaryDatum d = DictionaryDatum( new Dictionary );
( *d )[ names::amplitude ] = DoubleDatum( input_param[ 0 ] );
ptmp.set( d, this );
}

// if we get here, temporary contains consistent set of properties
P_ = ptmp;
}
Loading