Пример #1
0
        public void FillRequest(byte[] request, int offset)
        {
            FillResponse(request, offset, null);
            var bytes = ModbusHelper.EncodeBools(values);

            request[offset + 6] = (byte)bytes.Length;
            ModbusHelper.Copy(bytes, 0, request, offset + 7, bytes.Length);
        }
Пример #2
0
 public void EncodeBoolsTest()
 {
     Assert.AreEqual(by(), ModbusHelper.EncodeBools(bo()));
     Assert.AreEqual(by(0x01), ModbusHelper.EncodeBools(bo(true)));
     Assert.AreEqual(by(0x03), ModbusHelper.EncodeBools(bo(true, true)));
     Assert.AreEqual(by(0x13), ModbusHelper.EncodeBools(bo(true, true, false, false, true)));
     Assert.AreEqual(by(0x13, 0x05), ModbusHelper.EncodeBools(bo(true, true, false, false, true, false, false, false, true, false, true)));
 }
Пример #3
0
        public void FillResponse(byte[] response, int offset, object value)
        {
            var bytes = ModbusHelper.BytesForBools(Count);

            response[offset + 0] = Slave;
            response[offset + 1] = 2;
            response[offset + 2] = bytes;
            var data = ModbusHelper.EncodeBools(value as bool[]);

            ModbusHelper.Copy(data, 0, response, offset + 3, bytes);
        }