diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index fce33f4ec4c2af72b53a4f7513d3dc5bc3570b46..4d603099f8c519b50ddc0ef9adfb6e724f8e01ac 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -228,17 +228,16 @@ namespace MES_Wind } //Create a PRM_wind class and add all the properties from above PRMLibrary.Module prmwind = new PRMLibrary.Module(); - prmwind.input.powerLines = powerlinesToPRM; - prmwind.input.powerStations = powerpointsToPRM; - prmwind.input.prognosticCells = prognosticWind; - prmwind.input.prognosticCellSize = progcellsize; - prmwind.input.prognosticAffineCoefficients = prog_aff; - prmwind.input.climateCells = climWind; - prmwind.input.climateCellSize = climCellsize; - prmwind.input.climateAffineCoefficients = climAffinecoeffs; - //Calculate which lines are broken - List<PRMLibrary.Powerline> prmBrokenLines = prmwind.brokenPowerLinesAfterCheck(); - prmwind.CheckPower(); + PRMLibrary.Input input = new PRMLibrary.Input(); + input.powerLines = powerlinesToPRM; + input.powerStations = powerpointsToPRM; + input.prognosticCells = prognosticWind; + input.prognosticCellSize = progcellsize; + input.prognosticAffineCoefficients = prog_aff; + input.climateCells = climWind; + input.climateCellSize = climCellsize; + input.climateAffineCoefficients = climAffinecoeffs; + PRMLibrary.Output output = prmwind.CheckPower(input); // new FeatureSet for resulting broken powerlines //IFeatureSet brklineSet = new FeatureSet(FeatureType.Line); //DataTable dt = pwlineSet.DataTable; diff --git a/PRMLibrary/PRMLibrary.cs b/PRMLibrary/PRMLibrary.cs index 4ee38fd159c6eceb340999f33241d06e14f1e9d5..d3d72db517d283ef8bb423546925a7e92221b43f 100644 --- a/PRMLibrary/PRMLibrary.cs +++ b/PRMLibrary/PRMLibrary.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace PRMLibrary { @@ -295,60 +293,66 @@ namespace PRMLibrary /// <summary> /// DTO for input /// </summary> - public class InputDTO + public class Input { /// <summary> /// prognistic raster info /// </summary> - public List<List<PrognosticCell>> prognosticCells; + public List<List<PrognosticCell>> prognosticCells {get; set;} /// <summary> /// prognostic raster cell info /// </summary> - public CellSize prognosticCellSize; + public CellSize prognosticCellSize { get; set; } /// <summary> /// affine coefficients from prognostic raster projections /// </summary> - public double[] prognosticAffineCoefficients; + public double[] prognosticAffineCoefficients { get; set; } /// <summary> /// climate raster array /// </summary> - public List<List<ClimateCell>> climateCells; + public List<List<ClimateCell>> climateCells { get; set; } /// <summary> /// climate raster cell info /// </summary> - public CellSize climateCellSize; + public CellSize climateCellSize { get; set; } /// <summary> /// affine coefficients from climate raster projection /// </summary> - public double[] climateAffineCoefficients; + public double[] climateAffineCoefficients { get; set; } /// <summary> /// lines list /// </summary> - public List<Powerline> powerLines; + public List<Powerline> powerLines { get; set; } /// <summary> /// stations/poles list /// </summary> - public List<PowerStation> powerStations; + public List<PowerStation> powerStations { get; set; } /// <summary> - /// maximum distance for line segment + /// maximum distance for line segment, meters /// </summary> - public double dist_threshold = 500; + public double dist_threshold + { + get + { + return 500; + } + } } /// <summary> - /// Output DTO + /// Output /// </summary> - public class OutputDTO + public class Output { /// <summary> /// stations list without power /// </summary> - public List<PowerStation> disabledStations = new List<PowerStation>(); + public List<PowerStation> disabledStations { get; set; } /// <summary> /// broken lines list /// </summary> - public List<Powerline> disabledLines = new List<Powerline>(); + public List<Powerline> disabledLines { get; set; } } /// <summary> /// main calculations class @@ -358,40 +362,45 @@ namespace PRMLibrary /// <summary> /// Input Data /// </summary> - public InputDTO input; - /// <summary> - /// Output Data - /// </summary> - public OutputDTO output; + private Input input; /// <summary> /// Main function for power graph algorithm /// </summary> - public void CheckPower() + public Output CheckPower(Input input) { + this.input = input; + //Calculate which lines are broken + List<PRMLibrary.Powerline> prmBrokenLines = brokenPowerLinesAfterCheck(); //get the graph PreparingPowerItems(); //start from source points foreach (PowerStation pwstation in input.powerStations) { - if (pwstation.issource) { - CheckPowerPointsForStation(pwstation); + if (pwstation.issource) + { + CheckPowerPointsForStation(pwstation); } } //fill output + Output output = new Output(); + output.disabledStations = new List<PowerStation>(); + output.disabledLines = new List<Powerline>(); foreach (Powerline line in input.powerLines) { - if (line.isbroken) { - output.disabledLines.Add(line); + if (line.isbroken) + { + output.disabledLines.Add(line); } } foreach (PowerStation powerStation in input.powerStations) { - if (!powerStation.ison && !(powerStation.type.ToUpperInvariant().Trim() == "POLE")){ + if (!powerStation.ison && !(powerStation.type.ToUpperInvariant().Trim() == "POLE")) + { output.disabledStations.Add(powerStation); } } - return; + return output; } /// <summary> /// recursive search function for power graph @@ -475,7 +484,7 @@ namespace PRMLibrary /// function to chec if powerline is broken by wind /// </summary> /// <returns>list of broken powerlines</returns> - public List<Powerline> brokenPowerLinesAfterCheck() + private List<Powerline> brokenPowerLinesAfterCheck() { List<Powerline> brokenLines = new List<Powerline>(); // actually there are curves in powerLines @@ -618,7 +627,7 @@ namespace PRMLibrary return result; } - double[] affineCoefficients(FunctionType functionType) + private double[] affineCoefficients(FunctionType functionType) { switch (functionType) { @@ -641,7 +650,7 @@ namespace PRMLibrary // Taken from DotSpatial https://github.com/ViceIce/DotSpatial/blob/22c156c7646b1595d88d2523c066a9c6ab4d3a53/DotSpatial.Data/RasterBoundsExt.cs // RasterBoundsExt.cs. Define AffineCoefficients like this. - Index projectionToCell(Coordinate coordinate, FunctionType functionType) + private Index projectionToCell(Coordinate coordinate, FunctionType functionType) { double[] c = affineCoefficients(functionType); double rw, cl; @@ -675,7 +684,7 @@ namespace PRMLibrary return new Index(iRow, iCol); } - Coordinate cellToProjection(Index index, FunctionType functionType) + private Coordinate cellToProjection(Index index, FunctionType functionType) { switch (functionType) { @@ -717,7 +726,7 @@ namespace PRMLibrary return 0; } - double valueForFunction(FunctionType functionType, Index index) + private double valueForFunction(FunctionType functionType, Index index) { switch (functionType) { @@ -747,7 +756,7 @@ namespace PRMLibrary return 0; } - CellSize cellSizeForFunction(FunctionType functionType) + private CellSize cellSizeForFunction(FunctionType functionType) { switch (functionType) { @@ -768,7 +777,7 @@ namespace PRMLibrary throw new Exception("There is no cell size"); } - double interpol(Coordinate coords, FunctionType functionType) + private double interpol(Coordinate coords, FunctionType functionType) { // select directions for projections const bool normalX = true;// true - East, false West diff --git a/PRMLibrary/PRMLibrary.csproj b/PRMLibrary/PRMLibrary.csproj index 46e93d18572e399ca4cb33ef65de4adbbaf88f3c..d8654bae031b10340997c18ed22549d69dbdfd80 100644 --- a/PRMLibrary/PRMLibrary.csproj +++ b/PRMLibrary/PRMLibrary.csproj @@ -33,11 +33,9 @@ <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> - <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> - <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="PRMLibrary.cs" /> diff --git a/PRMLibrary/bin/Debug/PRMLibrary.dll b/PRMLibrary/bin/Debug/PRMLibrary.dll deleted file mode 100644 index b38bcda0e7828ef5fbfeb94416c65af3dd8a0042..0000000000000000000000000000000000000000 Binary files a/PRMLibrary/bin/Debug/PRMLibrary.dll and /dev/null differ diff --git a/PRMLibrary/bin/Debug/PRMLibrary.pdb b/PRMLibrary/bin/Debug/PRMLibrary.pdb deleted file mode 100644 index 33166b797f14ccbed1edfb7667d1b71dc292d0a8..0000000000000000000000000000000000000000 Binary files a/PRMLibrary/bin/Debug/PRMLibrary.pdb and /dev/null differ diff --git a/PRMLibrary/obj/Debug/PRMLibrary.csproj.FileListAbsolute.txt b/PRMLibrary/obj/Debug/PRMLibrary.csproj.FileListAbsolute.txt deleted file mode 100644 index 590309a5408cd344c37c367c691ea99f63c802ee..0000000000000000000000000000000000000000 --- a/PRMLibrary/obj/Debug/PRMLibrary.csproj.FileListAbsolute.txt +++ /dev/null @@ -1,4 +0,0 @@ -C:\Users\Geophyslab-laptop\Documents\MES_Wind2\PRMLibrary\bin\Debug\PRMLibrary.dll -C:\Users\Geophyslab-laptop\Documents\MES_Wind2\PRMLibrary\bin\Debug\PRMLibrary.pdb -C:\Users\Geophyslab-laptop\Documents\MES_Wind2\PRMLibrary\obj\Debug\PRMLibrary.dll -C:\Users\Geophyslab-laptop\Documents\MES_Wind2\PRMLibrary\obj\Debug\PRMLibrary.pdb diff --git a/PRMLibrary/obj/Debug/PRMLibrary.dll b/PRMLibrary/obj/Debug/PRMLibrary.dll deleted file mode 100644 index b38bcda0e7828ef5fbfeb94416c65af3dd8a0042..0000000000000000000000000000000000000000 Binary files a/PRMLibrary/obj/Debug/PRMLibrary.dll and /dev/null differ diff --git a/PRMLibrary/obj/Debug/PRMLibrary.pdb b/PRMLibrary/obj/Debug/PRMLibrary.pdb deleted file mode 100644 index 33166b797f14ccbed1edfb7667d1b71dc292d0a8..0000000000000000000000000000000000000000 Binary files a/PRMLibrary/obj/Debug/PRMLibrary.pdb and /dev/null differ