| | |
| | | //saveModel.MainData[""] |
| | | return base.AddData(saveModel); |
| | | } |
| | | |
| | | //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, string DeviceProDataBlock, string DeviceProParamType) |
| | | { |
| | | decimal DeviceProOffsets = DeviceProOffset + additionalOffset; |
| | | return new Dt_DeviceProtocol |
| | | { |
| | | DeviceId = DeviceID, |
| | | DeviceChildCode = DeviceChildCode, |
| | | DeviceProDataBlock = DeviceProDataBlock, |
| | | DeviceProOffset = DeviceProOffsets, |
| | | DeviceProDataLength = dataLength, |
| | | DeviceProDataType = dataType, |
| | | DeviceProParamName = paramName, |
| | | DeviceProParamType = DeviceProParamType, |
| | | DeviceProParamDes = "1", |
| | | DeviceProRemark = "", |
| | | Creater = "admin", |
| | | CreateDate = DateTime.Now, |
| | | }; |
| | | } |
| | | |
| | | public WebResponseContent AddAfterDeviceProtocol(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","DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 2, "int", 1, "ConveyorLineTaskNum", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 6, "string", 25, "ConveyorLineBarcode", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 34, "int", 1, "Reserve1", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 36, "int", 1, "Reserve2", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 38, "int", 1, "Reserve3", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 40, "byte", 1, "InteractiveSignal", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 42, "int", 1, "HasPallet", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 44, "int", 1, "ConveyorLineAlarm", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 46, "int", 1, "ResponState", "DB1000", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffset, 48, "int", 1, "Reserve5", "DB1000", "DeviceCommand") |
| | | |
| | | }; |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | public WebResponseContent AddBeforeDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead, decimal DeviceProOffsetWrite) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (DeviceProtocolExists(DeviceID, DeviceChildCode, DeviceProOffsetRead)) |
| | | { |
| | | throw new InvalidOperationException("已存在该节点明细"); |
| | | } |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 0, "int", 1, "InteractiveSignal","DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 2, "string", 25, "ConveyorLineBarcode", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 30, "dint", 1, "ConveyorLineTargetAddress", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 34, "dint", 1, "ConveyorLineTaskNum", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 38, "dint", 1, "ConveyorLineAlarm", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 0, "w", 1, "WriteInteractiveSignal", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 2, "string", 25, "WriteConveyorLineBarcode", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 30, "dint", 1, "WriteConveyorLineTargetAddress", "DB901", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 34, "dint", 1, "WriteConveyorLineTaskNum", "DB901", "DeviceCommand"), |
| | | |
| | | }; |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | public WebResponseContent AddBeforReadDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetRead) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (DeviceProtocolExists(DeviceID, DeviceChildCode, DeviceProOffsetRead)) |
| | | { |
| | | throw new InvalidOperationException("已存在该节点明细"); |
| | | } |
| | | |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 0, "int", 1, "InteractiveSignal","DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 2, "string", 25, "ConveyorLineBarcode", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 30, "dint", 1, "ConveyorLineTargetAddress", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 34, "dint", 1, "ConveyorLineTaskNum", "DB900", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 38, "dint", 1, "ConveyorLineAlarm", "DB900", "ReadDeviceCommand"), |
| | | }; |
| | | var result = BaseDal.AddData(protocols); |
| | | return content.OK(data: result); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |