Example #1
0
 private void TGConnector_DeviceFound(object sender, EventArgs e)
 {
     Connector.DeviceEventArgs devArgs = (Connector.DeviceEventArgs)e;
     this.LogAdd("ThinkGear device is found.");
     this.LogAdd($"Device ID: {devArgs.Device.HeadsetID}");
     this.LogAdd($"Device Port: { devArgs.Device.PortName}");
 }
Example #2
0
        /**
         * Called when a device is connected
         */
        static void OnDeviceConnected(object sender, EventArgs e)
        {
            Console.WriteLine("wwwww");


            //Thread t1 = new Thread(new ThreadStart(snake));
            // t1.Start();
            Thread.Sleep(10000);//睡眠500毫秒,也就是0.5秒
            IPAddress ip = IPAddress.Parse("127.0.0.1");

            tcp1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            tcp2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            tcp1.Connect(new IPEndPoint(ip, 9999));
            tcp2.Connect(new IPEndPoint(ip, 9999));

            Thread t2 = new Thread(new ThreadStart(tcp2_feed));

            t2.Start();

            buffer[0] = 90;
            buffer[1] = 8;
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            Console.WriteLine("Device found on: " + de.Device.PortName);

            de.Device.DataReceived += new EventHandler(OnDataReceived);
            Console.WriteLine("ppppppp");
        }
Example #3
0
        // Called when a device is connected

        static void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            Console.WriteLine("Device found on: " + de.Device.PortName);
            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
        /**
         * Called when a device is connected
         */
        void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            richTextBox1.Text += "Device found on: " + de.Device.PortName;

            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
Example #5
0
    void OnDeviceConnected(object sender, EventArgs e)
    {
        Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

        NSDebug.Log("OnDeviceConnected");

        de.Device.DataReceived += new EventHandler(OnDataReceived);
    }
Example #6
0
        // Called when a device is connected
        public void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            label14.Invoke((MethodInvoker)(() => label14.Text = "Device found on: " + de.Device.PortName));
            // MessageBox.Show( "Device found on: "  + de.Device.PortName);
            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
 public string DesconectarDiadema()
 {
     //StreamWriter dispositivo = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + "dispositivo.txt");
     //dispositivo.Close();
     connector.Close();
     De = null;
     return("Desconectando");
 }
Example #8
0
        void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs deviceEventArgs = (Connector.DeviceEventArgs)e;
            // refress data

            MessageBox.Show("New Headset Created.");
            checking = true;
            deviceEventArgs.Device.DataReceived += new EventHandler(OnDataReceived);
        }
        private void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs deviceEventArgs = (Connector.DeviceEventArgs)e;
            Console.WriteLine("Device found on: " + deviceEventArgs.Device.PortName);
            _event.HeadsetStatus = Globals.CONNECTED_STATUS;

            deviceEventArgs.Device.DataReceived += new EventHandler(OnDataReceived);
            _event.ConnHs = false;
            _event.DissHs = true;
        }
Example #10
0
        static void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            byte[] init = Encoding.Unicode.GetBytes("ready");
            connector.Send("COM5", init);


            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
