private static List<ConnectionInfo> GetConnectionInfosByConnections(E3Project project, Sheet sheet, int electricShemeTypeCode)
        {
            List<ConnectionInfo> connectionInfos = new List<ConnectionInfo>();
            Core core = project.GetCableCoreById(0);
            WireCore wire = project.GetWireCoreById(0);
            NormalDevice normalDevice = project.GetNormalDeviceById(0);
            DevicePin devicePin = project.GetDevicePinById(0);
            Connection connection = project.GetConnectionById(0);
            HashSet<int> electricSchemeSheetIds = GetElectricSchemeSheetIds(project.SheetIds, sheet, electricShemeTypeCode);
            List<int> connectionIds = project.ConnectionIds;
            foreach (int connectionId in connectionIds)
            {
                connection.Id = connectionId;

                List<int> pinIds = new List<int>(connection.PinIds.Count);
                foreach (int pinId in connection.PinIds)
                {
                    devicePin.Id = pinId;
                    pinIds.Add(devicePin.Id);
                }

                pinIds = pinIds.Distinct<int>().ToList<int>();
                pinIds.RemoveAll(id => { devicePin.Id = id; return !electricSchemeSheetIds.Contains(devicePin.SheetId); });

                Dictionary<string, List<int>> pinsBySignals = new Dictionary<string, List<int>>();
                foreach(int pinId in pinIds)
                {
                    devicePin.Id = pinId;
                    string signal = String.Intern(devicePin.SignalName);
                    if (!pinsBySignals.ContainsKey(signal))
                        pinsBySignals.Add(signal, new List<int>());
                    pinsBySignals[signal].Add(pinId);
                }

                foreach (string signal in pinsBySignals.Keys)
                {
                    pinIds = pinsBySignals[signal];
                    if (pinIds.Count > 1)
                        for(int i=1; i<pinIds.Count; i++)
                            connectionInfos.Add(new ConnectionInfo(pinIds[i - 1], pinIds[i], signal, normalDevice, devicePin, core, wire));
                }
            }
            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);
     }
 }
 private static Dictionary<int, DeviceSymbol> GetDeviceSymbolById(E3Project project, E3Text text, Dictionary<int, DeviceConnection> deviceConnectionById)
 {
     NormalDevice device = project.GetNormalDeviceById(0);
     DevicePin pin = project.GetDevicePinById(0);
     Dictionary<int, DeviceSymbol> deviceSymbolById = new Dictionary<int,DeviceSymbol>();
     foreach (int connectionId in deviceConnectionById.Keys)
     {
         DeviceConnection deviceConnection =  deviceConnectionById[connectionId];
         int startId = deviceConnection.StartDeviceId;
         int endId = deviceConnection.EndDeviceId;
         if (!deviceSymbolById.ContainsKey(startId))
         {
             device.Id = startId;
             deviceSymbolById.Add(startId, new DeviceSymbol(device, pin));
         }
         if (!deviceSymbolById.ContainsKey(endId))
         {
             device.Id = endId;
             deviceSymbolById.Add(endId, new DeviceSymbol(device, pin));
         }
         deviceSymbolById[startId].ConnectionIds.Add(connectionId);
         deviceSymbolById[endId].ConnectionIds.Add(connectionId);
     }
     foreach (DeviceSymbol deviceSymbol in deviceSymbolById.Values)
     {
         deviceSymbol.SetCableIds(deviceConnectionById);
         deviceSymbol.SetPinsAndHeightAndNameWidth(deviceConnectionById, deviceSymbolById, text);
     }
     return deviceSymbolById;
 }
 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;
 }