示例#1
0
        public void ReadHoldingRegistersConvertToTcpTest()
        {
            string expected = "00-03-00-00-00-06-01-03-00-00-00-02";
            ReadHoldingRegisters registers = ReadHoldingRegisters.Create(1, 0, 2);

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

            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void ReadHoldingRegistersRtuTest()
        {
            string expected = "01-03-00-00-00-02-C4-0B";
            ReadHoldingRegisters registers = ReadHoldingRegisters.Create(1, 0, 2);

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

            Assert.AreEqual(expected, actual);
        }
示例#3
0
        public void ReadHoldingRegistersSerializeTcpTest()
        {
            string expected = "00-03-00-00-00-06-01-03-00-00-00-02";
            ReadHoldingRegisters registers = ReadHoldingRegisters.Create(1, 3, 0, 0, 2);
            string jsonString = registers.Serialize();
            ReadHoldingRegisters registers2 = JsonConvert.DeserializeObject <ReadHoldingRegisters>(jsonString);

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

            Assert.AreEqual(expected, actual);
        }