Example #1
0
            public static void Main1()
            {
                #region Example-DefineAndRead
                var mapper = new DAClientMapper();
                var target = new MyClass();

                // Define a type-less mapping.

                mapper.DefineMapping(
                    new DAClientItemSource("AutoJet.ACPFileServerDA.1", "Cttmt2008.Parameter.Manual AI2", DADataSource.Cache),
                    new DAClientItemMapping(typeof(Int32)),
                    new ObjectMemberLinkingTarget(target.GetType(), target, "Value"));

                // Perform a read operation.
                mapper.Read();
                #endregion

                // Display the result.
                Console.WriteLine(target.Value);
            }
            public static void Subscribe()
            {
                var mapper = new DAClientMapper();
                var target = new MyClassSubscribe();

                // Define a type-less mapping.

                mapper.DefineMapping(
                    new DAClientItemSource("AutoJet.ACPFileServerDA.1", "Demo.Ramp", 1000, DADataSource.Cache),
                    new DAClientItemMapping(typeof(Double)),
                    new ObjectMemberLinkingTarget(target.GetType(), target, "Value"));

                // Perform a subscribe operation.
                mapper.Subscribe(true);

                Thread.Sleep(30 * 1000);

                // Perform an unsubscribe operation.
                mapper.Subscribe(false);
            }
Example #3
0
            public static void MappingKinds()
            {
                var mapper = new DAClientMapper();
                var target = new MyClassMappingKinds();

                // Define several type-less mappings for the same source, with different mapping kinds.

                Type targetType = target.GetType();
                var  source     = new DAClientItemSource("AutoJet.ACPFileServerDA.1", "Demo.Ramp", 1000, DADataSource.Cache);

                mapper.DefineMapping(
                    source,
                    new DAClientItemMapping(typeof(Double)),
                    new ObjectMemberLinkingTarget(targetType, target, "CurrentValue"));

                mapper.DefineMapping(
                    source,
                    new DAClientItemMapping(typeof(Double), DAItemMappingKind.Vtq),
                    new ObjectMemberLinkingTarget(targetType, target, "CurrentVtq"));

                mapper.DefineMapping(
                    source,
                    new DAClientItemMapping(typeof(Double), DAItemMappingKind.Exception),
                    new ObjectMemberLinkingTarget(targetType, target, "CurrentException"));

                mapper.DefineMapping(
                    source,
                    new DAClientItemMapping(typeof(Double), DAItemMappingKind.Result),
                    new ObjectMemberLinkingTarget(targetType, target, "CurrentResult"));

                // Perform a subscribe operation.
                mapper.Subscribe(true);

                Thread.Sleep(30 * 1000);

                // Perform an unsubscribe operation.
                mapper.Subscribe(false);
            }