zhangzengfei
2023-08-04 88da1e13a073e8b5656387a246d827593fbd6163
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package msg
 
import (
    "encoding/json"
    "plc-recorder/util"
 
    "plc-recorder/config"
    "plc-recorder/logger"
    "plc-recorder/nsqclient"
)
 
func SendDeviceLiveData(response *PLCResponse) {
    logger.Debug("plc live data: %+v", response)
    b, _ := json.Marshal(response)
 
    // nsq 发布
    nsqclient.Produce(config.Options.PubPLCDataTopic, b)
 
    // aps 发布
    if config.Options.ApsPLCDataWebApi != "" {
        _, err := util.HttpPost(config.Options.ApsPLCDataWebApi, b)
        if err != nil {
            logger.Warn(err.Error())
        }
    }
}