From 18a597999750aa3110e4f88b0cdebc9ba87935c4 Mon Sep 17 00:00:00 2001 From: Andrey Debolskiy <and.debol@gmail.com> Date: Wed, 14 Sep 2016 18:52:07 +0300 Subject: [PATCH] added xml comments and refactoring of app code --- MES_Wind/frmMain.Designer.cs | 95 +----- MES_Wind/frmMain.cs | 163 ++++------ PRMLibrary/PRMLibrary.cs | 283 ++++++++++++++++-- ...gnTimeResolveAssemblyReferencesInput.cache | Bin 5720 -> 0 bytes 4 files changed, 319 insertions(+), 222 deletions(-) delete mode 100644 PRMLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache diff --git a/MES_Wind/frmMain.Designer.cs b/MES_Wind/frmMain.Designer.cs index 5262cfc..8672b5d 100644 --- a/MES_Wind/frmMain.Designer.cs +++ b/MES_Wind/frmMain.Designer.cs @@ -35,11 +35,6 @@ this.map1 = new DotSpatial.Controls.Map(); this.splitter1 = new System.Windows.Forms.Splitter(); this.panel1 = new System.Windows.Forms.Panel(); - this.sdmDataOperations = new DotSpatial.Controls.SpatialDockManager(); - this.gbOperations = new System.Windows.Forms.GroupBox(); - this.btnViewAttributeTable = new System.Windows.Forms.Button(); - this.dgvAttributeTable = new System.Windows.Forms.DataGridView(); - this.bntLoadWindX = new System.Windows.Forms.Button(); this.btnLoadWindY = new System.Windows.Forms.Button(); this.btnCalcStress = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.sdmMapLegend)).BeginInit(); @@ -47,12 +42,6 @@ this.sdmMapLegend.Panel2.SuspendLayout(); this.sdmMapLegend.SuspendLayout(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.sdmDataOperations)).BeginInit(); - this.sdmDataOperations.Panel1.SuspendLayout(); - this.sdmDataOperations.Panel2.SuspendLayout(); - this.sdmDataOperations.SuspendLayout(); - this.gbOperations.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dgvAttributeTable)).BeginInit(); this.SuspendLayout(); // // appManager1 @@ -67,7 +56,7 @@ // // sdmMapLegend // - this.sdmMapLegend.Dock = System.Windows.Forms.DockStyle.Top; + this.sdmMapLegend.Dock = System.Windows.Forms.DockStyle.Fill; this.sdmMapLegend.Location = new System.Drawing.Point(0, 0); this.sdmMapLegend.Name = "sdmMapLegend"; // @@ -78,7 +67,7 @@ // sdmMapLegend.Panel2 // this.sdmMapLegend.Panel2.Controls.Add(this.map1); - this.sdmMapLegend.Size = new System.Drawing.Size(782, 234); + this.sdmMapLegend.Size = new System.Drawing.Size(782, 360); this.sdmMapLegend.SplitterDistance = 260; this.sdmMapLegend.TabControl1 = null; this.sdmMapLegend.TabControl2 = null; @@ -87,7 +76,7 @@ // legend1 // this.legend1.BackColor = System.Drawing.Color.White; - this.legend1.ControlRectangle = new System.Drawing.Rectangle(0, 0, 260, 234); + this.legend1.ControlRectangle = new System.Drawing.Rectangle(0, 0, 260, 360); this.legend1.Dock = System.Windows.Forms.DockStyle.Fill; this.legend1.DocumentRectangle = new System.Drawing.Rectangle(0, 0, 187, 428); this.legend1.HorizontalScrollEnabled = true; @@ -100,7 +89,7 @@ this.legend1.ResetOnResize = false; this.legend1.SelectionFontColor = System.Drawing.Color.Black; this.legend1.SelectionHighlight = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(238)))), ((int)(((byte)(252))))); - this.legend1.Size = new System.Drawing.Size(260, 234); + this.legend1.Size = new System.Drawing.Size(260, 360); this.legend1.TabIndex = 0; this.legend1.TabStop = false; this.legend1.Text = "legend1"; @@ -125,7 +114,7 @@ this.map1.ProjectionModeReproject = DotSpatial.Controls.ActionMode.Prompt; this.map1.RedrawLayersWhileResizing = false; this.map1.SelectionEnabled = true; - this.map1.Size = new System.Drawing.Size(518, 234); + this.map1.Size = new System.Drawing.Size(518, 360); this.map1.TabIndex = 0; this.map1.ZoomOutFartherThanMaxExtent = false; // @@ -139,7 +128,6 @@ // // panel1 // - this.panel1.Controls.Add(this.sdmDataOperations); this.panel1.Controls.Add(this.sdmMapLegend); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(114, 0); @@ -147,67 +135,6 @@ this.panel1.Size = new System.Drawing.Size(782, 360); this.panel1.TabIndex = 1; // - // sdmDataOperations - // - this.sdmDataOperations.Dock = System.Windows.Forms.DockStyle.Fill; - this.sdmDataOperations.Location = new System.Drawing.Point(0, 234); - this.sdmDataOperations.Name = "sdmDataOperations"; - this.sdmDataOperations.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // sdmDataOperations.Panel1 - // - this.sdmDataOperations.Panel1.Controls.Add(this.gbOperations); - // - // sdmDataOperations.Panel2 - // - this.sdmDataOperations.Panel2.Controls.Add(this.dgvAttributeTable); - this.sdmDataOperations.Size = new System.Drawing.Size(782, 126); - this.sdmDataOperations.SplitterDistance = 55; - this.sdmDataOperations.TabControl1 = null; - this.sdmDataOperations.TabControl2 = null; - this.sdmDataOperations.TabIndex = 1; - // - // gbOperations - // - this.gbOperations.Controls.Add(this.btnViewAttributeTable); - this.gbOperations.Dock = System.Windows.Forms.DockStyle.Fill; - this.gbOperations.Location = new System.Drawing.Point(0, 0); - this.gbOperations.Name = "gbOperations"; - this.gbOperations.Size = new System.Drawing.Size(782, 55); - this.gbOperations.TabIndex = 0; - this.gbOperations.TabStop = false; - this.gbOperations.Text = "Operations"; - // - // btnViewAttributeTable - // - this.btnViewAttributeTable.Location = new System.Drawing.Point(7, 22); - this.btnViewAttributeTable.Name = "btnViewAttributeTable"; - this.btnViewAttributeTable.Size = new System.Drawing.Size(188, 23); - this.btnViewAttributeTable.TabIndex = 0; - this.btnViewAttributeTable.Text = "View Attribute table"; - this.btnViewAttributeTable.UseVisualStyleBackColor = true; - this.btnViewAttributeTable.Click += new System.EventHandler(this.btnViewAttributeTable_Click); - // - // dgvAttributeTable - // - this.dgvAttributeTable.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dgvAttributeTable.Dock = System.Windows.Forms.DockStyle.Fill; - this.dgvAttributeTable.Location = new System.Drawing.Point(0, 0); - this.dgvAttributeTable.Name = "dgvAttributeTable"; - this.dgvAttributeTable.RowTemplate.Height = 24; - this.dgvAttributeTable.Size = new System.Drawing.Size(782, 67); - this.dgvAttributeTable.TabIndex = 0; - // - // bntLoadWindX - // - this.bntLoadWindX.Location = new System.Drawing.Point(12, 74); - this.bntLoadWindX.Name = "bntLoadWindX"; - this.bntLoadWindX.Size = new System.Drawing.Size(96, 46); - this.bntLoadWindX.TabIndex = 2; - this.bntLoadWindX.Text = "Load Xwind"; - this.bntLoadWindX.UseVisualStyleBackColor = true; - this.bntLoadWindX.Click += new System.EventHandler(this.bntLoadWindX_Click); - // // btnLoadWindY // this.btnLoadWindY.Location = new System.Drawing.Point(12, 147); @@ -235,7 +162,6 @@ this.ClientSize = new System.Drawing.Size(896, 360); this.Controls.Add(this.btnCalcStress); this.Controls.Add(this.btnLoadWindY); - this.Controls.Add(this.bntLoadWindX); this.Controls.Add(this.panel1); this.Controls.Add(this.splitter1); this.Name = "frmMain"; @@ -245,12 +171,6 @@ ((System.ComponentModel.ISupportInitialize)(this.sdmMapLegend)).EndInit(); this.sdmMapLegend.ResumeLayout(false); this.panel1.ResumeLayout(false); - this.sdmDataOperations.Panel1.ResumeLayout(false); - this.sdmDataOperations.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.sdmDataOperations)).EndInit(); - this.sdmDataOperations.ResumeLayout(false); - this.gbOperations.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.dgvAttributeTable)).EndInit(); this.ResumeLayout(false); } @@ -260,15 +180,10 @@ private DotSpatial.Controls.AppManager appManager1; private System.Windows.Forms.Splitter splitter1; private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Button bntLoadWindX; private DotSpatial.Controls.SpatialDockManager sdmMapLegend; private DotSpatial.Controls.Legend legend1; private DotSpatial.Controls.Map map1; private System.Windows.Forms.Button btnLoadWindY; private System.Windows.Forms.Button btnCalcStress; - private DotSpatial.Controls.SpatialDockManager sdmDataOperations; - private System.Windows.Forms.GroupBox gbOperations; - private System.Windows.Forms.DataGridView dgvAttributeTable; - private System.Windows.Forms.Button btnViewAttributeTable; } } \ No newline at end of file diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index 0337f1f..fce33f4 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -82,8 +82,8 @@ namespace MES_Wind private void btnLoadWindY_Click(object sender, EventArgs e) { string curDir = Environment.CurrentDirectory; - string path_to_tests = "\\MES_test_new\\"; - string file_path = curDir + path_to_tests; + string pathToTests = "\\MES_test_new\\"; + string file_path = curDir + pathToTests; map1.AddLayer(file_path+"u_test.asc"); map1.AddLayer(file_path + "v_test.asc"); @@ -94,50 +94,15 @@ namespace MES_Wind map1.AddLayer(file_path + "powerstations.shp"); map1.ZoomToMaxExtent(); } - - private void btnViewAttributeTable_Click(object sender, EventArgs e) - { - //Declare a datatable - DataTable dt = null; - - if (map1.GetLineLayers().Count() > 0) - { - MapLineLayer pwlLayer = default(MapLineLayer); - - pwlLayer = (MapLineLayer)map1.GetLineLayers()[0]; - - if (pwlLayer == null) - { - MessageBox.Show("The layer is not a line layer."); - } - else - { - //Get the shapefile's attribute table to our datatable dt - dt = pwlLayer.DataSet.DataTable; - - //Set the datagridview datasource from datatable dt - dgvAttributeTable.DataSource = dt; - } - } - else - { - MessageBox.Show("Please add a layer to the map."); - } - - - - } - + private void btnCalcStress_Click(object sender, EventArgs e) { - try - { //extract prognostic u layer - IMapRasterLayer u_rasterLayer = default(IMapRasterLayer); - IMapRasterLayer v_rasterLayer = default(IMapRasterLayer); - IMapRasterLayer clim5_rasterLayer = default(IMapRasterLayer); - IMapRasterLayer clim10_rasterLayer = default(IMapRasterLayer); - IMapRasterLayer clim15_rasterLayer = default(IMapRasterLayer); + IMapRasterLayer uRasterLayer = default(IMapRasterLayer); + IMapRasterLayer vRasterLayer = default(IMapRasterLayer); + IMapRasterLayer clim5RasterLayer = default(IMapRasterLayer); + IMapRasterLayer clim10RasterLayer = default(IMapRasterLayer); + IMapRasterLayer clim15RasterLayer = default(IMapRasterLayer); if (map1.GetRasterLayers().Count() == 1) { @@ -145,11 +110,11 @@ namespace MES_Wind return; } //this makes raster layers list in map1 ordered! - u_rasterLayer = map1.GetRasterLayers()[0]; - v_rasterLayer = map1.GetRasterLayers()[1]; - clim5_rasterLayer = map1.GetRasterLayers()[2]; - clim10_rasterLayer = map1.GetRasterLayers()[3]; - clim15_rasterLayer = map1.GetRasterLayers()[4]; + uRasterLayer = map1.GetRasterLayers()[0]; + vRasterLayer = map1.GetRasterLayers()[1]; + clim5RasterLayer = map1.GetRasterLayers()[2]; + clim10RasterLayer = map1.GetRasterLayers()[3]; + clim15RasterLayer = map1.GetRasterLayers()[4]; //get the powerline line layer IMapLineLayer pwlLayer = default(IMapLineLayer); @@ -168,57 +133,52 @@ namespace MES_Wind IFeatureSet pwpointsSet = pwstLayer.DataSet; //Start to cast raster to PRM classes // prognostic wind massives first - List<List<PRMLibrary.PrognosticCell>> prog_wind = new List<List<PRMLibrary.PrognosticCell>>(); - - PRMLibrary.Coordinate dummy_coord = new PRMLibrary.Coordinate(); - Coordinate dummy_rcoord = new Coordinate(); - PRMLibrary.PrognosticCell dummy_prognostic = new PRMLibrary.PrognosticCell(dummy_coord, 0, 0); - int rcount_prog = u_rasterLayer.DataSet.NumRows; - int ccount_prog = u_rasterLayer.DataSet.NumColumns; - for (int i =0; i< ccount_prog; i++) + List<List<PRMLibrary.PrognosticCell>> prognosticWind = new List<List<PRMLibrary.PrognosticCell>>(); + int rcountPrognostic = uRasterLayer.DataSet.NumRows; + int ccountPrognostic = uRasterLayer.DataSet.NumColumns; + for (int i =0; i< rcountPrognostic; i++) { - List<PRMLibrary.PrognosticCell> prog_wind_row = new List<PRMLibrary.PrognosticCell>(); - for (int j =0; j< rcount_prog; j++ ) + List<PRMLibrary.PrognosticCell> progWindRow = new List<PRMLibrary.PrognosticCell>(); + for (int j =0; j< ccountPrognostic; j++ ) { - dummy_prognostic.velocityX = u_rasterLayer.DataSet.Value[j, i]; - dummy_prognostic.velocityY = v_rasterLayer.DataSet.Value[j, i]; - dummy_rcoord = u_rasterLayer.Bounds.CellCenter_ToProj(j,i); - dummy_coord.X = dummy_rcoord.X; - dummy_coord.Y = dummy_rcoord.Y; - dummy_prognostic.coords = dummy_coord; - prog_wind_row.Add(dummy_prognostic); + PRMLibrary.PrognosticCell dummyPrognosticCell = new PRMLibrary.PrognosticCell(); + dummyPrognosticCell.velocityX = uRasterLayer.DataSet.Value[j, i]; + dummyPrognosticCell.velocityY = vRasterLayer.DataSet.Value[j, i]; + Coordinate dummyRCoords = uRasterLayer.Bounds.CellCenter_ToProj(j,i); + PRMLibrary.Coordinate cellCoords =new PRMLibrary.Coordinate(dummyRCoords.X,dummyRCoords.Y); + dummyPrognosticCell.coords = cellCoords; + progWindRow.Add(dummyPrognosticCell); } - prog_wind.Add(prog_wind_row); + prognosticWind.Add(progWindRow); //prog_wind_row.Clear(); } //Get cell info and Affine transform coefficients from prognostic wind rasters - PRMLibrary.CellSize prog_cell = new PRMLibrary.CellSize(u_rasterLayer.DataSet.CellWidth, u_rasterLayer.DataSet.CellHeight); - double[] prog_aff = u_rasterLayer.Bounds.AffineCoefficients; + PRMLibrary.CellSize progcellsize = new PRMLibrary.CellSize(uRasterLayer.DataSet.CellWidth, uRasterLayer.DataSet.CellHeight); + double[] prog_aff = uRasterLayer.Bounds.AffineCoefficients; //Now we create climate raster class - List<List<PRMLibrary.ClimateCell>> clim_wind = new List<List<PRMLibrary.ClimateCell>>(); - PRMLibrary.ClimateCell dummy_clim = new PRMLibrary.ClimateCell(dummy_coord, 0, 0, 0); - int rcount_clim = clim5_rasterLayer.DataSet.NumRows; - int ccount_clim = clim5_rasterLayer.DataSet.NumColumns; - for (int i = 0; i < ccount_clim; i++) + List<List<PRMLibrary.ClimateCell>> climWind = new List<List<PRMLibrary.ClimateCell>>(); + int rowCountClim = clim5RasterLayer.DataSet.NumRows; + int columnCountClim = clim5RasterLayer.DataSet.NumColumns; + for (int i = 0; i < rowCountClim; i++) { - List<PRMLibrary.ClimateCell> clim_wind_row = new List<PRMLibrary.ClimateCell>(); - for (int j = 0; j < rcount_clim; j++) + List<PRMLibrary.ClimateCell> climWindRow = new List<PRMLibrary.ClimateCell>(); + for (int j = 0; j < columnCountClim; j++) { - dummy_clim.wind5 = clim5_rasterLayer.DataSet.Value[j, i]; - dummy_clim.wind10 = clim10_rasterLayer.DataSet.Value[j, i] ; // Important: substract 3 to this to get powerlines broken - dummy_clim.wind15 = clim15_rasterLayer.DataSet.Value[j, i]; - dummy_rcoord = clim15_rasterLayer.Bounds.CellCenter_ToProj(j,i); - dummy_coord.X = dummy_rcoord.X; - dummy_coord.Y = dummy_rcoord.Y; - dummy_clim.coords = dummy_coord; - clim_wind_row.Add(dummy_clim); + PRMLibrary.ClimateCell dummyClim = new PRMLibrary.ClimateCell(); + dummyClim.wind5 = clim5RasterLayer.DataSet.Value[j, i]; + dummyClim.wind10 = clim10RasterLayer.DataSet.Value[j, i] ; // Important: substract 3 to this to get powerlines broken + dummyClim.wind15 = clim15RasterLayer.DataSet.Value[j, i]; + Coordinate dummyCellCoords = clim15RasterLayer.Bounds.CellCenter_ToProj(j,i); + PRMLibrary.Coordinate dummyClimCoords = new PRMLibrary.Coordinate(dummyCellCoords.X,dummyCellCoords.Y); + dummyClim.coords = dummyClimCoords; + climWindRow.Add(dummyClim); } - clim_wind.Add(clim_wind_row); + climWind.Add(climWindRow); //clim_wind_row.Clear(); } //Get cell info and affine transform coeff from climate rasters - PRMLibrary.CellSize clim_cell = new PRMLibrary.CellSize(clim5_rasterLayer.DataSet.CellWidth, clim5_rasterLayer.DataSet.CellHeight); - double[] clim_aff = clim5_rasterLayer.Bounds.AffineCoefficients; + PRMLibrary.CellSize climCellsize = new PRMLibrary.CellSize(clim5RasterLayer.DataSet.CellWidth, clim5RasterLayer.DataSet.CellHeight); + double[] climAffinecoeffs = clim5RasterLayer.Bounds.AffineCoefficients; // create PRM_line list to pass to PRM_wind from loaded line layer List<PRMLibrary.Powerline> powerlinesToPRM = new List<PRMLibrary.Powerline>(); foreach (IFeature feature in pwlineSet.Features) @@ -231,17 +191,17 @@ namespace MES_Wind dummyline.power = int.Parse(featureData["Power"].ToString()); dummyline.pointFromID = int.Parse(featureData["PointFrom"].ToString()); dummyline.pointToID = int.Parse(featureData["PointTo"].ToString()); - LineString ftline = feature.BasicGeometry as LineString; - dummyline.coords = DotspLinestringToPrm(ftline); + LineString featureline = feature.BasicGeometry as LineString; + dummyline.coords = DotspLinestringToPrm(featureline); powerlinesToPRM.Add(dummyline); } //create PRM_station list to pass to PRM_wind from loaded point layer List<PRMLibrary.PowerStation> powerpointsToPRM = new List<PRMLibrary.PowerStation>(); - foreach (IFeature ftpoint in pwpointsSet.Features) + foreach (IFeature featurepoint in pwpointsSet.Features) { PRMLibrary.PowerStation dummystation = new PRMLibrary.PowerStation(); - DataRow featureData = ftpoint.DataRow; - dummystation.identifier = ftpoint.Fid; + DataRow featureData = featurepoint.DataRow; + dummystation.identifier = featurepoint.Fid; dummystation.name = featureData["Name"].ToString(); dummystation.power = int.Parse(featureData["Power"].ToString()); int issr = int.Parse(featureData["IsSource"].ToString()); @@ -261,8 +221,8 @@ namespace MES_Wind } } dummystation.type = featureData["Type"].ToString(); - IPoint ftpt = ftpoint.BasicGeometry as IPoint; - dummystation.coords = DotspPointToPRM(ftpt); + IPoint featurepointcoords = featurepoint.BasicGeometry as IPoint; + dummystation.coords = DotspPointToPRM(featurepointcoords); powerpointsToPRM.Add(dummystation); } @@ -270,12 +230,12 @@ namespace MES_Wind PRMLibrary.Module prmwind = new PRMLibrary.Module(); prmwind.input.powerLines = powerlinesToPRM; prmwind.input.powerStations = powerpointsToPRM; - prmwind.input.prognosticCells = prog_wind; - prmwind.input.prognosticCellSize = prog_cell; + prmwind.input.prognosticCells = prognosticWind; + prmwind.input.prognosticCellSize = progcellsize; prmwind.input.prognosticAffineCoefficients = prog_aff; - prmwind.input.climateCells = clim_wind; - prmwind.input.climateCellSize = clim_cell; - prmwind.input.climateAffineCoefficients = clim_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(); @@ -289,13 +249,6 @@ namespace MES_Wind //LineSymbolizer symbol = new LineSymbolizer(Color.Red, 3); //brk_info_layer.Symbolizer = symbol; //brk_info_layer.LegendText = "Broken powerlines"; - - } - catch (Exception ex) - { - MessageBox.Show("Something went wrong"); - } - } } public class CheckPoint diff --git a/PRMLibrary/PRMLibrary.cs b/PRMLibrary/PRMLibrary.cs index 04ea64d..4ee38fd 100644 --- a/PRMLibrary/PRMLibrary.cs +++ b/PRMLibrary/PRMLibrary.cs @@ -5,48 +5,124 @@ using System.Text; namespace PRMLibrary { + /// <summary> + /// Index class for raster lists in list + /// </summary> public class Index { + /// <summary> + /// Outer index + /// </summary> public int Row; + /// <summary> + /// Inner index + /// </summary> public int Col; + /// <summary> + /// designated constructor + /// </summary> + /// <param name="Row">row index</param> + /// <param name="Col">column index</param> public Index(int Row, int Col) { this.Row = Row; this.Col = Col; } + /// <summary> + /// default constructor + /// </summary> public Index() : this(0, 0) { } } + /// <summary> + /// Coordinate pair + /// </summary> public class Coordinate { + /// <summary> + /// easting coordinate + /// </summary> public double X; + /// <summary> + /// northing coordinate + /// </summary> public double Y; - + /// <summary> + /// designated constructor + /// </summary> + /// <param name="X"></param> + /// <param name="Y"></param> public Coordinate(double X, double Y) { this.X = X; this.Y = Y; } + /// <summary> + /// default constructor + /// </summary> public Coordinate() : this(0, 0) { } } + /// <summary> + /// Cell obj for regular prognostic wind field + /// </summary> public class PrognosticCell { + /// <summary> + /// U - component of wind velocity + /// </summary> public double velocityX; + /// <summary> + /// V - component of wind velocity + /// </summary> public double velocityY; + /// <summary> + /// Cell center coordinates + /// </summary> public Coordinate coords; + /// <summary> + /// designated constructor + /// </summary> + /// <param name="coord"> Coordinate pair</param> + /// <param name="vX"> U component</param> + /// <param name="vY"> V component</param> public PrognosticCell(Coordinate coord, double vX, double vY) { this.coords = coord; this.velocityX = vX; this.velocityY = vY; } + /// <summary> + /// default constructor + /// </summary> + public PrognosticCell() : this(new Coordinate(), 0, 0) { } } + /// <summary> + /// Cell obj for climate wind regular data + /// </summary> public class ClimateCell { + /// <summary> + /// once-in-5-years frequency wind + /// </summary> public double wind5; + /// <summary> + /// once-in-10-years frequency wind + /// </summary> public double wind10; + /// <summary> + /// once-in-15-years frequency wind + /// </summary> public double wind15; + /// <summary> + /// Cell center coordinate pair + /// </summary> public Coordinate coords; - + /// <summary> + /// designated constructor + /// </summary> + /// <param name="coord"></param> + /// <param name="w5"></param> + /// <param name="w10"></param> + /// <param name="w15"></param> public ClimateCell(Coordinate coord, double w5, double w10, double w15) { this.coords = coord; @@ -54,7 +130,14 @@ namespace PRMLibrary this.wind10 = w10; this.wind15 = w15; } + /// <summary> + /// default constructor + /// </summary> + public ClimateCell() : this(new Coordinate(), 0, 0, 0) { } } + /// <summary> + /// Cell Size parameters + /// </summary> public struct CellSize { public double width; @@ -65,44 +148,126 @@ namespace PRMLibrary this.width = wdh; this.height = hgh; } - } + /// <summary> + /// power line object + /// </summary> public class Powerline { + /// <summary> + /// unique id + /// </summary> public int identifier { get; set; } + /// <summary> + /// year of construction + /// </summary> public int year; + /// <summary> + /// average height of cable span between two poles, meters + /// </summary> public double height; + /// <summary> + /// power kW for switches + /// </summary> public int power; + /// <summary> + /// Line vertices coordinate list + /// </summary> public List<Coordinate> coords { get; set; } + /// <summary> + /// assigned powerstation/pole + /// </summary> public int pointFromID; + /// <summary> + /// assigned powerstation/pole + /// </summary> public int pointToID; + /// <summary> + /// broken/not broken switch + /// </summary> public bool isbroken; + /// <summary> + /// power on switch + /// </summary> public bool ison; - - public Powerline(List<Coordinate> coord, int id, int yer, double h, int pw, bool isbrkn, bool ison, int toID, int fromID) + private int MissingIdValue = -1; + /// <summary> + /// designated constructor + /// </summary> + /// <param name="coord"></param> + /// <param name="id"></param> + /// <param name="yer"></param> + /// <param name="h"></param> + /// <param name="pw"></param> + /// <param name="isbrkn"></param> + /// <param name="ison"></param> + /// <param name="toID"></param> + /// <param name="fromID"></param> + public Powerline(List<Coordinate> coordinate, int id, int year, double height, int power, bool isbroken, bool ison, int toID, int fromID) { - this.coords = coord; + this.coords = coordinate; this.identifier = id; - this.year = yer; - this.height = h; - this.power = pw; - this.isbroken = isbrkn; + this.year = year; + this.height = height; + this.power = power; + this.isbroken = isbroken; this.ison = ison; this.pointFromID = fromID; this.pointToID = toID; } - public Powerline() : base() { } + /// <summary> + /// default constructor + /// </summary> + public Powerline() : this(new List<Coordinate>(), -1, 0, 0, 0, false, false, -1, -1) { } } + /// <summary> + /// powerstation/pole point class + /// </summary> public class PowerStation { + /// <summary> + /// unique id + /// </summary> public int identifier; + /// <summary> + /// Coordinates + /// </summary> public Coordinate coords; + /// <summary> + /// station name field + /// </summary> public string name; + /// <summary> + /// power, kW + /// </summary> public int power; + /// <summary> + /// type of point - trans/pole/endpoint + /// </summary> public string type; + /// <summary> + /// is point a source? + /// </summary> public bool issource; + /// <summary> + /// power on switch + /// </summary> public bool ison; + /// <summary> + /// asigned powerlines list + /// </summary> public List<Powerline> linelist; + private int MissingIdValue = -1; + /// <summary> + /// designated constructor + /// </summary> + /// <param name="crds"></param> + /// <param name="id"></param> + /// <param name="stname"></param> + /// <param name="stpower"></param> + /// <param name="sttype"></param> + /// <param name="issource"></param> + /// <param name="ison"></param> public PowerStation(Coordinate crds, int id, string stname, int stpower, string sttype, bool issource, bool ison) { this.coords = crds; @@ -113,7 +278,10 @@ namespace PRMLibrary this.issource = issource; this.ison = ison; } - public PowerStation() : base() { } + /// <summary> + /// default constructor + /// </summary> + public PowerStation() : this(new Coordinate(), -1, "", 0, "", false, false) { } } enum FunctionType @@ -124,40 +292,81 @@ namespace PRMLibrary FunctionClimate10 = 3, FunctionClimate15 = 4 } - + /// <summary> + /// DTO for input + /// </summary> public class InputDTO { - //prognistic raster info + /// <summary> + /// prognistic raster info + /// </summary> public List<List<PrognosticCell>> prognosticCells; + /// <summary> + /// prognostic raster cell info + /// </summary> public CellSize prognosticCellSize; + /// <summary> + /// affine coefficients from prognostic raster projections + /// </summary> public double[] prognosticAffineCoefficients; - //climate raster info + /// <summary> + /// climate raster array + /// </summary> public List<List<ClimateCell>> climateCells; + /// <summary> + /// climate raster cell info + /// </summary> public CellSize climateCellSize; + /// <summary> + /// affine coefficients from climate raster projection + /// </summary> public double[] climateAffineCoefficients; - //lines collection + /// <summary> + /// lines list + /// </summary> public List<Powerline> powerLines; - //station collection + /// <summary> + /// stations/poles list + /// </summary> public List<PowerStation> powerStations; - + /// <summary> + /// maximum distance for line segment + /// </summary> public double dist_threshold = 500; } - + /// <summary> + /// Output DTO + /// </summary> public class OutputDTO { - //broken stations and lines + /// <summary> + /// stations list without power + /// </summary> public List<PowerStation> disabledStations = new List<PowerStation>(); + /// <summary> + /// broken lines list + /// </summary> public List<Powerline> disabledLines = new List<Powerline>(); } - + /// <summary> + /// main calculations class + /// </summary> public class Module { + /// <summary> + /// Input Data + /// </summary> public InputDTO input; + /// <summary> + /// Output Data + /// </summary> public OutputDTO output; - //Main function for power graph algorithm + /// <summary> + /// Main function for power graph algorithm + /// </summary> public void CheckPower() { //get the graph @@ -169,6 +378,7 @@ namespace PRMLibrary CheckPowerPointsForStation(pwstation); } } + //fill output foreach (Powerline line in input.powerLines) { if (line.isbroken) { @@ -183,7 +393,10 @@ namespace PRMLibrary } return; } - //search function for power graph + /// <summary> + /// recursive search function for power graph + /// </summary> + /// <param name="sourcepoint"> powered station to search next powered station from</param> private void CheckPowerPointsForStation(PowerStation sourcepoint) { if (!sourcepoint.ison) @@ -229,7 +442,9 @@ namespace PRMLibrary } } - //preparing powerstations and lists of lines for them to get a graph-like structure + /// <summary> + /// preparing powerstations and lists of lines for them to get a graph-like structure + /// </summary> private void PreparingPowerItems() { //First we make sure that all the sources are ON @@ -256,9 +471,13 @@ namespace PRMLibrary powerStation.linelist = lines; } } + /// <summary> + /// function to chec if powerline is broken by wind + /// </summary> + /// <returns>list of broken powerlines</returns> public List<Powerline> brokenPowerLinesAfterCheck() { - List<Powerline> brklines = new List<Powerline>(); + List<Powerline> brokenLines = new List<Powerline>(); // actually there are curves in powerLines foreach (Powerline powerCurve in input.powerLines) { @@ -285,13 +504,23 @@ namespace PRMLibrary } if (powerCurve.isbroken) { - brklines.Add(powerCurve); + brokenLines.Add(powerCurve); } } - return brklines; + return brokenLines; } + /// <summary> + /// Divides the line between two vertices if needed + /// depending on dist_threshold + /// and checks if line is broken by wind in any of midpoints + /// </summary> + /// <param name="coord1">first vertice coordinate</param> + /// <param name="coord2">second vertice </param> + /// <param name="heightLine">height</param> + /// <param name="power">power for climatology switches</param> + /// <returns>true if line is broken false otherwise</returns> 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)); diff --git a/PRMLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/PRMLibrary/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache deleted file mode 100644 index a8396ac748a0cfb53f7f341086dd6c68daf79c83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5720 zcmZQzWME+U|NsAg5Y52Az`(=Az`&5=o0(jcU!0#-q8FA~T$-2@TvD2nnXl)ZpPQSX z=jr0AqY#!_RGgWgXKQGn2ZlNd&ZRjerA4W>d8wr(MTt2&3IU}_Iho1csg)u5*{ON9 zNe0GgrfKGBhK4Do28qUrtRO2baM<KjnwgUVvd=TGB(*5NAiOBCpdhtKFDS9dGq0eu zq*#oBfk84cCnvu=HN~;GI5jsZr_!~eBsCA@s$$;6f&%CKytK@8x6GVWvE;<Ol+2XG zl2n*VkZ7@VT4_#>TTx<eYI%N9HcTocF)1gtSOi7REk7qEwWwGQBp8xdl%84w*A`rw zRGeDkmzbMctdg0YmtU0XlA4xSnp5JLS6q^qlY?*_#9%G_iXg^8l!|9!H$oOe99fq_ zPGU)FaS56;T{4SOlS}f8GE<8M3Q|fEi-J=Vi;^<}5=%0QxeJQ&(=u~XL7osQN=?r! zE-9)+$a5B#B$lLtLQJXz)$d4#ilIsQ=I3Q*rxqz<7k0@kF33r&1X+l#5t^=~AsPdU z@{?1Gi}Q;di;^=kOHz|TDGaJ5H6^GtuOu@!6{-a)j21J+Y)ov-Y-|h+Ow4R-jEsyR z%*e<#pEbC$xFj`K&pAIQCpEbwGe56b&pkCSwJ0-L&nL6EB*8E`8jlk1)XK2LoYK^Q z#LS`uBe>GwlA_GKbRC7<;^h3IoXjLdJ~1IWo0yv?nkJi?8Cn{fq#9UQ#_Hg6#~^ho zEy5v|y1_cgjbmgSO`^0&Mey823&RI_nxb+B0<{!4nHd-uxHwrD7#KKNK?EC!U<b7% z7`Qk&KpajG!NtJ9z{U*{X5(RCU~sAqg4Q!u!TD(=<%vb9G4Pf^jGmus2)r2ADKpVC z(1F#?(3;q_qLz)9fq@~{*(xTqIJKxa#yvH^AfvK4CoxGkC$XR;zaYjXKe;qFHLs*N z#@97CK0Gro#V95q$k!(`sVK3iGA2JME5;=?sWd&tCABy+Juf6PH#I1=I6tQh-bx5c zO-n6G%}Y)#)=N%I&Pe6t1NnlVfq_8^)rrs=$QI;OHUS0(1_6+~0^AP@CTxNX3=Aw_ zc_9!hw>UG0O&An*ATd2-17kx=P7wwM20>7Of-svX$TGe1%)HzbHc)GaMK2{MhfN%$ zTQ9XDRS*>Bpa5o*U|?WKceaWND9TSSO3YONRn^4`8Wk31nlW%MC_qCnGqo5gq~R_^ z4f7a~qY%pUoP#qGiweN@OENGp#M8hsSd9s`M2dldA&CZ-z$^5kRIokL3=9k<w6n)0 zu_RFsL<FanAljy2n`LP0Ly)Cldt@0H7-DJXLr{v8V_;xNq@5KJxjA5;$TKi7q|w$I zpUk{MkX<aGl5Dj4r9}-nTK!V1TM!GbB;qqmQge%0<BKz^QaR$wAf0k%28Q)4@UjlG ze>2*70S!ms>}Sy;-4F7XVRS492d4t4c?QLTpmrQ+fQC(xfq@~2`sJ=5sEr7=Knc{M zaVyQqVFa~iKt(UAOF->MkgEj2ZAeg~NQHrcL896j>!408n<@hXgHW|cW?l(sbi=JE zKi9J)HMf>c4b*O{#xX8ZS<9wQrFN+X0|NtZbx>kCs2v6x;;3cQWME)$A-}1bl$i%@ sstSTypx{u`qEWPf+MuA&W(TJRkX0Za^V-q!gwXKjXn6u3vWn#f0BlBSasU7T -- GitLab