protected ITcSmTreeItem CreateHardware(IWorker worker, bool scanHardware, bool simulation)
        {
            OrderScriptContext context           = (OrderScriptContext)_context;
            ConfigurationInfo  configurationInfo = context.Order.ConfigurationInfo;
            HardwareInfo       hardware          = configurationInfo.Hardware;

            ITcSmTreeItem devices = systemManager.LookupTreeItem("TIID");                       // Getting IO-Configuration
            ITcSmTreeItem device  = null;

            if (worker.CancellationPending)
            {
                throw new Exception("Execution cancelled!");
            }

            // Scans the Fieldbus interfaces and adds an EtherCAT Device.
            string deviceName = "EtherCAT Master";

            worker.ProgressStatus = string.Format("Creating device '{0}'", deviceName);
            device = Helper.CreateEthernetDevice(this.systemManager, DeviceType.EtherCAT_DirectMode, deviceName, worker);

            ITcSmTreeItem parent = device;

            foreach (BoxInfo boxInfo in hardware.Boxes)
            {
                if (worker.CancellationPending)
                {
                    throw new Exception("Execution cancelled!");
                }

                ITcSmTreeItem box = CreateBox(parent, boxInfo, worker);
            }

            return(device);
        }
Ejemplo n.º 2
0
 public AutomationInterface(EnvDTE.Project project)
 {
     sysManager     = (ITcSysManager10)project.Object;
     configManager  = (ITcConfigManager)sysManager.ConfigurationManager;
     plcTreeItem    = sysManager.LookupTreeItem(Constants.PLC_CONFIGURATION_SHORTCUT);
     routesTreeItem = sysManager.LookupTreeItem(Constants.RT_CONFIG_ROUTE_SETTINGS_SHORTCUT);
 }
Ejemplo n.º 3
0
        }   //ActivateConfiguration()

        public void EditParams(ITcSmTreeItem drive, string filename)
        {
            //Create the filepath to the motor file using the path provided to load the excel spreadsheet.
            string file = filename;
            string path = buildPathString(file);

            //open the Motor file as an xml document,read its tags with InitCmds
            XmlDocument xDoc = new XmlDocument();

            xDoc.Load(path);
            XmlNode xNode = xDoc.SelectSingleNode("/EtherCATMailbox/CoE/InitCmds");

            string      driveParams = drive.ProduceXml();
            XmlNodeList xmlInitCmds = xNode.ChildNodes;

            foreach (XmlNode Cmd in xmlInitCmds)
            {
                string newStartListParam = "<" + Cmd.Name + ">";
                foreach (XmlNode node in Cmd)
                {
                    newStartListParam += "<" + node.Name + ">";
                    newStartListParam += node.InnerText;
                    newStartListParam += "</" + node.Name + ">";
                }
                newStartListParam += "</" + Cmd.Name + ">";
                int idx = driveParams.IndexOf("</InitCmd></InitCmds><CanOpenType>55</CanOpenType></CoE></Mailbox>");
                idx         = idx + 10;
                driveParams = driveParams.Insert(idx, newStartListParam);
            }
            drive.ConsumeXml(driveParams);
        }//EditParams
