public void ReadDeviceInfoAsync()
        {
            var amsTestSocket = new AmsSocketTest();

            amsTestSocket.SendMessage = new byte[] {
                0, 0, 32, 0, 0, 0, 5, 1, 204, 123, 1, 1, 33, 3, 10, 0, 0,
                120, 1, 1, 137, 128, 1, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0
            };

            amsTestSocket.ReceiveMessage = new byte[] {
                0, 0, 56, 0, 0, 0, 10, 0, 0, 120, 1, 1, 137, 128, 5, 1, 204, 123,
                1, 1, 33, 3, 1, 0, 5, 0, 24, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
                0, 2, 11, 234, 5, 84, 67, 97, 116, 80, 108, 99, 67, 116, 114, 108, 0, 0, 0, 0, 0
            };

            using (AdsClient client = new AdsClient(
                       amsNetIdSource: "10.0.0.120.1.1",
                       amsSocket: amsTestSocket,
                       amsNetIdTarget: "5.1.204.123.1.1"))
            {
                var task = client.ReadDeviceInfoAsync();
                task.Wait(5000);
                AdsDeviceInfo deviceInfo = task.Result;
                Assert.AreEqual(deviceInfo.ToString(), "Version: 2.11.1514 Devicename: TCatPlcCtrl");
            }
        }
Ejemplo n.º 2
0
        public void ReadDeviceInfoAsync()
        {
            var amsTestSocket = new AmsSocketTest();
			amsTestSocket.SendMessage = new byte[] {
                    0,0,32,0,0,0,5,1,204,123,1,1,33,3,10,0,0,
                    120,1,1,137,128,1,0,4,0,0,0,0,0,0,0,0,0,1,0,0,0};

            amsTestSocket.ReceiveMessage = new byte[] { 
                    0,0,56,0,0,0,10,0,0,120,1,1,137,128,5,1,204,123,
                    1,1,33,3,1,0,5,0,24,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
                    0,2,11,234,5,84,67,97,116,80,108,99,67,116,114,108,0,0,0,0,0};

            using (AdsClient client = new AdsClient(
                    amsNetIdSource: "10.0.0.120.1.1",
                    amsSocket: amsTestSocket,
                    amsNetIdTarget: "5.1.204.123.1.1"))
            {
                var task = client.ReadDeviceInfoAsync();
                task.Wait(5000);
                AdsDeviceInfo deviceInfo = task.Result;
                Assert.AreEqual(deviceInfo.ToString(), "Version: 2.11.1514 Devicename: TCatPlcCtrl");
            }
        }