Ejemplo n.º 1
0
        //This contructor is meant to be used for testing individual methods
        //It should never be called in a live use
        public SolutionHandler()
        {
            dte       = attachToExistingDte(@"C:\Users\NathanM\Desktop\DELETE ME\Garth Gaddy\TestDirectory\Test4.sln", ProgID);
            sol       = dte.Solution;
            pro       = sol.Projects.Item(1);
            sysMan    = (ITcSysManager11)pro.Object;
            adsClient = new TcAdsClient();
            ITcSmTreeItem drive = sysMan.LookupTreeItem(@"TIID^Device_1^InfeedWest0");

            LinkIoToPlc(drive);
        }
Ejemplo n.º 2
0
        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()