| | |
| | | |
| | | |
| | | [HttpPost, HttpPost,Route("AddCommonConveyorLineProtocol"), AllowAnonymous] |
| | | public WebResponseContent AddCommonConveyorLineProtocol(int DeviceId, string DeviceChildCode, decimal DeviceProOffset) |
| | | public WebResponseContent AddBeforeDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffsetWrite, decimal DeviceProOffsetRead) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceId, DeviceChildCode, DeviceProOffset, "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceId, DeviceChildCode, DeviceProOffset+8, "ReadDeviceCommand"), |
| | | }; |
| | | foreach (var deviceProtocol in protocols) |
| | | try |
| | | { |
| | | base.AddData(deviceProtocol); |
| | | var protocols = new List<Dt_DeviceProtocol> |
| | | { |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 0, "int", 1, "WriteConveyorLineTargetAddress","DB1101", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 2, "int", 1, "WriteConveyorLineTaskNum", "DB1101", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetWrite, 5, "byte", 1, "ConveyorLineCommand", "DB1101", "DeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 0, "int", 1, "InteractiveSignal", "DB1102", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 2, "int", 1, "ConveyorLineTaskNum", "DB1102", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 4, "dint", 1, "ConveyorLineTargetAddress", "DB1102", "ReadDeviceCommand"), |
| | | CreateDeviceProtocol(DeviceID, DeviceChildCode, DeviceProOffsetRead, 6, "dint", 1, "ConveyorLineAlarm", "DB1102", "ReadDeviceCommand"), |
| | | |
| | | }; |
| | | foreach (var deviceProtocol in protocols) |
| | | { |
| | | base.AddData(deviceProtocol); |
| | | } |
| | | return content.OK(); |
| | | } |
| | | return content.OK(); |
| | | catch (Exception ex) |
| | | { |
| | | return content.Error(ex.Message); |
| | | } |
| | | } |
| | | |
| | | private Dt_DeviceProtocol CreateDeviceProtocol(int DeviceID, string DeviceChildCode, decimal DeviceProOffset, string DeviceProParamType) |
| | | // 灏佽瀵硅薄鍒涘缓閫昏緫 |
| | | 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 = "DB50", |
| | | DeviceProOffset = DeviceProOffset, |
| | | DeviceProDataLength = 1, |
| | | DeviceProDataType = "int", |
| | | DeviceProParamName = "InteractiveSignal", |
| | | DeviceProDataBlock = DeviceProDataBlock, |
| | | DeviceProOffset = DeviceProOffsets, |
| | | DeviceProDataLength = dataLength, |
| | | DeviceProDataType = dataType, |
| | | DeviceProParamName = paramName, |
| | | DeviceProParamType = DeviceProParamType, |
| | | DeviceProParamDes = "1", |
| | | DeviceProRemark = "", |