/// <summary>
        /// Sets the phases.
        /// </summary>
        /// <param name="values">Values.</param>
        public void SetPhases(IEnumerable <SensorReading> records)
        {
            SensorReading prev         = records.First();
            var           currentPhase = new ShiftPhase
            {
                Axis    = Axis,
                Records = (new SensorReading[] { prev }).ToList()
            };

            for (int i = 1; i < records.Count(); i++)
            {
                SensorReading next = records.ElementAt(i);
                if (AreSameSign(prev, next, Axis))
                {
                    currentPhase.Records.Add(next);
                }
                else
                {
                    Phases.Add(currentPhase);
                    currentPhase = new ShiftPhase
                    {
                        Axis    = Axis,
                        Records = (new SensorReading[] { next }).ToList()
                    };
                }

                prev = next;
            }

            Phases.Add(currentPhase);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:BAT.Core.Common.SensorReading"/> class.
 /// </summary>
 /// <param name="oldReading">Old reading.</param>
 public SensorReading(SensorReading oldReading)
 {
     Time      = oldReading.Time;
     RecordNum = oldReading.RecordNum;
     Azimuth   = oldReading.Azimuth;
     Pitch     = oldReading.Pitch;
     Roll      = oldReading.Roll;
     AccelX    = oldReading.AccelX;
     AccelY    = oldReading.AccelY;
     AccelZ    = oldReading.AccelZ;
     Start     = oldReading.Start;
     End       = oldReading.End;
     Label     = (string.IsNullOrEmpty(oldReading.Label)
              ? InputFile.NoLabelProvided
              : oldReading.Label);
 }
        /// <summary>
        /// Checks to see if two decimal values are both pos. or both neg.
        /// </summary>
        /// <returns><c>true</c>, if same sign was same, <c>false</c> otherwise.</returns>
        /// <param name="first">first value to compare.</param>
        /// <param name="second">second value to compare.</param>
        bool AreSameSign(SensorReading first, SensorReading second, Constants.BAT.Axes axis)
        {
            switch (axis)
            {
            case Constants.BAT.Axes.X:
                return((first.AccelX < 0 && second.AccelX < 0) ||
                       (first.AccelX > 0 && second.AccelX > 0) ||
                       (first.AccelX == 0 && second.AccelX == 0));

            case Constants.BAT.Axes.Y:
                return((first.AccelY < 0 && second.AccelY < 0) ||
                       (first.AccelY > 0 && second.AccelY > 0) ||
                       (first.AccelY == 0 && second.AccelY == 0));

            default:
                return(false);
            }
        }