Example #1
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 #2
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);
        }
Example #3
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);
        }
Example #4
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 #5
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 #6
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);
        }