| | |
| | | |
| | | var processModelNumber string |
| | | plcConfig, code := service.NewDevicePlcService().GetDevicePlc() |
| | | if code == ecode.OK && plcConfig.ID != 0 { |
| | | if code == ecode.OK && plcConfig.ID != 0 && len(plcConfig.Details) > 0 { |
| | | plcConfig.MaxTryTimes = 2 |
| | | device, err := service.GetCurrentDevice() |
| | | if err != nil { |
| | |
| | | } |
| | | |
| | | func (slf *DevicePlc) AfterFind(tx *gorm.DB) error { |
| | | if slf.Detail != "" { |
| | | details := make([]*DevicePlcAddress, 0) |
| | | err := json.Unmarshal([]byte(slf.Detail), &details) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.Details = details |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | |
| | | RedisErr = 2003 // redis错误 |
| | | ParamsErr = 2004 // 请求参数错误 |
| | | NeedConfirmedErr = 2005 // 需要弹窗确认的错误 |
| | | PlcAddressError = 2006 //缺失加工数和目标数地址配置 |
| | | ) |
| | |
| | | DBErr: "数据库连接失败,请检查数据库配置!", |
| | | RedisErr: "redis错误", |
| | | ParamsErr: "请求参数错误", |
| | | PlcAddressError: "缺失加工数和目标数地址配置", |
| | | } |
| | | |
| | | func GetMsg(errCode int) (errMsg string) { |
| | |
| | | } |
| | | |
| | | func (slf DevicePlcService) GetDevicePlc() (*model.DevicePlc, int) { |
| | | DevicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() |
| | | devicePlc, err := model.NewDevicePlcSearch().SetDeviceId(conf.Conf.CurrentDeviceID).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | logx.Errorf("GetDevicePlc failed:%v", err) |
| | | return &model.DevicePlc{ |
| | |
| | | logx.Errorf("GetDevicePlc failed:%v", err) |
| | | return nil, ecode.DBErr |
| | | } |
| | | if len(devicePlc.Details) == 0 { |
| | | return nil, ecode.PlcAddressError |
| | | } |
| | | |
| | | return DevicePlc, ecode.OK |
| | | return devicePlc, ecode.OK |
| | | } |
| | | |
| | | func (slf DevicePlcService) GetDeviceChannelAmount() (int, error) { |