예제 #1
0
/**
 * Clears out all the messages to zombie objects
 */
void HSolveHub::clearFunc( Eref hub )
{
	clearMsgsFromFinfo( hub, compartmentSolveFinfo );
	clearMsgsFromFinfo( hub, hhchannelSolveFinfo );

	hub.dropAll( compartmentInjectFinfo->msg() );
}
예제 #2
0
/* create COMPARTMENT  */
map< string,Id > SbmlReader::createCompartment( Id location )
{
	static const Cinfo* kincomptCinfo = initKinComptCinfo();
	static const Finfo* sizeFinfo = kincomptCinfo->findFinfo( "size" );
	static const Finfo* dimensionFinfo = kincomptCinfo->findFinfo( "numDimensions" );
	map< string,Id > idMap;	
	//Id outcompt; //outside compartment	
	map< Id,string > outsideMap;
	map< Id,string > ::iterator iter;
	double msize = 0.0,size=0.0;	
	::Compartment* compt;
	unsigned int num_compts = model_->getNumCompartments();
	//cout << "num of compartments :" << num_compts <<endl;
	for ( unsigned int i = 0; i < num_compts; i++ )
	{
		compt = model_->getCompartment(i);
		std::string id = "";
		if ( compt->isSetId() ){
			id = compt->getId();
		}
		std::string name = "";
		if ( compt->isSetName() ){
			name = compt->getName();
		} 
		std::string outside = "";
		if ( compt->isSetOutside() ){
			outside = compt->getOutside ();
			
		}
		if ( compt->isSetSize() ){
			msize = compt->getSize();
		}
		UnitDefinition * ud = compt->getDerivedUnitDefinition();
		size = transformUnits( msize,ud );
		unsigned int dimension = compt->getSpatialDimensions();
		comptEl_ = Neutral::create( "KinCompt",id, location, Id::scratchId() ); //create Compartment 
		idMap[id] = comptEl_->id(); 
		if ( outside != "" )
			outsideMap[comptEl_->id()] = outside ; 
		if ( size != 0.0 )
		    ::set< double >( comptEl_, sizeFinfo, size );
		if ( dimension != 0 )
			::set< unsigned int >( comptEl_,dimensionFinfo,dimension );		
	}
	for ( iter = outsideMap.begin(); iter != outsideMap.end(); iter++ )
	{
		Eref msid = iter->first();			
		string outside = iter->second;	
		Id outcompt = idMap.find( outside )->second;	
		static const Finfo* outsideFinfo = kincomptCinfo->findFinfo( "outside" );
		static const Finfo* insideFinfo = kincomptCinfo->findFinfo( "inside" );
		msid.dropAll("child"); //delete the connection with old parent ie, /kinetics
		Eref(outcompt() ).add("childSrc",msid,"child",ConnTainer::Default); //create connection with new parent ie.outside compartment
		Eref( msid ).add( outsideFinfo->msg(),outcompt(),insideFinfo->msg(),ConnTainer::Default );
		
	}	
	
	return idMap;
}
예제 #3
0
void HSolveHub::clearMsgsFromFinfo( Eref hub, const Finfo * f )
{
	Conn* c = hub.e->targets( f->msg(), hub.i );
	vector< Element* > list;
	while ( c->good() ) {
		list.push_back( c->target().e );
		c->increment();
	}
	delete c;
	hub.dropAll( f->msg() );
	
	vector< Element* >::iterator i;
	for ( i = list.begin(); i != list.end(); i++ ) unzombify( *i );
}
예제 #4
0
/**
 * This operation turns the target element e into a zombie controlled
 * by the hub/solver. It gets rid of any process message coming into 
 * the zombie and replaces it with one from the solver.
 */
void HSolveHub::zombify( 
	Eref hub, Eref e,
	const Finfo* hubFinfo, Finfo* solveFinfo )
{
	// Replace the original procFinfo with one from the hub.
	const Finfo* procFinfo = e->findFinfo( "process" );
	e.dropAll( procFinfo->msg() );
	bool ret = hub.add( hubFinfo->msg(), e, procFinfo->msg(), 
		ConnTainer::Default );
	assert( ret );

	// Redirect original messages from the zombie to the hub.
	// Pending.

	// Replace the 'ThisFinfo' on the solved element
	e->setThisFinfo( solveFinfo );
}