Example #1
0
        private Page[] SerachByFullPageName(Project targetProject, string pageName, bool exactNameMatching = true)
        {
            #region Parameter Validation

            if (targetProject == null)
            {
                throw new ArgumentNullException(nameof(targetProject));
            }

            if (string.IsNullOrWhiteSpace(pageName))
            {
                throw new ArgumentNullException(nameof(pageName));
            }

            #endregion

            using (DMObjectsFinder finder = new DMObjectsFinder(targetProject))
                using (PagesFilter filter = new PagesFilter())
                {
                    filter.ExactNameMatching = exactNameMatching;
                    filter.Name = pageName;

                    return(finder.GetPages(filter));
                }
        }
Example #2
0
        public IEnumerable <Page> FilterPage(Project targetProject, string functionalAssignment, string plant, string location, string docType)
        {
            try
            {
                DMObjectsFinder  pageFinder     = new DMObjectsFinder(targetProject);
                PagesFilter      pageFilter     = new PagesFilter();
                PagePropertyList pageProperties = new PagePropertyList();

                pageProperties.DESIGNATION_FUNCTIONALASSIGNMENT = functionalAssignment;
                pageProperties.DESIGNATION_PLANT    = plant;
                pageProperties.DESIGNATION_LOCATION = location;
                pageProperties.DESIGNATION_DOCTYPE  = docType;

                pageFilter.SetFilteredPropertyList(pageProperties);

                Page[] filteredPages  = pageFinder.GetPages(pageFilter);
                int    totalPageCount = filteredPages.Length;

                MessageBox.Show("페이지 필터가 성공적으로 실행되었습니다.", "페이지 필터 성공", MessageBoxButtons.OK, MessageBoxIcon.Information);

                for (int pageIndex = 0; pageIndex < totalPageCount; pageIndex++)
                {
                    MessageBox.Show(string.Format("페이지[{0}] = [{1}]", pageIndex, filteredPages[pageIndex].Name), "페이지 필터 성공", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                return(filteredPages);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "페이지 필터 에러", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw ex;
            }
        }
Example #3
0
        private Page[] SerachPage(Project targetProject, PagePropertyList properties, bool exactNameMatching = false)
        {
            #region Parameter Validation

            if (targetProject == null)
            {
                throw new ArgumentNullException(nameof(targetProject));
            }

            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            #endregion

            using (DMObjectsFinder finder = new DMObjectsFinder(targetProject))
                using (PagesFilter filter = new PagesFilter())
                {
                    filter.ExactNameMatching = exactNameMatching;
                    filter.SetFilteredPropertyList(properties);

                    return(finder.GetPages(filter));
                }
        }
Example #4
0
        public static Page[] EplGetPages(string pageFilter, Project project)
        {
            DMObjectsFinder oFinder      = new DMObjectsFinder(project);
            PagesFilter     oPagesFilter = new PagesFilter();

            oPagesFilter.Name         = pageFilter;
            oPagesFilter.DocumentType = DocumentTypeManager.DocumentType.Undefined;
            //now we have all pages with names starting with "=AP+ST1" and type with "DocumentType.Frame"
            Page[] oPages = oFinder.GetPages(oPagesFilter);
            return(oPages);
        }
Example #5
0
        /// <summary>
        /// Синхронизация названий устройств и модулей
        /// </summary>
        /// <returns>Возвращает сообщения об ошибках во время выполнения.
        /// </returns>
        public string Execute()
        {
            ProjectConfiguration.GetInstance().ReadIO();
            if (ProjectConfiguration.GetInstance().DevicesIsRead == true)
            {
                ProjectConfiguration.GetInstance().SynchronizeDevices();
            }
            else
            {
                ProjectConfiguration.GetInstance().ReadDevices();
            }
            ProjectConfiguration.GetInstance().ReadBinding();

            ProjectConfiguration.GetInstance().Check();
            IO.IOManager.GetInstance().CalculateIOLinkAdresses();

            var     selection    = new SelectionSet();
            Project project      = selection.GetCurrentProject(true);
            var     objectFinder = new DMObjectsFinder(project);

            var functionsFilter = new FunctionsFilter();
            var properties      = new FunctionPropertyList();

            properties.FUNC_MAINFUNCTION = true;
            functionsFilter.SetFilteredPropertyList(properties);
            functionsFilter.Category = Function.Enums.Category.PLCBox;
            Function[] devicesFunctions = objectFinder.
                                          GetFunctions(functionsFilter);

            project.LockAllObjects();

            Dictionary <string, string> deviceConnections =
                CollectIOModulesData(devicesFunctions);

            bool containsNewValveTerminal = GetProjectVersionFromDevices(
                deviceConnections);

            synchronizedDevices.Clear();

            if (!containsNewValveTerminal)
            {
                SynchronizeAsOldProject(deviceConnections, devicesFunctions);
            }
            else
            {
                SynchronizeAsNewProject(deviceConnections, devicesFunctions);
            }

            ClearNotExistingBinding();

            return(errorMessage);
        }
Example #6
0
        /// <summary>
        /// Подготовка к чтению привязки.
        /// </summary>
        private void PrepareForReading()
        {
            var objectsFinder = new DMObjectsFinder(ApiHelper.GetProject());

            var properties = new FunctionPropertyList();
            properties.FUNC_MAINFUNCTION = true;
            
            var plcFilter = new FunctionsFilter();
            plcFilter.SetFilteredPropertyList(properties);
            plcFilter.Category = Function.Enums.Category.PLCBox;

            functionsForSearching = objectsFinder.GetFunctions(plcFilter);
        }
        public static List <Function> GetAnnotatedFunctions(Project pr)
        {
            DMObjectsFinder  objectFinder     = new DMObjectsFinder(pr);
            AnnotationFilter annotationFilter = new AnnotationFilter();

            Function[] soa = objectFinder.GetFunctionsWithCF(annotationFilter);

            foreach (Function f in soa)
            {
                Debug.WriteLine("function x: " + f.Location.X);
                Debug.WriteLine("function y: " + f.Location.Y);
            }

            return(soa.ToList <Function>());
        }
Example #8
0
        /// <summary>
        /// Подготовка к чтению устройств
        /// </summary>
        private void PrepareForReading()
        {
            deviceManager.Clear();
            var objectFinder = new DMObjectsFinder(ApiHelper.GetProject());

            var propertyList = new FunctionPropertyList();

            propertyList.FUNC_MAINFUNCTION = true;

            var functionsFilter = new FunctionsFilter();

            functionsFilter.IsPlaced = true;
            functionsFilter.SetFilteredPropertyList(propertyList);

            deviceFunctions = objectFinder.GetFunctions(functionsFilter);
        }
        /// <summary>
        /// Renames the InterruptionPoint
        /// </summary>
        /// <param name="interruptionPoint"></param>
        /// <param name="functionBasePropertyList"></param>
        public static void RenameAll(InterruptionPoint interruptionPoint, FunctionBasePropertyList functionBasePropertyList)
        {
            // Get all Interruptionpoints
            DMObjectsFinder          objectsFinder            = new DMObjectsFinder(interruptionPoint.Project);
            InterruptionPointsFilter interruptionPointsFilter = new InterruptionPointsFilter();

            interruptionPointsFilter.Name = interruptionPoint.Name;
            InterruptionPoint[] interruptionPoints = objectsFinder.GetInterruptionPoints(interruptionPointsFilter);

            // Device tag
            foreach (InterruptionPoint ip in interruptionPoints)
            {
                NameService nameService = new NameService(ip.Page);
                ip.LockObject();
                ip.NameParts = functionBasePropertyList;
                nameService.AdjustVisibleName(ip);
            }
        }
Example #10
0
        /// <summary>
        /// Поиск функции модуля ввода-вывода к которой привязан пневмоостров
        /// </summary>
        /// <param name="clampFunction">Функция клеммы модуля
        /// ввода-вывода</param>
        /// <returns>Функция модуля ввода-вывода</returns>
        private static Function GetValveTerminalIOModuleFunction(
            Function clampFunction)
        {
            var IOModuleFunction = new Function();

            string valveTerminalName = Regex.Match(clampFunction.Name,
                                                   Device.DeviceManager.valveTerminalPattern).Value;

            if (string.IsNullOrEmpty(valveTerminalName))
            {
                const string Message = "Ошибка поиска ОУ пневмоострова";
                throw new Exception(Message);
            }

            var objectFinder    = new DMObjectsFinder(ApiHelper.GetProject());
            var functionsFilter = new FunctionsFilter();
            var properties      = new FunctionPropertyList();

            properties.FUNC_MAINFUNCTION = true;
            functionsFilter.SetFilteredPropertyList(properties);
            functionsFilter.Category = Function.Enums.Category.PLCBox;
            Function[] functions = objectFinder.GetFunctions(functionsFilter);

            foreach (Function function in functions)
            {
                Function[] subFunctions = function.SubFunctions;
                if (subFunctions != null)
                {
                    foreach (Function subFunction in subFunctions)
                    {
                        var functionalText = subFunction.Properties
                                             .FUNC_TEXT_AUTOMATIC
                                             .ToString(ISOCode.Language.L___);
                        if (functionalText.Contains(valveTerminalName))
                        {
                            IOModuleFunction = subFunction.ParentFunction;
                            return(IOModuleFunction);
                        }
                    }
                }
            }
            return(IOModuleFunction);
        }
Example #11
0
        /// <summary>
        /// Подготовка к чтению IO.
        /// </summary>
        private void PrepareForReading()
        {
            var project         = ApiHelper.GetProject();
            var objectsFinder   = new DMObjectsFinder(project);
            var functionsFilter = new FunctionsFilter();

            var properties = new FunctionPropertyList();

            properties.FUNC_MAINFUNCTION = true;

            functionsFilter.SetFilteredPropertyList(properties);
            functionsFilter.Category = Function.Enums.Category.PLCBox;

            functionsForSearching = objectsFinder.GetFunctions(functionsFilter)
                                    .ToList();
            functionsForSearching.Sort(CompareFunctions);

            IOManager.Clear();
            isContainsNodes = false;
            isContainsA1    = CheckA1();
        }
Example #12
0
        /// <summary>
        /// Returns all objects of a EPLAN project
        /// </summary>
        /// <param name="project">EPLAN project</param>
        /// <returns>List of Placements</returns>
        public static List <Placement> GetAllObjects(Project project)
        {
            DMObjectsFinder dmObjectsFinder = new DMObjectsFinder(project);

            return(dmObjectsFinder.GetPlacements(null).ToList());
        }
Example #13
0
        void Update(object devin)
        {
            using (LockingStep oLS = new LockingStep())
            { // ... доступ к данным P8 ...
                SelectionSet Set            = new SelectionSet();
                Project      CurrentProject = Set.GetCurrentProject(true);
                projectname = CurrentProject.ProjectFullName;
                StorableObject[]  storableObjects = Set.Selection;
                List <Page>       Lpage           = Set.GetSelectedPages().ToList();
                DMObjectsFinder   dmObjectsFinder = new DMObjectsFinder(CurrentProject);
                List <Function3D> place3d;
                //place3d = dmObjectsFinder.GetFunctions3D(null).ToList();
                List <Function> place;
                //place = dmObjectsFinder.GetFunctions(null).ToList();
                List <Terminal> ltermlist;
                functype        devl = new functype();
                ((List <functype>)devin).Clear();
                int  id        = 0;
                int  id3d      = 0;
                bool placefind = false;
                progressBar1.Value   = 0;
                progressBar1.Maximum = Lpage.Count;

                for (int i = 0; i < Lpage.Count; i++)
                {
                    Type ltp = Lpage[i].GetType();
                    if (ltp.Name == "Page")
                    {
                        place = Lpage[i].Functions.ToList();
                        FunctionsFilter oterfilt = new FunctionsFilter();
                        oterfilt.Page = Lpage[i];
                        ltermlist     = dmObjectsFinder.GetTerminals(oterfilt).ToList();
                        //MessageBox.Show(ltermlist.Count.ToString());
                        for (int j = 0; j < place.Count; j++)
                        {
                            id += 1;
                            if (place[j].IsMainFunction != true)
                            {
                                continue;
                            }                                                  //// Проверяем является ли функция главной
                            //if (place[j].Properties.DESIGNATION_LOCATION.ToString() != listBox1.SelectedItem.ToString()) { continue; }
                            Functions3DFilter      f3d = new Functions3DFilter();
                            Function3DPropertyList oFunction3DPropertyList = new Function3DPropertyList();
                            oFunction3DPropertyList.DESIGNATION_LOCATION = place[j].Properties.DESIGNATION_LOCATION;
                            f3d.SetFilteredPropertyList(oFunction3DPropertyList);
                            place3d   = dmObjectsFinder.GetFunctions3D(f3d).ToList();
                            id3d     += place3d.Count;
                            placefind = false;
                            for (int l = 0; l < place3d.Count; l++)
                            {
                                //MessageBox.Show("F"+ place[j].ObjectIdentifier.ToString()+"F3D "+ place3d[l].ObjectIdentifier+"\n"+ place[j].Name+" "+place3d[l].Name);

                                if (place[j].Properties.FUNC_IDENTDEVICETAGWITHOUTSTRUCTURES == place3d[l].Properties.FUNC_IDENTDEVICETAGWITHOUTSTRUCTURES)
                                {
                                    placefind = true;
                                    break;
                                }
                            }
                            if (placefind == false)
                            {
                                devl.Name        = place[j].Name;
                                devl.Page        = Lpage[i].Name;
                                devl.Designation = place[j].Properties.DESIGNATION_LOCATION;
                                ((List <functype>)devin).Add(devl);
                            }
                        }

                        for (int t = 0; t < ltermlist.Count; t++)
                        {
                            if (ltermlist[t].IsMainTerminal != true)
                            {
                                continue;
                            }                                                      //// Проверяем является ли функция главной
                            //if (place[j].Properties.DESIGNATION_LOCATION.ToString() != listBox1.SelectedItem.ToString()) { continue; }
                            Functions3DFilter      f3d = new Functions3DFilter();
                            Function3DPropertyList oFunction3DPropertyList = new Function3DPropertyList();
                            oFunction3DPropertyList.DESIGNATION_LOCATION = ltermlist[t].Properties.DESIGNATION_LOCATION;
                            f3d.SetFilteredPropertyList(oFunction3DPropertyList);
                            place3d = dmObjectsFinder.GetFunctions3D(f3d).ToList();
                            id3d   += place3d.Count;
                            // MessageBox.Show(ltermlist[t].Name.ToString());
                            placefind = false;
                            for (int l = 0; l < place3d.Count; l++)
                            {
                                if (ltermlist[t].Name.ToString() == place3d[l].Name.ToString())
                                {
                                    placefind = true;
                                    break;
                                }
                            }
                            if (placefind == false)
                            {
                                devl.Name        = ltermlist[t].Name;
                                devl.Page        = Lpage[i].Name;
                                devl.Designation = ltermlist[t].Properties.DESIGNATION_LOCATION;
                                ((List <functype>)devin).Add(devl);
                            }
                        }
                    }
                    progressBar1.Value += 1;
                }
                label4.Text = id.ToString();
                label7.Text = id3d.ToString();
            }
        }
Example #14
0
        public bool Execute(ActionCallingContext oActionCallingContext)
        {
            // MessageBox.Show("Checkout Action");

            SelectionSet selectionSet = new SelectionSet();
            Project      project      = selectionSet.GetCurrentProject(true);

            //string creator = project.Properties[10013];
            //MessageBox.Show(creator);

            //Location[] location = project.GetLocationObjects(Project.Hierarchy.Plant);
            //string strDesc1 = ISOCodeUtil.GetISOStringValue(location[0].Properties.LOCATION_DESCRIPTION_SUPPLEMENTARYFIELD[1]);

            //MessageBox.Show(strDesc1);

            Page[] pages = project.Pages;

            DMObjectsFinder  finder = new DMObjectsFinder(project);
            PagePropertyList ppl    = new PagePropertyList();

            // ppl.DESIGNATION_LOCATION = "C1";
            // ppl.DESIGNATION_DOCTYPE = "SINGLE";
            // ppl.DESIGNATION_DOCTYPE = "MULTI";
            ppl.PAGE_TYPE_NUMERIC = 1;

            PagesFilter pf = new PagesFilter();

            pf.SetFilteredPropertyList(ppl);

            Page[] sPages = finder.GetPages(pf);

            // sPages[0].
            //FunctionPropertyList fpl = new FunctionPropertyList();

            //FunctionsFilter ff = new FunctionsFilter();
            //ff.SetFilteredPropertyList()

            ArrayList list = new ArrayList();

            Function[] ffss = finder.GetFunctions(null);

            foreach (Function f in ffss)
            {
                if (f.Category == Function.Enums.Category.Motor)
                {
                    list.Add(f);
                    ArticleReference[] ars = f.ArticleReferences;

                    if (ars.Count() > 0)
                    {
                        int     count   = ars[0].Count;
                        Article article = ars[0].Article;
                    }
                }
            }

            ArticleReferencePropertyList arpl = new ArticleReferencePropertyList();

            arpl.ARTICLE_MANUFACTURER = "RITTAL";
            ArticleReferencesFilter arf = new ArticleReferencesFilter();

            arf.SetFilteredPropertyList(arpl);

            ArticleReference[] fars = finder.GetArticleReferences(arf);

            foreach (ArticleReference item in fars)
            {
                // MessageBox.Show(string.Format("{0}[{1}]({2})", item.Properties.ARTICLEREF_PARTNO, item.Properties.ARTICLE_MANUFACTURER, item.Count));
            }

            // ArticleReference[] farsws = finder.GetArticleReferencesWithFilterScheme("default"); // P8에서 정의한 스키마로 필터

            //PagePropertyList newppl = new PagePropertyList();
            //// newppl.DESIGNATION_LOCATION = "MULTI";
            //newppl.DESIGNATION_DOCTYPE = "MULTI";
            //newppl.PAGE_COUNTER = "11";
            //newppl.PAGE_NOMINATIOMN = "Insert Macro By API";
            //newppl.PAGE_IDENTNAME = "1011";
            //newppl.PAGE_NUMBER = "11";
            //newppl.PAGE_NAME = "Insert Macro By API";

            //Page newPage = new Page();
            //newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl);

            //Insert insert = new Insert();
            //PointD point = new PointD(100, 250);
            //var resultObject = insert.WindowMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\m.ema", 0, newPage, point, Insert.MoveKind.Absolute);

            PagePropertyList newppl = new PagePropertyList();

            newppl.DESIGNATION_DOCTYPE = "MULTI";
            newppl.PAGE_COUNTER        = "211";
            newppl.PAGE_NOMINATIOMN    = "Insert Page Macro By API";
            newppl.PAGE_IDENTNAME      = "2011";
            newppl.PAGE_NUMBER         = "211";
            newppl.PAGE_NAME           = "Insert Page Macro By API";

            Page newPage = new Page();

            newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl);

            Insert insert       = new Insert();
            var    resultObject = insert.PageMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\mPage.emp", newPage, project, false, PageMacro.Enums.NumerationMode.Number);

            return(true);
        }