report.go 763 B

12345678910111213141516171819202122232425262728293031
  1. package iotDownService
  2. import (
  3. iotLog "IotAdmin/iot/log"
  4. iotProtocolHandler "IotAdmin/iot/protocol/handler"
  5. iotStruct "IotAdmin/iot/struct"
  6. )
  7. func reportData(dataArray *[]*iotStruct.CollectData) {
  8. if dataArray == nil || len(*dataArray) == 0 {
  9. return
  10. }
  11. for _, data := range *dataArray {
  12. cfg := data.SlaveConfig
  13. if cfg == nil {
  14. continue
  15. }
  16. for _, rc := range *cfg.ReportConfig {
  17. reportHandler, err := iotProtocolHandler.GetReportHandler(rc.Protocol)
  18. if err != nil {
  19. data.Logger.Errorf("GetReportHandler error:%s", err)
  20. continue
  21. }
  22. go func(d *iotStruct.CollectData, cfg *iotStruct.ReportConfig) {
  23. reportHandler.Adapter(d)
  24. str := reportHandler.Report(d, cfg)
  25. go iotLog.LogData(d, cfg, str)
  26. }(data, &rc)
  27. }
  28. }
  29. }