Ejemplo n.º 1
0
        public void WriteMultipleCoilsConvertToTcpTest()
        {
            string             expected = "00-19-00-00-00-09-01-0F-00-13-00-0A-02-CD-01";
            BitArray           array    = new BitArray(new bool[] { true, false, true, true, false, false, true, true, true, false });
            WriteMultipleCoils coils    = WriteMultipleCoils.Create(17, 19, array);

            byte[] msg    = coils.ConvertToTcp(1, 25, 0);
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void WriteMultipleCoilsSerializeTcpTest()
        {
            string             expected   = "00-19-00-00-00-09-01-0F-00-13-00-0A-02-CD-01";
            BitArray           array      = new BitArray(new bool[] { true, false, true, true, false, false, true, true, true, false });
            WriteMultipleCoils coils      = WriteMultipleCoils.Create(1, 25, 0, 19, array);
            string             jsonString = coils.Serialize();
            WriteMultipleCoils coil2      = JsonConvert.DeserializeObject <WriteMultipleCoils>(jsonString);

            byte[] msg    = coil2.Encode();
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }