Ejemplo n.º 1
0
        public void CoilsCode1ConvertToTcpTest()
        {
            string    expected = "00-01-00-00-00-06-04-01-00-0A-00-0D";
            ReadCoils coils    = ReadCoils.Create(4, 10, 13);

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

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void CoilsCode1RtuTest()
        {
            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);
            byte[] msg    = coils.Encode();
            string actual = System.BitConverter.ToString(msg);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
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);
        }