Ejemplo n.º 4
0
        /// <summary>
        /// Stops the PLC, assuming that you already have a running PLC.
        /// </summary>
        public Boolean stopPLC()
        {
            Console.WriteLine("Stopping " + project.Name);
            ITcSysManager4 systemManager = (ITcSysManager4)(project.Object);

            if (!systemManager.IsTwinCATStarted())
            {
                Console.WriteLine("No Twincat project running!!");
                return(false);
            }

            ITcSmTreeItem plcApp = getPLCApp(systemManager);

            System.Threading.Thread.Sleep(1000);
            if (!login(plcApp))
            {
                return(false);
            }

            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("Stopping PLC");
            plcApp.ConsumeXml(createXMLString(PLCAction.STOP));

            if (!checkWithTimeout(COMMAND_TIMEOUT, () => checkXmlIsString(plcApp, "PlcAppState", "Stop")))
            {
                Console.WriteLine("Failed to stop!");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        public void exportAxisXml(int axisNumber)
        {
            ITcSmTreeItem axisName       = Axes.Child[axisNumber + 1];
            string        xmlDescription = axisName.ProduceXml();

            File.WriteAllText(ConfigFolder + @"\" + AxisDirectory + @"\" + axisName.Name + @".xml", xmlDescription);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Checks that a solution contains at least one PLC project and starts the project running.
        /// </summary>
        public Boolean startPLC()
        {
            Console.WriteLine("Starting " + project.Name);
            ITcSysManager4 systemManager = (ITcSysManager4)(project.Object);

            ITcSmTreeItem plcApp = getPLCApp(systemManager);

            System.Threading.Thread.Sleep(1000);
            if (!login(plcApp))
            {
                return(false);
            }

            if (isRunning(plcApp))
            {
                Console.WriteLine("PLC is running");
                return(true);
            }

            System.Threading.Thread.Sleep(1000);
            Console.WriteLine("Starting PLC");
            plcApp.ConsumeXml(createXMLString(PLCAction.START));

            if (!checkWithTimeout(COMMAND_TIMEOUT, () => isRunning(plcApp)))
            {
                Console.WriteLine("Failed to start!");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Produces a string of data for use in the IO List file
        /// </summary>
        /// <param name="tierLevel"></param>
        /// <param name="ioName"></param>
        /// <returns></returns>
        public String getIoData(String tierLevel, ITcSmTreeItem ioName)
        {
            //Need to get product revision from XML
            XmlDocument ioXml = new XmlDocument();

            ioXml.LoadXml(ioName.ProduceXml());
            String productRevision;
            String name;
            String subType;
            String strB4; //not utilised but needs to be set. Can be used to state where in tree the device should appear when created.
            String ioListString;

            name    = ioName.Name;
            subType = (ioName.ItemSubType).ToString();

            var node = ioXml.SelectSingleNode("TreeItem/EtherCAT/Slave/Info/ProductRevision");

            if (node != null)
            {
                strB4           = " ";
                productRevision = node.InnerText;
            }
            else
            {
                strB4           = "null";
                productRevision = "null";
            }
            ioListString = tierLevel + "," + name + "," + subType + "," + strB4 + "," + productRevision;
            return(ioListString);
        }
Ejemplo n.º 8
0
 public void activateAndRunPLC()
 {
     adsClient.Connect(sysMan.GetTargetNetId(), 10000); //AMS net id of target system. TwinCAT system service port = 10000
     System.Threading.Thread.Sleep(10000);              //waiting for TwinCAT to go into Run mode.
     sysMan.ActivateConfiguration();
     sysMan.StartRestartTwinCAT();
     try
     {
         bool rundo = true;
         do
         {
             if (adsClient.ReadState().AdsState == AdsState.Run) //reads TwinCAT's system state, if it is in run mode then log into plc.
             {
                 string        xml        = "<TreeItem><IECProjectDef><OnlineSettings><Commands><LoginCmd>true</LoginCmd><StartCmd>true</StartCmd></Commands></OnlineSettings></IECProjectDef></TreeItem>";
                 ITcSmTreeItem plcProject = sysMan.LookupTreeItem("TIPC^Untitled1^Untitled1 Project");
                 plcProject.ConsumeXml(xml);
                 rundo = false;
             }
         } while (rundo);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
        private bool TryLookupChild3(ITcSmTreeItem parent, string childName, out ITcSmTreeItem child)
        {
            string parentPath = parent.PathName;
            string path       = parentPath + "^" + childName;

            return(TryLookupTreeItem(path, out child));
        }
Ejemplo n.º 10
0
        SpecificEventsModuleCreator(
            int targetIndex,
            ITcSmTreeItem pou,
            ITcSmTreeItem dut,
            ITcSmTreeItem gvl,
            ITcSmTreeItem eventManagers,
            ITcSmTreeItem modules,
            ITcSmTreeItem triggers

            )
        {
            this.eventManagers = eventManagers;
            this.modules       = modules;
            this.triggers      = triggers;
            this.pou           = pou;
            this.dut           = dut;
            this.gvl           = gvl;
            module             = AssignedConfigFileData.modulesContainer.content[targetIndex];
            eventNamesLists    = new List <String[]>();
            eventManagerNames  = new List <String>();
            this.targetIndex   = targetIndex;
            CreateModuleCode();
            Console.WriteLine("Code for module {0} created.", module.getName);
            CreateEventManagerCode();
        }
        private ITcSmTreeItem createItf(ItfInfo itfInfo, ITcSmTreeItem parent, IWorker worker, XmlDocument doc)
        {
            XmlNode itfNode = doc.SelectSingleNode("TcPlcObject/Itf");
            string  itfName = itfNode.Attributes["Name"].Value;

            worker.ProgressStatus = string.Format("Creating Interface '{0}' ...", itfName);

            ITcSmTreeItem item = null;
            XmlElement    node = (XmlElement)doc.SelectSingleNode("TcPlcObject/Itf/Declaration");

            string declString = node.InnerText;

            if (!TryLookupChild(parent, itfName, out item))
            {
                item = parent.CreateChild(itfName, TreeItemType.PlcInterface.AsInt32(), "", declString);
            }

            //Debug.Fail("");
            ITcXmlDocument xmlDoc = (ITcXmlDocument)item;

            xmlDoc.DocumentXml = doc.OuterXml;
            ITcPlcDeclaration decl = (ITcPlcDeclaration)item;

            //decl.DeclarationText = node.InnerText;
            return(item);
        }
        private ITcSmTreeItem createWorksheet2(WorksheetInfo info, ITcSmTreeItem parent, IWorker worker)
        {
            string template = Path.Combine(ApplicationDirectory, info.TemplatePath);

            XmlDocument doc = new XmlDocument();

            doc.Load(template);

            ITcSmTreeItem ret = null;

            switch (info.Type)
            {
            case PlcObjectType.DataType:
                ret = createDut((DataTypeInfo)info, parent, worker, doc);
                break;

            case PlcObjectType.POU:
                ret = createPou((POUInfo)info, parent, worker, doc);
                break;

            case PlcObjectType.Itf:
                ret = createItf((ItfInfo)info, parent, worker, doc);
                break;

            case PlcObjectType.Gvl:
                ret = createGvl((GvlInfo)info, parent, worker, doc);
                break;

            default:
                Debug.Fail("");
                break;
            }

            return(ret);
        }
        private ITcSmTreeItem createPlcFolder(ITcSmTreeItem parent, string folderName, string before, IWorker worker)
        {
            worker.ProgressStatus = string.Format("Creating Folder '{0}' ...", folderName);
            ITcSmTreeItem item = parent.CreateChild(folderName, TreeItemType.PlcFolder.AsInt32(), before, null);

            return(item);
        }
Ejemplo n.º 14
0
        protected override void OnExecute(IWorker worker)
        {
            worker.Progress = 0;

            ITcSmTreeItem plcConfig = systemManager.LookupTreeItem("TIPC"); // Getting PLC-Configuration

            CreatePlcProject(worker);                                       // Method of CodeGenerationBaseScript to create a new PLC project.
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Checks that the specified tag in the XML from the project tree matches the expected value.
        /// </summary>
        /// <param name="plcProjectItem">The tree to search.</param>
        /// <param name="tag">The tag to search for.</param>
        /// <param name="expected">The expected value.</param>
        /// <returns>True if the value is found, else false.</returns>
        private Boolean checkXmlIsString(ITcSmTreeItem plcProjectItem, String tag, String expected)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(plcProjectItem.ProduceXml(true));
            XmlNodeList loggedIn = doc.SelectNodes(String.Format("//{0}", tag));

            return(loggedIn.Item(0).InnerText.Equals(expected));
        }
        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 ConsumeTemplate(ITcSmTreeItem item, string templatePath)
        {
            string templ = Path.Combine(ApplicationDirectory, templatePath);

            XmlTextReader reader = new XmlTextReader(templ);

            reader.MoveToContent();
            item.ConsumeXml(reader.ReadOuterXml());
        }
        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);
        }
Ejemplo n.º 19
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.º 20
0
        }//CreatePLCVariable()

        private void LinkIoToPlc(ITcSmTreeItem drive)
        {
            /*------------------------------------------
             * This is a placehiolder method for the code needed to link our drives to the PLC.
             * When we say PLC we mean explicitly and exclusively the PLC, no NC task/configuration
             * can be used.
             * -----------------------------------------*/


            string plcInputsPath  = "TIPC^Untitled1^Untitled1 Instance^PlcTask Inputs";
            string plcOutputsPath = "TIPC^Untitled1^Untitled1 Instance^PlcTask Outputs";
            string drivePath      = drive.PathName;
            string boxName        = drive.Name;

            // Create links between the current drive and the PLC structure

            //Link the inputs
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Input 1", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Input_1");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Input 2", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Input_2");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Input 3", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Input_3");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Input 4", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Input_4");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Control input 1", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Control_input_1");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Control input 2", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Control_input_2");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Control input 3", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Control_input_3");
            this.sysMan.LinkVariables(drivePath + "^DI Inputs^Control input 4", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Control_input_4");
            this.sysMan.LinkVariables(drivePath + "^STM Status Channel 1^Status", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_1_Status");
            this.sysMan.LinkVariables(drivePath + "^STM Status Channel 2^Status", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_2_Status");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 1^Info data 1", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_1_info_data_1");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 1^Info data 2", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_1_info_data_2");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 1^Info data 3", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_1_info_data_3");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 2^Info data 1", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_2_info_data_1");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 2^Info data 2", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_2_info_data_2");
            this.sysMan.LinkVariables(drivePath + "^STM Synchron info data Channel 2^Info data 3", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Channel_2_info_data_3");
            this.sysMan.LinkVariables(drivePath + "^STM Inputs Device^Device Diag", plcInputsPath + "^EP7402_List.st" + boxName + ".stInputs^Device_Diag");

            //Link the Outputs
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Output 1", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Output_1");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Output 2", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Output_2");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Output 3", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Output_3");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Output 4", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Output_4");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Control output 1", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Control_output_1");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Control output 2", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Control_output_2");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Control output 3", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Control_output_3");
            this.sysMan.LinkVariables(drivePath + "^DO Outputs^Control output 4", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Control_output_4");
            this.sysMan.LinkVariables(drivePath + "^STM Control Channel 1^Control", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_1_Control");
            this.sysMan.LinkVariables(drivePath + "^STM Control Channel 2^Control", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_2_Control");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 1^Velocity", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_1_Velocity");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 1^Accelleration", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_1_Accelleration");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 1^Decceleration", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_1_Decceleration");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 2^Velocity", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_2_Velocity");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 2^Accelleration", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_2_Accelleration");
            this.sysMan.LinkVariables(drivePath + "^STM Target Velocity Channel 2^Decceleration", plcOutputsPath + "^EP7402_List.st" + boxName + ".stOutputs^Channel_2_Decceleration");
        }//LinkIoToPlc()
Ejemplo n.º 21
0
        private Boolean login(ITcSmTreeItem plcApp)
        {
            Console.WriteLine("Logging in");
            plcApp.ConsumeXml(createXMLString(PLCAction.LOGIN));

            if (!checkWithTimeout(COMMAND_TIMEOUT, () => checkXmlIsString(plcApp, "LoggedIn", "true")))
            {
                Console.WriteLine("Failed to login!");
                return(false);
            }
            return(true);
        }
 private bool TryLookupChild(ITcSmTreeItem parent, string childName, out ITcSmTreeItem child)
 {
     foreach (ITcSmTreeItem c in parent)
     {
         if (c.Name == childName)
         {
             child = c;
             return(true);
         }
     }
     child = null;
     return(false);
 }
 private bool TryLookupChild2(ITcSmTreeItem parent, string childName, out ITcSmTreeItem child)
 {
     try
     {
         child = parent.LookupChild(childName);
         return(true);
     }
     catch
     {
         child = null;
         return(false);
     }
 }
 private bool TryLookupTreeItem(string itemPath, out ITcSmTreeItem treeItem)
 {
     try
     {
         treeItem = this.systemManager.LookupTreeItem(itemPath);
         return(true);
     }
     catch
     {
         treeItem = null;
         return(false);
     }
 }
Ejemplo n.º 25
0
        //<Not used>
        public void addBaseSln(String slnBasePath)                                            //For adding collab code automatically - requires better gitbash
        {
            string        template = slnBasePath + @"\tc_project_app\tc_project_app.plcproj"; //path toproject template
            ITcSmTreeItem plc      = SystemManager.LookupTreeItem("TIPC");

            try
            {
                ITcSmTreeItem newProject = plc.CreateChild("basePLC", 0, "", template);
            }
            catch
            {
                MessageBox.Show("Nope"); //Change the template so it detects version installed and knows where to look
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Export xti file for a given device number under the IO (Will retain mappings by default)
 /// </summary>
 /// <param name="deviceNumber"></param>
 public Boolean exportHardwareXTI(int deviceNumber)
 {
     try
     {
         //ITcSmTreeItem io = SystemManager.LookupTreeItem("TIID");
         ITcSmTreeItem deviceName = Io.Child[deviceNumber];
         Io.ExportChild(deviceName.Name, ConfigFolder + IoFile);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 27
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()
Ejemplo n.º 28
0
 public static bool SearchForSubItem(string itemToLookFor, ref ITcSmTreeItem parentItem, ref ITcSmTreeItem childItem)
 {
     try
     {
         childItem = parentItem.LookupChild(itemToLookFor);
         Console.WriteLine(itemToLookFor + " item found.");
     }
     catch (Exception e)
     {
         Console.WriteLine(itemToLookFor + " item not found. Exiting on Enter.");
         Console.Read();
         Environment.Exit(-1);
     }
     return(true);
 }
        private ITcSmTreeItem CreateBox(ITcSmTreeItem parent, BoxInfo boxInfo, IWorker worker)
        {
            worker.ProgressStatus = string.Format("Creating Box '{0}' ({1})...", boxInfo.Name, boxInfo.Type);
            ITcSmTreeItem ret = parent.CreateChild(boxInfo.Name, (int)BoxType.EtherCAT_EXXXXX, "", boxInfo.Type);

            if (boxInfo.ChildBoxes != null)
            {
                foreach (BoxInfo child in boxInfo.ChildBoxes)
                {
                    ITcSmTreeItem tcChild = CreateBox(ret, child, worker);
                }
            }

            return(ret);
        }
        protected void CreateMotion(IWorker worker)
        {
            if (worker.CancellationPending)
            {
                throw new Exception("Execution cancelled!");
            }

            OrderScriptContext context           = (OrderScriptContext)_context;
            ConfigurationInfo  configurationInfo = context.Order.ConfigurationInfo;

            ITcSmTreeItem ncConfig = systemManager.LookupTreeItem("TINC");

            foreach (TaskInfo taskInfo in configurationInfo.MotionTasks)
            {
                ITcSmTreeItem task = null;

                worker.ProgressStatus = string.Format("Creating Motion Task '{0}'", taskInfo.Name);

                if (!TryLookupChild(ncConfig, taskInfo.Name, out task))
                {
                    task = ncConfig.CreateChild(taskInfo.Name, 1);
                }
                ITcSmTreeItem axes = null;
                TryLookupChild(task, "Axes", out axes);

                if (axes == null)
                {
                    TryLookupChild(task, "Achsen", out axes);
                }

                foreach (AxisInfo axisInfo in taskInfo.Axes)
                {
                    if (worker.CancellationPending)
                    {
                        throw new Exception("Execution cancelled!");
                    }

                    ITcSmTreeItem axis = null;
                    worker.ProgressStatus = string.Format("Creating Axis '{0}'", axisInfo.Name);

                    if (!TryLookupChild(axes, axisInfo.Name, out axis))
                    {
                        axis = axes.CreateChild(axisInfo.Name, 1);
                        ConsumeTemplate(axis, axisInfo.TemplatePath);
                    }
                }
            }
        }