handler.go 920 B

123456789101112131415161718192021222324252627282930313233
  1. package iotProtocolHandler
  2. import (
  3. iotInterface "IotAdmin/iot/interface"
  4. iotProtocol "IotAdmin/iot/protocol"
  5. iotElProtocol "IotAdmin/iot/protocol/collect"
  6. iotReportProtocol "IotAdmin/iot/protocol/report"
  7. "errors"
  8. )
  9. // GetMeterHandler 获取表计协议处理器
  10. func GetMeterHandler(protocol string) (handler iotInterface.MeterHandler, err error) {
  11. switch protocol {
  12. case iotProtocol.MeterElAdw300:
  13. handler = iotElProtocol.NewAdw300MeterHandler()
  14. case iotProtocol.MeterElPmc350b:
  15. handler = iotElProtocol.NewPmc350bMeterHandler()
  16. default:
  17. err = errors.New("not support protocol")
  18. }
  19. return
  20. }
  21. // GetReportHandler 获取上报协议处理器
  22. func GetReportHandler(protocol string) (handler iotInterface.ReportHandler, err error) {
  23. switch protocol {
  24. case iotProtocol.PlatElHj212:
  25. handler = iotReportProtocol.NewElHj212ReportHandler()
  26. default:
  27. err = errors.New("not support protocol")
  28. }
  29. return
  30. }