Ejemplo n.º 1
0
        //static List<Optoel.Optoel.Ble.BleSlave> ListbleSlave = new List<Optoel.Optoel.Ble.BleSlave>(); //alternatif kullanım
        private static void BleConnectResultevent(Optoel.Optoel.Ble.BleSlave e)
        {
            bleSlave = e;
            //ListbleSlave.Add(e);  // alternatif kullanım

            Console.WriteLine("\nConnected");
            Console.WriteLine("Device Conected State:   " + bleSlave.Connected);
            Console.WriteLine("Device Name:             " + bleSlave.DeviceName);
            Console.WriteLine("Mac Address:             " + bleSlave.MacAddress);
            Console.Write("Mac AddressHex:          ");
            string st = "";

            foreach (var item in bleSlave.MacAddressHEX)
            {
                st += item.ToString("X") + ":";
            }
            st = st.Remove(st.Length - 1);
            Console.WriteLine(st + "\n\n");

            bleSlave.SlaveDisconnected += new Optoel.Optoel.Ble.BleSlave.SlaveDisconnectedEventHandler(SlaveDisconnectedEvent);
            bleSlave.SlaveEnableResult += new Optoel.Optoel.Ble.BleSlave.EnableEventHandler(SlaveEnableResultEvent);
            bleSlave.SlaveBwResult     += new Optoel.Optoel.Ble.BleSlave.BwEventHandler(SlaveBwResultEvent);
            bleSlave.SlaveRangeResult  += new Optoel.Optoel.Ble.BleSlave.RangeEventHandler(SlaveRangeResultEvent);

            bleSlave.AccelData += new Optoel.Optoel.Ble.BleSlave.AccelDataEventHandler(AccelDataEvent);
            bleSlave.GyroData  += new Optoel.Optoel.Ble.BleSlave.GyroDataEventHandler(GyroDataEvent);
            bleSlave.MagnoData += new Optoel.Optoel.Ble.BleSlave.MagnoDataEventHandler(MagnoDataEvent);


            bleSlave.AccelEnable(Optoel.Optoel.Enable.Enable);
        }
Ejemplo n.º 2
0
        private static void GyroDataEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.BMX055.Gyro Gyro)
        {
            gyrocsv = Gyro;
            Console.WriteLine(sender.SlaveNumber + ". Device Gyro:    {0},    {1},    {2}", Gyro.RawX, Gyro.RawY, Gyro.RawZ);

            if (sender.SlaveNumber == 1)
            {
                swGyro1.WriteLine(Gyro.GyroDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Gyro.RawX.ToString(new CultureInfo("en-US", false)) + "," + Gyro.RawY.ToString(new CultureInfo("en-US", false)) + "," + Gyro.RawZ.ToString(new CultureInfo("en-US", false)));
                swGyro1.Flush();
            }
            else if (sender.SlaveNumber == 2)
            {
                swGyro2.WriteLine(Gyro.GyroDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Gyro.RawX.ToString(new CultureInfo("en-US", false)) + "," + Gyro.RawY.ToString(new CultureInfo("en-US", false)) + "," + Gyro.RawZ.ToString(new CultureInfo("en-US", false)));
                swGyro2.Flush();
            }

            //swAllData.WriteLine(
            //    accelcsv.RawX.ToString(new CultureInfo("en-US", false)) + "," +
            //    accelcsv.RawY.ToString(new CultureInfo("en-US", false)) + "," +
            //    accelcsv.RawZ.ToString(new CultureInfo("en-US", false)) + "," +

            //    gyrocsv.RawX.ToString(new CultureInfo("en-US", false)) + "," +
            //    gyrocsv.RawY.ToString(new CultureInfo("en-US", false)) + "," +
            //    gyrocsv.RawZ.ToString(new CultureInfo("en-US", false)) + "," +

            //    magnocsv.RawX.ToString(new CultureInfo("en-US", false)) + "," +
            //    magnocsv.RawY.ToString(new CultureInfo("en-US", false)) + "," +
            //    magnocsv.RawZ.ToString(new CultureInfo("en-US", false)) + ","
            //    );
            //swAllData.Flush();
        }
Ejemplo n.º 3
0
        private static void MagnoDataEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.BMX055.Magno Magno)
        {
            magnocsv = Magno;
            Console.WriteLine(sender.SlaveNumber + ". Device Magno:   {0},    {1},    {2}", Magno.RawX, Magno.RawY, Magno.RawZ);

            if (sender.SlaveNumber == 1)
            {
                swMagno1.WriteLine(Magno.MagnoDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Magno.RawX.ToString(new CultureInfo("en-US", false)) + "," + Magno.RawY.ToString(new CultureInfo("en-US", false)) + "," + Magno.RawZ.ToString(new CultureInfo("en-US", false)));
                swMagno1.Flush();
            }
            else if (sender.SlaveNumber == 2)
            {
                swMagno2.WriteLine(Magno.MagnoDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Magno.RawX.ToString(new CultureInfo("en-US", false)) + "," + Magno.RawY.ToString(new CultureInfo("en-US", false)) + "," + Magno.RawZ.ToString(new CultureInfo("en-US", false)));
                swMagno2.Flush();
            }
        }
Ejemplo n.º 4
0
        private static void RangeResultEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.Ble.BleSlave.RangeResultArgs e)
        {
            switch (e.Sensor)
            {
            case Optoel.Optoel.Sensor.Accel:
                Console.WriteLine(sender.SlaveNumber + ". Device Accel Range: " + e.Range.ToString());
                sender.GyroSetRange(Optoel.Optoel.GyroRange.GyroRange_1000s);

                break;

            case Optoel.Optoel.Sensor.Gyro:
                Console.WriteLine(sender.SlaveNumber + ". Device Gyro Range: " + e.Range.ToString());

                break;
            }
        }
