コード例 #1
0
    IEnumerator Reconnect(uint serial)
    {
        Debug.Log("looking for usb device " + serial.ToString());
        // polling to try and find the USB device
        while (true)
        {
            if (ANT_Common.getNumDetectedUSBDevices() > nDeviceConnected)
            {
                ANT_Device device = new ANT_Device();
                if (device.getSerialNumber() == serial)
                {
                    Debug.Log("usb found!");
                    AntManager.Instance.Reconnect(device);
                    foreach (AntChannel channel in AntManager.Instance.channelList)
                    {
                        channel.ReOpen(device);
                    }

                    yield break;
                }
                else
                {
                    device.Dispose();
                }
            }

            yield return(new WaitForSeconds(0.1f));
        }
    }
コード例 #2
0
ファイル: AntManager.cs プロジェクト: aamir015/ABCDWeb
 void OnApplicationQuit()
 {
     //dispose the device on app quit or the application will freeze
     if (device != null)
     {
         device.Dispose();
     }
 }
コード例 #3
0
ファイル: VariaRx.cs プロジェクト: jim-brook/VariaRx
 private void CloseAllChannles()
 {
     if (channel0 != null)
     {
         Console.WriteLine("Closing Channel");
         channel0.closeChannel();
         channel0.Dispose();
         channel0 = null;
     }
     if (device0 != null)
     {
         device0.Dispose();
         device0 = null;
     }
     //dispose time and wait object and semaphore
 }
コード例 #4
0
        int cursorIndex = 0;                                                            // index to handle cursor display while transmitting in broadcast mode

        /// <summary>
        /// Setup ANT-FS client to process messages from connected device
        /// </summary>
        public void Start(ANT_Device antDevice)
        {
            PrintMenu();
            try
            {
                // Create the ANT-FS client and attach it to a channel (in this case, 0)
                channel0    = antDevice.getChannel(0);
                antfsClient = new ANTFS_ClientChannel(channel0);

                // Setup callback to handle ANT-FS response events
                antfsClient.OnResponse += new Action <ANTFS_ClientChannel.Response>(HandleClientResponses);

                // Configure the client, and begin beaconing
                ConfigureClient(antDevice);

                while (!demoDone)
                {
                    string command = Console.ReadLine();
                    HandleUserInput(command);
                    Thread.Sleep(0);
                }
            }
            catch (ANTFS_Exception antEx)  // Handle exceptions thrown by ANT Managed library
            {
                Console.WriteLine("ANT-FS Exception: " + antEx.Message);
            }
            catch (Exception ex)  // Handle other exceptions
            {
                Console.WriteLine("Demo failed: " + ex.Message);
                Console.ReadLine();
            }
            finally
            {
                Console.WriteLine("Disconnecting module...");
                antDevice.Dispose();    // Close down the device completely and completely shut down all communication
                antfsClient.Dispose();  // Release all native resources used by the client
                Console.WriteLine("Demo has completed successfully!");
            }
        }
コード例 #5
0
        public void Stop()
        {
            // Nothing to stop if not started or already finished.
            if (state == AntState.NotStarted || state == AntState.Finished)
            {
                return;
            }

            //if (state == AntState.StartFail || state == AntState.ConnectFail)
            //    return;

            if (this.channel != null)
            {
                try
                {
                    ANT_Channel tempChannel = this.channel;
                    this.channel = null;
                    tempChannel.closeChannel(RESPONSE_WAIT_TIME);
                    tempChannel.Dispose();
                }
                catch { }
            }

            if (this.device != null)
            {
                try
                {
                    ANT_Device tempDevice = this.device;
                    this.device = null;

                    // We use a temp var here because this Dispose method is a little strange...
                    tempDevice.Dispose();
                }
                catch { }
            }

            UpdateState(AntState.Finished);
        }
コード例 #6
0
ファイル: AntReader.cs プロジェクト: oszust002/MgrGame
 private void OnDestroy()
 {
     _device?.Dispose();
 }