2015-01-31 93 views
1

我正在存储一个WPF应用程序中的类型双变量传感器的读数,来自Thalmic Lab的Myo传感器的degreeOutput。存储在变量中的值随着用户移动手臂而不断变化,但是我希望在人物姿势不是不断变化的值时,将运动中某个点的度数读数存储起来。如何保存不断变化的变量的当前值?

在我当前的实现中,我触发painfulArcStartTbx中显示的degreeOutput的值来表示我想要测量的弧的起始值,但这不符合计划。

取而代之的是,当握住拳头时,度数值输出到文本框,但是不断变化。

我希望只有在握拳之后没有任何阅读时才输出初始阅读。

圆弧的末端读数应该在拳头姿势松开后输出,但是我得到的结果与上面相同。

有没有人有任何建议,我可以如何才能存储当前价值的拳头举行点和当前价值的拳头姿势是放手?

这就是度输出处理方法:

private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e) 
     { 
      App.Current.Dispatcher.Invoke((Action)(() => 
      { 

       //need to record degree reading when pose made that 
       //signifies begining of painful arc. 
       //then specify a second pose that signals the end of 
       //painful arc and store arc reading, eg 92dg - 108dg 


       //myo indicator must be facing down or degrees will be inverted. 
       degreeOutput = ((e.Pitch + PITCH_MIN) * CALLIBRATION_FACTOR); 

       degreeOfAbductionTbx.Text = "Degree: " + degreeOutput; 

       if(e.Myo.Pose == Pose.Fist) 
       { 
        //get the start reading of the painful arc 
        painfulArcStartTbx.Text = "start: " + degreeOutput; 

       } 
       //then get the finish reading of the painful arc 
       //after the fist pose has been let go, indicating 
       //end of pain in movement 
       else 
       { 

        painfulArcEndTbx.Text = "end: " + degreeOutput; 

       } 




      })); 

     } 

回答

3

我可以在这里完全错误的,因为我已经不知道该传感器是什么,但似乎你错过了一些非常基本的:

 private string startingDegree; 
     private string endDegree; 
     private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e) 
    { 
     App.Current.Dispatcher.Invoke((Action)(() => 
     { 

      //need to record degree reading when pose made that 
      //signifies begining of painful arc. 
      //then specify a second pose that signals the end of 
      //painful arc and store arc reading, eg 92dg - 108dg 


      //myo indicator must be facing down or degrees will be inverted. 
      degreeOutput = ((e.Pitch + PITCH_MIN) * CALLIBRATION_FACTOR); 

      degreeOfAbductionTbx.Text = "Degree: " + degreeOutput; 

      if(e.Myo.Pose == Pose.Fist) 
      { 
       endDegree = string.Empty; 
       if(string.IsNullOrEmpty(startingDegree)) 
       { 
        startingDegree = "start: " + degreeOutput; 
       } 

       //get the start reading of the painful arc 
       painfulArcStartTbx.Text = startingDegree; 

      } 
      //then get the finish reading of the painful arc 
      //after the fist pose has been let go, indicating 
      //end of pain in movement 
      else 
      { 
       startingDegree = string.Empty; 
       if(string.IsNullOrEmpty(endDegree)) 
       { 
        endDegree = "end: " + degreeOutput; 
       } 
       painfulArcEndTbx.Text = endDegree; 

      } 




     })); 

    } 
+0

那么我会用双?但那正是我刚才输入的内容。 – 2015-01-31 21:58:53

+0

@TonyHopkinson给出这一行:'App.Current.Dispatcher.Invoke'这是一个RT应用程序,所以在应用程序体系结构我不会这样做,这需要在虚拟机上是'ObservableProperty',但是OP没有提供超出必要性的许多信息,所以。 – zaitsman 2015-01-31 22:01:40

+0

@zaitsman我现在就来测试一下,但是痛苦的ArcEndTbx应该在刚刚停止握拳姿势后存储读取的度数值,我认为在上面的代码末尾将会是一个不断变化的值,因为您将它设置为'degreeOutput' – 2015-01-31 22:07:48