Exemplo n.º 1
0
        /// <summary>
        /// 更新变量
        /// </summary>
        /// <param name="tagTable">变量表</param>
        /// <param name="tag">变量</param>
        /// <param name="properties">变量数据</param>
        /// <param name="isConstant">是否静态变量</param>
        //public static IBLTag UpdateTag(
        //  this ICoreObject tagTable,
        //  IBLTag tag,
        //  Dictionary<string, string> properties,
        //  bool isConstant = false,
        //  ISynchronizeInvoke synchronizer = null)
        //{
        //  ISynchronizeInvoke UsingSynchronizer;
        //  if (synchronizer == null)
        //  {
        //    UsingSynchronizer = tagTable.GetSynchronizer();
        //  }
        //  else
        //  {
        //    UsingSynchronizer = synchronizer;
        //  }
        //  return TiaStarter.RunFuncInSynchronizer(UsingSynchronizer,
        //    () =>
        //    {
        //      bool result = UpdateTagReal(tagTable, tag, properties, isConstant);
        //      return FindRootTagByName(tagTable.GetParent(), tag.Name);
        //    }) as IBLTag;
        //}

        public static IBLTag ToBLTag(this ICoreObject tagRef,
                                     ISynchronizeInvoke synchronizer = null)
        {
            ISynchronizeInvoke UsingSynchronizer;

            if (synchronizer == null)
            {
                UsingSynchronizer = tagRef.GetSynchronizer();
            }
            else
            {
                UsingSynchronizer = synchronizer;
            }

            return(TiaStarter.RunFuncInSynchronizer(UsingSynchronizer,
                                                    (p_tag) =>
            {
                if (p_tag == null)
                {
                    return null;
                }
                IBusinessLogicConnector businessLogicConnector = tagRef as IBusinessLogicConnector;
                if (businessLogicConnector == null)
                {
                    return null;
                }
                return businessLogicConnector.GetBusinessLogic("Siemens.Automation.DomainServices.TagService") as IBLTag;
            }, tagRef) as IBLTag);
        }
Exemplo n.º 2
0
        public static ICoreObject CreateTagTable(this ICoreObject folder,
                                                 string Name,
                                                 ISynchronizeInvoke synchronizer = null)
        {
            ISynchronizeInvoke UsingSynchronizer;

            if (synchronizer == null)
            {
                UsingSynchronizer = folder.GetSynchronizer();
            }
            else
            {
                UsingSynchronizer = synchronizer;
            }
            return(TiaStarter.RunFuncInSynchronizer(UsingSynchronizer, (Func <ICoreObject>)
                                                        (() => {
                ITagService tagService = folder.GetTagService();
                TagServiceProxy tsp = new TagServiceProxy(tagService);
                return tsp.CreateTagTable(folder, folder.GetTagTableType(), false, Name);
            })) as ICoreObject);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新变量
        /// </summary>
        /// <param name="tagTable">变量表</param>
        /// <param name="tag">变量</param>
        /// <param name="properties">变量数据</param>
        /// <param name="isConstant">是否静态变量</param>
        public static IBLTag UpdateTag(
            this ICoreObject tagTable,
            IBLTag tag,
            Dictionary <string, string> properties,
            bool isConstant = false,
            ISynchronizeInvoke synchronizer = null)
        {
            ISynchronizeInvoke UsingSynchronizer;

            if (synchronizer == null)
            {
                UsingSynchronizer = tagTable.GetSynchronizer();
            }
            else
            {
                UsingSynchronizer = synchronizer;
            }
            return(TiaStarter.RunFuncInSynchronizer(UsingSynchronizer,
                                                    () =>
            {
                bool result = UpdateTagReal(tagTable, tag, properties, isConstant);
                return FindRootTagByName(tagTable.GetParent(), tag.Name);
            }) as IBLTag);
        }