void OnNewReceiveUdpServerEvent(object sender, NewEventReceiveUDPServerArgs e) { try { _sensorCalibration.Push(e.ReceiveUDPServerMessage); GyroQuaternion gyroQuaternionInverse = GyroQuaternion.Inverse(e.ReceiveUDPServerMessage); GyroQuaternion gyroQuaternionCalibrationResult = _sensorCalibration.GetCalibrationResult(e.ReceiveUDPServerMessage.sensorName); if (gyroQuaternionCalibrationResult != null) { GyroQuaternion gyroQuaternion = GyroQuaternion.Multiply(gyroQuaternionInverse, gyroQuaternionCalibrationResult); gyroQuaternion = GetSettingsAxis(gyroQuaternion); if (_senderUdpClient.UdpSocket != null && _senderUdpClient.UdpSocket.Connected) { _senderUdpClient.Send(gyroQuaternion); } if (e.ReceiveUDPServerMessage.sensorName == GetSelectorSensorValue()) { gyroQuaternion = _filterQuaternion.Filter(gyroQuaternion); Cube3DRender(gyroQuaternion); } } } catch (Exception) { // ignored } }
public void InvokeOnNewReceiveUDPServer(GyroQuaternion quat) { NewReceiveUDPServer handler = OnNewReceiveUDPServer; NewEventReceiveUDPServerArgs e = new NewEventReceiveUDPServerArgs(quat); handler?.Invoke(this, e); }