Example #11
0
        // Called when a device is connected
        static void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;
            Console.WriteLine("Device found on: " + de.Device.PortName);

            try
            {
                // Determine whether the directory exists.
                if (Directory.Exists(path))
                {
                    Console.WriteLine("That path exists already. Restart the program and enter a different Test Name.");
                    Thread.Sleep(2000);
                    return;
                }

                // Try to create the directory.
                DirectoryInfo di = Directory.CreateDirectory(path);
                Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));
            }
            catch (Exception ex)
            {
                Console.WriteLine("The process failed: {0}", ex.ToString());
            }
            finally { }


            File.AppendAllText(path + "info.txt", testName + "|" + testDate + "|" + testComments);

            try
            {
                string fileName   = "results.html";
                string sourcePath = "";
                string targetPath = path;
                string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
                string destFile   = System.IO.Path.Combine(targetPath, fileName);
                System.IO.File.Copy(sourceFile, destFile, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong!");
            }
            finally { }


            Console.WriteLine("Recording Started.");

            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("To end the test, type \"end\" into the comment prompt and press Enter.");
            Console.ResetColor();

            Console.Write("Comment: ");
            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
Example #12
0
 private void TGConnector_DeviceConnected(object sender, EventArgs e)
 {
     Connector.DeviceEventArgs devArgs = (Connector.DeviceEventArgs)e;
     this.LogAdd("ThinkGear device is connected.");
     if (devArgs?.Device != null)
     {
         this.LogAdd($"Headset ID: {devArgs.Device.HeadsetID}");
         this.LogAdd($"PortName: { devArgs.Device.PortName}");
         this.LogAdd($"Data Received Rate: { devArgs.Device.DataReceivedRate}");
         this.LogAdd($"Last Update: { devArgs.Device.lastUpdate:yyyy/MM/dd hh:mm:ss}");
     }
     devArgs.Device.DataReceived += TGConnector_DataReceived;
 }
    // All the handlers below are called from the reading thread, and therefore
    // need to use ScheduleTask to dispatch events to the main unity thread!

    void HandleOnDeviceConnected(object sender, EventArgs e)
    {
        Connector.DeviceEventArgs deviceEventArgs = (Connector.DeviceEventArgs)e;
        Debug.Log("New Headset Created: " + deviceEventArgs.Device.PortName);
        ScheduleTask(new Task(delegate {
            if (OnHeadsetConnected != null)
            {
                OnHeadsetConnected(0);                 // TODO: meaningful return value?
            }
        }));
        // set up event handling for data:
        deviceEventArgs.Device.DataReceived += this.HandleOnDataReceived;
    }
    // Called when a device is connected
    void OnDeviceConnected(object sender, EventArgs e)
    {
        E = e;
        Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;
        _De = (Connector.DeviceEventArgs)e;
        Console.WriteLine("Device found on: " + de.Device.PortName);

        //de.Device.DataReceived += new EventHandler(OnDataReceived);
        String       ruta_archivo = System.AppDomain.CurrentDomain.BaseDirectory + "ondas.txt";
        StreamWriter escritura    = File.AppendText(ruta_archivo);

        escritura.Write("Device found on: " + de.Device.PortName);
        escritura.Close();
    }
Example #15
0
        // Called when a device is connected

        static void OnDeviceConnected(object sender, EventArgs e)
        {
            Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;

            Console.WriteLine("Device found on: " + de.Device.PortName);

            Console.WriteLine("Connecting to Arduino");

            port = new SerialPort("COM8", 115200, Parity.None, 8, StopBits.One); //type here the port of the Arduino

            port.Open();

            Thread.Sleep(3000);

            Console.WriteLine("Connected to Arduino");

            de.Device.DataReceived += new EventHandler(OnDataReceived);
        }
    void OnDeviceConnected(object sender, EventArgs e)
    {
        Connector.DeviceEventArgs de = (Connector.DeviceEventArgs)e;
        Console.WriteLine("Device found on: " + de.Device.PortName);
        De = de;
        StreamWriter dispositivo = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + "dispositivo.txt");

        dispositivo.WriteLine("Device found on");
        dispositivo.Close();
        //de.Device.DataReceived += new EventHandler(OnDataReceived);
        String       ruta_archivo = System.AppDomain.CurrentDomain.BaseDirectory + "datosC.txt";
        StreamWriter datosC       = new StreamWriter(ruta_archivo);

        //datosC.WriteLine("Device found on");
        datosC.WriteLine(de.Device.PortName);
        datosC.WriteLine(de.Device.HeadsetID);
        datosC.Close();
        numS = 0;
    }
 private void OnDeviceConnected(object sender, EventArgs e)
 {
     Connector.DeviceEventArgs deviceEventArgs = (Connector.DeviceEventArgs)e;
     deviceEventArgs.Device.DataReceived += new EventHandler(this.OnDataReceived);
 }