| | |
| | | "apsClient/router" |
| | | "apsClient/serf" |
| | | "apsClient/service" |
| | | "apsClient/service/plc_address" |
| | | "fmt" |
| | | "log" |
| | | "net/http" |
| | | _ "net/http/pprof" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | //加载plc写入地址 |
| | | plc_address.LoadAddressFromFile() |
| | | //plc_address.LoadAddressFromFile() |
| | | |
| | | // 启动数据同步 |
| | | var serfStartChan = make(chan bool) |
| | |
| | | var syncTables = []string{ |
| | | "procedures", |
| | | "process_model", |
| | | "production_progress", |
| | | "work_order", |
| | | "task_status_sync", |
| | | "device", |
| | | "device_plc", |
| | | "system_status", |
| | | "process_model_plc_address", |
| | | "reports_to_cloud", |
| | | "report_work", |
| | | } |
| | | |
| | | agent := serf.InitAgent("apsClient", syncTables, sqlitex.GetDB()) |
| | |
| | | return |
| | | } |
| | | |
| | | //从文件里读取当前生产设备id |
| | | conf.Conf.CurrentDeviceID = service.ReadDeviceIDFromFile() |
| | | if conf.Conf.CurrentDeviceID == "" { |
| | | conf.Conf.CurrentDeviceID = conf.Conf.System.DeviceId |
| | | //从文件里读取当前生产设备id获取设备列表第一个 |
| | | err := service.InitCurrentDeviceID(serf.Vasystem.ServerID) |
| | | if err != nil { |
| | | logx.Errorf("InitCurrentDeviceID error: %v, exit", err) |
| | | return |
| | | } |
| | | |
| | | go func() { |
| | | service.ReportsSystemDeviceToCloud(serf.Vasystem.ServerID) |
| | | }() |
| | | |
| | | // 判断当前集群状态 |
| | | logx.Infof("current agent.ClusterStatus:%v", agent.ClusterStatus) |
| | | log.Println("current agent.ClusterStatus:", agent.ClusterStatus) |