/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> /// <returns>Task that completes when response from PLC is parsed.</returns> public async Task WriteAsync(params DataItem[] dataItems) { var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); await stream.WriteAsync(message.Array, 0, length).ConfigureAwait(false); var response = await COTP.TSDU.ReadAsync(stream).ConfigureAwait(false); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> /// <returns>Task that completes when response from PLC is parsed.</returns> public async Task WriteAsync(params DataItem[] dataItems) { AssertPduSizeForWrite(dataItems); var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); var response = await RequestTsduAsync(message.Array, 0, length).ConfigureAwait(false); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> public void Write(params DataItem[] dataItems) { var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); stream.Write(message.Array, 0, length); var response = COTP.TSDU.Read(stream); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> public void Write(params DataItem[] dataItems) { AssertPduSizeForWrite(dataItems); var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); var response = RequestTsdu(message.Array, 0, length); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> /// <returns>Task that completes when response from PLC is parsed.</returns> public async Task WriteAsync(params DataItem[] dataItems) { AssertPduSizeForWrite(dataItems); var stream = GetStreamIfAvailable(); var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); await stream.WriteAsync(message.Array, 0, length).ConfigureAwait(false); var response = await COTP.TSDU.ReadAsync(stream, CancellationToken.None).ConfigureAwait(false); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> public void Write(params DataItem[] dataItems) { AssertPduSizeForWrite(dataItems); var stream = GetStreamIfAvailable(); var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); stream.Write(message.Array, 0, length); var response = COTP.TSDU.Read(stream); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); }
/// <summary> /// Write DataItem(s) to the PLC. Throws an exception if the response is invalid /// or when the PLC reports errors for item(s) written. /// </summary> /// <param name="dataItems">The DataItem(s) to write to the PLC.</param> public void Write(params DataItem[] dataItems) { AssertPduSizeForWrite(dataItems); var message = new ByteArray(); var length = S7WriteMultiple.CreateRequest(message, dataItems); lock (streamLock) { stream.Write(message.Array, 0, length); message.Clear(); message = null; var response = COTP.TSDU.Read(stream); S7WriteMultiple.ParseResponse(response, response.Length, dataItems); } }