public void CreateWriteMultipleRegistersResponse()
 {
     WriteMultipleRegistersResponse response = new WriteMultipleRegistersResponse(12, 39, 2);
     Assert.AreEqual(Modbus.WriteMultipleRegisters, response.FunctionCode);
     Assert.AreEqual(12, response.SlaveAddress);
     Assert.AreEqual(39, response.StartAddress);
     Assert.AreEqual(2, response.NumberOfPoints);
 }
        public void ToString_Test()
        {
            var response = new WriteMultipleRegistersResponse(1, 2, 3);

            Assert.AreEqual("Wrote 3 holding registers starting at address 2.", response.ToString());
        }
 public void CreateWriteMultipleRegistersResponseMaxSize()
 {
     WriteMultipleRegistersResponse response = new WriteMultipleRegistersResponse(1, 2, Modbus.MaximumRegisterRequestResponseSize);
     Assert.AreEqual(Modbus.MaximumRegisterRequestResponseSize, response.NumberOfPoints);
 }
 public void CreateModbusMessageWriteMultipleRegistersResponse()
 {
     WriteMultipleRegistersResponse response =
         ModbusMessageFactory.CreateModbusMessage<WriteMultipleRegistersResponse>(new byte[]
         {17, Modbus.WriteMultipleRegisters, 0, 1, 0, 2});
     WriteMultipleRegistersResponse expectedResponse = new WriteMultipleRegistersResponse(17, 1, 2);
     AssertModbusMessagePropertiesAreEqual(expectedResponse, response);
     Assert.AreEqual(expectedResponse.StartAddress, response.StartAddress);
     Assert.AreEqual(expectedResponse.NumberOfPoints, response.NumberOfPoints);
 }
Ejemplo n.º 5
0
 public void WriteMultipleRegisters()
 {
     ushort startAddress = 35;
     ushort[] valuesToWrite = new ushort[] { 1, 2, 3, 4, 5 };
     Assert.AreNotEqual(valuesToWrite, _testDataStore.HoldingRegisters.Slice(startAddress - 1, valuesToWrite.Length).ToArray());
     WriteMultipleRegistersResponse expectedResponse = new WriteMultipleRegistersResponse (1, startAddress, (ushort) valuesToWrite.Length);
     WriteMultipleRegistersResponse response = ModbusSlave.WriteMultipleRegisters(new WriteMultipleRegistersRequest(1, startAddress, new RegisterCollection(valuesToWrite)), _testDataStore, _testDataStore.HoldingRegisters);
     AssertModbusMessagePropertiesAreEqual(expectedResponse, response);
 }
Ejemplo n.º 6
0
        internal static WriteMultipleRegistersResponse WriteMultipleRegisters(WriteMultipleRegistersRequest request, ModbusDataCollection<ushort> dataSource)
        {
            DataStore.WriteData(request.Data, dataSource, request.StartAddress);
            WriteMultipleRegistersResponse response = new WriteMultipleRegistersResponse(request.SlaveAddress, request.StartAddress, request.NumberOfPoints);

            return response;
        }