Пример #1
0
        static void Main(string[] args)
        {
            Calls    call  = new Calls();
            CommNode comm1 = new Comms(1);
            CommNode comm2 = new Comms(2);

            comm1.LinkCallback(new Ping(), new CallBack(call.PingCallback));
            comm2.LinkCallback(new Ping(), new CallBack(call.PingCallback));

            comm1.InitConnection(TransportProtocol.ZIGBEE_LINK, "COM5", "", 57600);
            comm2.InitConnection(TransportProtocol.ZIGBEE_LINK, "COM6", "", 57600);
            Console.WriteLine(comm1.AddAddress(2, "0013A2004067E4AE", 0));
            Console.WriteLine(comm2.AddAddress(1, "0013A20040917A31", 0));
            //comm1.InitConnection(TransportProtocol.UDP_LINK, "1337", "127.0.0.1", 57600);
            //comm2.InitConnection(TransportProtocol.UDP_LINK, "1338", "127.0.0.1", 57600);
            //Console.WriteLine(comm1.AddAddress(2, "127.0.0.1", 1338));
            //Console.WriteLine(comm2.AddAddress(1, "127.0.0.1", 1337));
            //Ping ping = new Ping("I am from C#!");
            comm1.Run();
            comm2.Run();
            Ping ping = new Ping("From C#, From the xbee!!");

            //TargetDesignationCommand command = new TargetDesignationCommand(45.34f, 23.22f, 234.44f);
            while (true)
            {
                comm1.Send(ping, 2);
                //comm1.Send(command, 1);
                System.Threading.Thread.Sleep(1000);
            }
            comm1.Stop(); //This call is essential to stop threads because finalizer may not be called.
            comm2.Stop();
        }