Skip to content
Snippets Groups Projects
Commit 5fb5afa9 authored by Debolskiy Andrey's avatar Debolskiy Andrey :bicyclist_tone5:
Browse files

Fixed most of the comments from 23.11 e-mail

parent ba0d62ae
No related branches found
No related tags found
No related merge requests found
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using WindStressPRM;
namespace Mes_Wind_console namespace Mes_Wind_console
{ {
class Program class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{
Test();
}
static void Test()
{ {
const int rowCountPrognostic = 3; const int rowCountPrognostic = 3;
const int colCountPrognostic = 3; const int colCountPrognostic = 3;
WindStressPRM.Matrix<WindStressPRM.PrognosticCell> prognosticMatrix = new WindStressPRM.Matrix<WindStressPRM.PrognosticCell>(); var prognosticMatrix = new Matrix<PrognosticCell> // TODO: Matrix Лишняя проверка Cells.Rank в RowsCount() / ColumnCount()?
prognosticMatrix.Cells = new WindStressPRM.PrognosticCell[rowCountPrognostic, colCountPrognostic]; {
prognosticMatrix.Size = new WindStressPRM.CellSize(500, 500); Cells = new PrognosticCell[rowCountPrognostic, colCountPrognostic],
prognosticMatrix.Origin = new WindStressPRM.Coordinate(3555223.71, 5828444.07); Size = new CellSize(500, 500),
Origin = new Coordinate(3555223.71, 5828444.07), // TODO: Coordinate в комментариях к полям - широта и долгота ?? done
};
// fill cells of prognostic matrix // fill cells of prognostic matrix
for (int i = 0; i < rowCountPrognostic; i++) for (int i = 0; i < rowCountPrognostic; i++)
{ {
...@@ -23,87 +30,92 @@ namespace Mes_Wind_console ...@@ -23,87 +30,92 @@ namespace Mes_Wind_console
// Also you can use Double.NaN; // Also you can use Double.NaN;
double uValue = 100 * (i + j * 10); double uValue = 100 * (i + j * 10);
double vValue = -(i + j * 10); double vValue = -(i + j * 10);
prognosticMatrix.Cells[i, j] = new WindStressPRM.PrognosticCell(uValue, vValue); prognosticMatrix.Cells[i, j] = new PrognosticCell(uValue, vValue); // TODO: PrognosticCell комментарии к параметрам - размерность, про NaN
} }
} }
//Now we create climate raster class //Now we create climate raster class
const int rowCountClim = 3; const int rowCountClim = 3;
const int columnCountClim = 3; const int columnCountClim = 3;
WindStressPRM.Matrix<WindStressPRM.ClimateCell> climateMatrix = new WindStressPRM.Matrix<WindStressPRM.ClimateCell>(); var climateMatrix = new Matrix<ClimateCell>
climateMatrix.Cells = new WindStressPRM.ClimateCell[rowCountClim, columnCountClim]; {
climateMatrix.Size = new WindStressPRM.CellSize(500, 500); Cells = new ClimateCell[rowCountClim, columnCountClim],
climateMatrix.Origin = new WindStressPRM.Coordinate(3555223.71, 5828444.07); Size = new CellSize(500, 500),// TODO: CellSize названия width/height. DONE
Origin = new Coordinate(3555223.71, 5828444.07),
};
// fill cells of climate matrix // fill cells of climate matrix
for (int i = 0; i < rowCountClim; i++) for (int i = 0; i < rowCountClim; i++)
{ {
for (int j = 0; j < columnCountClim; j++) for (int j = 0; j < columnCountClim; j++)
{ {
//add or substruct in range 0 - 27 to change what lines will be broken //add or substruct in range 0 - 27 to change what lines will be broken
double clim5 = 5; climateMatrix.Cells[i, j] = new ClimateCell(5, 10, 15, 20); // TODO: ClimateCell комментарии к параметрам - размерность, про NaN. DONE
double clim10 = 10;
double clim15 = 15;
double clim25 = 20;
climateMatrix.Cells[i, j] = new WindStressPRM.ClimateCell(clim5, clim10, clim15, clim25);
} }
} }
// create powerlines layer // create powerlines layer
List<WindStressPRM.Powerline> powerlines = new List<WindStressPRM.Powerline>(); var powerlines = new List<Powerline>();
WindStressPRM.Coordinate first = climateMatrix.Origin; Coordinate first = climateMatrix.Origin;
const int numbStations = 5; const int numStations = 5;
const double step = 100; const double step = 100;
for (int i = 0; i < numbStations - 1; i++) for (int i = 0; i < numStations - 1; i++)
{ {
WindStressPRM.Powerline dummyline = new WindStressPRM.Powerline(); // TODO: Powerline и др. детализация сообщения об ошибке (какой параметр вышел за пределы и его значение). DONE
dummyline.Identifier = 100 + i; var dummyline = new Powerline(new List<Coordinate>(), 100 + i, 2000, 10, 330, i + 1, i);
dummyline.Year = 2000;
dummyline.Height = 10;
dummyline.Voltage = 330;
dummyline.PointFromID = i;
dummyline.PointToID = i + 1;
dummyline.Coordinates = new List<WindStressPRM.Coordinate>();
dummyline.Coordinates.Add(first); dummyline.Coordinates.Add(first);
WindStressPRM.Coordinate second = new WindStressPRM.Coordinate(first.X + step, first.Y - step); var second = new Coordinate(first.X + step, first.Y - step);
dummyline.Coordinates.Add(second); dummyline.Coordinates.Add(second);
first = second; first = second;
powerlines.Add(dummyline); powerlines.Add(dummyline);
} }
//create Powerstation list
List<WindStressPRM.PowerStation> powerpoints = new List<WindStressPRM.PowerStation>();
for (int i = 0; i < numbStations; i++)
{
WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation();
dummystation.Identifier = i;
dummystation.Name = "dummy name";
dummystation.Power = 330;
dummystation.IsSource = i == 0;
//casting stationtype //create Powerstation list
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole; var powerpoints = new List<PowerStation>();
if (i == numbStations - 1) for (int i = 0; i < numStations; i++)
{ {
dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat; // TODO: PowerStation и др. соответствие названий полей и параметров конструкторов. DONE
} // TODO: PowerStation проверка параметров на допустимый диапазон. DONE
dummystation.Coordinate = new WindStressPRM.Coordinate(climateMatrix.Origin.X + step * i, climateMatrix.Origin.X - step * i); powerpoints.Add(new PowerStation(
powerpoints.Add(dummystation); new Coordinate(climateMatrix.Origin.X + step * i, climateMatrix.Origin.X - step * i),
i,
String.Format("Station #{0}", i),
330, // TODO: PowerStation - название поля Voltage вместо Power?. DONE
((i == numStations - 1) ? PowerStation.StationType.Endstat : PowerStation.StationType.Pole), // TODO: StationType комментарии к значениям enum. Done
(i == 0)));
} }
//Create a PRM_wind class and add all the properties from above //Create a PRM_wind class and add all the properties from above
WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker(); var prmwind = new StressPowerChecker();
WindStressPRM.Input input = new WindStressPRM.Input(); var input = new Input
input.PowerLines = powerlines; {
input.PowerStations = powerpoints; PowerLines = powerlines,
input.PrognosticCells = prognosticMatrix; PowerStations = powerpoints,
input.ClimateCells = climateMatrix; // TODO: PrognosticCells/ClimateCells - требуется ли совпадение размеров и координат узлов двух данных матриц? Если требуется, то нужна проверка в CheckPower()
WindStressPRM.Output output = prmwind.CheckPower(input); // DONE, не требуется.
foreach (WindStressPRM.Powerline line in output.DisabledLines) { PrognosticCells = prognosticMatrix,
Console.WriteLine("disabled line identifier is " + line.Identifier.ToString()); ClimateCells = climateMatrix,
};
var output = prmwind.CheckPower(input);
foreach (var line in output.DisabledLines)
{
Console.WriteLine("disabled line identifier is {0}", line.Identifier);
} }
foreach (WindStressPRM.PowerStation station in output.DisabledStations) {
Console.WriteLine("disabled station identifier is " + station.Identifier.ToString()); foreach (var station in output.DisabledStations)
{
Console.WriteLine("disabled station identifier is {0}", station.Identifier);
} }
foreach (WindStressPRM.Coordinate coordinate in output.SpectificCoordinates) {
Console.WriteLine("in coordinate " + coordinate.X.ToString() + "; " + coordinate.Y.ToString() + " 35kV and less could be broken"); foreach (var coordinate in output.SpectificCoordinates) // TODO: Название Output.Spectific -> Specific ?
{
Console.WriteLine("in coordinate ({0}; {1}) 35kV and less could be broken", coordinate.X, coordinate.Y);
} }
Console.WriteLine("end"); Console.WriteLine("end");
Console.ReadKey();
} }
} }
} }
...@@ -7,7 +7,7 @@ namespace WindStressPRM ...@@ -7,7 +7,7 @@ namespace WindStressPRM
{ {
/// <summary> /// <summary>
/// Cell obj for climate wind regular data /// Cell obj for climate wind regular data
/// Объект - ячейка полей ветра определенной повторяемости на 10м на регулярной сетке /// Объект - ячейка поля модуля ветра определенной повторяемости на 10м на регулярной сетке
/// </summary> /// </summary>
public class ClimateCell public class ClimateCell
{ {
...@@ -33,12 +33,13 @@ namespace WindStressPRM ...@@ -33,12 +33,13 @@ namespace WindStressPRM
/// </summary> /// </summary>
public double Wind25 { get; private set; } public double Wind25 { get; private set; }
/// <summary> /// <summary>
/// designated constructor /// designated constructor, NaN интерпретируется как отсутствие значения параметра в ячейке.
/// </summary> /// </summary>
/// <param name="coord"></param> /// <param name="coord"></param>
/// <param name="w5"></param> /// <param name="w5"> скорость ветра повторяемости один раз в 5 лет, м/с</param>
/// <param name="w10"></param> /// <param name="w10"> скорость ветра повторяемости один раз в 10 лет, м/с</param>
/// <param name="w15"></param> /// <param name="w15"> скорость ветра повторяемости один раз в 15 лет, м/с</param>
/// <param name="w25"> скорость ветра повторяемости один раз в 25 лет, м/с (для ЛЭП постройки после 1986г)</param>
public ClimateCell(double w5, double w10, double w15, double w25) public ClimateCell(double w5, double w10, double w15, double w25)
{ {
this.Wind5 = w5; this.Wind5 = w5;
...@@ -77,7 +78,11 @@ namespace WindStressPRM ...@@ -77,7 +78,11 @@ namespace WindStressPRM
w25 = 0; w25 = 0;
} }
// ветер по модулю не должен превышать 70м/с // ветер по модулю не должен превышать 70м/с
return Math.Abs(w5) < 70 && Math.Abs(w10) < 70 && Math.Abs(w15) < 70 && Math.Abs(w25) < 70; if (w5 >= 0 && w5 > 70) { throw new System.ArgumentOutOfRangeException("w5", w5, "Expected 0=<w5<70"); }
if (w10 >= 0 && w10 > 70) { throw new System.ArgumentOutOfRangeException("w10", w10, "Expected 0=<w10<70"); }
if (w15 >= 0 && w15 > 70) { throw new System.ArgumentOutOfRangeException("w15", w15, "Expected 0=<w15<70"); }
if (w25 >= 0 && w25 > 70) { throw new System.ArgumentOutOfRangeException("w25", w25, "Expected 0=<w25<70"); }
return w5 >=0 && w5 < 70 && w10 >=0 && w10 < 70 && w15 >= 0 && w15 < 70 && w25 >= 0 && w25 < 70;
} }
} }
} }
...@@ -26,22 +26,25 @@ namespace WindStressPRM ...@@ -26,22 +26,25 @@ namespace WindStressPRM
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// power, kV /// voltage, kV
/// напряжение, кВ /// напряжение, кВ
/// </summary> /// </summary>
public int Power { get; set; } public int Voltage { get; set; }
/// <summary> /// <summary>
/// type of point - trans/pole/endpoint /// type of point - trans/pole/endpoint
/// тип станции - трансформаторная подстанция/столб/понижающая(конечная)подстанция /// тип станции - трансформаторная подстанция/столб/понижающая(конечная)подстанция
///столбы не идут в аутпут, и обрабатываються алгоритмом, так что если есть на куске графа, саязанного только столбами есть сломанный сегмент ///столбы не идут в аутпут, и обрабатываються алгоритмом, так что если есть на куске графа, саязанного только столбами есть сломанный сегмент
/// весб кусок графа обесточен /// весь кусок графа обесточен
/// </summary> /// </summary>
public enum StationType public enum StationType
{ {
Pole, Trans, Endstat Pole, Trans, Endstat
}; };
/// <summary> /// <summary>
/// тип подстанции /// тип подстанции: pole/trans/endstat: является ли станция столбом, распределительной подстанцией, или станцией в вершине графа питания
/// тип столб - в картографической дишифровке ЛЭП могут ветвиться на столбах, при этом, очевидно, столбы не распределяют питание в отличии от подстанций.
/// распределительная подстанция - станция на которой граф ветвиться и известно что это не столб.
/// станция в вершине графа
/// </summary> /// </summary>
public StationType Stationtype { get; set; } public StationType Stationtype { get; set; }
/// <summary> /// <summary>
...@@ -71,26 +74,28 @@ namespace WindStressPRM ...@@ -71,26 +74,28 @@ namespace WindStressPRM
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
/// <param name="crds"></param> /// <param name="coords"> Coordinates/координаты станции </param>
/// <param name="id"></param> /// <param name="id">Station ID/ ИД станции </param>
/// <param name="stname"></param> /// <param name="name">Station Name/Название станции</param>
/// <param name="stpower"></param> /// <param name="voltage"> voltage, класс напряжения кВ</param>
/// <param name="sttype"></param> /// <param name="stationtype">Тип станции: столб/Подстанция/Конечная станция</param>
/// <param name="issource"></param> /// <param name="issource"> является ли станция генерирующей</param>
/// <param name="ison"></param> public PowerStation(Coordinate coords, int id, string name, int voltage, StationType stationtype, bool issource)
public PowerStation(Coordinate crds, int id, string stname, int stpower, StationType sttype, bool issource) {
{ this.Coordinate = coords;
this.Coordinate = crds;
this.Identifier = id; this.Identifier = id;
this.Name = stname; this.Name = name;
this.Power = stpower; this.Voltage = voltage;
this.Stationtype = sttype; this.Stationtype = stationtype;
this.IsSource = issource; this.IsSource = issource;
this.IsON = false; this.IsON = false;
} }
public bool CheckValue() public bool CheckValue()
{ {
bool checker = Identifier >= 0 && Power > 0 && Power < 1000; bool checker = Identifier >= 0;
if (!checker) { throw new System.ArgumentOutOfRangeException("Identifier", Identifier, "Identifer expected to be more than 0"); }
checker = checker && Voltage > 0 && Voltage < 1500;
if (!checker) { throw new System.ArgumentOutOfRangeException("Voltage", Voltage, "Voltage expected to be in range (0,1500)"); }
return checker; return checker;
} }
/// <summary> /// <summary>
...@@ -107,6 +112,7 @@ namespace WindStressPRM ...@@ -107,6 +112,7 @@ namespace WindStressPRM
this.LineList.Add(line); this.LineList.Add(line);
} }
} }
if (this.LineList.Count == 0) { throw new System.Exception("Station has no corresponding/attached lines"); }
return; return;
} }
/// <summary> /// <summary>
...@@ -139,6 +145,7 @@ namespace WindStressPRM ...@@ -139,6 +145,7 @@ namespace WindStressPRM
} }
/// <summary> /// <summary>
/// Sets CurrentVolt parameter based on the highest voltage of lines powering it /// Sets CurrentVolt parameter based on the highest voltage of lines powering it
/// Задает текущее значение питающего напряжения станции
/// </summary> /// </summary>
public void SetCurrentVolt() public void SetCurrentVolt()
{ {
...@@ -148,6 +155,9 @@ namespace WindStressPRM ...@@ -148,6 +155,9 @@ namespace WindStressPRM
} }
return; return;
} }
/// <summary>
/// Выключить питание на соединенных со станцией линиях
/// </summary>
public void TurnOffAttachedLines() public void TurnOffAttachedLines()
{ {
foreach(Powerline line in this.LineList) { line.IsON = false; } foreach(Powerline line in this.LineList) { line.IsON = false; }
......
...@@ -27,7 +27,7 @@ namespace WindStressPRM ...@@ -27,7 +27,7 @@ namespace WindStressPRM
/// </summary> /// </summary>
public double Height { get; set; } public double Height { get; set; }
/// <summary> /// <summary>
/// power kV for switches /// voltage class kV for switches
/// Напряжение ЛЭП, кВ /// Напряжение ЛЭП, кВ
/// </summary> /// </summary>
public int Voltage { get; set; } public int Voltage { get; set; }
...@@ -64,15 +64,13 @@ namespace WindStressPRM ...@@ -64,15 +64,13 @@ namespace WindStressPRM
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
/// <param name="coord"></param> /// <param name="coord"> Line vertices coordinate list/список координат вершин ЛЭП как линейного объекта</param>
/// <param name="id"></param> /// <param name="id"> uniq id/уникальный идентификатор </param>
/// <param name="yer"></param> /// <param name="year">year of construction/год постройки ЛЭП </param>
/// <param name="h"></param> /// <param name="height"> average height of cable span between two poles, meters/средняя высота пролета, м</param>
/// <param name="pw"></param> /// <param name="voltage"> voltage class kV for switches, Напряжение ЛЭП, кВ</param>
/// <param name="isbrkn"></param> /// <param name="toID"> assigned powerstation/pole/идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)</param>
/// <param name="ison"></param> /// <param name="fromID"> assigned powerstation/pole/идентификатор соответсвующего конца/начала линии (столб, трансформаторная подстанция, понижающая подстанция)</param>
/// <param name="toID"></param>
/// <param name="fromID"></param>
public Powerline(IList<Coordinate> coordinates, int id, int year, double height, int voltage, int toID, int fromID) public Powerline(IList<Coordinate> coordinates, int id, int year, double height, int voltage, int toID, int fromID)
{ {
this.Coordinates = coordinates; this.Coordinates = coordinates;
...@@ -96,9 +94,18 @@ namespace WindStressPRM ...@@ -96,9 +94,18 @@ namespace WindStressPRM
public bool CheckValue() public bool CheckValue()
{ {
bool checker = bool checker =
Identifier >= 0 && Math.Abs(Year - 1985) < 45 && Identifier >= 0;
Math.Abs(Height - 15) < 15 && Voltage > 0 && Voltage < 1000 && if (!checker) { throw new System.ArgumentOutOfRangeException("Identifier", Identifier, "Expected >0"); }
PointFromID >= 0 && PointToID >= 0; checker = checker && Year > 1900 && Year < 2050;
if (!checker) { throw new System.ArgumentOutOfRangeException("Year", Year, "Expected 1900<Year<2050"); }
checker = checker && Height > 0 && Height < 50;
if (!checker) { throw new System.ArgumentOutOfRangeException("Height", Height, "Expected 0<Height<50"); }
checker = checker && Voltage > 0 && Voltage < 1500;
if (!checker) { throw new System.ArgumentOutOfRangeException("Voltage", Voltage, "Expected 0<Voltage<1500"); }
checker = checker && PointFromID >= 0;
if (!checker) { throw new System.ArgumentOutOfRangeException("PointFromID", PointFromID, "Expected >0"); }
checker = checker && PointToID >= 0;
if (!checker) { throw new System.ArgumentOutOfRangeException("PointToID", PointToID, "Expected >0"); }
return checker; return checker;
} }
} }
......
...@@ -24,9 +24,9 @@ namespace WindStressPRM ...@@ -24,9 +24,9 @@ namespace WindStressPRM
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
/// <param name="coord"> Coordinate pair</param> /// <param name="coord"> Coordinate pair, координаты ячейки </param>
/// <param name="vX"> U component</param> /// <param name="vX"> U component m/s, скорость ветра по X м/с, NaN если значение отсутствует </param>
/// <param name="vY"> V component</param> /// <param name="vY"> V component m/s, скорость ветра по Y м/с, NaN если значение отсутствует</param>
public PrognosticCell(double vX, double vY) public PrognosticCell(double vX, double vY)
{ {
this.VelocityX = vX; this.VelocityX = vX;
......
...@@ -12,22 +12,22 @@ namespace WindStressPRM ...@@ -12,22 +12,22 @@ namespace WindStressPRM
public class CellSize public class CellSize
{ {
/// <summary> /// <summary>
/// ширина ячейки (расстояние между соседними по широте центрами ячеек) /// ширина ячейки (расстояние между соседними по X центрами ячеек, в размерности координат)
/// </summary> /// </summary>
public double Width { get; set; } public double Width { get; set; }
/// <summary> /// <summary>
/// высота ячейки (расстояние между соседними по долготе центрами ячеек) /// высота ячейки (расстояние между соседними по Y центрами ячеек, в размерности координат)
/// </summary> /// </summary>
public double Height { get; set; } public double Height { get; set; }
/// <summary> /// <summary>
/// designated constructor /// designated constructor
/// </summary> /// </summary>
/// <param name="wdh">Cell Width</param> /// <param name="wdh">Cell Width, ширина ячейки (расстояние между соседними по X центрами ячеек, в размерности координат)</param>
/// <param name="hgh">Cell Height</param> /// <param name="hgh">Cell Height, высота ячейки (расстояние между соседними по Y центрами ячеек, в размерности координат)</param>
public CellSize(double wdh, double hgh) public CellSize(double width, double height)
{ {
this.Width = wdh; this.Width = width;
this.Height = hgh; this.Height = height;
if (!(this.CheckValue())) if (!(this.CheckValue()))
{ {
throw new System.ArgumentException("Cell width or height values are incorrect!"); throw new System.ArgumentException("Cell width or height values are incorrect!");
......
...@@ -5,17 +5,18 @@ namespace WindStressPRM ...@@ -5,17 +5,18 @@ namespace WindStressPRM
{ {
/// <summary> /// <summary>
/// Coordinate pair /// Coordinate pair
/// пара координат, может быть рамерности: м, км, градус, однако для всех экземпляров должна быть одной и той же.
/// </summary> /// </summary>
public class Coordinate public class Coordinate
{ {
/// <summary> /// <summary>
/// easting coordinate /// easting coordinate
/// Координата по широте /// Координата по долготе/ X, (м, км, градус)
/// </summary> /// </summary>
public double X { get; private set; } public double X { get; private set; }
/// <summary> /// <summary>
/// northing coordinate /// northing coordinate
/// Координата по долготе /// Координата по широте/Y, (м, км, градус)
/// </summary> /// </summary>
public double Y { get; private set; } public double Y { get; private set; }
/// <summary> /// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment