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

tmp

parent eee6c0ec
Branches
No related tags found
No related merge requests found
File deleted
......@@ -268,17 +268,17 @@ namespace MES_Wind
}
//Create a PRM_wind class and add all the properties from above
PRMLibrary.Module prmwind = new PRMLibrary.Module();
prmwind.powerLines = powerlinesToPRM;
prmwind.powerStations = powerpointsToPRM;
prmwind.prognosticCells = prog_wind;
prmwind.prognosticCellSize = prog_cell;
prmwind.prognosticAffineCoefficients = prog_aff;
prmwind.climateCells = clim_wind;
prmwind.climateCellSize = clim_cell;
prmwind.climateAffineCoefficients = clim_aff;
prmwind.input.powerLines = powerlinesToPRM;
prmwind.input.powerStations = powerpointsToPRM;
prmwind.input.prognosticCells = prog_wind;
prmwind.input.prognosticCellSize = prog_cell;
prmwind.input.prognosticAffineCoefficients = prog_aff;
prmwind.input.climateCells = clim_wind;
prmwind.input.climateCellSize = clim_cell;
prmwind.input.climateAffineCoefficients = clim_aff;
//Calculate which lines are broken
List<PRMLibrary.Powerline> prmBrokenLines = prmwind.brokenPowerLinesAfterCheck();
prmwind.checkPower();
prmwind.CheckPower();
// new FeatureSet for resulting broken powerlines
//IFeatureSet brklineSet = new FeatureSet(FeatureType.Line);
//DataTable dt = pwlineSet.DataTable;
......
......@@ -125,7 +125,7 @@ namespace PRMLibrary
FunctionClimate15 = 4
}
public class Module
public class InputDTO
{
//prognistic raster info
public List<List<PrognosticCell>> prognosticCells;
......@@ -141,35 +141,44 @@ namespace PRMLibrary
public List<Powerline> powerLines;
//station collection
public List<PowerStation> powerStations;
public double dist_threshold = 500;
}
public class OutputDTO
{
//broken stations and lines
public List<PowerStation> disabledStations = new List<PowerStation>();
public List<Powerline> disabledLines = new List<Powerline>();
public double dist_threshold = 500;
}
public class Module
{
public InputDTO input;
public OutputDTO output;
//Main function for power graph algorithm
public void checkPower()
public void CheckPower()
{
//get the graph
PreparingPowerItems();
//start from source points
foreach (PowerStation pwstation in powerStations)
foreach (PowerStation pwstation in input.powerStations)
{
if (pwstation.issource) {
CheckPowerPointsForStation(pwstation);
}
}
foreach (Powerline line in powerLines)
foreach (Powerline line in input.powerLines)
{
if (line.isbroken) {
disabledLines.Add(line);
output.disabledLines.Add(line);
}
}
foreach (PowerStation powerStation in powerStations)
foreach (PowerStation powerStation in input.powerStations)
{
if (!powerStation.ison && !(powerStation.type.ToUpperInvariant().Trim() == "POLE")){
disabledStations.Add(powerStation);
output.disabledStations.Add(powerStation);
}
}
return;
......@@ -180,7 +189,6 @@ namespace PRMLibrary
if (!sourcepoint.ison)
{
throw new Exception("CheckPowerPointsForStation is called from disabled sourcepoint");
return;
}
// if the point is not a pole - i.e. we know
// it can redistribute power within connected lines
......@@ -190,7 +198,7 @@ namespace PRMLibrary
if (!line.isbroken && !line.ison)
{
line.ison = true;
foreach (PowerStation powerStation in powerStations)
foreach (PowerStation powerStation in input.powerStations)
{
if (powerStation.identifier != sourcepoint.identifier && (powerStation.identifier == line.pointFromID || powerStation.identifier == line.pointToID))
{
......@@ -226,7 +234,7 @@ namespace PRMLibrary
{
//First we make sure that all the sources are ON
//and all non sources are OFF
foreach (PowerStation powerStation in powerStations)
foreach (PowerStation powerStation in input.powerStations)
{
if (powerStation.issource == true) {
powerStation.ison = true;
......@@ -237,7 +245,7 @@ namespace PRMLibrary
// for each power station we create a list of powerlines it is attached to
List<Powerline> lines = new List<Powerline>();
foreach (Powerline line in powerLines)
foreach (Powerline line in input.powerLines)
{
//we also switch OFF all lines
line.ison = false;
......@@ -252,7 +260,7 @@ namespace PRMLibrary
{
List<Powerline> brklines = new List<Powerline>();
// actually there are curves in powerLines
foreach (Powerline powerCurve in powerLines)
foreach (Powerline powerCurve in input.powerLines)
{
// get coordinates list
List<Coordinate> points = powerCurve.coords;
......@@ -287,7 +295,7 @@ namespace PRMLibrary
private bool linearLineIsBroken(Coordinate coord1, Coordinate coord2, double heightLine, int power)
{
double distance = Math.Sqrt((coord2.X - coord1.X) * (coord2.X - coord1.X) + (coord2.Y - coord1.Y) * (coord2.Y - coord1.Y));
double distpropD = distance / dist_threshold;
double distpropD = distance / input.dist_threshold;
List<Coordinate> pointlist = new List<Coordinate>();
Coordinate midpoint = new Coordinate();
int distpropI = Convert.ToInt32(distpropD);
......@@ -388,13 +396,13 @@ namespace PRMLibrary
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return prognosticAffineCoefficients;
return input.prognosticAffineCoefficients;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return climateAffineCoefficients;
return input.climateAffineCoefficients;
}
default:
break;
......@@ -445,13 +453,13 @@ namespace PRMLibrary
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return prognosticCells[index.Row][index.Col].coords;
return input.prognosticCells[index.Row][index.Col].coords;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return climateCells[index.Row][index.Col].coords;
return input.climateCells[index.Row][index.Col].coords;
}
default:
break;
......@@ -466,13 +474,13 @@ namespace PRMLibrary
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return forRows ? prognosticCells.Count : prognosticCells[0].Count;
return forRows ? input.prognosticCells.Count : input.prognosticCells[0].Count;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return forRows ? climateCells.Count : climateCells[0].Count;
return forRows ? input.climateCells.Count : input.climateCells[0].Count;
}
default:
break;
......@@ -486,23 +494,23 @@ namespace PRMLibrary
{
case FunctionType.FunctionVelocityX:
{
return prognosticCells[index.Row][index.Col].velocityX;
return input.prognosticCells[index.Row][index.Col].velocityX;
}
case FunctionType.FunctionVelocityY:
{
return prognosticCells[index.Row][index.Col].velocityY;
return input.prognosticCells[index.Row][index.Col].velocityY;
}
case FunctionType.FunctionClimate5:
{
return climateCells[index.Row][index.Col].wind5;
return input.climateCells[index.Row][index.Col].wind5;
}
case FunctionType.FunctionClimate10:
{
return climateCells[index.Row][index.Col].wind10;
return input.climateCells[index.Row][index.Col].wind10;
}
case FunctionType.FunctionClimate15:
{
return climateCells[index.Row][index.Col].wind15;
return input.climateCells[index.Row][index.Col].wind15;
}
default:
break;
......@@ -517,13 +525,13 @@ namespace PRMLibrary
case FunctionType.FunctionVelocityX:
case FunctionType.FunctionVelocityY:
{
return prognosticCellSize;
return input.prognosticCellSize;
}
case FunctionType.FunctionClimate5:
case FunctionType.FunctionClimate10:
case FunctionType.FunctionClimate15:
{
return climateCellSize;
return input.climateCellSize;
}
default:
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment