DipSensorMagHelper.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Wit.SDK.Modular.Sensor.Utils
  7. {
  8. /// <summary>
  9. /// 倾角传感器磁场帮助类
  10. /// </summary>
  11. public class DipSensorMagHelper
  12. {
  13. /// <summary>
  14. /// 磁场转换标准单位uT(微特)
  15. /// </summary>
  16. public static double GetMagToUt(short reg72, double regMag)
  17. {
  18. double dRet = regMag;
  19. switch (reg72)
  20. {
  21. case 2:
  22. dRet = dRet * 0.15;
  23. break;
  24. case 3:
  25. dRet = dRet * 13 / 1000.0;
  26. break;
  27. case 4:
  28. dRet = dRet * 0.058;
  29. break;
  30. case 5:
  31. dRet = dRet * 0.098;
  32. break;
  33. case 6:
  34. dRet = dRet / 120;
  35. break;
  36. case 7:
  37. dRet = dRet * 20 / 1000.0;
  38. break;
  39. }
  40. return Math.Round(dRet, 3);
  41. }
  42. /// <summary>
  43. /// 标准单位uT(微特)转换磁场数据
  44. /// </summary>
  45. public static double GetUtToMag(short reg72, double reguTMag)
  46. {
  47. double dRet = reguTMag;
  48. switch (reg72)
  49. {
  50. case 2:
  51. dRet = dRet / 0.15;
  52. break;
  53. case 3:
  54. dRet = dRet * 1000.0 / 13.0 ;
  55. break;
  56. case 4:
  57. dRet = dRet / 0.058;
  58. break;
  59. case 5:
  60. dRet = dRet / 0.098;
  61. break;
  62. case 6:
  63. dRet = dRet * 120;
  64. break;
  65. case 7:
  66. dRet = dRet * 1000.0 / 20.0 ;
  67. break;
  68. }
  69. return dRet;
  70. }
  71. }
  72. }