コード例 #1
0
 /// <summary>
 /// Creates new record and Bluetooth manager classes before attempting to connect to the IMU device.
 /// If an instance of the Bluetooth manager is already in effect, will make a call to dispose of it first.
 /// </summary>
 /// <returns> Whether the connection attempt to the IMU device was successful.</returns>
 public bool connect()
 {
     if (bt_manager != null)
     {
         dispose_previous_connection();
     }
     records    = new Records(IMU_number);
     bt_manager = new BTManager(this, MAC_address, debug_connection_reports, conn_info_set);
     return(bt_manager.connect());
 }
コード例 #2
0
 /// <summary>
 /// Performs safe termination of the Bluetooth manager's underlying data stream thread, disposes of
 /// the associated 32Feet Bluetooth client and then the Bluetooth manager itself.
 /// </summary>
 public void dispose_previous_connection()
 {
     if (bt_manager.get_data != null && bt_manager.safe_to_terminate)
     {
         bt_manager.get_data.Abort();
     }
     if (bt_manager.client != null)
     {
         bt_manager.client.Close();
     }
     bt_manager = null;
 }
コード例 #3
0
        /// <summary>
        /// Closes the Bluetooth connection by terminating the associated thread, sending a stop command to the IMU device
        /// and closing the underlying Bluetooth connection.
        /// </summary>
        public void close()
        {
            if (bt_manager != null && bt_manager.client != null)
            {
                bt_manager.send_data("M0dg");
                bt_manager.stream_open = false;

                if (bt_manager.get_data != null)
                {
                    /*
                     * while (!bt_manager.safe_to_terminate)
                     * {
                     *  System.Diagnostics.Debug.WriteLine(IMU_number + "--" + "waiting");
                     * }
                     */
                    //bt_manager.get_data.Abort();
                }
                bt_manager.client.Close();
                bt_manager = null;
            }
        }