report.go 807 B

123456789101112131415161718192021222324252627282930313233
  1. package iotDownService
  2. import (
  3. iotLog "IotAdmin/iot/log"
  4. iotProtocol "IotAdmin/iot/protocol"
  5. iotElProtocol "IotAdmin/iot/protocol/electric"
  6. iotStruct "IotAdmin/iot/struct"
  7. )
  8. func reportData(dataArray *[]*iotStruct.CollectData) {
  9. if dataArray == nil || len(*dataArray) == 0 {
  10. return
  11. }
  12. var reportHandler iotProtocol.ReportHandler
  13. for _, data := range *dataArray {
  14. cfg := data.SlaveConfig
  15. if cfg == nil {
  16. continue
  17. }
  18. for _, rc := range *cfg.ReportConfig {
  19. switch rc.Protocol {
  20. case iotProtocol.PlatElHj212:
  21. reportHandler = iotElProtocol.NewElHj212ReportHandler()
  22. default:
  23. }
  24. go func(d *iotStruct.CollectData, cfg *iotStruct.ReportConfig) {
  25. reportHandler.Adapter(d)
  26. str := reportHandler.Report(d, cfg)
  27. go iotLog.LogData(d, cfg, str)
  28. }(data, &rc)
  29. }
  30. }
  31. }