public XLSXImporterProxy( ICoreObject cpu, ISynchronizeInvoke synchronizer = null) { if (synchronizer == null) { Synchronizer = cpu.GetSynchronizer(); } else { Synchronizer = synchronizer; } TiaStarter.RunInSynchronizer(Synchronizer, () => { XLSXImporter = new XLSXImporter(cpu.GetTagService(), MassDataHandler.CreateWorkbook(null), cpu.GetDefaultTagTable(Synchronizer), XLSXImportExportOptions.IncludeTags | XLSXImportExportOptions.IncludeConstants, cpu.GetFolderService(), cpu.GetCommandProcessor(), null, null, cpu.GetNameService(), cpu.GetRangeCheck()); }); }
/// <summary> /// 创建变量 /// </summary> /// <param name="cpu">控制器</param> /// <param name="tagTable">变量表</param> /// <param name="properties">变量数据</param> /// <param name="isConstant">是否静态变量</param> public static IBLTag CreateRootTagInTagTable( this ICoreObject cpu, ICoreObject tagTable, Dictionary <string, string> properties, bool isConstant = false, ISynchronizeInvoke synchronizer = null ) { ISynchronizeInvoke UsingSynchronizer; if (synchronizer == null) { UsingSynchronizer = cpu.GetSynchronizer(); } else { UsingSynchronizer = synchronizer; } return(TiaStarter.RunInSynchronizer(UsingSynchronizer, () => { IObjectTypeInfo iot = null; if (isConstant) { iot = tagTable.GetConstantType(); } else { iot = tagTable.GetTagType(); } ITagService tagService = cpu.GetTagService(); using (new ObjectFrameBulkOperationMode(tagTable)) { return tagService.CreateRootTag( cpu, iot, Enumerable.ToDictionary(properties, kvp => kvp.Key, (Func <KeyValuePair <string, string>, object>)(kvp => kvp.Value))) as IBLTag; } }) as IBLTag); }
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); }
/// <summary> /// 按名称查找变量 /// </summary> /// <param name="cpu">控制器</param> /// <param name="tagName">变量名称</param> public static IBLTag FindRootTagByName( this ICoreObject cpu, string tagName, ISynchronizeInvoke synchronizer = null) { ISynchronizeInvoke UsingSynchronizer; if (synchronizer == null) { UsingSynchronizer = cpu.GetSynchronizer(); } else { UsingSynchronizer = synchronizer; } return(TiaStarter.RunInSynchronizer(UsingSynchronizer, (p_cpu, p_tagName) => { ITagService tagService = cpu.GetTagService(); return tagService.FindRootTagByName(p_tagName, p_cpu, "InverseTarget", true); }, cpu, tagName) as IBLTag); }
/// <summary> /// 取得控制器所有变量 /// </summary> public static RootTagCollectionProxy FindRootTags(this ICoreObject cpu, ISynchronizeInvoke synchronizer = null) { ISynchronizeInvoke UsingSynchronizer; if (synchronizer == null) { UsingSynchronizer = cpu.GetSynchronizer(); } else { UsingSynchronizer = synchronizer; } return(TiaStarter.RunInSynchronizer(UsingSynchronizer, (p_cpu) => { ITagService tagService = cpu.GetTagService(); IList list = tagService.FindRootTags(p_cpu, cpu.GetTagType(), "InverseTarget", true); RootTagCollectionProxy rtcp = new RootTagCollectionProxy(list, UsingSynchronizer); return rtcp; }, cpu) as RootTagCollectionProxy); }