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.

            // Generate the random center location of the event.
            eventCenter = (XYDoubleLocation)location;

            eventCenter.SetField(field);

            Notify(generateStaticReport(time, eventCenter));

            foreach (FloodingQueryNode node in nodes.NodeQueue)
            { // Find which nodes are within the effective detection area.
                if (eventCenter.Distance(node.Location) <= eventSize) // if in the event area
                {
                    FloodingQueryApplicationMessage appMsg = new FloodingQueryApplicationMessage(); // Create a new app message
                    MessageEvent msgEvent = new MessageEvent(appMsg); // create a new message event
                    msgEvent.Referrer = node; // set the referrer to the current node

                    NodeTimerEvent timerEvent = new NodeTimerEvent();   // create a timer event
                    timerEvent.Time = time;
                    timerEvent.Event = msgEvent;                        // apply the message event
                    timerEvent.node = node;
                    eventMgr.AddEvent(timerEvent);                      // add the event to the Event Queue.
                }
            }
        }
        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 Deploy()
        {
            if (!isInitialized)
                throw new InvalidOperationException("RandomDeployer not initialized!");

            List<XYDoubleLocation> pointList = new List<XYDoubleLocation>();

            rand = randFactory.CreateRandomizer();

            bool continueFlag;
            XYDoubleLocation initial, final, current;
            initial = (XYDoubleLocation)field[0];
            final = (XYDoubleLocation)field[1];
            current = new XYDoubleLocation();

            // Sink
            current = new XYDoubleLocation(final.X, (final.Y - initial.Y)/2);
            current.SetField(field);
            nodes.AddNode(nodeFactory.CreateNode(current));
            pointList.Add(current);
            nodes.GetNodeByID(0).IsSink = true;

            // Sources
            for (int i = 1; i < 6; i++)
            {
                current = new XYDoubleLocation(initial.X, (i-1)*(final.Y-initial.Y)/4);
                current.SetField(field);
                nodes.AddNode(nodeFactory.CreateNode(current));
                pointList.Add(current);
            }

            // Node Field
            for (int i = 6; i < numNodes; i++)
            {
                continueFlag = false;
                while (!continueFlag)
                {
                    continueFlag = true;
                    current = new XYDoubleLocation(
                        rand.NextDouble() * (final.X - initial.X - 2 * padding) + initial.X + padding,
                        rand.NextDouble() * (final.Y - initial.Y - 2 * padding) + initial.Y + padding);
                    foreach (XYDoubleLocation point in pointList)
                    {
                        if (current.Distance(point) < minDistance)
                            continueFlag = false;
                    }
                }
                pointList.Add(current);
                current.SetField(field);
                nodes.AddNode(nodeFactory.CreateNode(current));
            }
        }