예제 #1
0
        public void CoilsCode1TcpTest()
        {
            string    expected = "00-01-00-00-00-06-04-01-00-0A-00-0D";
            ReadCoils coils    = ReadCoils.Create(4, 1, 0, 10, 13);

            //Coils coils = new Coils(4, 1, 0, 1, 10, 13);
            byte[] msg    = coils.Encode();
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void CoilsCode1SerializeRtuTest()
        {
            string    expected = "04-01-00-0A-00-0D-DD-98";
            ReadCoils coils    = ReadCoils.Create(4, 10, 13);
            //Coils coils = new Coils(1, 4, 10, 13);
            string    jsonString = coils.Serialize();
            ReadCoils coils2     = JsonConvert.DeserializeObject <ReadCoils>(jsonString);

            //Coils coils2 = JsonConvert.DeserializeObject<Coils>(jsonString);
            byte[] msg    = coils2.Encode();
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }