ReadUnit_Response.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace PressureGage_3051.MessageEntity.Incoming
  5. {
  6. public class ReadUnit_Response : MessageBase
  7. {
  8. private Dictionary<byte, string> unitMapper = new Dictionary<byte, string>();
  9. private Dictionary<byte, string> rangeMapper = new Dictionary<byte, string>();
  10. public ReadUnit_Response()
  11. {
  12. unitMapper[11] = "Pa";
  13. unitMapper[12] = "KPa";
  14. unitMapper[237] = "MPa";
  15. rangeMapper[0] = "1KPa";
  16. rangeMapper[1] = "6KPa";
  17. rangeMapper[2] = "40KPa";
  18. }
  19. public int DataNumber
  20. {
  21. get
  22. {
  23. return RawDataField.First();
  24. }
  25. }
  26. public string PressureUnit
  27. {
  28. get
  29. {
  30. return unitMapper[RawDataField[2]];
  31. }
  32. }
  33. public string StaticPressureUnit
  34. {
  35. get
  36. {
  37. return unitMapper[RawDataField[4]];
  38. }
  39. }
  40. public DeviceTypeEnum DeviceType
  41. {
  42. get
  43. {
  44. return (DeviceTypeEnum)RawDataField[6];
  45. }
  46. }
  47. public SensorTypeEnum SensorType
  48. {
  49. get
  50. {
  51. return (SensorTypeEnum)RawDataField[8];
  52. }
  53. }
  54. public string MeasuringRange
  55. {
  56. get
  57. {
  58. return rangeMapper[RawDataField[10]];
  59. }
  60. }
  61. public override string ToLogString()
  62. {
  63. return base.ToLogString();
  64. }
  65. }
  66. public enum DeviceTypeEnum : byte
  67. {
  68. Pressure = 0,
  69. Temperature = 1,
  70. Flow = 2
  71. }
  72. public enum SensorTypeEnum : byte
  73. {
  74. DifferentialPressure = 0,
  75. GaugePressure = 3,
  76. AbsolutPressure = 6
  77. }
  78. }