| | |
| | | "apsClient/pkg/logx" |
| | | "apsClient/pkg/structx" |
| | | "encoding/json" |
| | | "errors" |
| | | "github.com/jinzhu/gorm" |
| | | ) |
| | | |
| | |
| | | func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) { |
| | | plcConfig, code := slf.GetDevicePlc() |
| | | if code != ecode.OK || plcConfig.ID == 0 { |
| | | logx.Errorf("GetDeviceChannelAmount failed:%v, code:%v", plcConfig, code) |
| | | return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!") |
| | | return 1, nil |
| | | } |
| | | if len(plcConfig.Details) == 0 { |
| | | logx.Errorf("GetDeviceChannelAmount failed, addressList == 0, %+v", plcConfig) |
| | | return 0, errors.New("未获取到PLC地址,请在工艺模型库中上传!") |
| | | return 1, nil |
| | | } |
| | | return len(plcConfig.Details) / 2, nil |
| | | } |