Пример #1
0
void GlobalEvents::execute(GlobalEvent_t type) const
{
	for (const auto& it : serverMap) {
		GlobalEvent* globalEvent = it.second;
		if (globalEvent->getEventType() == type) {
			globalEvent->executeEvent();
		}
	}
}
Пример #2
0
void GlobalEvents::execute(GlobalEvent_t type)
{
	for (GlobalEventMap::iterator it = serverMap.begin(); it != serverMap.end(); ++it) {
		GlobalEvent* globalEvent = it->second;
		if (globalEvent->getEventType() == type) {
			globalEvent->executeEvent();
		}
	}
}
Пример #3
0
bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
	GlobalEvent* globalEvent = reinterpret_cast<GlobalEvent*>(event);
	if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
		GlobalEventMap::iterator it = timerMap.find(globalEvent->getName());
		if (it == timerMap.end()) {
			timerMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			if (timerEventId == 0) {
				timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
			}

			return true;
		}
	} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
		GlobalEventMap::iterator it = serverMap.find(globalEvent->getName());
		if (it == serverMap.end()) {
			serverMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			return true;
		}
	} else { // think event
		auto it = thinkMap.find(globalEvent->getName());
		if (it == thinkMap.end()) {
			thinkMap.insert(std::make_pair(globalEvent->getName(), globalEvent));
			if (thinkEventId == 0) {
				thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
			}
			return true;
		}
	}

	std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
	return false;
}
Пример #4
0
void 
OPRijVij::eventUpdate(const GlobalEvent& globEvent, const NEventData& SDat)
{
  BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges)
    process2PED(rvdotacc[mapKey(globEvent.getType(), getClassKey(globEvent))],
		pDat);
}
Пример #5
0
 void 
 OPViscosityE::eventUpdate(const GlobalEvent& iEvent, const NEventData& PDat) 
 {
   stream(iEvent.getdt());
   impulseDelG(PDat);
   updateConstDelG(PDat);
 }
Пример #6
0
  void 
  OPThermalDiffusionE::eventUpdate(const GlobalEvent& iEvent, 
				   const NEventData& PDat) 
  {
    stream(iEvent.getdt());
    delG += impulseDelG(PDat);
    updateConstDelG(PDat);
  }
  void 
  OPThermalConductivitySpeciesSpeciesE::eventUpdate(const GlobalEvent& iEvent, 
						    const NEventData& PDat) 
  {
    stream(iEvent.getdt());
    //impulseDelG(PDat);
    updateConstDelG(PDat);
  }
Пример #8
0
void GlobalEvents::think()
{
	int64_t now = OTSYS_TIME();

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();
	for (const auto& it : thinkMap) {
		GlobalEvent* globalEvent = it.second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			continue;
		}

		if (!globalEvent->executeEvent()) {
			std::cout << "[Error - GlobalEvents::think] Failed to execute event: " << globalEvent->getName() << std::endl;
		}

		nextExecutionTime = globalEvent->getInterval();
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		thinkEventId = g_scheduler->addEvent(createSchedulerTask(std::max<int64_t>(SCHEDULER_MINTICKS, nextScheduledTime),
											std::bind(&GlobalEvents::think, this)));
	}
}
Пример #9
0
void GlobalEvents::timer()
{
	time_t now = time(nullptr);

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();

	auto it = timerMap.begin();
	while (it != timerMap.end()) {
		GlobalEvent* globalEvent = it->second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			++it;
			continue;
		}

		if (!globalEvent->executeEvent()) {
			it = timerMap.erase(it);
			continue;
		}

		nextExecutionTime = 86400;
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);

		++it;
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		timerEventId = g_scheduler->addEvent(createSchedulerTask(std::max<int64_t>(1000, nextScheduledTime * 1000),
							                std::bind(&GlobalEvents::timer, this)));
	}
}
Пример #10
0
bool GlobalEvents::registerEvent(Event* event, const pugi::xml_node&)
{
	GlobalEvent* globalEvent = static_cast<GlobalEvent*>(event); //event is guaranteed to be a GlobalEvent
	if (globalEvent->getEventType() == GLOBALEVENT_TIMER) {
		auto result = timerMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			if (timerEventId == 0) {
				timerEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::timer, this)));
			}
			return true;
		}
	} else if (globalEvent->getEventType() != GLOBALEVENT_NONE) {
		auto result = serverMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			return true;
		}
	} else { // think event
		auto result = thinkMap.emplace(globalEvent->getName(), globalEvent);
		if (result.second) {
			if (thinkEventId == 0) {
				thinkEventId = g_scheduler.addEvent(createSchedulerTask(SCHEDULER_MINTICKS, std::bind(&GlobalEvents::think, this)));
			}
			return true;
		}
	}

	std::cout << "[Warning - GlobalEvents::configureEvent] Duplicate registered globalevent with name: " << globalEvent->getName() << std::endl;
	return false;
}
Пример #11
0
  void 
  OPVACF::eventUpdate(const GlobalEvent& iEvent, const NEventData& PDat) 
  {
    //Move the time forward
    currentdt += iEvent.getdt();
  
    //Now test if we've gone over the step time
    while (currentdt >= dt)
      {
	currentdt -= dt;
	newG(PDat);
      }
  }
Пример #12
0
  void
  OPMisc::eventUpdate(const GlobalEvent& eevent, const NEventData& NDat)
  {
    stream(eevent.getdt());
    eventUpdate(NDat);

    BOOST_FOREACH(const ParticleEventData& pData, NDat.L1partChanges)
      newEvent(pData.getParticleID(), pData.getType(), getClassKey(eevent));

    BOOST_FOREACH(const PairEventData& pData, NDat.L2partChanges)
      {
	newEvent(pData.particle1_.getParticleID(), pData.getType(), getClassKey(eevent));
	newEvent(pData.particle2_.getParticleID(), pData.getType(), getClassKey(eevent));
      }
  }
Пример #13
0
void 
OPCubeComp::eventUpdate(const GlobalEvent& globEvent, const NEventData& SDat)
{
  BOOST_FOREACH(const PairEventData& pDat, SDat.L2partChanges)
    {
      mapdata& ref = angles[mapKey(globEvent.getType(), 
				   getClassKey(globEvent))];
      std::vector<double> vals(NDIM, 0);
      
      for (size_t i(0); i < NDIM; ++i)
	vals[i] = pDat.rij[i] * pDat.rij[i] / Sim->dynamics.units().unitArea();
      
      std::sort(vals.begin(), vals.end());
      
      for (size_t i(0); i < NDIM; ++i)
	ref.angles[i].addVal(vals[i]);
    }
}
Пример #14
0
void GlobalEvents::timer()
{
	time_t now = time(nullptr);

	int64_t nextScheduledTime = std::numeric_limits<int64_t>::max();

	auto it = timerMap.begin();
	while (it != timerMap.end()) {
		GlobalEvent* globalEvent = it->second;

		int64_t nextExecutionTime = globalEvent->getNextExecution() - now;
		if (nextExecutionTime > 0) {
			if (nextExecutionTime < nextScheduledTime) {
				nextScheduledTime = nextExecutionTime;
			}

			++it;
			continue;
		}

		if (!globalEvent->executeEvent()) {
			std::cout << "[Error - GlobalEvents::timer] Failed to execute event: " << globalEvent->getName() << std::endl;
		}

		if (g_config.getBoolean(ConfigManager::SHUTDOWN_AT_SERVERSAVE)) {
			it = timerMap.erase(it);
			continue;
		}

		nextExecutionTime = 86400;
		if (nextExecutionTime < nextScheduledTime) {
			nextScheduledTime = nextExecutionTime;
		}

		globalEvent->setNextExecution(globalEvent->getNextExecution() + nextExecutionTime);

		++it;
	}

	if (nextScheduledTime != std::numeric_limits<int64_t>::max()) {
		timerEventId = g_scheduler.addEvent(createSchedulerTask(std::max<int64_t>(1000, nextScheduledTime * 1000),
							                boost::bind(&GlobalEvents::timer, this)));
	}
}
Пример #15
0
 void 
 OPCollTicker::eventUpdate(const GlobalEvent &event, const NEventData&) 
 {
   stream(event.getdt());
   ticker();
 }
Пример #16
0
 void 
 OPIntEnergyHist::eventUpdate(const GlobalEvent &event, const NEventData&) 
 {
   intEnergyHist.addVal(_ptrOPMisc->getConfigurationalU(), event.getdt());
 }
Пример #17
0
 classKey getClassKey(const GlobalEvent& g)
 {
   return classKey(g.getGlobalID(), GLOBAL);
 }
Пример #18
0
bool
System::operator<(const GlobalEvent& gEvent) const
{
    return dt < gEvent.getdt();
}