| | |
| | | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/model/request" |
| | | _ "apsClient/model/response" |
| | |
| | | return |
| | | } |
| | | |
| | | if !params.Method.Valid() { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "接口方式不正确") |
| | | return |
| | | } |
| | | |
| | | if params.Method == constvar.PlcMethodModbusTCP && (params.Address == "" || params.Port == 0) { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "当接口方式为modbusTCP时,address和port不能为空") |
| | | return |
| | | } |
| | | if params.Method == constvar.PlcMethodSerial && (params.BaudRate == 0 || params.SerialName == "") { |
| | | ctx.FailWithMsg(ecode.ParamsErr, "当接口方式为serial时,baudRate和serialName不能为空") |
| | | return |
| | | } |
| | | |
| | | errCode := service.NewDevicePlcService().UpdateDevicePlc(¶ms) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |