Пример #1
0
        public static void GetDevices()
        {
            // Объекты массивов Id
            Object DevIds = new Object();
            //Object textIds = new Object();
            string placedName;


            App?.PutInfo(0, "Starting GetDevices!");
            Prj = (e3Job)App?.CreateJobObject();
            Sym = (e3Symbol)Prj.CreateSymbolObject();
            Dev = (e3Device)Prj.CreateDeviceObject();
            Cmp = (e3Component)Prj.CreateComponentObject();
            Pin = (e3Pin)Prj.CreatePinObject();

            // Получаем массив Id устройств
            int nd = Prj.GetAllDeviceIds(ref DevIds);
            // Переменные среды
            int    PinCnt;
            Object PinIds = new Object();
            string imbaseKEY;
            bool   DoItAgain = false;

            ///////////////////////////////////////
            prjNum    = Prj.GetAttributeValue("NUMPROJ") + " ПЭ3";
            placename = Prj.GetAttributeValue("OBOZNACHENIE") + " " + Prj.GetAttributeValue("Uslovn_obozn") + " " + Prj.GetAttributeValue("Name_of_schemes") + ". Перечень элементов";
            executor  = Prj.GetAttributeValue("vyp");


            if (Prj.GetName().Length > 18)
            {
                AVSName = Prj.GetName().Substring(0, 18) + ".PE";
            }
            else
            {
                AVSName = Prj.GetName() + ".PE";
            }
            AVSFileNew = Prj.GetPath() + AVSName; //'Имя файла AVS(без пробелов)
            /////////////////////////////////////////



            foreach (var devId in (Array)DevIds)
            {
                if (devId != null)
                {
                    Dev.SetId((int)devId);
                    Cmp.SetId((int)devId);

                    if (Dev.IsWireGroup() == 0 && Dev.IsCable() == 0 && Dev.GetComponentName() != "" && Dev.IsAssembly() == 0)
                    {
                        bool   isTerminal = (Dev.IsTerminal() == 1 && Dev.IsTerminalBlock() != 1);
                        string pinName    = null;
                        string axapta     = "";
                        // Позиционное обозначение
                        placedName = Dev.GetName();
                        // Если клемма
                        if (isTerminal)
                        {
                            PinCnt = Dev.GetPinIds(ref PinIds);
                            if (PinCnt > 0) // если выводов нет, то и клемма не попадет в отчет...
                            {
                                foreach (var pinId in (Array)PinIds)
                                {
                                    if (pinId == null)
                                    {
                                        continue;
                                    }
                                    Pin.SetId((int)pinId);
                                    if (Pin.GetName() != "")
                                    {
                                        pinName = Pin.GetName();
                                    }
                                    break;
                                }
                            }
                        }

                        imbaseKEY = Cmp.GetAttributeValue("Imbase_KEY");
                        if (imbaseKEY.Length != "i609010608038500008C".Length && imbaseKEY.Length != 1)
                        {
                            Prj.JumpToID((int)devId);
                            e3Dbe = new e3DbeApplication(); // объект приложения
                            e3Dbe.EditComponent(Dev.GetComponentName(), Dev.GetComponentVersion());
                            //        msgbox "Не корректный ключ Imbase - " & ImbaseKEY & " - изделия - " & dev.getname
                            Console.WriteLine($"Не корректный ключ Imbase - {imbaseKEY} - изделия - {Dev.GetName()}");
                            Console.WriteLine("Нажмите 'Enter' после корректировки изделия");
                            Console.ReadLine();
                            //'обновить
                            Prj.UpdateComponent(Cmp.GetName(), 0);
                            imbaseKEY = Cmp.GetAttributeValue("Imbase_KEY");
                            DoItAgain = true;
                        }
                        // devList.Add(new E3Device(placedName, new string[] {Dev.GetComponentName(), imbaseKEY, Cmp.GetAttributeValue("Description"), Dev.GetAttributeValue("Primechanie"), Dev.GetAttributeValue("Исполнение")}, pinName));


                        if (imbaseKEY.Length == "i609010608038500008C".Length)
                        {
                            if (isTerminal)
                            {
                                devList.Add(new E3Device(placedName, new string[] { "I" + imbaseKEY, "6", placedName + ":" + pinName, ImBaseEx.GetFullDesignation(imbaseKEY, ref axapta).Replace("\"\"", "\""), "1", Dev.GetAttributeValue("Primechanie"), axapta, "1" }, pinName));
                            }
                            else
                            {
                                devList.Add(new E3Device(placedName, new string[] { "I" + imbaseKEY, "6", placedName, ImBaseEx.GetFullDesignation(imbaseKEY, ref axapta).Replace("\"\"", "\""), "1", Dev.GetAttributeValue("Primechanie"), axapta, "1" }, pinName));
                            }
                        }
                        else
                        {
                            if (isTerminal)
                            {
                                devList.Add(new E3Device(placedName, new string[] { "Нет данных", "5", placedName + ":" + pinName, Cmp.GetAttributeValue("Description"), "1", Dev.GetAttributeValue("Primechanie"), "Нет данных", "1" }, pinName));
                            }
                            else
                            {
                                devList.Add(new E3Device(placedName, new string[] { "Нет данных", "5", placedName, Cmp.GetAttributeValue("Description"), "1", Dev.GetAttributeValue("Primechanie"), "Нет данных", "1" }, pinName));
                            }
                        }
                    }
                    if (DoItAgain)
                    {
                        // Думаю можно продолжать без выхода
                        // Environment.Exit(0);
                    }
                }
            }
            // Сортировка устройств
            devList.Sort(delegate(E3Device x, E3Device y)
            {
                if (x.IsTerminal() && x.Name == y.Name)
                {
                    if (x.SortPinValue() == y.SortPinValue())
                    {
                        return(x.PinName.CompareTo(y.PinName));
                    }
                    else
                    {
                        return(x.SortPinValue().CompareTo(y.SortPinValue()));
                    }
                }
                else
                {
                    if (GetLetter(x.Name) == GetLetter(y.Name))
                    {
                        return(x.SortNameValue().CompareTo(y.SortNameValue()));
                    }
                    else
                    {
                        return(x.Name.CompareTo(y.Name));
                    }
                }
            });

            foreach (E3Device dev in devList)
            {
                //   Console.WriteLine(dev);
                SortDevList(dev);
            }

            Debug.Flush();
        }
Пример #2
0
 protected Pin(int id, E3ObjectFabric e3ObjectFabric)
 {
     this.e3ObjectFabric = e3ObjectFabric;
     pin = e3ObjectFabric.GetPin(id);
 }