public IInfoReport Subtract(IInfoReport targetFromThisObject)
        {
            // Probably will be unused for this report type.
            if (targetFromThisObject is PEQNodeInfoReport)
            {
                int newID;
                double newTimestamp;
                ILocation newLocation;
                bool sameNode;
                if (targetFromThisObject.ID == _id)
                {
                    sameNode = true;
                    newID = _id;
                    newLocation = _location;
                }
                else
                {
                    sameNode = false;
                    newID = int.MaxValue;
                    newLocation = null;
                }

                if (targetFromThisObject.Time > _timestamp)
                    newTimestamp = targetFromThisObject.Time;
                else newTimestamp = _timestamp;

                PEQNodeInfoReport target = (PEQNodeInfoReport)targetFromThisObject;
                PEQNodeInfoReport output = new PEQNodeInfoReport(newID, newTimestamp,
                    _key, _label);
                output._location = newLocation;
                output._sentHellos = _sentHellos - target._sentHellos;
                output._sentBuildTrees = _sentBuildTrees - target._sentBuildTrees;
                output._sentSubscribes = _sentSubscribes - target._sentSubscribes;
                output._sentNotifys = _sentNotifys - target._sentNotifys;
                output._sentACKs = _sentACKs - target._sentACKs;
                output._sentSearches = _sentSearches - target._sentSearches;
                output._sentResponses = _sentResponses - target._sentResponses;
                output._rcvdHellos = _rcvdHellos - target._rcvdHellos;
                output._rcvdBuildTrees = _rcvdBuildTrees - target._rcvdBuildTrees;
                output._rcvdSubscribes = _rcvdSubscribes - target._rcvdSubscribes;
                output._rcvdNotifys = _rcvdNotifys - target._rcvdNotifys;
                output._rcvdACKs = _rcvdACKs - target._rcvdACKs;
                output._rcvdSearches = _rcvdSearches - target._rcvdSearches;
                output._rcvdResponses = _rcvdResponses - target._rcvdResponses;
                output._procApplications = _procApplications - target._procApplications;
                output._Collisions = _Collisions - target._Collisions;
                return output;
            }
            else return null;
        }
Exemplo n.º 2
0
        IInfoReport GeneratePEQNodeInfoReport(int sentHellos, int rcvdHellos, int sentBuildTrees,
            int rcvdBuildTrees, int sentSubscribes, int rcvdSubscribes, int sentNotifys,
            int rcvdNotifys, int sentACKs, int rcvdACKs, int sentSearches, int rcvdSearches,
            int sentResponses, int rcvdResponses, int procApplications, int Collisions)
        {
            PEQNodeInfoReport report = new PEQNodeInfoReport(_id.GetID(), _eventManager.CurrentClock,
                "PEQ_Node", "PEQ Node:");
            report._sentHellos = sentHellos;
            report._rcvdHellos = rcvdHellos;
            report._sentBuildTrees = sentBuildTrees;
            report._rcvdBuildTrees = rcvdBuildTrees;
            report._sentSubscribes = sentSubscribes;
            report._rcvdSubscribes = rcvdSubscribes;
            report._sentNotifys = sentNotifys;
            report._rcvdNotifys = rcvdNotifys;
            report._sentACKs = sentACKs;
            report._rcvdACKs = rcvdACKs;
            report._sentSearches = sentSearches;
            report._rcvdSearches = rcvdSearches;
            report._sentResponses = sentResponses;
            report._rcvdResponses = rcvdResponses;
            report._procApplications = procApplications;
            report._Collisions = Collisions;
            report.Loc = this.Location;

            return report;
        }
        /*       / \
         *     // | \\
         *    /   |   \
         *        |           */
        public IInfoReport Add(IInfoReport withTarget)
        {
            if (withTarget is PEQNodeInfoReport)
            {
                int newID;
                double newTimestamp;
                ILocation newLocation;
                bool sameNode;
                if (withTarget.ID == _id)
                {
                    sameNode = true;
                    newID = _id;
                    newLocation = _location;
                }
                else
                {
                    sameNode = false;
                    newID = int.MaxValue;
                    newLocation = null;
                }

                if (withTarget.Time > _timestamp)
                    newTimestamp = withTarget.Time;
                else newTimestamp = _timestamp;

                PEQNodeInfoReport target = (PEQNodeInfoReport)withTarget;
                PEQNodeInfoReport output = new PEQNodeInfoReport(newID, newTimestamp,
                    _key, _label);
                output._location = newLocation;
                output._sentHellos = _sentHellos + target._sentHellos;
                output._sentBuildTrees = _sentBuildTrees + target._sentBuildTrees;
                output._sentSubscribes = _sentSubscribes + target._sentSubscribes;
                output._sentNotifys = _sentNotifys + target._sentNotifys;
                output._sentACKs = _sentACKs + target._sentACKs;
                output._sentSearches = _sentSearches + target._sentSearches;
                output._sentResponses = _sentResponses + target._sentResponses;
                output._rcvdHellos = _rcvdHellos + target._rcvdHellos;
                output._rcvdBuildTrees = _rcvdBuildTrees + target._rcvdBuildTrees;
                output._rcvdSubscribes = _rcvdSubscribes + target._rcvdSubscribes;
                output._rcvdNotifys = _rcvdNotifys + target._rcvdNotifys;
                output._rcvdACKs = _rcvdACKs + target._rcvdACKs;
                output._rcvdSearches = _rcvdSearches + target._rcvdSearches;
                output._rcvdResponses = _rcvdResponses + target._rcvdResponses;
                output._procApplications = _procApplications + target._procApplications;
                output._Collisions = _Collisions + target._Collisions;
                return output;
            }
            else return null;
        }