public void GetSymhandleByName()
        {
            var amsTestSocket = new AmsSocketTest();
            amsTestSocket.SendMessage = new byte[] {
                    0,0,58,0,0,0,5,1,204,123,1,1,33,3,10,0,0,120,
                    1,1,137,128,9,0,4,0,26,0,0,0,0,0,0,0,1,0,0,0,
                    3,240,0,0,0,0,0,0,4,0,0,0,10,0,0,0,46,84,69,83,
                    84,84,73,77,69,0};

            amsTestSocket.ReceiveMessage = new byte[] {
                    0,0,44,0,0,0,10,0,0,120,1,1,137,128,5,1,204,123,
                    1,1,33,3,9,0,5,0,12,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
                    0,4,0,0,0,141,2,0,164};

            using (AdsClient client = new AdsClient(
                    amsNetIdSource: "10.0.0.120.1.1",
                    amsSocket: amsTestSocket,
                    amsNetIdTarget: "5.1.204.123.1.1"))
            {
                uint handle = client.GetSymhandleByName(".TESTTIME");
                Assert.AreEqual(handle, 2751464077);

                //Symhandle release
                amsTestSocket.SendMessage = new byte[] {
                    0,0,48,0,0,0,5,1,204,123,1,1,33,3,10,0,0,120,1,1,137,
                    128,3,0,4,0,16,0,0,0,0,0,0,0,2,0,0,0,6,240,0,0,0,0,0,
                    0,4,0,0,0,141,2,0,164};

                amsTestSocket.ReceiveMessage = new byte[] {
                     0,0,36,0,0,0,5,1,204,123,1,1,137,128,5,1,204,123,1,1,
                     33,3,3,0,5,0,4,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0};

            }
        }
Beispiel #2
0
        public void RunTest()
        {
            using (AdsClient client = new AdsClient(settings))
            {
                var deviceInfo = client.ReadDeviceInfo();
                Console.WriteLine("Device info: " + deviceInfo.ToString());

                Console.WriteLine();
                Console.WriteLine("Available symbols: ");
                var symbols = client.Special.GetSymbols();
                foreach (var symbol in symbols)
                {
                    Console.WriteLine("  " + symbol.ToString());
                }
                Console.WriteLine();

                uint startTestHandle = client.GetSymhandleByName("MAIN.STARTTEST");
                Console.WriteLine("Handle StartTest: " + startTestHandle.ToString());

                uint testIsRunningHandle = client.GetSymhandleByName("MAIN.TESTISRUNNING");
                Console.WriteLine("Handle TestIsRunning: " + testIsRunningHandle.ToString());

                uint stopTestHandle = client.GetSymhandleByName("MAIN.STOPTEST");
                Console.WriteLine("Handle StopTest: " + stopTestHandle.ToString());

                var testIsRunning = client.Read <bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());

                client.Write <bool>(startTestHandle, true);
                Console.WriteLine("Starting test");

                testIsRunning = client.Read <bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());


                //TODO



                client.Write <bool>(stopTestHandle, true);
                Console.WriteLine("Stopping test");

                testIsRunning = client.Read <bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());
            }
        }
Beispiel #3
0
        public void RunTest()
        {
            using (AdsClient client = new AdsClient(settings))
            {
                var deviceInfo = client.ReadDeviceInfo();
                Console.WriteLine("Device info: " + deviceInfo.ToString());

                Console.WriteLine();
                Console.WriteLine("Available symbols: ");
                var symbols = client.Special.GetSymbols();
                foreach (var symbol in symbols)
                {
                    Console.WriteLine("  " + symbol.ToString());
                }
                Console.WriteLine();

                uint startTestHandle = client.GetSymhandleByName("MAIN.STARTTEST");
                Console.WriteLine("Handle StartTest: " + startTestHandle.ToString());

                uint testIsRunningHandle = client.GetSymhandleByName("MAIN.TESTISRUNNING");
                Console.WriteLine("Handle TestIsRunning: " + testIsRunningHandle.ToString());

                uint stopTestHandle = client.GetSymhandleByName("MAIN.STOPTEST");
                Console.WriteLine("Handle StopTest: " + stopTestHandle.ToString());

                var testIsRunning = client.Read<bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());

                client.Write<bool>(startTestHandle, true);
                Console.WriteLine("Starting test");

                testIsRunning = client.Read<bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());

                //TODO

                client.Write<bool>(stopTestHandle, true);
                Console.WriteLine("Stopping test");

                testIsRunning = client.Read<bool>(testIsRunningHandle);
                Console.WriteLine("Is test running? " + testIsRunning.ToString());
            }
        }
        public void GetSymhandleByName()
        {
            var amsTestSocket = new AmsSocketTest();

            amsTestSocket.SendMessage = new byte[] {
                0, 0, 58, 0, 0, 0, 5, 1, 204, 123, 1, 1, 33, 3, 10, 0, 0, 120,
                1, 1, 137, 128, 9, 0, 4, 0, 26, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                3, 240, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 10, 0, 0, 0, 46, 84, 69, 83,
                84, 84, 73, 77, 69, 0
            };

            amsTestSocket.ReceiveMessage = new byte[] {
                0, 0, 44, 0, 0, 0, 10, 0, 0, 120, 1, 1, 137, 128, 5, 1, 204, 123,
                1, 1, 33, 3, 9, 0, 5, 0, 12, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
                0, 4, 0, 0, 0, 141, 2, 0, 164
            };

            using (AdsClient client = new AdsClient(
                       amsNetIdSource: "10.0.0.120.1.1",
                       amsSocket: amsTestSocket,
                       amsNetIdTarget: "5.1.204.123.1.1"))
            {
                uint handle = client.GetSymhandleByName(".TESTTIME");
                Assert.AreEqual(handle, 2751464077);

                //Symhandle release
                amsTestSocket.SendMessage = new byte[] {
                    0, 0, 48, 0, 0, 0, 5, 1, 204, 123, 1, 1, 33, 3, 10, 0, 0, 120, 1, 1, 137,
                    128, 3, 0, 4, 0, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 240, 0, 0, 0, 0, 0,
                    0, 4, 0, 0, 0, 141, 2, 0, 164
                };

                amsTestSocket.ReceiveMessage = new byte[] {
                    0, 0, 36, 0, 0, 0, 5, 1, 204, 123, 1, 1, 137, 128, 5, 1, 204, 123, 1, 1,
                    33, 3, 3, 0, 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0
                };
            }
        }