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


C# Port.Test方法代码示例

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


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

示例1: Update

        /// <summary>
        /// Frame update
        /// </summary>
        /// <param name="update"></param>
        public override void Update(FrameUpdate update)
        {
            if (_raycastProperties == null)
            {
                base.Update(update);
                return;
            }

            _appTime = (float)update.ApplicationTime;

            // assume pose of parent
            if (Parent != null)
                State.Pose = Parent.State.Pose;

            _elapsedSinceLastScan += (float)update.ElapsedTime;
            // only retrieve raycast results every SCAN_INTERVAL.
            // For entities that are compute intenisve, you should consider giving them
            // their own task queue so they dont flood a shared queue
            if (_elapsedSinceLastScan > SCAN_INTERVAL)
            {
                _elapsedSinceLastScan = 0;
                // the LRF looks towards the negative Z axis (towards the user), not the positive Z axis
                // which is the default orientation. So we have to rotate its orientation by 180 degrees

                _raycastProperties.OriginPose.Orientation = TypeConversion.FromXNA(
                    TypeConversion.ToXNA(State.Pose.Orientation) * xna.Quaternion.CreateFromAxisAngle(new xna.Vector3(0, 1, 0), (float)Math.PI));

                // to calculate the position of the origin of the raycast, we must first rotate the LocalPose position
                // of the raycast (an offset from the origin of the parent entity) by the orientation of the parent entity.
                // The origin of the raycast is then this rotated offset added to the parent position.
                xna.Matrix parentOrientation = xna.Matrix.CreateFromQuaternion(TypeConversion.ToXNA(State.Pose.Orientation));
                xna.Vector3 localOffset = xna.Vector3.Transform(TypeConversion.ToXNA(_sonarBox.State.LocalPose.Position), parentOrientation);

                _raycastProperties.OriginPose.Position = State.Pose.Position + TypeConversion.FromXNA(localOffset);
                _raycastResultsPort = PhysicsEngine.Raycast2D(_raycastProperties);
                _raycastResultsPort.Test(out _lastResults);
                if (_serviceNotification != null && _lastResults != null)
                {
                    _serviceNotification.Post(_lastResults);
                }
            }

            base.Update(update);
        }
开发者ID:raul-arrabales,项目名称:crubots,代码行数:48,代码来源:SimulatedPioneerSonar.cs

示例2: TestWithEmptyPort

        public void TestWithEmptyPort()
        {
            var p = new Port<int> ();

            int res = 99;
            Assert.IsFalse (p.Test (out res), "#1");
            Assert.AreEqual (0, res, "#2");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:8,代码来源:PortTest.cs

示例3: CleanupTask

        public void CleanupTask()
        {
            Port<int> pa = new Port<int> ();
            Port<string> pb = new Port<string> ();

            Type[] types = new Type[] { typeof (int), typeof (string) };
            IPortReceive[] ports = new IPortReceive[] { pa, pb };
            int count = 2;
            Handler<ICollection[]> handler = (cols) => { };
            var mig = new MultipleItemGather (types, ports, count, handler);
            var dq = new SerialDispatchQueue ();
            mig.TaskQueue = dq;

            mig.Execute ();

            ITask task = null;
            var rec = ports [0].GetReceivers () [0];
            Assert.IsTrue (rec.Evaluate (new PortElement<int> (10), ref task), "#1");
            Assert.IsNull (task, "#2");
            Assert.IsTrue (rec.Evaluate (new PortElement<int> (20), ref task), "#3");
            Assert.IsNotNull (task, "#4");

            mig.Cleanup (task);

            Assert.AreEqual (2, pa.ItemCount, "#4");
            Assert.AreEqual (0, pb.ItemCount, "#5");

            Assert.AreEqual (10, pa.Test (), "#6");
            Assert.AreEqual (20, pa.Test (), "#7");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:30,代码来源:MultipleItemGatherTest.cs

示例4: PostUnknownType

        public void PostUnknownType()
        {
            var p = new Port<int> ();
            int tmp;

            p.PostUnknownType (10);
            Assert.AreEqual (1, p.ItemCount, "#1");
            p.Post (20);
            Assert.AreEqual (2, p.ItemCount, "#2");
            Assert.AreEqual (10, p.Test (), "#3");
            p.Test (out tmp);
            Assert.AreEqual (20, tmp, "#4");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:13,代码来源:PortTest.cs

示例5: PostThenReceive

        public void PostThenReceive()
        {
            var p = new Port<int> ();
            p.Post (10);

            int res;
            Assert.IsTrue (p.Test (out res), "#1");
            Assert.AreEqual (10, res, "#2");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:9,代码来源:PortTest.cs

示例6: PostAndReceiveOrdering

        public void PostAndReceiveOrdering()
        {
            var p = new Port<int> ();
            p.Post (10);
            p.Post (20);
            p.Post (30);

            int res;
            Assert.IsTrue (p.Test (out res), "#1");
            Assert.AreEqual (10, res, "#2");

            Assert.IsTrue (p.Test (out res), "#3");
            Assert.AreEqual (20, res, "#4");

            Assert.IsTrue (p.Test (out res), "#5");
            Assert.AreEqual (30, res, "#6");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:17,代码来源:PortTest.cs

示例7: PortStatusAfterConstruction

        public void PortStatusAfterConstruction()
        {
            var p = new Port<int> ();
            int val = 0;

            Assert.IsFalse (p.Test (out val), "#1");

            IPortReceive rec = p;
            Assert.AreEqual (0, rec.GetItems ().Length, "#r1");
            Assert.AreEqual (0, rec.GetReceivers ().Length, "#r2");
            Assert.IsNull (rec.Test (), "#r3");
            Assert.AreEqual (0, rec.ItemCount, "#r4");

            IPortArbiterAccess paa = p;
            Assert.AreEqual (PortMode.Default, paa.Mode, "#p1");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:16,代码来源:PortTest.cs

示例8: IfReceiverReturnsTrueMessageIsNotEnqueued

        public void IfReceiverReturnsTrueMessageIsNotEnqueued()
        {
            var p = new Port<int> ();
            int tmp;
            IPortReceive ipr = p;
            ipr.RegisterReceiver (new EvalTask (false));

            p.Post (10);
            Assert.IsTrue (p.Test (out tmp), "#1");

            p = new Port <int> ();
            ipr = p;
            ipr.RegisterReceiver (new EvalTask (true));
            p.Post (10);
            Assert.IsFalse (p.Test (out tmp), "#2");
        }
开发者ID:kumpera,项目名称:Ccr,代码行数:16,代码来源:PortTest.cs


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