/// <summary> /// Requests renewed data from the CyberGlove and populates the finger objects with this /// new data. /// </summary> protected virtual void pollJointData() { // Calculate the size of the array. int max = NR_FINGERS * NR_JOINTS + 2; // Create an array of doubles, that will later be filled with joint data. double[] arr = new double[max]; // Poll() fills arr with data and returns the size of the new array. // If that size is not 22, something weird is going on. int size = Poll(this.vhtHand, arr, max); // Fill the hand with data. populate(arr); // Update the position. PositionRecord pr = PositionParser.GetMatch(this); // Huge ugly if test... // Call the event if this position is recognized, and it's not the same // as the last recognized function. if (pr != null && pr != CurrentPosition && pr != LastPosition) { LastPosition = pr; PositionHasChanged(this, pr); // Check whether any motions have been detected... // There can be multiple matches. List <MotionRecord> matches = MotionParser.GetMatches(pr); foreach (MotionRecord mr in matches) { MotionHasDetected(this, mr); } } CurrentPosition = pr; DataHasUpdated(this); }
/// <summary> /// Polls for updated data. Because this is an emulator, the next line in the /// record will be used. /// </summary> protected override void pollJointData() { // Clone the current item into this hand, and increase the index Populate(sequence[currentPos++]); // Update the position. PositionRecord pr = PositionParser.GetMatch(this); // Huge ugly if test... // Call the event if this position is recognized, and it's not the same // as the last recognized function. if (pr != null && pr != CurrentPosition && pr != LastPosition) { LastPosition = pr; PositionHasChanged(this, pr); // Check whether any motions have been detected... // There can be multiple matches. List <MotionRecord> matches = MotionParser.GetMatches(pr); foreach (MotionRecord mr in matches) { MotionHasDetected(this, mr); } } CurrentPosition = pr; DataHasUpdated(this); // Check whether we need to stop polling now. checkIfEnded(); }