往plc写目标数时,优先往写入地址写,没有写入地址再往读取地址写
| | |
| | | processModelNumber = processModel.Number |
| | | } |
| | | |
| | | fieldType := constvar.PlcStartAddressTypeTotalNumber |
| | | for _, pc := range plcConfig.Details { //如果有写入地址,优先往写入地址写入,没有的话往读取地址写入 |
| | | if pc.FieldName == constvar.PlcStartAddressTypeTotalNumberWrite && pc.Channel == procedure.Channel { |
| | | fieldType = constvar.PlcStartAddressTypeTotalNumberWrite |
| | | } |
| | | } |
| | | plcConfig.CurrentTryTimes = 0 |
| | | err = service.PlcWrite(plcConfig, constvar.PlcStartAddressTypeTotalNumber, procedure.Channel, order.Amount.IntPart()) |
| | | err = service.PlcWrite(plcConfig, fieldType, procedure.Channel, order.Amount.IntPart()) |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.NeedConfirmedErr, "PLC请求失败,请检查PLC配置!") |
| | | return |
| | |
| | | type PlcStartAddressType int |
| | | |
| | | const ( |
| | | PlcStartAddressTypeFinishNumber PlcStartAddressType = 1 |
| | | PlcStartAddressTypeTotalNumber PlcStartAddressType = 2 |
| | | PlcStartAddressTypeFinishNumber PlcStartAddressType = 1 |
| | | PlcStartAddressTypeTotalNumber PlcStartAddressType = 2 |
| | | PlcStartAddressTypeTotalNumberWrite PlcStartAddressType = 3 |
| | | ) |
| | | |
| | | type PlcStartAddressValueType string |