proto.go 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package meter
  2. const (
  3. // 电表类型
  4. MeterAdw300 = "ADW300"
  5. MeterPmc350b = "PMC350B"
  6. // 上报平台协议
  7. PlatYcHj212 = "YC-HJ212"
  8. )
  9. var (
  10. meterProto = make([]string, 0) //电表协议列表
  11. platProto = make([]string, 0) //上报协议列表
  12. )
  13. // InitMeterProto 初始化电表协议列表和上报协议列表
  14. func InitMeterProto() {
  15. //在这里添加支持的电表协议列表
  16. meterProto = append(meterProto, MeterAdw300)
  17. meterProto = append(meterProto, MeterPmc350b)
  18. meterProto = append(meterProto, "TEST")
  19. //在这里添加支持的上报协议列表
  20. platProto = append(platProto, PlatYcHj212)
  21. }
  22. // GetMeterProtoList 获取电表协议列表
  23. func GetMeterProtoList() []string {
  24. return meterProto
  25. }
  26. // GetPlatProtoList 获取上报协议列表
  27. func GetPlatProtoList() []string {
  28. return platProto
  29. }
  30. func VerifyMeterProto(proto string) bool {
  31. if proto == "" {
  32. return false
  33. }
  34. for _, v := range meterProto {
  35. if proto == v {
  36. return true
  37. }
  38. }
  39. return false
  40. }