123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #region Copyright
- #endregion
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Text;
- using System.IO;
- namespace Dynastream.Fit
- {
-
-
-
- internal class FieldComponent
- {
- #region Fields
- internal byte fieldNum;
- internal bool accumulate;
- internal int bits;
- internal double scale;
- internal double offset;
- internal long accumulatedValue = 0;
- internal long lastValue = 0;
- #endregion // Fields
- #region Properties
- #endregion // Properties
- #region Constructors
- internal FieldComponent(byte fieldNum, bool accumulate, int bits, double scale, double offset)
- {
- this.fieldNum = fieldNum;
- this.accumulate = accumulate;
- this.bits = bits;
- this.scale = scale;
- this.offset = offset;
- }
- internal FieldComponent(FieldComponent component)
- {
- this.fieldNum = component.fieldNum;
- this.accumulate = component.accumulate;
- this.bits = component.bits;
- this.scale = component.scale;
- this.offset = component.offset;
- this.accumulatedValue = component.accumulatedValue;
- this.lastValue = component.lastValue;
- }
- #endregion // Constructors
- #region Methods
- public long Accumulate(long value)
- {
- long mask = (1L << bits) - 1;
- accumulatedValue += (value - lastValue) & mask;
- lastValue = value;
- return accumulatedValue;
- }
- #endregion // Methods
- }
- }
|