// Load .WIND data from file. public virtual void Load(string WINDPLUSFileName) { StreamReader WINDFile = File.OpenText(WINDPLUSFileName); var warnings = new List <string>(); int index = WINDPLUSFileName.LastIndexOf("\\", StringComparison.Ordinal); string WINDPLUSFilePath = WINDPLUSFileName.Remove(index); //Number of wind groups in .WIND file: string nGroups = WINDFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); AddVariable("NUMBER_OF_WINDS", numberOfGroups); //Reset data structs to store .WIND data in local memory: var mainTable = new List <string[]>(); WINDFileContents.Clear(); //2 values not contained in WINDFIleContents: string windPlusWindCoeff = WINDFile.ReadLine(); string windPlusAirDensity = WINDFile.ReadLine(); for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data from .WIND file.... try { // // // // // // // // // Empty lines left intentionally //Secondary table (Wind velocities table) file name: string secondaryTableFileName = WINDFile.ReadLine().Trim(); //Read extra lines: int nExtraLines = Convert.ToInt32(WINDFile.ReadLine().Trim()); var extras = new string[nExtraLines]; for (int ii = 0; ii < nExtraLines; ++ii) { extras[ii] = WINDFile.ReadLine(); } //Create this group from data just read: var group = new WIND(); group.SecondaryFileName = secondaryTableFileName; group.nExtraLines = nExtraLines; group.ExtraData = extras; //Store data of this zone: WINDFileContents.Add(group); //Store in mainTable a row to be shown in zones table in DIP tab: //(index, wind velocities name) var row = new string[2]; row[0] = i.ToString(); row[1] = secondaryTableFileName; mainTable.Add(row); //Potential new velocities group (secundary dependant table). Velocities data (time, Ux, Uy) is stored in //a file whose name could be repeated ni the .WIND file for another zone. Only one copy of the file contents is //stored in memory in MyWind structure. If modified, only that copy is changed. It is permanently stored when //the user clicks "Save .WIND". Universal.LoadSecondaryTable("WIND", WINDPLUSFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 1803171736: error while proccessing ", "ERROR 1803171736: error procesando ") + WINDPLUSFileName + ". " + Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } WINDFile.Close(); //Save variables associated to control tags: double windCoeff = Convert.ToDouble(windPlusWindCoeff); double airDensity = Convert.ToDouble(windPlusAirDensity); AddVariable("WINDPLUS_STRESSCOEFF_CD", windCoeff); AddVariable("WINDPLUS_AIRDENSITY", airDensity); AddVariable("WINDPLUSZONES_VALUES", mainTable); if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 0811121034: The following wind files do not exist: \n\n", "WARNING 0811121034: Los siguientes archivos no existen: \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Load data from file public virtual void Load(string BRIDGESFileName) { StreamReader BRIDGESFile = File.OpenText(BRIDGESFileName); var warnings = new List <string>(); int index = BRIDGESFileName.LastIndexOf("\\", StringComparison.Ordinal); string BRIDGESFilePath = BRIDGESFileName.Remove(index); //Read number of bridges groups in .BRIDGES file: string nGroups = BRIDGESFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); AddVariable("NUMBER_OF_BRIDGES", numberOfGroups); //Reset data structs to store .BRIDGES data in local memory:: var mainTable = new List <string[]>(); BRIDGESFileContents.Clear(); // //(Code space for individual variables) // for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data groups from .BRIDGES file.... try { //Bridge name: string bridgeName = BRIDGESFile.ReadLine().Trim(); //x1, y1, x2, y2. string parameters = BRIDGESFile.ReadLine(); // // // // Empty lines left intentionally //Secondary table (Bridge geometry profiles table) file name: string secondaryTableFileName = BRIDGESFile.ReadLine().Trim(); //Read extra lines: int nExtraLines = Convert.ToInt32(BRIDGESFile.ReadLine().Trim()); var extras = new string[nExtraLines]; for (var ii = 0; ii < nExtraLines; ++ii) { extras[ii] = BRIDGESFile.ReadLine(); } //Create this group from data just read: var group = new BRIDGES(); group.BridgeName = bridgeName; group.Parameters = parameters; group.SecondaryFileName = secondaryTableFileName; group.nExtraLines = nExtraLines; group.ExtraData = extras; //Store data in memory for this geometry group: BRIDGESFileContents.Add(group); //Store in mainTable a row to be shown in bridges table in DIP tab: // (bridge name, bridge geometry file name) var row = new string[2]; row[0] = bridgeName; row[1] = secondaryTableFileName; mainTable.Add(row); //Potential new brige geometry group (secundary dependant table). Geometries (x, Bed, Z lower, Z upper, Deck) are // stored in a file whose name could be repeated in the .BRIDGES file for another bridge. Only one copy of the file contents is //stored in memory in BridgeGeometryGroups. If modified, only that copy is changed. //It will be permanently stored when the user clicks "Save .BRIDGES". Universal.LoadSecondaryTable("BRIDGES", BRIDGESFilePath + "\\" + secondaryTableFileName, ref warnings); //LoadBridgesSecondaryData(BRIDGESFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 300417-1236 while proccessing file:\n\n", "ERROR 300417-1236 procesando archivo:\n\n") + BRIDGESFileName + "\n\n" + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } BRIDGESFile.Close(); //Save variables associated to control tags: AddVariable("BRIDGES_VALUES", mainTable); // // // Empty lines left intentionally if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 3004171237: The following bridges files do not exist: \n\n", "ADVERTENCIA 3004171237: Los siguientes archivos de puentes no existen: \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Load data from file public virtual void Load(string DAMBREACHFileName) { StreamReader DAMBREACHFile = File.OpenText(DAMBREACHFileName); var warnings = new List <string>(); int index = DAMBREACHFileName.LastIndexOf("\\", StringComparison.Ordinal); string DAMBREACHFilePath = DAMBREACHFileName.Remove(index); //Read number of dam breaches groups in .DAMBREACH file: string nGroups = DAMBREACHFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); AddVariable("NUMBER_OF_DAMBREACHES", numberOfGroups); //Reset data structs to store .DAMBREACH data in local memory: var mainTable = new List <string[]>(); DAMBREACHFileContents.Clear(); // //(Code space for individual variables) // for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data groups from .DAMBREACH file.... try { //Dam Breach name: string damBreachName = DAMBREACHFile.ReadLine().Trim(); //X0, Y0: string coordinates = DAMBREACHFile.ReadLine().Trim(); string[] split = coordinates.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string X0 = split[0]; string Y0 = split[1]; //Crest z crest, beach angle, cofficient: string parameters = DAMBREACHFile.ReadLine(); split = parameters.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string zCrest = split[0]; string breachAngle = split[1];; string coeff = split[2]; //Secondary table (dam breach evolution) file name: string secondaryTableFileName = DAMBREACHFile.ReadLine().Trim(); //Read extra lines: int nExtraLines = Convert.ToInt32(DAMBREACHFile.ReadLine().Trim()); var extras = new string[nExtraLines]; for (var ii = 0; ii < nExtraLines; ++ii) { extras[ii] = DAMBREACHFile.ReadLine(); } //Create this group from data just read: var group = new DAMBREACHES(); group.DamBreachName = damBreachName; group.Coordinates = coordinates; group.Parameters = parameters; group.SecondaryFileName = secondaryTableFileName; group.nExtraLines = nExtraLines; group.ExtraData = extras; //Store data in memory for this apenings group: DAMBREACHFileContents.Add(group); //Store in mainTable a row to be shown in dam breach table in DIP tab: //(dam breach name, z crest, angle, coeff, file name) var row = new string[7]; row[0] = damBreachName; row[1] = X0; row[2] = Y0; row[3] = zCrest; row[4] = breachAngle; row[5] = coeff; row[6] = secondaryTableFileName; mainTable.Add(row); //Potential new temporal evolution group (secundary dependant table). evolution (time, width, height) is // stored in a file whose name could be repeated in the .DAMBREACH file for another dam breach. Only one copy of the file contents is //stored in memory in SecondaryGroups structure. If modified, only that copy is changed. //It will be permanently stored when the user clicks "Save .DAMBREACH". Universal.LoadSecondaryTable("DAMBREACH", DAMBREACHFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 1206171118: error while proccessing ", "ERROR 1206171118: error leyendo ") + DAMBREACHFileName + ". " + Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } DAMBREACHFile.Close(); //Save variables associated to control tags: AddVariable("DAMBREACH_VALUES", mainTable); // // // Empty lines left intentionally if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 1206171119: The following dam breach files do not exist: \n\n", "ADVERTENCIA 1206171119: Los siguientes archivos de brechas presas no existen : \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Load data from file public virtual void Load(string GATESFileName) { StreamReader GATESFile = File.OpenText(GATESFileName); var warnings = new List <string>(); int index = GATESFileName.LastIndexOf("\\", StringComparison.Ordinal); string GATESFilePath = GATESFileName.Remove(index); //Read number of gate groups in .GATES file: string nGroups = GATESFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); AddVariable("NUMBER_OF_GATES", numberOfGroups); //Reset data structs to store .GATES data in local memory: var mainTable = new List <string[]>(); GATESFileContents.Clear(); // //(Code space for individual variables) // for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data groups from .GATES file.... try { //Gate name: string gateName = GATESFile.ReadLine().Trim(); //Crest elevation, gate height, and Cd. string parameters = GATESFile.ReadLine(); string[] split = parameters.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string crestElevation = split[0]; string gateHeight = split[1];; string Cd = split[2]; //Secondary table (Gates openings table) file name: string secondaryTableFileName = GATESFile.ReadLine().Trim(); //Read extra lines: int nExtraLines = Convert.ToInt32(GATESFile.ReadLine().Trim()); var lines = new string[nExtraLines]; for (var ii = 0; ii < nExtraLines; ++ii) { lines[ii] = GATESFile.ReadLine(); } //Create this group from data just read: var group = new GATES(); group.GateName = gateName; group.Parameters = parameters; group.SecondaryFileName = secondaryTableFileName; group.nExtraLines = nExtraLines; group.ExtraData = lines; //Store data in memory for this apenings group: GATESFileContents.Add(group); //Store in mainTable a row to be shown in gates table in DIP tab: //(gate name, crest elevation, gate height, Cd, openings table name) var row = new string[5]; row[0] = gateName; row[1] = crestElevation; row[2] = gateHeight; row[3] = Cd; row[4] = secondaryTableFileName; mainTable.Add(row); //Potential new openings group (secundary dependant table). Openings (time, aperture) is // stored in a file whose name could be repeated in the .GATES file for another gate. Only one copy of the file contents is //stored in memory in OpeningsFiles (of GATEOpenings structure). If modified, only that copy is changed. //It will be permanently stored when the user clicks "Save .GATES". Universal.LoadSecondaryTable("GATES", GATESFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 2304171526: error while proccessing ", "ERROR 2304171526: error procesando ") + GATESFileName + ". " + Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } GATESFile.Close(); //Save variables associated to control tags: AddVariable("GATES_VALUES", mainTable); // // // Empty lines left intentionally if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 2003171725: The following gates files do not exist: \n\n", "WARNING 2003171725: Los siguientes archivos no existen: \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//Load .LRAIN data from file public virtual void Load(string LRAINFileName) { StreamReader RAINFile = File.OpenText(LRAINFileName); var warnings = new List <string>(); int index = LRAINFileName.LastIndexOf("\\", StringComparison.Ordinal); string LRAINFilePath = LRAINFileName.Remove(index); //Number of rain/evaporation groups in .LRAIN file: string nGroups = RAINFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); if (numberOfGroups > 0) { AddVariable("NUMBER_OF_RAINEVAP_ZONES", numberOfGroups); //Reset data structs to store .LRAIN data in local memory: var mainTable = new List <string[]>(); LRAINFileContents.Clear(); // //(Code space for individual variables) // for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data from .LRAIN file.... try { // // // // // // // // // Empty lines left intentionally //Secondary table (Rain/evaporation table) file name: string secondaryTableFileName = RAINFile.ReadLine().Trim(); //Read extra lines: int nExtraLines = Convert.ToInt32(RAINFile.ReadLine().Trim()); var extras = new string[nExtraLines]; for (int ii = 0; ii < nExtraLines; ++ii) { extras[ii] = RAINFile.ReadLine(); } //Create this group from data just read: var group = new LRAIN(); group.SecondaryFileName = secondaryTableFileName; group.nExtraLines = nExtraLines; group.ExtraData = extras; //Store data of this zone: LRAINFileContents.Add(group); //Store in mainTable a row to be shown in zones table in DIP tab: //(index, rain/evaporation hydrograph) var row = new string[2]; row[0] = i.ToString(); row[1] = secondaryTableFileName; mainTable.Add(row); //Potential new rain/evaporation group (secundary dependant table). Rain/evaporation data hydrograph (time, Rainfall, Evaporation) is // stored in a file whose name could be repeated in the .LRAIN file for another zone. Only one copy of the file contents is //stored in memory in SecondaryGroups structure. If modified, only that copy is changed. It is permanently stored when //the user clicks "Save .LRAIN". Universal.LoadSecondaryTable("LRAIN", LRAINFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 2003171649: error while proccessing ", "ERROR 2003171649: error procesando ") + LRAINFileName + ". " + Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Save variables associated to control tags: AddVariable("RAINEVAPZONES_VALUES", mainTable); // // // // Empty lines left intentionally if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 2003171725: The following rain/evaporation files do not exist: \n\n", "WARNING 2003171725: Los siguientes archivos no existen: \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { //Number of zones (groups) is negative => Rainfall/evaporation modelled from .RFC catalogue. //MessageBox.Show("Rainfall/Evaporation will be modelled from .RFC catalogue.", "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } RAINFile.Close(); }
//Load .SOURCES data from file public virtual void Load(string SOURCESFileName) { StreamReader SOURCESFile = File.OpenText(SOURCESFileName); var warnings = new List <string>(); int index = SOURCESFileName.LastIndexOf("\\", StringComparison.Ordinal); string SOURCESFilePath = SOURCESFileName.Remove(index); //Number of sources groups in .SOURCES file: string nGroups = SOURCESFile.ReadLine(); int numberOfGroups = Convert.ToInt32(nGroups); AddVariable("NUMBER_OF_SOURCES", numberOfGroups); //Reset data structs to store .LRAIN data in local memory: var mainTable = new List <string[]>(); SOURCESFileContents.Clear(); // //(Code space for individual variables) // for (int i = 0; i < numberOfGroups; ++i) { //Read all rest of data from .SOURCES file.... try { string secondaryTableFileName; // // // // // // Empty lines left intentionally //Source name: string sourceName = SOURCESFile.ReadLine().Trim(); //Source type: string sourceType = SOURCESFile.ReadLine().Trim(); if (!int.TryParse(sourceType, out int intType)) { // Expecting an integer. Maybe it is version previous to 2018. secondaryTableFileName = sourceType; sourceType = "1"; } else { //Secondary table file name: secondaryTableFileName = SOURCESFile.ReadLine().Trim(); } //X Y: string xy = SOURCESFile.ReadLine().Trim(); string[] split = xy.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string X = split[0]; string Y = split[1]; //Create this group from data just read: var group = new SOURCES(); group.SourceName = sourceName; group.SourceType = sourceType; group.SecondaryFileName = secondaryTableFileName; group.XY = xy; //Store data of this zone: SOURCESFileContents.Add(group); //Store in mainTable a row to be shown in zones table in DIP tab: //(index, rain/evaporation hydrograph) var row = new string[5]; row[0] = sourceName; row[1] = sourceType; row[2] = secondaryTableFileName; row[3] = X; row[4] = Y; mainTable.Add(row); //Potential new sources group (secundary dependant table). Sources data (time, Elevations, Concentrations (various)) is // stored in a file whose name could be repeated in the .SOURCES file for another group. Only one copy of the file contents is //stored in memory in SecondaryGroups structure. If modified, only that copy is changed. It is permanently stored when //the user clicks "Save .SOURCES". Universal.LoadSecondaryTable("SOURCES", SOURCESFilePath + "\\" + secondaryTableFileName, ref warnings); } catch (Exception ex) { MessageBox.Show(Universal.Idioma("ERROR 0208171811: error while proccessing ", "ERROR 0208171811: error procesando ") + SOURCESFileName + ". " + Environment.NewLine + ex.Message, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Error); } } SOURCESFile.Close(); //Save variables associated to control tags: AddVariable("SOURCES_VALUES", mainTable); // // // // Empty lines left intentionally if (warnings.Count > 0) { string warningsList = Universal.Idioma("WARNING 0208171813: The following sources files do not exist: \n\n", "WARNING 0208171813: Los siguientes archivos no existen: \n\n"); for (int i = 0; i < warnings.Count; i++) { warningsList += " ° " + warnings[i] + "\n"; } warningsList += Universal.Idioma("\nDefault files were created.", "\nAchivos por defecto fueron creados."); MessageBox.Show(warningsList, "RiverFlow2D", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }