void nest::cg_connect( nest::ConnectionGeneratorDatum& cg, IntVectorDatum& sources, IntVectorDatum& targets, const DictionaryDatum& params_map, const Name& synmodel_name ) { const Token synmodel = kernel().model_manager.get_synapsedict()->lookup( synmodel_name ); if ( synmodel.empty() ) throw UnknownSynapseType( synmodel_name.toString() ); const index synmodel_id = static_cast< index >( synmodel ); RangeSet source_ranges; cg_get_ranges( source_ranges, ( *sources ) ); RangeSet target_ranges; cg_get_ranges( target_ranges, ( *targets ) ); cg_connect( cg, source_ranges, ( *sources ), target_ranges, ( *targets ), params_map, synmodel_id ); }
// Connect for conn_generator array array dict synapsetype void ConnectionGeneratorModule::CGConnect_cg_iV_iV_D_lFunction::execute( SLIInterpreter* i ) const { i->assert_stack_load( 5 ); ConnectionGeneratorDatum cg = getValue< ConnectionGeneratorDatum >( i->OStack.pick( 4 ) ); IntVectorDatum sources = getValue< IntVectorDatum >( i->OStack.pick( 3 ) ); IntVectorDatum targets = getValue< IntVectorDatum >( i->OStack.pick( 2 ) ); DictionaryDatum params_map = getValue< DictionaryDatum >( i->OStack.pick( 1 ) ); const Name synmodel_name = getValue< std::string >( i->OStack.pick( 0 ) ); cg_connect( cg, sources, targets, params_map, synmodel_name ); i->OStack.pop( 5 ); i->EStack.pop(); }
void nest::cg_connect( nest::ConnectionGeneratorDatum& cg, const index source_id, const index target_id, const DictionaryDatum& params_map, const Name& synmodel_name ) { Subnet* sources = dynamic_cast< Subnet* >( kernel().node_manager.get_node( source_id ) ); if ( sources == NULL ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "sources must be a subnet." ); throw SubnetExpected(); } if ( !sources->is_homogeneous() ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "sources must be a homogeneous subnet." ); throw BadProperty(); } if ( dynamic_cast< Subnet* >( *sources->local_begin() ) ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "Only 1-dim subnets are supported as sources." ); throw BadProperty(); } Subnet* targets = dynamic_cast< Subnet* >( kernel().node_manager.get_node( target_id ) ); if ( targets == NULL ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "targets must be a subnet." ); throw SubnetExpected(); } if ( !targets->is_homogeneous() ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "targets must be a homogeneous subnet." ); throw BadProperty(); } if ( dynamic_cast< Subnet* >( *targets->local_begin() ) ) { LOG( M_ERROR, "CGConnect_cg_i_i_D_l", "Only 1-dim subnets are supported as targets." ); throw BadProperty(); } const Token synmodel = kernel().model_manager.get_synapsedict()->lookup( synmodel_name ); if ( synmodel.empty() ) throw UnknownSynapseType( synmodel_name.toString() ); const index synmodel_id = static_cast< index >( synmodel ); const modelrange source_range = kernel().modelrange_manager.get_contiguous_gid_range( ( *sources->local_begin() )->get_gid() ); index source_offset = source_range.get_first_gid(); RangeSet source_ranges; source_ranges.push_back( Range( source_range.get_first_gid(), source_range.get_last_gid() ) ); const modelrange target_range = kernel().modelrange_manager.get_contiguous_gid_range( ( *targets->local_begin() )->get_gid() ); index target_offset = target_range.get_first_gid(); RangeSet target_ranges; target_ranges.push_back( Range( target_range.get_first_gid(), target_range.get_last_gid() ) ); cg_connect( cg, source_ranges, source_offset, target_ranges, target_offset, params_map, synmodel_id ); }