register.go 1.9 KB

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