Exemple #1
0
 public CableInfo(CableDevice cable, string lengthAttribute)
 {
     Id      = cable.Id;
     Name    = cable.Name;
     Type    = String.Intern(cable.ComponentName);
     Length  = cable.GetAttributeValue(lengthAttribute);
     Length  = String.IsNullOrEmpty(Length) ? "0 м" : Length + " м";
     Signals = new List <string>();
 }
        private static void GetDeviceConnectionByIdAndCableInfoById(E3Project project, HashSet <int> electricSchemeSheetIds, out Dictionary <int, DeviceConnection> deviceConnectionById, out Dictionary <int, CableInfo> cableInfoById)
        {
            CableDevice  cable       = project.GetCableDeviceById(0);
            CableCore    core        = project.GetCableCoreById(0);
            NormalDevice startDevice = project.GetNormalDeviceById(0);
            NormalDevice endDevice   = project.GetNormalDeviceById(0);
            DevicePin    startPin    = project.GetDevicePinById(0);
            DevicePin    endPin      = project.GetDevicePinById(0);
            WireCore     wire        = project.GetWireCoreById(0);

            deviceConnectionById = new Dictionary <int, DeviceConnection>();
            cableInfoById        = new Dictionary <int, CableInfo>();
            int connectionId = 0;

            foreach (int cableId in project.CableIds)
            {
                cable.Id = cableId;
                foreach (int coreId in cable.CoreIds)
                {
                    core.Id = coreId;
                    int startPinId = core.StartPinId;
                    int endPinId   = core.EndPinId;
                    if (endPinId == 0 || startPinId == 0)   // проверка на неподключенные концы
                    {
                        continue;
                    }
                    startPin.Id = startPinId;                               // id вывода
                    if (!electricSchemeSheetIds.Contains(startPin.SheetId)) // проверка на то, что вывод расположен на принципиальной схеме
                    {
                        continue;
                    }
                    endPin.Id = endPinId;
                    if (!electricSchemeSheetIds.Contains(endPin.SheetId))
                    {
                        continue;
                    }
                    startDevice.Id = startPinId;
                    endDevice.Id   = endPinId;
                    if (startDevice.Assignment.Equals(endDevice.Assignment) && !(startDevice.GetAttributeValue("IncludeInOWS").Equals("1") || endDevice.GetAttributeValue("IncludeInOWS").Equals("1")))
                    {
                        continue;
                    }
                    string signal = startPin.SignalName;
                    deviceConnectionById.Add(connectionId++, new DeviceConnection(startDevice.Id, startPin.Name, endDevice.Id, endPin.Name, cableId, signal));
                    string lengthAttribute = "Lenght_m_sp";
                    if (!cableInfoById.ContainsKey(cableId))
                    {
                        cableInfoById.Add(cableId, new CableInfo(cable, lengthAttribute));
                    }
                    cableInfoById[cableId].Signals.Add(signal);
                }
            }
            foreach (int wireId in project.WireIds)
            {
                wire.Id = wireId;
                int startPinId = wire.StartPinId;
                int endPinId   = wire.EndPinId;
                if (endPinId == 0 || startPinId == 0)   // проверка на неподключенные концы
                {
                    continue;
                }
                startPin.Id = startPinId;                               // id вывода
                if (!electricSchemeSheetIds.Contains(startPin.SheetId)) // проверка на то, что вывод расположен на принципиальной схеме
                {
                    continue;
                }
                endPin.Id = endPinId;
                if (!electricSchemeSheetIds.Contains(endPin.SheetId))
                {
                    continue;
                }
                startDevice.Id = startPinId;
                endDevice.Id   = endPinId;
                if (startDevice.Assignment.Equals(endDevice.Assignment) && !(startDevice.GetAttributeValue("IncludeInOWS").Equals("1") || endDevice.GetAttributeValue("IncludeInOWS").Equals("1")))
                {
                    continue;
                }
                string signal = startPin.SignalName;
                deviceConnectionById.Add(connectionId++, new DeviceConnection(startDevice.Id, startPin.Name, endDevice.Id, endPin.Name, wireId, signal));
                string lengthAttribute = "Lenght_m_sp";
                if (!cableInfoById.ContainsKey(wireId))
                {
                    cableInfoById.Add(wireId, new CableInfo(wire, lengthAttribute));
                }
                cableInfoById[wireId].Signals.Add(signal);
            }
        }