AccumulatedField.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #region Copyright
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // The following FIT Protocol software provided may be used with FIT protocol
  4. // devices only and remains the copyrighted property of Dynastream Innovations Inc.
  5. // The software is being provided on an "as-is" basis and as an accommodation,
  6. // and therefore all warranties, representations, or guarantees of any kind
  7. // (whether express, implied or statutory) including, without limitation,
  8. // warranties of merchantability, non-infringement, or fitness for a particular
  9. // purpose, are specifically disclaimed.
  10. //
  11. // Copyright 2016 Dynastream Innovations Inc.
  12. ////////////////////////////////////////////////////////////////////////////////
  13. // ****WARNING**** This file is auto-generated! Do NOT edit this file.
  14. // Profile Version = 16.60Release
  15. // Tag = production-akw-16.60.00-0-g5d3d436
  16. ////////////////////////////////////////////////////////////////////////////////
  17. #endregion
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. namespace Dynastream.Fit
  23. {
  24. public class AccumulatedField
  25. {
  26. public int mesgNum;
  27. public int destFieldNum;
  28. private long lastValue;
  29. private long accumulatedValue;
  30. public AccumulatedField(int mesgNum, int destFieldNum)
  31. {
  32. this.mesgNum = mesgNum;
  33. this.destFieldNum = destFieldNum;
  34. this.lastValue = 0;
  35. this.accumulatedValue = 0;
  36. }
  37. public long Accumulate(long value, int bits)
  38. {
  39. long mask = (1L << bits) - 1;
  40. accumulatedValue += (value - lastValue) & mask;
  41. lastValue = value;
  42. return accumulatedValue;
  43. }
  44. public long Set(long value)
  45. {
  46. accumulatedValue = value;
  47. this.lastValue = value;
  48. return accumulatedValue;
  49. }
  50. }
  51. }