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());
            }
        }
示例#2
0
        void DataUpdated(object sender, MagnetometerReadingChangedEventArgs e)
        {
            var reading = e.Reading;
            var data    = new MagnetometerData(reading.MagneticFieldX, reading.MagneticFieldY, reading.MagneticFieldZ);

            RaiseReadingChanged(data);
        }
示例#3
0
        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();
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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;
 }
示例#10
0
 internal MagnetometerChangedEventArgs(MagnetometerData reading) => Reading = reading;
示例#11
0
 internal static void OnChanged(MagnetometerData reading)
 => OnChanged(new MagnetometerChangedEventArgs(reading));
示例#12
0
 private void MagnetometerDataUpdated(object sender, MagnetometerData​Updated​Event​Args args)
        void ISensorEventListener.OnSensorChanged(SensorEvent e)
        {
            var data = new MagnetometerData(e.Values[0], e.Values[1], e.Values[2]);

            Magnetometer.OnChanged(data);
        }
示例#14
0
 public MagnetometerChangedEventArgs(MagnetometerData reading) =>
示例#15
0
 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);
 }