当前位置: 首页>>代码示例>>C#>>正文


C# IEvent.Clone方法代码示例

本文整理汇总了C#中IEvent.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# IEvent.Clone方法的具体用法?C# IEvent.Clone怎么用?C# IEvent.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEvent的用法示例。


在下文中一共展示了IEvent.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteAction

        public void ExecuteAction(IEvent e)
        {
            if (!isInitialized)
                throw new InvalidOperationException("UWAPhysicalProcessor not initialized!");

            NodesIterator iterator;

            INode currentNode;
            INode referrerNode;

            MessageEvent e_msg;
            MessageEvent MessageEveClone;
            L2Event e_L2;

            NodeTimerEvent beginTransmitTimerEvent;
            NodeTimerEvent endTransmitTimerEvent;
            NodeTimerEvent beginReceiveTimerEvent;
            InTransitEvent inTransitTimerEvent;

            ReportLevel msgLevel = ReportLevel.Routine;

            double currentDistance;
            double transmissionTime;
            double propagationTime;
            double receivePower;

            if (e is MessageEvent)
            {
                e_msg = (MessageEvent)e;
                transmissionTime = calculateTransmissionTime(e_msg.message.SizeBytes()
                    + overheadBytes);

                if (e_msg.Referrer is INode)
                {
                    referrerNode = (INode)e_msg.Referrer;
                    iterator = new NodesIterator(this.nodes);
                    msgLevel = referrerNode.GetMessageLevel(e_msg.message);

                    // Begin Transmitting at referring node
                    referrerNode.PreTransmit(); // Perform pre-transmit activities at node.
                    beginTransmitTimerEvent = new NodeBeginTransmitEvent();
                    beginTransmitTimerEvent.Time = this.eventMgr.CurrentClock + processingDelay;
                    beginTransmitTimerEvent.node = referrerNode;
                    beginTransmitTimerEvent.Duration = transmissionTime;
                    this.eventMgr.AddEvent(beginTransmitTimerEvent);

                    // Generate Graphical Reports (Wave)
                    if (!e.SuppressReport)
                        repIWF.SendWaveReport(this.eventMgr.CurrentClock + processingDelay,
                            (e_msg.message.SizeBytes() + overheadBytes) * 8, msgLevel, (INode)e_msg.Referrer);

                    // End Transmitting at referring node
                    endTransmitTimerEvent = new NodeEndTransmitEvent();
                    endTransmitTimerEvent.Time = this.eventMgr.CurrentClock + processingDelay
                        + calculateTransmissionTime(e_msg.message.SizeBytes()
                             + overheadBytes);
                    endTransmitTimerEvent.node = referrerNode;
                    this.eventMgr.AddEvent(endTransmitTimerEvent);

                    while (!iterator.IsDone())
                    {
                        currentNode = iterator.Next();
                        currentDistance = referrerNode.Location.Distance(currentNode.Location);
                        propagationTime = calculatePropagationTime(currentDistance);
                        receivePower = transmitPower - transmissionLoss(currentDistance);
                        bool hasClosure = true;
                        if (receivePower < minReceivePower)
                            hasClosure = false;

                        if ((currentDistance <= this.maxRange) && (currentDistance > 0))
                        {
                            // Clone the message event
                            MessageEveClone = (MessageEvent)e.Clone();
                            MessageEveClone.Time = processingDelay + transmissionTime
                                + propagationTime + this.eventMgr.CurrentClock;
                            MessageEveClone.Referrer = currentNode;

                            // Begin Receving at transmitting node.
                            beginReceiveTimerEvent = new NodeBeginReceiveEvent();
                            beginReceiveTimerEvent.Time = this.eventMgr.CurrentClock + processingDelay
                                + propagationTime;  // FIRST bit arrives at receiver
                            beginReceiveTimerEvent.node = currentNode;
                            beginReceiveTimerEvent.Duration = transmissionTime;
                            this.eventMgr.AddEvent(beginReceiveTimerEvent);

                            // Create L2 Event
                            e_L2 = new L2Event(this, referrerNode, MessageEveClone,
                                propagationTime, transmissionTime, receivePower, hasClosure);
                            this.eventMgr.AddEvent(e_L2);

                        } // if out of range, drop message
                    }

                } // if Referrer <> INode, drop message.
            }
            else if (e is L2Event)
            {
                e_L2 = (L2Event)e;

                e_msg = (MessageEvent)e_L2.EncapsulatedEvent;
//.........这里部分代码省略.........
开发者ID:malweth,项目名称:Modular-Network-Simulator,代码行数:101,代码来源:UWAPhysicalProcessor.cs


注:本文中的IEvent.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。