コード例 #1
0
        private void Update()
        {
            WLHostDev host        = null;
            Canvas    aimhost     = null;
            double    mindistance = double.PositiveInfinity;

            foreach (var x in rootcvs.Children)
            {
                switch (x)
                {
                case WirelessComHostCanvas wlch:
                    Point  p    = TranslatePoint(new Point(0, 0), rootcvs);
                    double dist = wlch.DistanceSquareOf(p.X, p.Y);
                    if (dist < mindistance && dist <= wlch.SignalDistance * wlch.SignalDistance && dist <= SignalDistance * SignalDistance)
                    {
                        mindistance = dist;
                        host        = wlch.WLComHost;
                        aimhost     = wlch;
                    }
                    break;
                }
            }
            dev.SetHost(host);
            aimHost = aimhost;
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: frto027/IotSimulate
        public void TestMethod1()
        {
            byte[] b1 = new byte[1024], b2 = new byte[1024];

            for (int i = 0; i < 1024; i++)
            {
                b1[i] = (byte)i;
            }

            var dev  = new WLDev();
            var dev2 = new WLDev();
            var host = new WLHostDev();

            dev.SetHost(host);
            dev2.SetHost(host);
            dev.SendMessage(b1, 0, 1024);

            Assert.AreEqual(0, dev.RemainData);
            Assert.AreEqual(1024, dev2.RemainData);
            Assert.AreEqual(1024, host.RemainData);
        }