ReadRegisters_Response.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace GasConcentrations_Yt95h.MessageEntity.Incoming
  5. {
  6. public class ReadRegisters_Response : MessageBase
  7. {
  8. private Dictionary<byte, string> unitMapper = new Dictionary<byte, string>();
  9. public ReadRegisters_Response()
  10. {
  11. unitMapper[0] = "PPM";
  12. unitMapper[1] = "PPB";
  13. unitMapper[2] = "%";
  14. unitMapper[3] = "%LEL";
  15. unitMapper[4] = "Mg/m3";
  16. unitMapper[5] = "℃";
  17. unitMapper[6] = "RH%";
  18. unitMapper[7] = "Kpa";
  19. }
  20. public int DataNumber
  21. {
  22. get
  23. {
  24. return RawDataField.First();
  25. }
  26. }
  27. public float Concentration
  28. {
  29. get
  30. {
  31. return BitConverter.ToSingle(RawDataField.GetRange(1, 4).ToArray(), 0);
  32. }
  33. }
  34. public GasTypeEnum GasType
  35. {
  36. get
  37. {
  38. return (GasTypeEnum)RawDataField[5];
  39. }
  40. }
  41. public string Unit
  42. {
  43. get
  44. {
  45. return unitMapper[RawDataField[6]];
  46. }
  47. }
  48. public AlarmTypeEnum AlarmType
  49. {
  50. get
  51. {
  52. return (AlarmTypeEnum)RawDataField[7];
  53. }
  54. }
  55. public override string ToLogString()
  56. {
  57. return base.ToLogString();
  58. }
  59. }
  60. public enum GasTypeEnum : byte
  61. {
  62. //可燃气体
  63. FuelGas = 7
  64. }
  65. public enum AlarmTypeEnum : byte
  66. {
  67. Normal = 1,
  68. LowAlarm = 2,
  69. HighAlarm = 3
  70. }
  71. }