public static void DataHandling(IConfigurationRoot configuration, ITcSysManager10 systemManager, bool debugMode) { //Define Internal Variables List <ITcSmTreeItem> adapterList; //Get JSon Settings var xaeIoData = new XaeIoData(); var xaeFileData = new XaeFileData(); try { configuration.GetSection("XaeIoData").Bind(xaeIoData); configuration.GetSection("XaeFileData").Bind(xaeFileData); } catch (Exception e) { DataRelease(e.Message, debugMode); return; } //Write Header Helpers.DebugLogger("TwinCAT Io Tree Module", debugMode); Helpers.DebugLogger("-------------------", debugMode); //Get Adapter List adapterList = new List <ITcSmTreeItem>(); adapterList.Clear(); //Get Base IO-Node ITcSmTreeItem ioBase = systemManager.LookupTreeItem("TIID"); Helpers.DebugLogger($"Actual Found {ioBase.ChildCount} Adapters", debugMode); //Check Directory string folderName = Helpers.CheckFolder(xaeIoData.folder, debugMode); //Fill Adapter List foreach (ITcSmTreeItem childAdapter in ioBase) { Helpers.DebugLogger($"Adapter: {childAdapter.Name}", debugMode); //Recurve Work GetTreeItems(childAdapter, adapterList); } }
public static void DataHandling(IConfigurationRoot configuration, ITcSysManager10 systemManager, bool debugMode) { //Define Internal Variables List <string> adapterList; //Get JSon Settings var xaeIoData = new XaeIoData(); var xaeFileData = new XaeFileData(); try { configuration.GetSection("XaeIoData").Bind(xaeIoData); configuration.GetSection("XaeFileData").Bind(xaeFileData); } catch (Exception e) { DataRelease(e.Message, debugMode); return; } //Write Header Helpers.DebugLogger("TwinCAT IO-xti Module", debugMode); Helpers.DebugLogger("-------------------", debugMode); Helpers.DebugLogger($"Selected Apdapter Import: {xaeIoData.import}", debugMode); Helpers.DebugLogger($"Selected Apdapter Export: {xaeIoData.export}", debugMode); Helpers.DebugLogger("-------------------", debugMode); if (!xaeIoData.import && !xaeIoData.export) { DataRelease("Io Module Nothing do to - Exit", debugMode); return; } //Get Adapter List adapterList = new List <string>(); adapterList.Clear(); //Get Base IO-Node //if systemManager.GetType ITcSmTreeItem ioBase = systemManager.LookupTreeItem("TIID"); Helpers.DebugLogger($"Actual Found {ioBase.ChildCount} Adapters", debugMode); //Export XTI Files if (xaeIoData.export) { //Check Directory string folderName = Helpers.CheckFolder(xaeIoData.folder, debugMode); //Fill Adapter List foreach (ITcSmTreeItem childAdapter in ioBase) { Helpers.DebugLogger($"Adapter: {childAdapter.Name}", debugMode); adapterList.Add(childAdapter.Name); } //Export Adapter foreach (string adapterString in adapterList) { string fileName = ""; if (xaeIoData.exportTimestamp) { fileName = folderName + Helpers.TimeStamp() + "_" + adapterString + ".xti"; } else { fileName = folderName + adapterString + ".xti"; } Helpers.DebugLogger($"Export: {adapterString} - {fileName}", debugMode); ioBase.ExportChild(adapterString, fileName); } } //Import XTI Files if (xaeIoData.import) { //Check Directory string folderName = Helpers.CheckFolder(xaeIoData.folder, debugMode); string[] importFiles = Directory.GetFiles(folderName); foreach (string importFile in importFiles) { //Check if File is XTI and not Backupfile if ((importFile.IndexOf(".xti") > -1) && (importFile.IndexOf(".bak") == -1)) { Helpers.DebugLogger(importFile, debugMode); ioBase.ImportChild(importFile, "", true, ""); } } } }