| | |
| | | return base.AddData(saveModel); |
| | | } |
| | | |
| | | //public WebResponseContent InsertProtocol_Line(int PLCid,string ChildCode,) |
| | | //public WebResponseContent InsertProtocol_Line(int PLCid, string ChildCode,decimal ProOffsetStart) |
| | | //{ |
| | | |
| | | // Type type = typeof(); |
| | | //} |
| | | |
| | | |
| | | // 封装检查逻辑 |
| | | private bool DeviceProtocolExists(int DeviceID, string DeviceChildCode, decimal DeviceProOffset) |
| | | { |
| | | return BaseDal.QueryFirst(x => x.DeviceId == DeviceID && x.DeviceChildCode == DeviceChildCode && x.DeviceProOffset == DeviceProOffset) != null; |
| | | } |
| | | |
| | | // 封装对象创建逻辑 |
| | | private Dt_DeviceProtocol CreateDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset, int additionalOffset, string dataType, int dataLength, string paramName) |
| | | { |
| | | decimal DeviceProOffsets = DeviceProOffset + additionalOffset; |
| | | return new Dt_DeviceProtocol |
| | | { |
| | | DeviceId = DeviceID, |
| | | DeviceChildCode = DeviceChildCode, |
| | | DeviceProDataBlock = "DB1000", |
| | | DeviceProOffset = DeviceProOffsets, |
| | | DeviceProDataLength = dataLength, |
| | | DeviceProDataType = dataType, |
| | | DeviceProParamName = paramName, |
| | | DeviceProParamType = "DeviceCommand", |
| | | DeviceProParamDes = "1", |
| | | DeviceProRemark = "", |
| | | Creater = "admin", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | } |
| | | |
| | | public WebResponseContent AddDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (DeviceProtocolExists(DeviceID, DeviceChildCode, DeviceProOffset)) |
| | | { |
| | | throw new InvalidOperationException("已存在该节点明细"); |
| | | } |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 0, "int", 1, "ConveyorLineTargetAddress"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 2, "int", 1, "ConveyorLineTaskNum"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 6, "string", 25, "ConveyorLineBarcode"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 34, "int", 1, "Reserve1"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 36, "int", 1, "Reserve2"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 38, "int", 1, "Reserve3"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 40, "byte", 1, "InteractiveSignal"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 42, "int", 1, "HasPallet"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 44, "int", 1, "ConveyorLineAlarm"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 46, "int", 1, "ResponState"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 48, "int", 1, "Reserve5") |
| | | |
| | | }; |
| | | var result=BaseDal.AddData(protocols); |
| | | return content.OK(data:result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |