public void GenerateEvent() { SimulationCompleteEvent simCompleteEvent = new SimulationCompleteEvent(nodes); simCompleteEvent.Time = endTime; eventMgr.AddEvent(simCompleteEvent); }
public void GenerateEvent(double time, ILocation location) { // Overloads GenerateEvent to allow the simulation to provide the time the event occurs. XYDoubleLocation initalCorner = (XYDoubleLocation)field[0]; // Casting to xyLocation objects. Other XYDoubleLocation finalCorner = (XYDoubleLocation)field[1]; // coordinate systems are not supported. List<PEQNode> nodesInRange = new List<PEQNode>(); // Generate the random center location of the event. eventCenter = (XYDoubleLocation)location; eventCenter.SetField(field); Notify(generateStaticReport(time, eventCenter)); foreach (PEQNode node in nodes.NodeQueue) { // Find which nodes are within the effective detection area. if (eventCenter.Distance(node.Location) <= eventSize) // if in the event area nodesInRange.Add(node); } double eventTime = 0; for (int i = 0; i < this.numOccurances; i++) { eventTime = time + i / this.eventFreq; foreach (PEQNode node in nodesInRange) { PEQMessageApplication appMsg = new PEQMessageApplication(); // Create a new app message appMsg._Data._DataID = _dataID++; MessageEvent msgEvent = new MessageEvent(appMsg); // create a new message event msgEvent.Referrer = node; // set the referrer to the current node PEQDataInfoReport rep = new PEQDataInfoReport(node.ID, eventTime); rep._Sent = 1; rep._DataID = appMsg._Data._DataID; Notify(rep); PEQTimerInternal messageTimer = new PEQTimerInternal(appMsg, eventTime, node); eventMgr.AddEvent(messageTimer); // add the event to the Event Queue. } } SimulationCompleteEvent simCompleteEvent = new SimulationCompleteEvent(nodes); simCompleteEvent.Time = eventTime + 60; // one minute after last event occurs eventMgr.AddEvent(simCompleteEvent); }
public void GenerateEvent() { // Rather than setting a random time, in this case the event is simply generated at 15 seconds. XYDoubleLocation initalCorner = (XYDoubleLocation)field[0]; // Casting to xyLocation objects. Other XYDoubleLocation finalCorner = (XYDoubleLocation)field[1]; // coordinate systems are not supported. XYDoubleLocation location = new XYDoubleLocation((float)(randomizer.NextDouble() * (finalCorner.X - initalCorner.X) + initalCorner.X), (float)(randomizer.NextDouble() * (finalCorner.Y - initalCorner.Y) + initalCorner.Y)); GenerateEvent(location); SimulationCompleteEvent simCompleteEvent = new SimulationCompleteEvent(nodes); simCompleteEvent.Time = eventMeanTime + 60; // one minute after event occurs eventMgr.AddEvent(simCompleteEvent); }