Example #1
0
        private void ParseAndAddData(string value)
        {
            if (!string.IsNullOrWhiteSpace(value))
            {
                DateTime timeStamp = DateTime.UtcNow;

                double[] xyz        = new double[3];
                string[] parsedData = value.Split(',');

                if (parsedData.Length != 3)
                {
                    return;
                }

                for (int i = 0; i < xyz.Length; i++)
                {
                    if (double.TryParse(parsedData[i], out double result))
                    {
                        xyz[i] = result;
                    }
                }

                var data = new AccelerometerReadingDto {
                    Timestamp = timeStamp,
                    X         = xyz[0],
                    Y         = xyz[1],
                    Z         = xyz[2],
                };

                AccelerometerChanged?.Invoke(new AccelerometerChangedEventArgs {
                    Data = data,
                });
            }
        }
Example #2
0
 /// <summary>Raises the accelerometer changed event.</summary>
 ///
 /// <remarks>Jordi Hutjens, 10-11-2018.</remarks>
 ///
 /// <param name="e">Event information to send to registered event handlers.</param>
 protected virtual void OnAccelerometerChanged(AccelerometerChangedEventArgs e)
 {
     AccelerometerChanged?.Invoke(this, e);
 }