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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| package nsq
|
| import (
| "apsClient/conf"
| "apsClient/constvar"
| "apsClient/model/common"
| "apsClient/pkg/logx"
| "apsClient/pkg/safe"
| "errors"
| "fmt"
| "time"
| )
|
| func Init() error {
| if len(conf.Conf.NsqConf.NodeId) <= 0 {
| return errors.New("no NodeId")
| }
|
| if err := initProducer(); err != nil {
| return err
| }
|
| safe.Go(func() {
| caller := NewCaller(fmt.Sprintf(constvar.NsqTopicGetPlcAddress, conf.Conf.NsqConf.NodeId), fmt.Sprintf(constvar.NsqTopicSendPlcAddress, conf.Conf.NsqConf.NodeId))
| var addressResult common.ResponsePlcAddress
| err := caller.Call(common.RequestPlcAddress{DeviceId: conf.Conf.System.DeviceId}, &addressResult, time.Second*2)
| if err != nil {
| logx.Infof("SendParams2 err: %v", err.Error())
| }
| })
|
| safe.Go(func() {
| _ = Consume(fmt.Sprintf(constvar.NsqTopicScheduleTask, conf.Conf.NsqConf.NodeId), conf.Conf.System.DeviceId)
| })
|
| safe.Go(func() {
| _ = Consume(fmt.Sprintf(constvar.NsqTopicSendPlcAddress, conf.Conf.NsqConf.NodeId), conf.Conf.System.DeviceId)
| })
|
| safe.Go(func() {
| _ = Consume(fmt.Sprintf(constvar.NsqTopicProcessParamsResponse, conf.Conf.NsqConf.NodeId), conf.Conf.System.DeviceId)
| })
|
| return nil
| }
|
|