1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #region Copyright
- #endregion
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Dynastream.Fit
- {
- public class AccumulatedField
- {
- public int mesgNum;
- public int destFieldNum;
- private long lastValue;
- private long accumulatedValue;
- public AccumulatedField(int mesgNum, int destFieldNum)
- {
- this.mesgNum = mesgNum;
- this.destFieldNum = destFieldNum;
- this.lastValue = 0;
- this.accumulatedValue = 0;
- }
- public long Accumulate(long value, int bits)
- {
- long mask = (1L << bits) - 1;
- accumulatedValue += (value - lastValue) & mask;
- lastValue = value;
- return accumulatedValue;
- }
- public long Set(long value)
- {
- accumulatedValue = value;
- this.lastValue = value;
- return accumulatedValue;
- }
- }
- }
|