| | |
| | | "apsClient/conf" |
| | | "apsClient/model" |
| | | "apsClient/pkg/logx" |
| | | "github.com/jinzhu/gorm" |
| | | "os" |
| | | "strings" |
| | | ) |
| | | |
| | | func GetDeviceIDList() (deviceIds []string, err error) { |
| | | devices, err := model.NewDeviceSearch().SetDeviceMac(conf.Conf.System.DeviceId).FindNotTotal() |
| | | if err == gorm.ErrRecordNotFound { |
| | | return nil, nil |
| | | } |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | |
| | | } |
| | | if len(deviceList) == 0 { |
| | | conf.Conf.CurrentDeviceID = conf.Conf.System.DeviceId |
| | | return nil |
| | | } else { |
| | | conf.Conf.CurrentDeviceID = deviceList[0] |
| | | } |
| | | conf.Conf.CurrentDeviceID = deviceList[0] |
| | | SetDeviceIDToFile(conf.Conf.CurrentDeviceID) |
| | | return nil |
| | | } |
| | |
| | | |
| | | func (slf *PlcConfig) Check() bool { |
| | | plcConfig, _ := service.NewDevicePlcService().GetDevicePlc() |
| | | if plcConfig == nil { |
| | | return false |
| | | } |
| | | if plcConfig.Method == "" { |
| | | return false |
| | | } |