register.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package protocol
  2. // 消息ID枚举
  3. type MsgID uint32
  4. //type DeviceAddress []byte
  5. const (
  6. ReadAddress MsgID = 0x93
  7. // 注册心跳
  8. Msgdlt_0x0040 MsgID = 0x0040
  9. //上传正向有功总电能
  10. Msgdlt_0x33333433 MsgID = 0x33333433
  11. //上传反向有功总电能
  12. Msgdlt_0x33333533 MsgID = 0x33333533
  13. //上传A电压
  14. Msgdlt_0x33343435 MsgID = 0x33343435
  15. //上传A电流
  16. Msgdlt_0x33343535 MsgID = 0x33343535
  17. //上传B电压
  18. Msgdlt_0x33353435 MsgID = 0x33353435
  19. //上传B电流
  20. Msgdlt_0x33353535 MsgID = 0x33353535
  21. //上传C电压
  22. Msgdlt_0x33363435 MsgID = 0x33363435
  23. //上传C电流
  24. Msgdlt_0x33363535 MsgID = 0x33363535
  25. //当前总有功功率
  26. Msgdlt_0x33333635 MsgID = 0x33333635
  27. //当前总无功功率
  28. Msgdlt_0x33333735 MsgID = 0x33333735
  29. //总功率因数
  30. Msgdlt_0x33333935 MsgID = 0x33333935
  31. //当前视在功率
  32. Msgdlt_0x33333835 MsgID = 0x33333835
  33. )
  34. // 消息实体映射
  35. var entityMapper = map[uint32]func() Entity{
  36. uint32(Msgdlt_0x0040): func() Entity {
  37. return new(Dlt_0x0040)
  38. },
  39. uint32(Msgdlt_0x33333433): func() Entity {
  40. return new(Dlt_0x33333433)
  41. },
  42. uint32(Msgdlt_0x33333533): func() Entity {
  43. return new(Dlt_0x33333533)
  44. },
  45. uint32(Msgdlt_0x33343435): func() Entity {
  46. return new(Dlt_0x33343435)
  47. },
  48. uint32(Msgdlt_0x33343535): func() Entity {
  49. return new(Dlt_0x33343535)
  50. },
  51. uint32(Msgdlt_0x33353435): func() Entity {
  52. return new(Dlt_0x33353435)
  53. },
  54. uint32(Msgdlt_0x33353535): func() Entity {
  55. return new(Dlt_0x33353535)
  56. },
  57. uint32(Msgdlt_0x33363435): func() Entity {
  58. return new(Dlt_0x33363435)
  59. },
  60. uint32(Msgdlt_0x33363535): func() Entity {
  61. return new(Dlt_0x33363535)
  62. },
  63. uint32(Msgdlt_0x33333635): func() Entity {
  64. return new(Dlt_0x33333635)
  65. },
  66. uint32(Msgdlt_0x33333735): func() Entity {
  67. return new(Dlt_0x33333735)
  68. },
  69. uint32(Msgdlt_0x33333935): func() Entity {
  70. return new(Dlt_0x33333935)
  71. },
  72. uint32(Msgdlt_0x33333835): func() Entity {
  73. return new(Dlt_0x33333835)
  74. },
  75. uint32(ReadAddress): func() Entity {
  76. return new(Dlt_0x93)
  77. },
  78. }
  79. // Register 类型注册
  80. func Register(typ uint32, creator func() Entity) {
  81. entityMapper[typ] = creator
  82. }