Esempio n. 1
0
        public void ApplyRangeMatrixTest()
        {
            int[,] int3x3Matrix = new int[, ]
            {
                { 1, 2, 3 },
                { 4, 5, 6 },
                { 7, 8, 9 },
            };

            Matrix matrix = new Matrix(int3x3Matrix, BuiltInType.Int32);

            // Select the center element
            Opc.Ua.NumericRange numericRange = Opc.Ua.NumericRange.Parse("1,1");

            object value = matrix;

            StatusCode statusCode = numericRange.ApplyRange(ref value);

            Assert.AreEqual(new StatusCode(StatusCodes.Good), statusCode);

            int[,] range = value as int[, ];

            Assert.NotNull(range, "Applied range null or not type of int[,]");
            Assert.AreEqual(2, range.Rank);
            Assert.AreEqual(5, range[0, 0]);
        }
Esempio n. 2
0
        public void UpdateRangeMatrixTest()
        {
            int[,] dstInt3x3Matrix = new int[, ]
            {
                { 1, 2, 3 },
                { 4, 5, 6 },
                { 7, 8, 9 },
            };

            Matrix dstMatrix = new Matrix(dstInt3x3Matrix, BuiltInType.Int32);

            // Update the center element
            Opc.Ua.NumericRange numericRange = Opc.Ua.NumericRange.Parse("1,1");
            object     dst        = dstMatrix;
            StatusCode statusCode = numericRange.UpdateRange(ref dst, new int[, ] {
                { 10 }
            });

            Assert.AreEqual(new StatusCode(StatusCodes.Good), statusCode);

            dstMatrix = dst as Matrix;
            Assert.NotNull(dstMatrix);

            int[,] modifiedInt3x3Matrix = dstMatrix.ToArray() as int[, ];

            Assert.AreEqual(new int[, ]
            {
                { 1, 2, 3 },
                { 4, 10, 6 },
                { 7, 8, 9 },
            }, modifiedInt3x3Matrix);
        }
Esempio n. 3
0
        public void UpdateStringArrayTest()
        {
            // Update the middle element "Test2" to "That2" by modifying "es" to "ha".
            Opc.Ua.NumericRange numericRange = Opc.Ua.NumericRange.Parse("1,1:2");
            object     dst        = new string[] { "Test1", "Test2", "Test3" };
            StatusCode statusCode = numericRange.UpdateRange(ref dst, new string[] { "ha" });

            Assert.AreEqual(new StatusCode(StatusCodes.Good), statusCode);

            string[] updatedValue = dst as string[];
            Assert.NotNull(updatedValue);
            Assert.AreEqual(new string[] { "Test1", "That2", "Test3" }, updatedValue);
        }
Esempio n. 4
0
        public void UpdateByteStringArrayTest()
        {
            // Update the middle element <0x55, 0x66, 0x77, 0x88> to <0x55, 0xDD, 0xEE, 0x88> by modifying 0x66 to 0xDD and 0x77 to 0xEE.
            Opc.Ua.NumericRange numericRange = Opc.Ua.NumericRange.Parse("1,1:2");
            object dst = new byte[][]
            {
                new byte[] { 0x11, 0x22, 0x33, 0x44 },
                new byte[] { 0x55, 0x66, 0x77, 0x88 },
                new byte[] { 0x99, 0xAA, 0xBB, 0xCC }
            };
            StatusCode statusCode = numericRange.UpdateRange(ref dst, new byte[][] { new byte[] { 0xDD, 0xEE } });

            Assert.AreEqual(new StatusCode(StatusCodes.Good), statusCode);

            byte[][] updatedValue = dst as byte[][];
            Assert.NotNull(updatedValue);
            Assert.AreEqual(new byte[][]
            {
                new byte[] { 0x11, 0x22, 0x33, 0x44 },
                new byte[] { 0x55, 0xDD, 0xEE, 0x88 },
                new byte[] { 0x99, 0xAA, 0xBB, 0xCC }
            }, updatedValue);
        }