private void createPlaceholder(PlaceholderInfo info, ITcSmTreeItem plcProject, IWorker worker) { worker.ProgressStatus = string.Format("Adding Placeholder '{0}' ...", info.PlaceholderName); ITcSmTreeItem referencesItem = plcProject.LookupChild("References"); ITcPlcLibraryManager libraryManager = (ITcPlcLibraryManager)referencesItem; libraryManager.AddPlaceholder(info.PlaceholderName); }
private void createLibrary(LibraryInfo info, ITcSmTreeItem plcProject, IWorker worker) { worker.ProgressStatus = string.Format("Adding Library '{0}' ...", info.LibraryName); ITcSmTreeItem referencesItem = plcProject.LookupChild("References"); ITcPlcLibraryManager libraryManager = (ITcPlcLibraryManager)referencesItem; libraryManager.AddLibrary(info.LibraryName); }
public void AddLibrary(ref ITcPlcLibraryManager libraryManager) { string libPath = buildPathString("MDR_Control.library"); //---Install library into new repository libraryManager.InstallLibrary("System", libPath, true); //--library must exists in TwinCAT folder. //--- libpath needs to be added to basefolder in this install command (needs full path to folder + MDR_Control.library //---Add library from repository libraryManager.AddLibrary("MDR_Control", "1.0", "BAUS"); }
public void DeleteLibrary(ref ITcPlcLibraryManager libraryManager) { //---Create new repo path //string newRepoPath = @"C:\TwinCAT\3.1\Components\Plc\Managed Libraries\BAUS"; //---Remove Library from references libraryManager.RemoveReference("MDR_Control"); //---Uninstall library from repository libraryManager.UninstallLibrary("System", "MDR_Control", "1.0", "BAUS"); //---Remove repository from system }
public SolutionHandler(string filePath, string FileName) { this.BASEFOLDER = filePath; this._solutionName = _tcProjectName = FileName; this.adsClient = new TcAdsClient(); MessageFilter.Register(); /* ----------------------------------------------------------------- * Creates new solution based off of TwinCAT's XAE and PLC templates. * -----------------------------------------------------------------*/ if (dte == null) { CreateNewProject(); } pro = sol.Projects.Item(1); sysMan = (ITcSysManager11)pro.Object; //System.Threading.Thread.Sleep(5000); ITcSmTreeItem plc = sysMan.LookupTreeItem("TIPC"); plc.CreateChild("Untitled1", 0, "", "Standard PLC Template"); //---Navigate to References node and cast to Library Manager interface ITcSmTreeItem references = sysMan.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^References"); ITcPlcLibraryManager libraryManager = (ITcPlcLibraryManager)this.RetrieveLibMan(); /* ------------------------------------------------------ * Check to see if library already exists, if it does it will delete before adding to avoid any exceptions. * ------------------------------------------------------ */ foreach (ITcPlcLibRef libraryReference in libraryManager.References) { if (libraryReference is ITcPlcLibrary) { ITcPlcLibrary library = (ITcPlcLibrary)libraryReference; if (library.Name == "MDR_Control") { DeleteLibrary(ref libraryManager); } } } /* ------------------------------------------------------ * Add our MDR library to the project References. * ------------------------------------------------------ */ AddLibrary(ref libraryManager); MessageFilter.Revoke(); }//Constructor()