public void WriteBoolTest()
        {
            var comPort         = Substitute.For <IComPort>();
            var protocolFinsTcp = new PlcOmronFins(comPort, 0);
            var excepted        = new byte[] {
                0x46, 0x49, 0x4E, 0x53,
                0x00, 0x00, 0x00, 0x1B,
                0x00, 0x00, 0x00, 0x02,
                0x00, 0x00, 0x00, 0x00,
                0x80, 0x00, 0x02,
                0x00, 0x00, 0x00,
                0x00, 0x00, 0x00,
                0x00,
                0x01, 0x02,
                0x02,
                0x00, 0x64, 0x01,
                0x00, 0x01,
                0x00
            };

            try
            {
                protocolFinsTcp.Write(new DataAddress()
                {
                    Value  = "D100",
                    Type   = DataAddressType.Boolean,
                    Offset = 1
                }, new bool[] { false });
            }
            catch
            {
            }

            comPort.Received().Write(Arg.Is <byte[]>(e => !e.Except(excepted).Any() && !excepted.Except(e).Any()), 0, excepted.Length);
        }
        public void ConnectTest()
        {
            var comPort1 = new TcpClientComPort(new TcpClientComPortConfigInfo()
            {
                LocalIPAddress  = "192.168.88.1",
                LocalPort       = 8001,
                RemoteIPAddress = "192.168.88.120",
                RemotePort      = 9600,
                ReceiveTimeout  = 500,
                SendTimeout     = 500
            });
            var protocolFinsTcp1 = new PlcOmronFins(comPort1, 0);
            var comPort2         = new TcpClientComPort(new TcpClientComPortConfigInfo()
            {
                LocalIPAddress  = "192.168.88.2",
                LocalPort       = 8002,
                RemoteIPAddress = "192.168.88.120",
                RemotePort      = 9600,
                ReceiveTimeout  = 500,
                SendTimeout     = 500
            });
            var protocolFinsTcp2 = new PlcOmronFins(comPort2, 0);

            comPort1.Open();
            comPort2.Open();

            protocolFinsTcp1.Initialize();
            protocolFinsTcp2.Initialize();

            protocolFinsTcp1.Write <short>(new DataAddress()
            {
                Type   = DataAddressType.Short,
                Offset = 0,
                Value  = "D8816"
            }, new short[] { 2 });

            protocolFinsTcp2.Write <short>(new DataAddress()
            {
                Type   = DataAddressType.Short,
                Offset = 0,
                Value  = "D8816"
            }, new short[] { 3 });
        }
        public void WriteFloatTest()
        {
            var comPort         = Substitute.For <IComPort>();
            var protocolFinsTcp = new PlcOmronFins(comPort, 0);
            var excepted        = new byte[] {
                0x46, 0x49, 0x4E, 0x53,
                0x00, 0x00, 0x00, 0x1E,
                0x00, 0x00, 0x00, 0x02,
                0x00, 0x00, 0x00, 0x00,
                0x80, 0x00, 0x02,
                0x00, 0x00, 0x00,
                0x00, 0x00, 0x00,
                0x00,
                0x01, 0x02,
                0x82,
                0x00, 0x64, 0x00,
                0x00, 0x01,
                0x3f, 0x80, 0x00, 0x00
            };

            try
            {
                comPort.BytesToRead.Returns(0);
                protocolFinsTcp.Write(new DataAddress()
                {
                    Value  = "D100",
                    Type   = DataAddressType.Float,
                    Offset = 0
                }, new float[] { 1 });
            }
            catch
            {
            }

            comPort.Received().Write(Arg.Is <byte[]>(e => !e.Except(excepted).Any() && !excepted.Except(e).Any()), 0, excepted.Length);
        }