示例#1
0
void Cell::output_func(adevs::Bag<CellEvent>& yb) 
{
	CellEvent e;
	// Assume we are dying
	e.value = Dead;
	// Check in case this in not true
	if (check_born_rule())
	{
		e.value = Alive;
	}
	// Set the initial visualization value
	if (vis_phase != NULL) *vis_phase = e.value;
	// Generate an event for each neighbor
	for (long int dx = -1; dx <= 1; dx++)
	{
		for (long int dy = -1; dy <= 1; dy++)
		{
			e.x = (x+dx)%w;
			e.y = (y+dy)%h;
			if (e.x < 0) e.x = w-1;
			if (e.y < 0) e.y = h-1;
			// Don't send to self
			if (e.x != x || e.y != y)
			{
				yb.insert(e);
			}
		}
	}
}
void FourZoneBuildingExt::output_func(const double *q, const bool* state_event,
	adevs::Bag<OMC_ADEVS_IO_TYPE>& yb)
{
	FourZoneBuilding::output_func(q,state_event,yb);
	update_vars(q,false);
	PortValue<BuildingEvent*> pv;
	pv.port = BuildingModelInterface::tempData;
	pv.value = new TemperatureEvent(OUTDOOR_THERMOMETER,0,get_outdoor_d1());
	yb.insert(pv);
	pv.value = new TemperatureEvent(THERMOSTAT_THERMOMETER,0,get_z1_t1());
	yb.insert(pv);
	pv.value = new TemperatureEvent(THERMOSTAT_THERMOMETER,1,get_z2_t1());
	yb.insert(pv);
	pv.value = new TemperatureEvent(THERMOSTAT_THERMOMETER,2,get_z3_t1());
	yb.insert(pv);
	pv.value = new TemperatureEvent(THERMOSTAT_THERMOMETER,3,get_z4_t1());
	yb.insert(pv);
	pv.port = extraTempData;
	pv.value = new TemperatureEvent(THERMOSTAT_THERMOMETER,4,get_znoise_t1());
	yb.insert(pv);
}
void SolutionQueue::output_func(adevs::Bag<QCell>& yb){
	yb.insert(solutionlist.front());
}
void Cell::output_func(adevs::Bag<vec>& yb){
/* EXPERIMENTAL BEHAVIOR CODE */
//	// If the cell hasn't attached
//	if(getTimeAttached() == 0.0){
//		// check to see if the cell could attach
//		vec dist = p + ta()*v;
//		
//		if(dist[2] < BioChem::getInstance()->getFilterTopPos()){
//			// see what would happen if the cell did attach
//			dist[2] = BioChem::getInstance()->getFilterTopPos();
//			
//			// look at all the other cells
//			CellPopulation* pop = CellPopulation::getInstance();
//			CellPopulation::iterator iter;
//			bool settled = false;
//			for(iter = pop->begin(); iter != pop->end(); iter++){
//				vec position = (*iter)->getPos();
//				do{
//					// could this cell collide?
//					if(getDistance(position, dist) < 1.0){
//						// avoid collision by stacking
//						vec stackem;
//						stackem[0] = r.uniform(-1.0,1.0);
//						stackem[1] = r.uniform(-1.0,1.0);
//						stackem[2] = 0.0;
//						dist = position + stackem;
//					}
//				} while (!settled);
//			}
//			
//			p += ta()*v;
//			p[2] = BioChem::getInstance()->getFilterTopPos();
//		} else {
//			// set the position to the new position
//			p = dist;
//		}
//	}
	
	
	/* Move in current direction */
	if (getTime() >= getTimeAttached()) p += ta()*v;
//	if (getTime() >= 3.0) p += ta()*v;
	
	// Don't go below 0.0
	if (p[0] < (double)0.3)
		p[0] = (double)0.3;
	if (p[1] < (double)0.3)
		p[1] = (double)0.3;
	
	// Don't go above Width or Depth
	if (p[0] > BioChem::getInstance()->getDomain()[0]-(double)0.3)
		p[0] = BioChem::getInstance()->getDomain()[0]-(double)0.3;
	if (p[1] > BioChem::getInstance()->getDomain()[1]-(double)0.3)
		p[1] = BioChem::getInstance()->getDomain()[1]-(double)0.3;
	
	// Don't go above or below the filter
	if (p[2] < BioChem::getInstance()->getFilterBottomPos())
		p[2] = BioChem::getInstance()->getFilterBottomPos();
	if (p[2] > BioChem::getInstance()->getFilterTopPos())
		p[2] = BioChem::getInstance()->getFilterTopPos();
	/* Output new position */
	yb.insert(p);
}