Accumulator.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 Accumulator
  25. {
  26. List<AccumulatedField> accumulatedFields;
  27. public Accumulator()
  28. {
  29. accumulatedFields = new List<AccumulatedField>();
  30. }
  31. public void Set(int mesgNum, int destFieldNum, long value)
  32. {
  33. AccumulatedField accumField = null;
  34. int i;
  35. for (i = 0; i < accumulatedFields.Count; i++)
  36. {
  37. accumField = accumulatedFields[i];
  38. if ((accumField.mesgNum == mesgNum) && (accumField.destFieldNum == destFieldNum))
  39. break;
  40. }
  41. if (i == accumulatedFields.Count)
  42. {
  43. accumField = new AccumulatedField(mesgNum, destFieldNum);
  44. accumulatedFields.Add(accumField);
  45. }
  46. accumField.Set(value);
  47. }
  48. public long Accumulate(int mesgNum, int destFieldNum, long value, int bits)
  49. {
  50. AccumulatedField accumField = null;
  51. int i;
  52. for (i = 0; i < accumulatedFields.Count; i++)
  53. {
  54. accumField = accumulatedFields[i];
  55. if ((accumField.mesgNum == mesgNum) && (accumField.destFieldNum == destFieldNum))
  56. break;
  57. }
  58. if (i == accumulatedFields.Count)
  59. {
  60. accumField = new AccumulatedField(mesgNum, destFieldNum);
  61. accumulatedFields.Add(accumField);
  62. }
  63. return accumField.Accumulate(value, bits);
  64. }
  65. }
  66. }