From 2493f6c8c338a3a0b5e4b021cb10409d35980e75 Mon Sep 17 00:00:00 2001 From: Anton Kudryashov <qubabox@mail.ru> Date: Wed, 30 Nov 2016 20:24:02 +0300 Subject: [PATCH] - fixed comments and checks --- MES_Wind/frmMain.cs | 37 ++++++++++--------------- WindStressPRM/DTO/Output.cs | 6 ++-- WindStressPRM/Objects/ClimateCell.cs | 40 +++++++++++++++++---------- WindStressPRM/Objects/PowerStation.cs | 17 ++++++------ 4 files changed, 52 insertions(+), 48 deletions(-) diff --git a/MES_Wind/frmMain.cs b/MES_Wind/frmMain.cs index 3d0d829..6dfa09a 100644 --- a/MES_Wind/frmMain.cs +++ b/MES_Wind/frmMain.cs @@ -226,47 +226,38 @@ namespace MES_Wind List<WindStressPRM.PowerStation> powerpointsToPRM = new List<WindStressPRM.PowerStation>(); foreach (IFeature featurepoint in pwpointsSet.Features) { - WindStressPRM.PowerStation dummystation = new WindStressPRM.PowerStation(); DataRow featureData = featurepoint.DataRow; - dummystation.Identifier = featurepoint.Fid; - dummystation.Name = featureData["Label"].ToString(); - dummystation.Voltage = int.Parse(featureData["Voltage"].ToString()); + int identifier = featurepoint.Fid; + String Name = featureData["Label"].ToString(); + int Voltage = int.Parse(featureData["Voltage"].ToString()); int issr = int.Parse(featureData["IsSource"].ToString()); - if (issr == 0) - { - dummystation.IsSource = false; - } - else - { - if (issr == 1) - { - dummystation.IsSource = true; - } - else - { - MessageBox.Show("Some entities in Column IsSource of powerstation datatable are not strict ones or zeros"); - } + bool isSource = issr == 1; + if (issr > 1) { + MessageBox.Show("Some entities in Column IsSource of powerstation datatable are not strict ones or zeros"); } + WindStressPRM.PowerStation.StationType stationType; //casting stationtype if (featureData["Sttype"].ToString().Trim().ToUpper() == "POLE") { - dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Pole; + stationType = WindStressPRM.PowerStation.StationType.Pole; } else if (featureData["Sttype"].ToString().Trim().ToUpper() == "TRANS") { - dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Trans; + stationType = WindStressPRM.PowerStation.StationType.Trans; } else if (featureData["Sttype"].ToString().Trim().ToUpper() == "ENDPOINT") { - dummystation.Stationtype = WindStressPRM.PowerStation.StationType.Endstat; + stationType = WindStressPRM.PowerStation.StationType.Endstat; } else { throw new System.Exception("Point in powerstation layer has unrecognised type"); } IPoint featurepointcoords = featurepoint.BasicGeometry as IPoint; - dummystation.Coordinate = DotspPointToPRM(featurepointcoords); - powerpointsToPRM.Add(dummystation); + WindStressPRM.PowerStation dummyStation = new WindStressPRM.PowerStation( + DotspPointToPRM(featurepointcoords), identifier, Name, Voltage, stationType, isSource + ); + powerpointsToPRM.Add(dummyStation); } //Create a PRM_wind class and add all the properties from above WindStressPRM.StressPowerChecker prmwind = new WindStressPRM.StressPowerChecker(); diff --git a/WindStressPRM/DTO/Output.cs b/WindStressPRM/DTO/Output.cs index 8d76305..fc287ad 100644 --- a/WindStressPRM/DTO/Output.cs +++ b/WindStressPRM/DTO/Output.cs @@ -21,8 +21,10 @@ namespace WindStressPRM /// </summary> public List<Powerline> DisabledLines { get; set; } /// <summary> - /// specific coordinates in which probable break of 35 kV powerlines may occure, checked on regular grid - /// список точек с возможной поломкой ЛЭП меньше 35кВ с регулярной сетки + /// specific coordinates in which probable break of 35 kV powerlines may occure, checked on regular grid with interpolation. + /// minimum distance between these points equals to Input.Distance35kVCheck meters. + /// список координат точек с возможной поломкой ЛЭП меньше 35кВ, среди пересечения скоростей и прогностического ветра. + /// минимальное расстояние между которыми не менее Input.Distance35kVCheck метров /// </summary> public List<Coordinate> SpecificCoordinates { get; set; } } diff --git a/WindStressPRM/Objects/ClimateCell.cs b/WindStressPRM/Objects/ClimateCell.cs index 8f67c2e..0a8bcec 100644 --- a/WindStressPRM/Objects/ClimateCell.cs +++ b/WindStressPRM/Objects/ClimateCell.cs @@ -12,23 +12,23 @@ namespace WindStressPRM public class ClimateCell { /// <summary> - /// once-in-5-years frequency wind, m/s - /// скорость ветра повторяемости один раз в 5 лет, м/с + /// once-in-5-years frequency wind module, m/s + /// модуль скорости ветра с повторяемостью один раз в 5 лет, м/с /// </summary> public double Wind5; /// <summary> - /// once-in-10-years frequency wind, m/s - /// скорость ветра повторяемости один раз в 10 лет, м/с + /// once-in-10-years frequency wind module, m/s + /// модуль скорости ветра с повторяемостью один раз в 10 лет, м/с /// </summary> public double Wind10 { get; private set; } /// <summary> - /// once-in-15-years frequency wind, m/s - /// скорость ветра повторяемости один раз в 15 лет, м/с + /// once-in-15-years frequency wind module, m/s + /// модуль скорости ветра с повторяемостью один раз в 15 лет, м/с /// </summary> public double Wind15 { get; private set; } /// <summary> - /// once-in-25-years frequency wind, m/s - /// скорость ветра повторяемости один раз в 25 лет, м/с + /// once-in-25-years frequency wind module, m/s + /// модуль скорости ветра с повторяемостью один раз в 25 лет, м/с /// для ЛЭП, построенных после 1987 года. /// </summary> public double Wind25 { get; private set; } @@ -73,16 +73,28 @@ namespace WindStressPRM { w15 = 0; } - if (Double.IsNaN(w25)) + if (Double.IsNaN(w25)) { w25 = 0; } // ветер по модулю не должен превышать 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; + 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 true; } } } diff --git a/WindStressPRM/Objects/PowerStation.cs b/WindStressPRM/Objects/PowerStation.cs index 5611c78..3f7ac81 100644 --- a/WindStressPRM/Objects/PowerStation.cs +++ b/WindStressPRM/Objects/PowerStation.cs @@ -67,10 +67,6 @@ namespace WindStressPRM /// список оканчивающихся/начинающихся на подстанции ЛЭП /// </summary> public IList<Powerline> LineList { get; set; } - public PowerStation() - { - //default constructor - } /// <summary> /// designated constructor /// </summary> @@ -89,14 +85,17 @@ namespace WindStressPRM this.Stationtype = stationtype; this.IsSource = issource; this.IsON = false; + CheckValue(); } - public bool CheckValue() + public void CheckValue() { 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; + if (Identifier < 0) { + throw new System.ArgumentOutOfRangeException("Identifier", Identifier, "Identifer expected to be more than 0"); + } + if (Voltage < 0 || Voltage > 1500) { + throw new System.ArgumentOutOfRangeException("Voltage", Voltage, "Voltage expected to be in range (0,1500)"); + } } /// <summary> /// Gets attached lines list -- GitLab