internal static ReadCoilsInputsResponse ReadDiscretes(ReadCoilsInputsRequest request, DataStore dataStore, ModbusDataCollection<bool> dataSource) { DiscreteCollection data = DataStore.ReadData<DiscreteCollection, bool>(dataStore, dataSource, request.StartAddress, request.NumberOfPoints, dataStore.SyncRoot); var response = new ReadCoilsInputsResponse(request.FunctionCode, request.SlaveAddress, data.ByteCount, data); return response; }
internal Task <bool[]> PerformReadDiscretesAsync(ReadCoilsInputsRequest request) { return(Task.Factory.StartNew(() => PerformReadDiscretes(request))); }
internal bool[] PerformReadDiscretes(ReadCoilsInputsRequest request) { ReadCoilsInputsResponse response = Transport.UnicastMessage <ReadCoilsInputsResponse>(request); return(response.Data.Take(request.NumberOfPoints).ToArray()); }
public void ToString_ReadInputsRequest() { ReadCoilsInputsRequest request = new ReadCoilsInputsRequest(Modbus.ReadInputs, 5, 1, 10); Assert.Equal("Read 10 inputs starting at address 1.", request.ToString()); }
public void CalculateLrc() { ReadCoilsInputsRequest request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 10); Assert.AreEqual(243, ModbusUtility.CalculateLrc(new byte[] { 1, 1, 0, 1, 0, 10 })); }
public void CreateReadCoilsInputsRequestMaxSize() { ReadCoilsInputsRequest response = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 2, Modbus.MaximumDiscreteRequestResponseSize); Assert.AreEqual(Modbus.MaximumDiscreteRequestResponseSize, response.NumberOfPoints); }
private bool[] PerformReadDiscretesAsync(ReadCoilsInputsRequest request) { var response = Transport.UnicastMessageAsync <ReadCoilsInputsResponse>(request); return(response.Data.Take(request.NumberOfPoints).ToArray()); }
private Task <bool[]> PerformReadDiscretesAsync(ReadCoilsInputsRequest request) => Task.Factory.StartNew(() => PerformReadDiscretes(request));