Esempio n. 1
0
void Cell::delta_ext(double e, const adevs::Bag<CellEvent>& xb) 
{
	// Update the count if living neighbors
	adevs::Bag<CellEvent>::const_iterator iter;
	for (iter = xb.begin(); iter != xb.end(); iter++)
	{
		if ((*iter).value == Dead) nalive--;
		else nalive++;
	}
}
void BottomQueue::delta_ext(double e, const adevs::Bag<QCell>& xb){
	QCell holder;
	
	if(!xb.empty()){
		adevs::Bag<QCell>::iterator iter = xb.begin();
		while(iter != xb.end()){
			holder = *iter;
			bottomlist.push_back(holder);
			iter++;
		}
	}
}
void FourZoneBuildingExt::external_event(double* q, double e,
	const adevs::Bag<OMC_ADEVS_IO_TYPE>& xb)
{
	bool updateValues = false;
	FourZoneBuilding::external_event(q,e,xb);
	Bag<OMC_ADEVS_IO_TYPE>::const_iterator iter = xb.begin();
	for (; iter != xb.end(); iter++)
	{
		if ((*iter).port == BuildingModelInterface::sample) takeSample = true;
		else if ((*iter).port == BuildingModelInterface::onOffCmd)
		{
			OnOffEvent* cmd = dynamic_cast<OnOffEvent*>((*iter).value);
			if (cmd->getItem() == HEATING_UNIT)
			{
				updateValues = true;
				if (cmd->getUnit() == 0)
					set_z1_heatStage(cmd->getMode());
				else if (cmd->getUnit() == 1)
					set_z2_heatStage(cmd->getMode());
				else if (cmd->getUnit() == 2)
					set_z3_heatStage(cmd->getMode());
				else if (cmd->getUnit() == 3)
					set_z4_heatStage(cmd->getMode());
				else if (cmd->getUnit() == 4)
					set_znoise_heatStage(cmd->getMode());
			}
			else if (cmd->getItem() == COOLING_UNIT)
			{
				updateValues = true;
				if (cmd->getUnit() == 0)
					set_z1_coolStage(cmd->getMode());
				else if (cmd->getUnit() == 1)
					set_z2_coolStage(cmd->getMode());
				else if (cmd->getUnit() == 2)
					set_z3_coolStage(cmd->getMode());
				else if (cmd->getUnit() == 3)
					set_z4_coolStage(cmd->getMode());
				else if (cmd->getUnit() == 4)
					set_znoise_coolStage(cmd->getMode());
			}
		}
	}
	if (updateValues)
		update_vars(q,true);
}
void FourZoneBuildingExt::gc_output(adevs::Bag<OMC_ADEVS_IO_TYPE>& gb)
{
	Bag<OMC_ADEVS_IO_TYPE>::iterator iter = gb.begin();
	for (; iter != gb.end(); iter++)
		delete ((*iter).value);
}