Ejemplo n.º 1
0
        private void cmdConnect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (SPBluetooth.GetInsntace().IsOpen)
                {
                    SPBluetooth.GetInsntace().Close();
                    cmdConnect.Content = "Connect";
                }
                else
                {
                    SPBluetooth.GetInsntace().PortName = comboCOMMPorts.SelectedItem.ToString().Trim();

                    // configs
                    SPBluetooth.GetInsntace().BaudRate = 115200;
                    SPBluetooth.GetInsntace().DataBits = 8;
                    SPBluetooth.GetInsntace().StopBits = System.IO.Ports.StopBits.One;
                    SPBluetooth.GetInsntace().Parity   = System.IO.Ports.Parity.None;

                    SPBluetooth.GetInsntace().Open();
                    cmdConnect.Content = "Disconnect";
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Comm port Not Available \n コンポート接続されていません", "Comm port Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void CheckJointPositions()
        {
            // get the zeroth body
            if (bodies.Length == 0)
            {
                return;
            }

            Body body = bodies[0];

            double handRight  = Math.Round(body.Joints[JointType.HandRight].Position.X * 10, 0);
            double elbowRight = Math.Round(body.Joints[JointType.ElbowRight].Position.X * 10, 0);

            if (body.Joints[JointType.HandRight].Position.Y <= body.Joints[JointType.ElbowRight].Position.Y)
            {
                lblTitle.Content = "No";
                return;
            }

            if (handRight > elbowRight)
            {
                rightflag = 1;
            }
            else if (handRight < elbowRight)
            {
                rightflag = 2;
            }
            else if (handRight == elbowRight)
            {
                if (rightflag == 2)
                {
                    Console.WriteLine("Waved");
                    lblTitle.Content = "Waved";
                    try
                    {
                        if (SPBluetooth.GetInsntace().IsOpen)
                        {
                            SPBluetooth.GetInsntace().DiscardInBuffer();
                            SPBluetooth.GetInsntace().DiscardOutBuffer();

                            SPBluetooth.GetInsntace().WriteLine("SUW,123456789012345678901234567890AB,10");
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                    catch (Exception r)
                    {
                        Console.WriteLine(r.Message);
                    }
                }
                else
                {
                }
            }
        }
Ejemplo n.º 3
0
 void MainWindow_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
 {
     Console.Write(SPBluetooth.GetInsntace().ReadExisting());
 }
Ejemplo n.º 4
0
 public MainWindow()
 {
     InitializeComponent();
     FillCommports();
     SPBluetooth.GetInsntace().DataReceived += MainWindow_DataReceived;
 }
Ejemplo n.º 5
0
 private void cmdbuzzer_Click(object sender, RoutedEventArgs e)
 {
     SPBluetooth.GetInsntace().WriteLine("SUW,123456789012345678901234567890AB,10");
 }
Ejemplo n.º 6
0
 private void cmdsconnectBlootooth_Click(object sender, RoutedEventArgs e)
 {
     SPBluetooth.GetInsntace().WriteLine("E,0,001EC0462DE8");
 }
Ejemplo n.º 7
0
 private void cmdStopSearch_Click(object sender, RoutedEventArgs e)
 {
     SPBluetooth.GetInsntace().WriteLine("X");
 }
Ejemplo n.º 8
0
 private void cmdEchoOff_Click(object sender, RoutedEventArgs e)
 {
     SPBluetooth.GetInsntace().WriteLine("+");
 }