-class EpicRollerCoasters_TelemetryReceiver
+class EpicRollerCoasters_Telemetry
// Launch Options: -telemetry network
// Launch Options: -telemetry network -port 7701
lastReceivedUDPPacket = text;
- //Debug.Log(">> " + lastReceivedUDPPacket);
+ //Console.WriteLine(">> " + lastReceivedUDPPacket);
// UDPPacket output example:
- // S[027.559]Y[-004.332]P[165.854]R[-054.661]W[000.007]H[000.000]U[027.559]
- // S[027.694]Y[-004.398]P[165.538]R[044.135]W[-000.072]H[-000.071]U[027.694]
- float speed = ParseNumber("S", lastReceivedUDPPacket);
- float yaw = ParseNumber("Y", lastReceivedUDPPacket);
- float pitch = ParseNumber("P", lastReceivedUDPPacket);
- float roll = ParseNumber("R", lastReceivedUDPPacket);
- float heave = ParseNumber("H", lastReceivedUDPPacket);
- float sway = ParseNumber("W", lastReceivedUDPPacket);
- float surge = ParseNumber("U", lastReceivedUDPPacket);
- Console.WriteLine(">> Speed: {0}, Yaw: {1}, Pitch: {2}, Roll: {3}, Heave: {4}, Sway: {5}, Surge: {6}",
- speed, yaw, pitch, roll, heave, sway, surge);
+ // S[005.001]V[023.729]F[008.801]Y[173.541]P[000.049]R[000.052]H[000.000]W[000.004]U[005.001]A[000.119]I[-000.001]O[000.000]N[00]C[00]G[00]
+ // S[026.953]V[044.193]F[016.940]Y[159.710]P[001.965]R[-003.653]H[000.182]W[000.170]U[026.952]A[000.480]I[000.541]O[-000.098]N[11]C[19]G[05]
+ float speed = GetNumber("S", lastReceivedUDPPacket);
+ float vibrationIntensity = GetNumber("V", lastReceivedUDPPacket);
+ float vibrationFrequency = GetNumber("F", lastReceivedUDPPacket);
+ float yaw = GetNumber("Y", lastReceivedUDPPacket);
+ float pitch = GetNumber("P", lastReceivedUDPPacket);
+ float roll = GetNumber("R", lastReceivedUDPPacket);
+ float heave = GetNumber("H", lastReceivedUDPPacket);
+ float sway = GetNumber("W", lastReceivedUDPPacket);
+ float surge = GetNumber("U", lastReceivedUDPPacket);
+ float yawVel = GetNumber("A", lastReceivedUDPPacket);
+ float pitchVel = GetNumber("I", lastReceivedUDPPacket);
+ float rollVel = GetNumber("O", lastReceivedUDPPacket);
+ float rideIndex = GetInt("N", lastReceivedUDPPacket);
+ float carIndex = GetInt("C", lastReceivedUDPPacket);
+ float gunIndex = GetInt("G", lastReceivedUDPPacket);
+ string rideName = ((RideType)rideIndex).ToString();
+ string carName = ((CartType)carIndex).ToString();
+ string gunName = ((GunType)gunIndex).ToString();
+ Console.WriteLine(">> Speed: {0}, Yaw: {1}, Pitch: {2}, Roll: {3}, Heave: {4}, Sway: {5}, Surge: {6}, YawVelocity: {7}, PitchVelocity: {8}, RollVelocity: {9}, RideName: {10}, CarName: {11}, GunName: {12}, VibrationIntensity: {13}, VibrationFrequency: {14}",
+ speed, yaw, pitch, roll, heave, sway, surge, yawVel, pitchVel, rollVel, rideName, carName, gunName, vibrationIntensity, vibrationFrequency);
- private static float ParseNumber(string prefix, string data)
+ private float GetNumber(string prefix, string data)
string numberRx = @"\-*\d{3}\.\d{3}";
string dataBlockRx = @"\[" + numberRx + @"\]";
+ private int GetInt(string prefix, string data)
+ string intRx = @"\-*\d{2}";
+ string dataBlockRx = @"\[" + intRx + @"\]";
+ string value = new Regex(prefix + dataBlockRx).Match(data).Value;
+ int number = int.Parse(new Regex(intRx).Match(value).Value, CultureInfo.InvariantCulture);