예제 #1
0
 static void InsertSupplier(Line line, int index)
 {
     var supplier = new Device();
     supplier.DriverType = DriverType.RSR2_MP;
     supplier.Cable.CableType = line.Devices[index].Cable.CableType;
     supplier.Cable.Length = line.Devices[index].Cable.Length;
     supplier.Cable.Resistivity = line.Devices[index].Cable.Resistivity;
     line.Devices.Insert(index, supplier);
 }
예제 #2
0
        public static IEnumerable<DeviceIndicator> CalculateLine(Line line)
        {
            var calcPower = new Algorithms.CalcPowerAlgorithm(line);
            calcPower.Calculate();

            foreach (Device device in line.Devices)
                yield return new DeviceIndicator(device, calcPower.Result[device].il, calcPower.Result[device].ud);
                        
        }       
예제 #3
0
        public static List<int> GetLinePatch(Line line)
        {
            var patch = new List<int>();
            
            Line testLine = new Line();
            testLine.IsCircular = line.IsCircular;
            testLine.Devices = line.Devices.ToList();

            int step = (int)(line.Devices.Count / 10);
            if (step == 0)
                step = 1;
            int index = 0;
            while (true)
            {
                if (!CalculateLine(testLine).Any(x => x.HasIError || x.HasUError))
                {
                    return patch;
                }

                if (testLine.MaxAdress >= 255)
                    return null;
                
                index += step;
                if (index >= testLine.Devices.Count)
                    index = testLine.Devices.Count - 1;
                InsertSupplier(testLine, index);
                
                if (CalculateLine(testLine).Any(x=>testLine.Devices.IndexOf(x.Device) < index && (x.HasIError || x.HasUError)))
                {
                    while (true)
                    {
                        testLine.Devices.RemoveAt(index);
                        index--;
                        InsertSupplier(testLine, index);
                        if (!CalculateLine(testLine).Any(x => testLine.Devices.IndexOf(x.Device) < index && (x.HasIError || x.HasUError)))
                        {
							AddPatchItem(patch, index);
                            break;
                        }
                    }
                }
                else
                {
                    if (!CalculateLine(testLine).Any(x => x.HasIError || x.HasUError))
                    {
                        AddPatchItem(patch, index);
                        return patch;
                    }
                    testLine.Devices.RemoveAt(index);
                }
            }
        }
예제 #4
0
		public CalcPowerAlgorithm(Line line)
		{
			Line = line;
		}