| | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/pkg/sqlitex" |
| | | "apsClient/service" |
| | | "apsClient/service/plc_address" |
| | | "fmt" |
| | | "net" |
| | | "sync" |
| | | ) |
| | | |
| | |
| | | constvar.ProblemCodeNetwork, |
| | | constvar.ProblemCodeDB, |
| | | constvar.ProblemCodeSerf, |
| | | constvar.ProblemCodeNsq, |
| | | constvar.ProblemCodeCloud, |
| | | constvar.ProblemCodeDevice, |
| | | constvar.ProblemCodeProcessModel, |
| | | constvar.ProblemCodePlcConfig, |
| | | constvar.ProblemCodePlcAddressList, |
| | | constvar.ProblemCodePlcProcessModelAddressList, |
| | |
| | | constvar.ProblemCodeNetwork: "网络连接", |
| | | constvar.ProblemCodeDB: "数据库", |
| | | constvar.ProblemCodeSerf: "serf集群", |
| | | constvar.ProblemCodeNsq: "消息队列", |
| | | constvar.ProblemCodeCloud: "消息队列", |
| | | constvar.ProblemCodeDevice: "生产设备绑定", |
| | | constvar.ProblemCodeProcessModel: "工艺参数", |
| | | constvar.ProblemCodePlcConfig: "plc配置", |
| | | constvar.ProblemCodePlcAddressList: "plc地址表", |
| | | constvar.ProblemCodePlcProcessModelAddressList: "plc工艺参数地址表", |
| | |
| | | checkObj = &DB{} |
| | | case constvar.ProblemCodeSerf: |
| | | checkObj = &Serf{} |
| | | case constvar.ProblemCodeNsq: |
| | | case constvar.ProblemCodeCloud: |
| | | checkObj = &Nsq{} |
| | | case constvar.ProblemCodeDevice: |
| | | checkObj = &Device{} |
| | |
| | | checkObj = &PlcProcessModelAddressList{} |
| | | case constvar.ProblemCodePlcConnect: |
| | | checkObj = &PlcConnect{} |
| | | default: |
| | | continue |
| | | } |
| | | checkResultListTemp = append(checkResultListTemp, &CheckResult{ |
| | | ItemCode: item, |
| | |
| | | type Network struct{} |
| | | |
| | | func (slf *Network) Check() bool { |
| | | return false |
| | | ifaces, err := net.Interfaces() |
| | | if err != nil { |
| | | fmt.Println("Error:", err) |
| | | return false |
| | | } |
| | | var netAllFailed bool |
| | | for _, iFace := range ifaces { |
| | | if iFace.Flags == net.FlagUp { |
| | | netAllFailed = false |
| | | fmt.Printf("Interface %s is DOWN, indicating a network issue.\n", iFace.Name) |
| | | } |
| | | } |
| | | return !netAllFailed |
| | | } |
| | | |
| | | type DB struct{} |
| | |
| | | type Nsq struct{} |
| | | |
| | | func (slf *Nsq) Check() bool { |
| | | return false |
| | | old, err := model.NewSystemStatusSearch().SetKey(constvar.SystemStatusKeyNsq).First() |
| | | if err != nil { |
| | | return false |
| | | } |
| | | return old.Value == constvar.SystemStatusValueNormal |
| | | } |
| | | |
| | | type Device struct{} |
| | |
| | | |
| | | func (slf *PlcConfig) Check() bool { |
| | | plcConfig, _ := service.NewDevicePlcService().GetDevicePlc() |
| | | if plcConfig == nil { |
| | | return false |
| | | } |
| | | if plcConfig.Method == "" { |
| | | return false |
| | | } |
| | |
| | | |
| | | func (slf *PlcAddressList) Check() bool { |
| | | plcConfig, _ := service.NewDevicePlcService().GetDevicePlc() |
| | | return len(plcConfig.Details) > 0 |
| | | return plcConfig != nil && len(plcConfig.Details) > 0 |
| | | } |
| | | |
| | | type PlcProcessModelAddressList struct{} |
| | | |
| | | func (slf *PlcProcessModelAddressList) Check() bool { |
| | | return plc_address.IsLoad() |
| | | record, err := model.NewProcessModelPlcAddressSearch().SetDeviceID(conf.Conf.CurrentDeviceID).First() |
| | | if err != nil { |
| | | return false |
| | | } |
| | | if len(record.AddressList) == 0 { |
| | | return false |
| | | } |
| | | return true |
| | | } |
| | | |
| | | type PlcConnect struct{} |