Ejemplo n.º 5
0
        private static void AccelDataEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.BMX055.Accel Accel)
        {
            accelcsv = Accel;
            Console.WriteLine(sender.SlaveNumber + ". Device Accel:   {0},    {1},    {2}", Accel.RawX, Accel.RawY, Accel.RawZ);

            if (sender.SlaveNumber == 1)
            {
                swAccel1.WriteLine(Accel.AccelDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Accel.RawX.ToString(new CultureInfo("en-US", false)) + "," + Accel.RawY.ToString(new CultureInfo("en-US", false)) + "," + Accel.RawZ.ToString(new CultureInfo("en-US", false)));
                swAccel1.Flush();
            }
            else if (sender.SlaveNumber == 2)
            {
                swAccel2.WriteLine(Accel.AccelDataNumber.ToString(new CultureInfo("en-US", false)) + ", " + Accel.RawX.ToString(new CultureInfo("en-US", false)) + "," + Accel.RawY.ToString(new CultureInfo("en-US", false)) + "," + Accel.RawZ.ToString(new CultureInfo("en-US", false)));
                swAccel2.Flush();
            }
        }
Ejemplo n.º 6
0
        private static void EnableResultEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.Ble.BleSlave.EnableResultArgs e)
        {
            switch (e.Sensor)
            {
            case Optoel.Optoel.Sensor.Accel:
                if (e.Enable == Optoel.Optoel.Enable.Enable)
                {
                    Console.WriteLine("{0}. Device Accel Enable", sender.SlaveNumber);
                }
                else if (e.Enable == Optoel.Optoel.Enable.Disable)
                {
                    Console.WriteLine("{0}. Device Accel Disable", sender.SlaveNumber);
                }

                sender.GyroEnable(Optoel.Optoel.Enable.Enable);
                break;

            case Optoel.Optoel.Sensor.Gyro:
                if (e.Enable == Optoel.Optoel.Enable.Enable)
                {
                    Console.WriteLine("{0}. Device Gyro Enable", sender.SlaveNumber);
                }
                else if (e.Enable == Optoel.Optoel.Enable.Disable)
                {
                    Console.WriteLine("{0}. Device Gyro Disable", sender.SlaveNumber);
                }

                sender.MagnoEnable(Optoel.Optoel.Enable.Enable);
                break;

            case Optoel.Optoel.Sensor.Magno:
                if (e.Enable == Optoel.Optoel.Enable.Enable)
                {
                    Console.WriteLine("{0}. Device Magno Enable", sender.SlaveNumber);
                }
                else if (e.Enable == Optoel.Optoel.Enable.Disable)
                {
                    Console.WriteLine("{0}. Device Magno Disable", sender.SlaveNumber);
                }

                sender.AccelSetBw(Optoel.Optoel.AccelBw.AccelBw_62f5);
                break;
            }
        }
Ejemplo n.º 7
0
        private static void BwResultEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.Ble.BleSlave.BwResultArgs e)
        {
            switch (e.Sensor)
            {
            case Optoel.Optoel.Sensor.Accel:
                Console.WriteLine(sender.SlaveNumber + ". Device Accel Bw: " + e.Bw.ToString());
                sender.GyroSetBw(Optoel.Optoel.GyroBw.GyroBw_100Hz);

                break;

            case Optoel.Optoel.Sensor.Gyro:
                Console.WriteLine(sender.SlaveNumber + ". Device Gyro Bw: " + e.Bw.ToString());
                sender.MagnoSetBw(Optoel.Optoel.MagnoBw.MagnoBw_30Hz);

                break;

            case Optoel.Optoel.Sensor.Magno:
                Console.WriteLine(sender.SlaveNumber + ". Device Magno Bw: " + e.Bw.ToString());
                sender.AccelSetRange(Optoel.Optoel.AccelRange.AccelRange_4g);

                break;
            }
        }
Ejemplo n.º 8
0
        private static void BleConnectResultevent(Optoel.Optoel.Ble.BleSlave e)
        {
            //bleSlave = e;  /* alternatif kullanım */
            e.SlaveNumber = slaveNmbr; // Kullanıcı tarafından isteğe göre verilen cihaz numarası.
            slaveNmbr++;
            ListbleSlave.Add(e);

            Console.WriteLine("\nConnected");
            Console.WriteLine("Device Conected State:   " + e.Connected);
            Console.WriteLine("Device Name:             " + e.DeviceName);
            Console.WriteLine("Mac Address:             " + e.MacAddress);
            Console.Write("Mac AddressHex:          ");
            string st = "";

            foreach (var item in e.MacAddressHEX)
            {
                st += item.ToString("X") + ":";
            }
            st = st.Remove(st.Length - 1);
            Console.WriteLine(st + "\n\n");

            e.AccelEnable(Optoel.Optoel.Enable.Enable);
        }
Ejemplo n.º 9
0
 private static void SlaveErrorEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.Ble.ErrorHandleArgs e)
 {
     Console.WriteLine("\n{0}. Device Error!", sender.SlaveNumber);
     Console.WriteLine("Error Code: " + e.ErrorCode);
     Console.WriteLine("Error:  " + e.ErrorMessage);
 }
Ejemplo n.º 10
0
 private static void DisconnectedEvent(Optoel.Optoel.Ble.BleSlave sender, Optoel.Optoel.Ble.BleSlave.DisconnectedEventArgs e)
 {
     Console.WriteLine("\n{0}. Device disconnected!", sender.SlaveNumber);
     Console.WriteLine("Reason Code: " + e.ReasonCode);
     Console.WriteLine("Reason:  " + e.Reason);
 }