NEST main@caf0ae8
 
Loading...
Searching...
No Matches
cont_delay_synapse_impl.h
Go to the documentation of this file.
1/*
2 * cont_delay_synapse_impl.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef CONT_DELAY_SYNAPSE_IMPL_H
24#define CONT_DELAY_SYNAPSE_IMPL_H
25
26#include "cont_delay_synapse.h"
27
28// Includes from nestkernel:
30#include "connector_model.h"
31#include "event.h"
32
33
34namespace nest
35{
36
37template < typename targetidentifierT >
40 , weight_( 1.0 )
41 , delay_offset_( 0.0 )
42{
43}
44
45template < typename targetidentifierT >
46void
48{
49 ConnectionBase::get_status( d );
50
51 d[ names::weight ] = weight_;
52 d[ names::delay ] = Time( Time::step( get_delay_steps() ) ).get_ms() - delay_offset_;
53 d[ names::size_of ] = static_cast< long >( sizeof( *this ) );
54}
55
56template < typename targetidentifierT >
57void
59{
60 ConnectionBase::set_status( d, cm );
61
62 d.update_value( names::weight, weight_ );
63
64 // set delay if mentioned
65 double delay;
66
67 if ( d.update_value( names::delay, delay ) )
68 {
69
70 const double h = Time::get_resolution().get_ms();
71
72 double int_delay;
73 const double frac_delay = std::modf( delay / h, &int_delay );
74
75 if ( frac_delay == 0 )
76 {
78 set_delay_steps( Time::delay_ms_to_steps( delay ) );
79 delay_offset_ = 0.0;
80 }
81 else
82 {
83 const long lowerbound = static_cast< long >( int_delay );
85 set_delay_steps( lowerbound + 1 );
86 delay_offset_ = h * ( 1.0 - frac_delay );
87 }
88 }
89}
90
91template < typename targetidentifierT >
92void
94{
95 if ( syn_spec.known( names::delay ) )
96 {
98 "Connect",
99 "The delay will be rounded to the next multiple of the time step. "
100 "To use a more precise time delay it needs to be defined within "
101 "the synapse, e.g. with CopyModel()." );
102 }
103}
104
105} // of namespace nest
106
107#endif // #ifndef CONT_DELAY_SYNAPSE_IMPL_H
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
bool known(const std::string &key) const
Check whether there exists a value with specified key in the dictionary.
Definition dictionary.h:677
DelayChecker & get_delay_checker()
Returns the delay checker for the current thread.
Definition connection_manager.cpp:207
Base class for representing connections.
Definition connection.h:110
Definition connector_model.h:69
void assert_valid_delay_ms(double)
Raise exception if delay value in milliseconds is invalid.
Definition delay_checker.cpp:149
void assert_two_valid_delays_steps(long, long)
Raise exception if either of the two delays in steps is invalid.
Definition delay_checker.cpp:212
Definition nest_time.h:135
static Time get_resolution()
Definition nest_time.h:325
static long delay_ms_to_steps(double ms)
Definition nest_time.h:535
double get_ms() const
Definition nest_time.h:490
void check_synapse_params(const Dictionary &d) const
Issue warning if delay is given in syn_spec.
Definition cont_delay_synapse_impl.h:93
cont_delay_synapse()
Default Constructor.
Definition cont_delay_synapse_impl.h:38
void set_status(const Dictionary &d, ConnectorModel &cm)
Set properties of this connection from the values given in dictionary.
Definition cont_delay_synapse_impl.h:58
void get_status(Dictionary &d) const
Get all properties of this connection and put them into a dictionary.
Definition cont_delay_synapse_impl.h:47
ConnectionManager connection_manager
Definition kernel_manager.h:239
#define LOG(s, fctn, msg)
Definition logging.h:29
const std::string delay("delay")
const std::string weight("weight")
const std::string size_of("sizeof")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
KernelManager & kernel()
Definition kernel_manager.h:311
Definition nest_time.h:246