public void MagnetometerData_Comparison( float x1, float y1, float z1, float x2, float y2, float z2, bool equals) { var data1 = new MagnetometerData(x1, y1, z1); var data2 = new MagnetometerData(x2, y2, z2); if (equals) { Assert.True(data1.Equals(data2)); Assert.True(data1 == data2); Assert.False(data1 != data2); Assert.Equal(data1, data2); Assert.Equal(data1.GetHashCode(), data2.GetHashCode()); } else { Assert.False(data1.Equals(data2)); Assert.False(data1 == data2); Assert.True(data1 != data2); Assert.NotEqual(data1, data2); Assert.NotEqual(data1.GetHashCode(), data2.GetHashCode()); } }
void DataUpdated(object sender, MagnetometerReadingChangedEventArgs e) { var reading = e.Reading; var data = new MagnetometerData(reading.MagneticFieldX, reading.MagneticFieldY, reading.MagneticFieldZ); RaiseReadingChanged(data); }
private void Magnetometer_ReadingChanged(object sender, MagnetometerChangedEventArgs e) { MagnetometerData reading = e.Reading; Vector3Data data = MagneticField; data.TimeStamp = DateTime.UtcNow; data.Value = reading.MagneticField; data.SendNotification(); }
void ISensorEventListener.OnSensorChanged(SensorEvent e) { if ((e?.Values?.Count ?? 0) < 3) { return; } var data = new MagnetometerData(e.Values[0], e.Values[1], e.Values[2]); Magnetometer.OnChanged(data); }
static void DataUpdated(CMMagnetometerData data, NSError error) { if (data == null) { return; } var field = data.MagneticField; var magnetometerData = new MagnetometerData(field.X, field.Y, field.Z); OnChanged(magnetometerData); }
void DataUpdated(CMMagnetometerData data, NSError error) { if (data == null) { return; } #pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619 var field = data.MagneticField; var magnetometerData = new MagnetometerData(field.X, field.Y, field.Z); #pragma warning restore CA1416 RaiseReadingChanged(magnetometerData); }
void ISensorEventListener.OnSensorChanged(SensorEvent?e) { var values = e?.Values ?? Array.Empty <float>(); if (values.Count < 3) { return; } var data = new MagnetometerData(values[0], values[1], values[2]); DataCallback?.Invoke(data); }
void RaiseReadingChanged(MagnetometerData data) { var args = new MagnetometerChangedEventArgs(data); if (UseSyncContext) { MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(this, args)); } else { ReadingChanged?.Invoke(this, args); } }
private void Magnometer_ReadingChanged(object sender, MagnetometerChangedEventArgs e) { this.MagnetometerData = e.Reading; }
internal MagnetometerChangedEventArgs(MagnetometerData reading) => Reading = reading;
internal static void OnChanged(MagnetometerData reading) => OnChanged(new MagnetometerChangedEventArgs(reading));
private void MagnetometerDataUpdated(object sender, MagnetometerDataUpdatedEventArgs args)
void ISensorEventListener.OnSensorChanged(SensorEvent e) { var data = new MagnetometerData(e.Values[0], e.Values[1], e.Values[2]); Magnetometer.OnChanged(data); }
public MagnetometerChangedEventArgs(MagnetometerData reading) =>
public SensorData(Vector3 v_accelerometer, Vector3 v_gyroscope, Vector3 v_magnetometer) { accelerometer = new AccelerometerData(v_accelerometer); gyroscope = v_gyroscope; magnetometer = new MagnetometerData(v_magnetometer, 0); }