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);
            }
Exemplo n.º 2
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);
            }