Esempio n. 1
0
        private void txtThumbPos_KeyDown(object sender, KeyEventArgs e)
        {
            if (handManualState)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    Console.WriteLine(SendMessageConfig.SendToHand(Int16.Parse(txtThumbPos.Text == string.Empty ? "0" : txtThumbPos.Text), Int16.Parse(txtIndexPos.Text == string.Empty ? "0" : txtIndexPos.Text)
                                                                   , Int16.Parse(txtMiddlePos.Text == string.Empty ? "0" : txtMiddlePos.Text), Int16.Parse(txtRingPos.Text == string.Empty ? "0" : txtRingPos.Text), Int16.Parse(txtPinkyPos.Text == string.Empty ? "0" : txtPinkyPos.Text)
                                                                   , 100, 100, 100, 100, 100));
                }
                if (e.KeyCode == Keys.Enter && hand.IsConnected())
                {
                    hand.SendMessage(SendMessageConfig.SendToHand(Int16.Parse(txtThumbPos.Text == string.Empty ? "0" : txtThumbPos.Text), Int16.Parse(txtIndexPos.Text == string.Empty ? "0" : txtIndexPos.Text)
                                                                  , Int16.Parse(txtMiddlePos.Text == string.Empty ? "0" : txtMiddlePos.Text), Int16.Parse(txtRingPos.Text == string.Empty ? "0" : txtRingPos.Text), Int16.Parse(txtPinkyPos.Text == string.Empty ? "0" : txtPinkyPos.Text)
                                                                  , 100, 100, 100, 100, 100));

                    trThumb.Value  = Int16.Parse(txtThumbPos.Text == string.Empty ? "0" : txtThumbPos.Text);
                    trIndex.Value  = Int16.Parse(txtIndexPos.Text == string.Empty ? "0" : txtIndexPos.Text);
                    trMiddle.Value = Int16.Parse(txtMiddlePos.Text == string.Empty ? "0" : txtMiddlePos.Text);
                    trRing.Value   = Int16.Parse(txtRingPos.Text == string.Empty ? "0" : txtRingPos.Text);
                    trPinky.Value  = Int16.Parse(txtPinkyPos.Text == string.Empty ? "0" : txtPinkyPos.Text);
                    Console.WriteLine(SendMessageConfig.SendToHand((Int16)trThumb.Value, (Int16)trIndex.Value, (Int16)trMiddle.Value, (Int16)trRing.Value, (Int16)trPinky.Value, 100, 100, 100, 100, 100));
                }
            }
        }
Esempio n. 2
0
 private void btnDemoHand_Click(object sender, EventArgs e)
 {
     if (!demoFlag)
     {
         hand.SendMessage(SendMessageConfig.SendToHand(100, 100, 100, 100, 100, 100, 100, 100, 100, 100));
         demoFlag         = true;
         btnDemoHand.Text = "StopDemo";
         Task.Run(() =>
         {
             Thread.Sleep(1000);
             while (demoFlag)
             {
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(100, 70, 80, 100, 100, 100, 100, 100, 100, 100));
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(70, 30, 40, 100, 70, 100, 100, 100, 100, 100));
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(30, 60, 20, 70, 40, 100, 100, 100, 100, 100));
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(60, 90, 50, 40, 20, 100, 100, 100, 100, 100));
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(90, 100, 100, 20, 50, 100, 100, 100, 100, 100));
                 Thread.Sleep(450);
                 hand.SendMessage(SendMessageConfig.SendToHand(100, 100, 100, 60, 80, 100, 100, 100, 100, 100));
             }
         });
     }
     else
     {
         btnDemoHand.Text = "Demo";
         demoFlag         = false;
     }
 }
Esempio n. 3
0
 private void trPinky_Scroll(object sender, EventArgs e)
 {
     if (btnStartHand.Text == "AutoReceive")
     {
         hand.SendMessage(SendMessageConfig.SendToHand((Int16)trThumb.Value, (Int16)trIndex.Value, (Int16)trMiddle.Value, (Int16)trRing.Value, (Int16)trPinky.Value, 100, 100, 100, 100, 100));
         Console.WriteLine(SendMessageConfig.SendToHand((Int16)trThumb.Value, (Int16)trIndex.Value, (Int16)trMiddle.Value, (Int16)trRing.Value, (Int16)trPinky.Value, 100, 100, 100, 100, 100));
         setScrollTextBoxes();
     }
 }
Esempio n. 4
0
        private void Hand_ReceiveMessageHandler(object sender, MessageReceiveEventArgs e)
        {
            int[] values = Array.ConvertAll(e.Message.Split(','), int.Parse);
            if (hand.RFIDEnabled)
            {
                if (values[15] != 0)
                {
                    hand.HandRFID = (HandRFIDs)values[15];
                    Console.WriteLine(SendMessageConfig.SendRFIDFeedback((HandRFIDs)values[15]));
                }
            }

            Invoke(new Action(() =>
            {
                try
                {
                    // How to run these codes as parallel

                    hand.Thumb.Position  = values[0];
                    hand.Index.Position  = values[1];
                    hand.Middle.Position = values[2];
                    hand.Ring.Position   = values[3];
                    hand.Pinky.Position  = values[4];
                    if (!handManualState)
                    {
                        trThumb.Value     = values[0] > trThumb.Maximum ? trThumb.Maximum : (values[0] < trThumb.Minimum ? trThumb.Minimum : values[0]);
                        trIndex.Value     = values[1] > trIndex.Maximum ? trIndex.Maximum : (values[1] < trIndex.Minimum ? trIndex.Minimum : values[1]);
                        trMiddle.Value    = values[2] > trMiddle.Maximum ? trIndex.Maximum : (values[2] < trMiddle.Minimum ? trMiddle.Minimum : values[2]);
                        trRing.Value      = values[3] > trRing.Maximum ? trRing.Maximum : (values[3] < trRing.Minimum ? trRing.Minimum : values[3]);
                        trPinky.Value     = values[4] > trPinky.Maximum ? trPinky.Maximum : (values[4] < trPinky.Minimum ? trPinky.Minimum : values[4]);
                        txtThumbPos.Text  = trThumb.Value.ToString();
                        txtIndexPos.Text  = trIndex.Value.ToString();
                        txtMiddlePos.Text = trMiddle.Value.ToString();
                        txtRingPos.Text   = trRing.Value.ToString();
                        txtPinkyPos.Text  = trPinky.Value.ToString();
                        SelectAllTextBoxes();
                    }
                    thumbCur.Text       = values[5].ToString();
                    indexCur.Text       = values[6].ToString();
                    middleCur.Text      = values[7].ToString();
                    ringCur.Text        = values[8].ToString();
                    pinkyCur.Text       = values[9].ToString();
                    lblThumbFsr.Text    = values[10].ToString();
                    lblIndexFsr.Text    = values[11].ToString();
                    lblMiddleFsr.Text   = values[12].ToString();
                    lblRingFsr.Text     = values[13].ToString();
                    lblTemppinky.Text   = $"Temperature: {values[14]}";
                    panelTemp.BackColor = setTempColor(values[14]);
                    lblRfid.Text        = $"RFID : {values[15]}";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.GetBaseException().ToString() + "\n\n" + "Receiving from hand");
                }
            }));
        }
Esempio n. 5
0
        private void Emg1c_MessageReceived(object sender, MessageReceiveEventArgs e)
        {
            //string[] values = e.Message.Split(new[] {':','#'}, StringSplitOptions.None);
            Match[] values = Regex.Matches(e.Message, @":+[0-9]+#").Cast <Match>().ToArray();
            try
            {
                for (int i = 0; i < values.Length; i++)
                {
                    string temp1 = values[i].Value;
                    string temp  = temp1.Substring(1, temp1.IndexOf('#') - 1);
                    // threshold
                    if (emg1cThresholdCheck.Checked)
                    {
                        if (int.Parse(temp) > numEmg1cThreshold.Value && !emg1cThresholdReach)
                        {
                            Console.WriteLine(SendMessageConfig.HandFist());
                            hand.SendMessage(SendMessageConfig.HandFist());
                            emg1cThresholdReach = true;
                        }
                        else if (int.Parse(temp) < numEmg1cThreshold.Value && emg1cThresholdReach)
                        {
                            Console.WriteLine(SendMessageConfig.HandOpen());
                            hand.SendMessage(SendMessageConfig.HandOpen());
                            emg1cThresholdReach = false;
                        }
                    }

                    //Thread.Sleep(emg1c.Delay);
                    if (int.TryParse(temp, out int j))
                    {
                        emg1cChartValue.Add(new ChartModel()
                        {
                            Data = double.Parse(temp),
                            Time = DateTime.Now
                        });
                        Invoke(new Action(() =>
                        {
                            emg1cChart.AxisX[0].MaxValue = DateTime.Now.Ticks + TimeSpan.FromSeconds(2).Ticks;
                            emg1cChart.AxisX[0].MinValue = DateTime.Now.Ticks - TimeSpan.FromSeconds(10).Ticks;
                        }));
                        if (emg1cChartValue.Count > 100)
                        {
                            emg1cChartValue.RemoveAt(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetBaseException().ToString() + "\n\nFROM EMG1C RECEIVE");
            }
        }