FieldComponent.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.Diagnostics;
  21. using System.Text;
  22. using System.IO;
  23. namespace Dynastream.Fit
  24. {
  25. /// <summary>
  26. ///
  27. /// </summary>
  28. internal class FieldComponent
  29. {
  30. #region Fields
  31. internal byte fieldNum;
  32. internal bool accumulate;
  33. internal int bits;
  34. internal double scale;
  35. internal double offset;
  36. internal long accumulatedValue = 0;
  37. internal long lastValue = 0;
  38. #endregion // Fields
  39. #region Properties
  40. #endregion // Properties
  41. #region Constructors
  42. internal FieldComponent(byte fieldNum, bool accumulate, int bits, double scale, double offset)
  43. {
  44. this.fieldNum = fieldNum;
  45. this.accumulate = accumulate;
  46. this.bits = bits;
  47. this.scale = scale;
  48. this.offset = offset;
  49. }
  50. internal FieldComponent(FieldComponent component)
  51. {
  52. this.fieldNum = component.fieldNum;
  53. this.accumulate = component.accumulate;
  54. this.bits = component.bits;
  55. this.scale = component.scale;
  56. this.offset = component.offset;
  57. this.accumulatedValue = component.accumulatedValue;
  58. this.lastValue = component.lastValue;
  59. }
  60. #endregion // Constructors
  61. #region Methods
  62. public long Accumulate(long value)
  63. {
  64. long mask = (1L << bits) - 1;
  65. accumulatedValue += (value - lastValue) & mask;
  66. lastValue = value;
  67. return accumulatedValue;
  68. }
  69. #endregion // Methods
  70. } // Class
  71. } // namespace