private static List<ConnectionInfo> GetConnectionInfosByCoresAndWires(E3Project project) { List<ConnectionInfo> connectionInfos = new List<ConnectionInfo>(); CableDevice cable = project.GetCableDeviceById(0); Core core = project.GetCableCoreById(0); WireCore wire = project.GetWireCoreById(0); NormalDevice normalDevice = project.GetNormalDeviceById(0); DevicePin devicePin = project.GetDevicePinById(0); List<int> cableIds = project.CableIds; List<int> wireIds = project.WireIds; foreach (int cableId in cableIds) { cable.Id = cableId; foreach (int coreId in cable.CoreIds) { core.Id = coreId; connectionInfos.Add(new ConnectionInfo(core, normalDevice, devicePin, cable.Name, cable.ComponentName)); } } foreach (int wireId in wireIds) { wire.Id = wireId; connectionInfos.Add(new ConnectionInfo(wire, normalDevice, devicePin, wire.Name, wire.WireType)); } return connectionInfos; }
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); } }