ÎļþÃû´Ó Yw.Epanet.Calcu.Core/04-Inp/InpGenerateHelper.cs ÐÞ¸Ä |
| | |
| | | namespace Yw.Epanet |
| | | { |
| | | /// <summary> |
| | | /// Inpçæè¾
å©ç±» |
| | | /// Inpçæå¨ |
| | | /// </summary> |
| | | public static class InpGenerateHelper |
| | | public static class InpGenerater |
| | | { |
| | | private const char _section_head = '[';// è头 |
| | | private const char _section_tail = ']';//èå°¾ |
| | | |
| | | //è·åèç¹åç§° |
| | | private static string GetSectionName(string sectionName) |
| | | { |
| | | var name = $"{_section_head}{sectionName?.ToUpper()}{_section_tail}"; |
| | | return name; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 转æ¢è³Inpå符串 |
| | |
| | | |
| | | #region Title |
| | | |
| | | var titleSectionName = GetSectionName(InpSection.Title); |
| | | var titleSectionName = InpSection.Title; |
| | | sb.AppendLine(titleSectionName); |
| | | sb.AppendLine(nw.Title); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Junctions |
| | | |
| | | var junctionsSectionName = GetSectionName(InpSection.Junctions); |
| | | var junctionsSectionName = InpSection.Junctions; |
| | | sb.AppendLine(junctionsSectionName); |
| | | sb.AppendLine(";ID \tElev \tDemand \tDemandPattern"); |
| | | var allJunctionList = nw.GetAllJunctions(); |
| | |
| | | |
| | | #region Reservoirs |
| | | |
| | | var reservoirsSectionName = GetSectionName(InpSection.Reservoirs); |
| | | var reservoirsSectionName = InpSection.Reservoirs; |
| | | sb.AppendLine(reservoirsSectionName); |
| | | sb.AppendLine(";ID \tHead \tHeadPattern"); |
| | | nw.Reservoirs?.ForEach(x => |
| | |
| | | |
| | | #region Tanks |
| | | |
| | | var tanksSectionName = GetSectionName(InpSection.Tanks); |
| | | var tanksSectionName = InpSection.Tanks; |
| | | sb.AppendLine(tanksSectionName); |
| | | sb.AppendLine(";ID \tPoolElev \tInitLevel \tMinLevel \tMaxLevel \tMinVol \tVolCurve"); |
| | | nw.Tanks?.ForEach(x => |
| | |
| | | |
| | | #region Pipes |
| | | |
| | | var pipesSectionName = GetSectionName(InpSection.Pipes); |
| | | var pipesSectionName = InpSection.Pipes; |
| | | sb.AppendLine(pipesSectionName); |
| | | sb.AppendLine(";ID \tStartNodeId \tEndNodeId \tLength \tDiameter \tRoughness \tMinorLoss \tLinkStatus"); |
| | | nw.Pipes?.ForEach(x => |
| | |
| | | |
| | | #region Pumps |
| | | |
| | | var pumpsSectionName = GetSectionName(InpSection.Pumps); |
| | | var pumpsSectionName = InpSection.Pumps; |
| | | sb.AppendLine(pumpsSectionName); |
| | | sb.AppendLine(";ID \tStartNodeId \tEndNodeId \tProperty"); |
| | | nw.Pumps?.ForEach(x => |
| | |
| | | |
| | | #region Valves |
| | | |
| | | var valvesSectionName = GetSectionName(InpSection.Valves); |
| | | var valvesSectionName = InpSection.Valves; |
| | | sb.AppendLine(valvesSectionName); |
| | | sb.AppendLine(";ID \tStartNodeId \tEndNodeId \tDiameter \tValveType \tValveSetting \tMinorLoss"); |
| | | nw.Valves?.ForEach(x => |
| | |
| | | |
| | | #region Emitters |
| | | |
| | | var emittersSectionName = GetSectionName(InpSection.Emitters); |
| | | var emittersSectionName = InpSection.Emitters; |
| | | sb.AppendLine(emittersSectionName); |
| | | sb.AppendLine(";ID \tCoefficient"); |
| | | var allEmitterList = nw.Emitters; |
| | |
| | | |
| | | #region Curves |
| | | |
| | | var curvesSectionName = GetSectionName(InpSection.Curves); |
| | | var curvesSectionName = InpSection.Curves; |
| | | sb.AppendLine(curvesSectionName); |
| | | sb.AppendLine(";ID \tX-Value \tY-Value"); |
| | | nw.Curves?.ForEach(x => |
| | |
| | | |
| | | #region Patterns |
| | | |
| | | var patternsSectionName = GetSectionName(InpSection.Patterns); |
| | | var patternsSectionName = InpSection.Patterns; |
| | | sb.AppendLine(patternsSectionName); |
| | | sb.AppendLine(";ID \tMultipliers"); |
| | | nw.Patterns?.ForEach(x => |
| | |
| | | |
| | | #region Energy |
| | | |
| | | var energySectionName = GetSectionName(InpSection.Energy); |
| | | var energySectionName = InpSection.Energy; |
| | | sb.AppendLine(energySectionName); |
| | | sb.AppendLine("Global Efficiency \t75 \t;"); |
| | | sb.AppendLine("Global Price \t0 \t;"); |
| | |
| | | |
| | | #region Status |
| | | |
| | | var statusSectionName = GetSectionName(InpSection.Status); |
| | | var statusSectionName = InpSection.Status; |
| | | sb.AppendLine(statusSectionName); |
| | | sb.AppendLine(";ID \tStatus/Setting"); |
| | | nw.Pipes?.ForEach(x => |
| | |
| | | |
| | | #region Demands |
| | | |
| | | var demandsSectionName = GetSectionName(InpSection.Demands); |
| | | var demandsSectionName = InpSection.Demands; |
| | | sb.AppendLine(demandsSectionName); |
| | | sb.AppendLine(";Junction \tDemand \tPattern \tCategory"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Controls |
| | | |
| | | var controlsSectionName = GetSectionName(InpSection.Controls); |
| | | var controlsSectionName = InpSection.Controls; |
| | | sb.AppendLine(controlsSectionName); |
| | | sb.AppendLine(string.Empty); |
| | | |
| | |
| | | |
| | | #region Rules |
| | | |
| | | var rulesSectionName = GetSectionName(InpSection.Rules); |
| | | var rulesSectionName = InpSection.Rules; |
| | | sb.AppendLine(rulesSectionName); |
| | | sb.AppendLine(string.Empty); |
| | | |
| | |
| | | |
| | | #region Quality |
| | | |
| | | var qualitySectionName = GetSectionName(InpSection.Quality); |
| | | var qualitySectionName = InpSection.Quality; |
| | | sb.AppendLine(qualitySectionName); |
| | | sb.AppendLine(";Node \tInitQual"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Reactions |
| | | |
| | | var reactionsSectionName = GetSectionName(InpSection.Reactions); |
| | | var reactionsSectionName = InpSection.Reactions; |
| | | sb.AppendLine(reactionsSectionName); |
| | | sb.AppendLine(";Type \tPipe/Tank \tCoefficient"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Sources |
| | | |
| | | var sourcesSectionName = GetSectionName(InpSection.Sources); |
| | | var sourcesSectionName = InpSection.Sources; |
| | | sb.AppendLine(sourcesSectionName); |
| | | sb.AppendLine(";Node \tType \tQuality \tPattern"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Mixing |
| | | |
| | | var mixingSectionName = GetSectionName(InpSection.Mixing); |
| | | var mixingSectionName = InpSection.Mixing; |
| | | sb.AppendLine(mixingSectionName); |
| | | sb.AppendLine(";Tank \tModel"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Options |
| | | |
| | | var optionsSectionName = GetSectionName(InpSection.Options); |
| | | var optionsSectionName = InpSection.Options; |
| | | sb.AppendLine(optionsSectionName); |
| | | sb.AppendLine("Units \tCMH"); |
| | | sb.AppendLine("Headloss \tH-W"); |
| | |
| | | |
| | | #region Times |
| | | |
| | | var timesSectionName = GetSectionName(InpSection.Times); |
| | | var timesSectionName = InpSection.Times; |
| | | sb.AppendLine(timesSectionName); |
| | | sb.AppendLine("Duration \t0:00"); |
| | | sb.AppendLine("Hydraulic Timestep \t1:00"); |
| | |
| | | |
| | | #region Report |
| | | |
| | | var reportSectionName = GetSectionName(InpSection.Report); |
| | | var reportSectionName = InpSection.Report; |
| | | sb.AppendLine(reportSectionName); |
| | | sb.AppendLine("Status \tYes"); |
| | | sb.AppendLine("Summary \tNo"); |
| | |
| | | |
| | | #region Tags |
| | | |
| | | var tagsSectionName = GetSectionName(InpSection.Tags); |
| | | var tagsSectionName = InpSection.Tags; |
| | | sb.AppendLine(tagsSectionName); |
| | | sb.AppendLine(string.Empty); |
| | | |
| | |
| | | |
| | | #region Coordinates |
| | | |
| | | var coordinatesSectionName = GetSectionName(InpSection.Coordinates); |
| | | var coordinatesSectionName = InpSection.Coordinates; |
| | | sb.AppendLine(coordinatesSectionName); |
| | | sb.AppendLine(";ID \tX-Coord \tY-Coord"); |
| | | var allNodeList = nw.GetAllNodes(); |
| | |
| | | |
| | | #region Vertices |
| | | |
| | | var verticesSectionName = GetSectionName(InpSection.Vertices); |
| | | var verticesSectionName = InpSection.Vertices; |
| | | sb.AppendLine(verticesSectionName); |
| | | sb.AppendLine(";Link \tX-Coord \tY-Coord"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Labels |
| | | |
| | | var labelsSectionName = GetSectionName(InpSection.Labels); |
| | | var labelsSectionName = InpSection.Labels; |
| | | sb.AppendLine(labelsSectionName); |
| | | sb.AppendLine(";X-Coord \tY-Coord \tLabel & Anchor Node"); |
| | | sb.AppendLine(string.Empty); |
| | |
| | | |
| | | #region Backdrop |
| | | |
| | | var backdropSectionName = GetSectionName(InpSection.Backdrop); |
| | | var backdropSectionName = InpSection.Backdrop; |
| | | sb.AppendLine(backdropSectionName); |
| | | sb.AppendLine("DIMENSIONS \t0.000 \t0.000 \t10000.000 \t10000.000"); |
| | | sb.AppendLine("UNITS \tNone"); |
| | |
| | | |
| | | #region End |
| | | |
| | | var endSectionName = GetSectionName(InpSection.End); |
| | | var endSectionName = InpSection.End; |
| | | sb.AppendLine(endSectionName); |
| | | |
| | | #endregion |