} // END FUNCTION SetCodes() // Parse the Vicon UDP packet on a separate thread private void ReciveveData() { try { while (!this.terminateFlag) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(IP), port); byte[] data = m_client.Recieve(ref endPoint); // Convert bytes to UTF-8 string string text = Encoding.UTF8.GetString(data); // Initialize a verbatium expression string string expr = @""; // Initialize a container for float parsing float tmpNum = 0; // For each short code, regex through the UDP packet for (int ii = 0; ii < shortCodes.Length; ii++) { // Grab the short code string code = shortCodes[ii]; // Build expression string expr = code + @":\t([0-9\.]+)\t([0-9\.]+)\t([0-9\.]+)"; // Attempt regex regOut = regex.Match(text, expr); // IF the regex found a match, then parse x-y-z if (regOut != NULL) { // Attempt to parse the x-value as a float bool resX = float.TryParse(regOut[1], out tempNum); if (resX == true) { newPoints[ii, 1] = tempNum; } // END IF TryParse(x) // Attempt to parse the y-value as a float bool resY = float.TryParse(regOut[2], out tempNum); if (resY == true) { newPoints[ii, 2] = tempNum; } // END IF TryParse(y) // Attempt to parse the z-value as a float bool resZ = float.TryParse(regOut[3], out tempNum); if (resZ == true) { newPoints[ii, 3] = tempNum; } // END IF TryParse(z) } // END IF regex output } // END FOR shortCodes // Set newPoints this.SetPoints(newPoints); } // END FOR } // END TRY catch (Exception ex) { Console.WriteLine(ex.Message); // Output error message } // END CATCH } // END FUNCTION