예제 #1
0
        public bool Connect()
        {
            Debug.WriteLine("About to open Sphero " + this.Name + ".");

            com = new SpheroCommunicator();

            bool connected = false;

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    com.openPort(this.ComPortName);
                }
                catch (Exception)
                {
                    Debug.WriteLine("Opening Sphero " + this.Name + " failed on try " + (i + 1).ToString());
                    continue;
                }

                connected = true;
                Debug.WriteLine("Sphero " + this.Name + " opened on try " + (i + 1).ToString());



                break;
            }

            if (connected)
            {
                if (this.DebugMode)
                {
                    var p = PacketFactory.new_SetRGBLEDPacket((byte)200, (byte)200, (byte)0, false);
                    this.com.write(p);
                }
            }
            else
            {
                Debug.WriteLine("Unable to open Sphero " + this.Name + "!");
            }

            return(connected);
        }
예제 #2
0
        public bool Connect()
        {
            Debug.WriteLine("About to open Sphero " + this.Name + ".");

            com = new SpheroCommunicator();

            bool connected = false;

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    com.openPort(this.ComPortName);
                }
                catch (Exception)
                {
                    Debug.WriteLine("Opening Sphero " + this.Name + " failed on try " + (i + 1).ToString());
                    continue;
                }

                connected = true;
                Debug.WriteLine("Sphero " + this.Name + " opened on try " + (i + 1).ToString());

                break;
            }

            if (connected)
            {
                if (this.DebugMode)
                {
                    var p = PacketFactory.new_SetRGBLEDPacket((byte)200, (byte)200, (byte)0, false);
                    this.com.write(p);
                }
            }
            else
            {
                Debug.WriteLine("Unable to open Sphero " + this.Name + "!");
            }

            return connected;
        }
예제 #3
0
 public SpheroCommander()
 {
     spheroComm = new SpheroCommunicator();
 }