Пример #1
0
        public Form1()
        {
            InitializeComponent();

            // start a new instance of the xbox one controller
            xb1c = new XInputController();

            // if there is a connection then update the current values
            if (xb1c.connected)
            {
                base_val     = xb1c.leftThumb.X;
                shoulder_val = xb1c.leftThumb.Y;
                elbow_val    = xb1c.rightThumb.Y;
                gripper_val  = xb1c.rightThumb.X;
            }
            else
            {
                MessageBox.Show(this, "The Xbox One controller did not connect properly.\n", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            //init xbees
            comms = new Comms(THIS_ID);
            comms.InitConnection(TransportProtocol.ZIGBEE_LINK, "COM3", "", 57600);
            comms.AddAddress(UGV_ID, "0013A20040917A31", 0);
            comms.LinkCallback(new NGCP.ArmPosition(0, 0, 0, 0), new CallBack(ArmPositionCallBack));
            comms.LoadKey("NGCP Project 2016");
            comms.Run();
            // set timer event to start reading and updating from the controller
            timer1.Start();
        }
Пример #2
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();
        }