protected void CreateMappings(IWorker worker)
        {
            OrderScriptContext context           = (OrderScriptContext)_context;
            ConfigurationInfo  configurationInfo = context.Order.ConfigurationInfo;

            MappingsInfo info = configurationInfo.Mappings;

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

                worker.ProgressStatus = "Generating mappings ...";
                ConsumeMappings(info.TemplatePath);
            }
        }
Exemple #2
0
        /* ===============================================================================================
         * Constructor
         * =============================================================================================== */
        public ConfigurationInfo(XmlElement configNode)
        {
            XmlDocument doc = configNode.OwnerDocument;

            /* ------------------------------------------------------------------
             * Read configuration attributes 'id' and 'name'
             * ------------------------------------------------------------------ */
            this._id   = configNode.Attributes["id"].Value;
            this._name = configNode.Attributes["name"].Value;

            /* ------------------------------------------------------------------
             * Read configuration node 'ProjectTemplates'
             * ------------------------------------------------------------------ */
            XmlNode projectTemplateNode = configNode.SelectSingleNode("ProjectTemplate");

            if (projectTemplateNode != null)
            {
                this._projectTemplate = projectTemplateNode.InnerText;
            }

            /* ------------------------------------------------------------------
             * Read configuration node 'Script'
             * ------------------------------------------------------------------ */
            XmlNode scriptNode = configNode.SelectSingleNode("Script");

            this._script = scriptNode.InnerText;

            /* ------------------------------------------------------------------
             * Read configuration node 'Description'
             * ------------------------------------------------------------------ */
            XmlNode descriptionNode = configNode.SelectSingleNode("Description");

            this._description = descriptionNode.InnerText;

            /* ------------------------------------------------------------------
             * Read configuration node 'Plc\PlcProjectName'
             * ------------------------------------------------------------------ */
            XmlNode plcNameNode = configNode.SelectSingleNode("Plc/PlcProjectName");

            if (plcNameNode != null)
            {
                _plcProjectName = plcNameNode.InnerText;
            }
            else
            {
                _plcProjectName = "GeneratedProject";
            }

            /* ------------------------------------------------------------------
             * Read configuration node 'Plc\PlcObjects\PlcObject' and all child nodes
             * ------------------------------------------------------------------ */
            _plcObjects = new List <PlcObjectInfo>();
            XmlNodeList plcObjectNodeList = configNode.SelectNodes("Plc/PlcObjects/PlcObject");

            addPlcElements(ref _plcObjects, plcObjectNodeList);

            /* ------------------------------------------------------------------
             * Read configuration node 'Motion\Tasks'
             * ------------------------------------------------------------------ */
            _motionTasks = new List <TaskInfo>();
            XmlNodeList motionTasksNodeList = configNode.SelectNodes("Motion/Task");

            addMotionTasks(ref _motionTasks, motionTasksNodeList);

            /* ------------------------------------------------------------------
             * Read configuration node 'Hardware' and all child nodes
             * ------------------------------------------------------------------ */
            XmlElement hardwareElement = (XmlElement)configNode.SelectSingleNode("Hardware");

            _hardware = new HardwareInfo(hardwareElement);

            /* ------------------------------------------------------------------
             * Read configuration node 'Mappings' (note: mappings are specified in another XML file)
             * ------------------------------------------------------------------ */
            XmlNode mappingsNode = configNode.SelectSingleNode("Mappings");

            _mappings = new MappingsInfo((XmlElement)mappingsNode);

            /* ------------------------------------------------------------------
             * Read configuration node 'Options\Option' and all child nodes
             * ------------------------------------------------------------------ */
            _options = new List <OptionInfo>();
            XmlNodeList optionNodeRefs = configNode.SelectNodes("Options/Option");

            if (optionNodeRefs != null)
            {
                foreach (XmlNode optionNodeRef in optionNodeRefs)
                {
                    string optionId = optionNodeRef.InnerText;
                    string xPath    = string.Format("//Root/MachineOptions/Option[@id='{0}']", optionId);

                    XmlNode optionNode = doc.SelectSingleNode(xPath);

                    if (optionNode != null)
                    {
                        OptionInfo option = new OptionInfo((XmlElement)optionNode);
                        _options.Add(option);
                    }
                }
            }
        }