Skip to content
Snippets Groups Projects
Commit 0c8b48c3 authored by Антон Кудряшов's avatar Антон Кудряшов
Browse files

- fixed minor issues

- deleted PRMLib obj,bin files
parent 18a59799
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
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
......
......@@ -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" />
......
File deleted
File deleted
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
File deleted
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment