示例#1
0
        private void ComposeReport(Network net)
        {
            buffer.WriteLine(SectType.REPORT.ParseStr());

            FieldsMap fMap = net.FieldsMap;

            buffer.WriteLine("PAGESIZE       {0}", net.PageSize);
            buffer.WriteLine("STATUS         " + net.StatFlag);
            buffer.WriteLine("SUMMARY        " + (net.SummaryFlag ? Keywords.w_YES : Keywords.w_NO));
            buffer.WriteLine("ENERGY         " + (net.EnergyFlag ? Keywords.w_YES : Keywords.w_NO));

            switch (net.NodeFlag)
            {
            case ReportFlag.FALSE:
                buffer.WriteLine("NODES NONE");
                break;

            case ReportFlag.TRUE:
                buffer.WriteLine("NODES ALL");
                break;

            case ReportFlag.SOME: {
                int j = 0;
                foreach (Node node  in  net.Nodes)
                {
                    if (node.RptFlag)
                    {
                        // if (j % 5 == 0) buffer.WriteLine("NODES "); // BUG: Baseform bug

                        if (j % 5 == 0)
                        {
                            buffer.WriteLine();
                            buffer.Write("NODES ");
                        }

                        buffer.Write("{0} ", node.Name);
                        j++;
                    }
                }
                break;
            }
            }

            switch (net.LinkFlag)
            {
            case ReportFlag.FALSE:
                buffer.WriteLine("LINKS NONE");
                break;

            case ReportFlag.TRUE:
                buffer.WriteLine("LINKS ALL");
                break;

            case ReportFlag.SOME: {
                int j = 0;
                foreach (Link link  in  net.Links)
                {
                    if (link.RptFlag)
                    {
                        // if (j % 5 == 0) buffer.write("LINKS \n"); // BUG: Baseform bug
                        if (j % 5 == 0)
                        {
                            buffer.WriteLine();
                            buffer.Write("LINKS ");
                        }

                        buffer.Write("{0} ", link.Name);
                        j++;
                    }
                }
                break;
            }
            }

            for (FieldType i = 0; i < FieldType.FRICTION; i++)
            {
                Field f = fMap.GetField(i);

                if (!f.Enabled)
                {
                    buffer.WriteLine("{0,-19} NO", f.Name);
                    continue;
                }

                buffer.WriteLine("{0,-19} PRECISION {1}", f.Name, f.Precision);

                if (f.GetRptLim(RangeType.LOW) < Constants.BIG)
                {
                    buffer.WriteLine("{0,-19} BELOW {1:0.######}", f.Name, f.GetRptLim(RangeType.LOW));
                }

                if (f.GetRptLim(RangeType.HI) > -Constants.BIG)
                {
                    buffer.WriteLine("{0,-19} ABOVE {1:0.######}", f.Name, f.GetRptLim(RangeType.HI));
                }
            }

            buffer.WriteLine();
        }
示例#2
0
        private void ComposeReport()
        {
            _writer.WriteStartElement(SectType.REPORT.ToString().ToLower());

            FieldsMap fMap = _net.FieldsMap;

            WriteOption("pagesize", _net.PageSize.ToString());
            WriteOption("status", _net.StatFlag.ParseStr());
            WriteOption("summary", (_net.SummaryFlag ? Keywords.w_YES : Keywords.w_NO));
            WriteOption("energy", (_net.EnergyFlag ? Keywords.w_YES : Keywords.w_NO));

            switch (_net.NodeFlag)
            {
            case ReportFlag.FALSE:
                WriteOption("nodes", "none");
                break;

            case ReportFlag.TRUE:
                WriteOption("nodes", "all");
                break;

            case ReportFlag.SOME: {
                _writer.WriteStartElement("option");
                _writer.WriteAttributeString("name", "nodes");
                _writer.WriteAttributeString("value", "some");

                foreach (Node node in _net.Nodes)
                {
                    if (node.RptFlag)
                    {
                        _writer.WriteStartElement("node");
                        _writer.WriteAttributeString("name", node.Name);
                        _writer.WriteEndElement();
                    }
                }

                _writer.WriteEndElement();
                break;
            }
            }

            switch (_net.LinkFlag)
            {
            case ReportFlag.FALSE:
                WriteOption("links", "none");
                break;

            case ReportFlag.TRUE:
                WriteOption("links", "all");
                break;

            case ReportFlag.SOME:
                _writer.WriteStartElement("option");
                _writer.WriteAttributeString("name", "links");
                _writer.WriteAttributeString("value", "some");

                foreach (Link link in _net.Links)
                {
                    if (link.RptFlag)
                    {
                        _writer.WriteStartElement("link");
                        _writer.WriteAttributeString("name", link.Name);
                        _writer.WriteEndElement();
                    }
                }

                _writer.WriteEndElement();

                break;
            }

            for (FieldType i = 0; i < FieldType.FRICTION; i++)
            {
                Field f = fMap.GetField(i);

                if (!f.Enabled)
                {
                    _writer.WriteStartElement("field");
                    _writer.WriteAttributeString("name", f.Name);
                    _writer.WriteAttributeString("enabled", "false");
                    _writer.WriteEndElement();
                    continue;
                }

                _writer.WriteStartElement("field");
                _writer.WriteAttributeString("name", f.Name);
                _writer.WriteAttributeString("enabled", "true");
                _writer.WriteAttributeString("precision", f.Precision.ToString());

                if (f.GetRptLim(RangeType.LOW) < Constants.BIG)
                {
                    _writer.WriteAttributeString("below", XmlConvert.ToString(f.GetRptLim(RangeType.LOW)));
                }

                if (f.GetRptLim(RangeType.HI) > -Constants.BIG)
                {
                    _writer.WriteAttributeString("above", XmlConvert.ToString(f.GetRptLim(RangeType.HI)));
                }

                _writer.WriteEndElement();
            }

            _writer.WriteEndElement();
        }
示例#3
0
        /// <summary>Write simulation summary to one worksheet.</summary>
        ///  <param name="inpFile">Hydraulic network file name.</param>
        /// <param name="net">Hydraulic network.</param>
        /// <param name="msxFile">MSX file.</param>
        /// <param name="msx">MSX solver.</param>
        public void WriteSummary(string inpFile, EpanetNetwork net, string msxFile, EpanetMSX msx)
        {
            var sh = _sheet.NewSpreadsheet("Summary");

            try {
                FieldsMap fMap = net.FieldsMap;

                if (net.Title != null)
                {
                    for (int i = 0; i < net.Title.Count && i < 3; i++)
                    {
                        if (!string.IsNullOrEmpty(net.Title[i]))
                        {
                            sh.AddData(
                                net.Title[i].Length > 70
                                ? net.Title[i].Substring(0, 70)
                                : net.Title[i]);
                        }
                    }
                }

                sh.AddData("\n");
                sh.AddData(Text.FMT19, inpFile);
                sh.AddData(Text.FMT20, net.Junctions.Count());

                int nReservoirs = net.Reservoirs.Count();
                int nTanks      = net.Tanks.Count();
                int nValves     = net.Valves.Count();
                int nPumps      = net.Pumps.Count();
                int nPipes      = net.Links.Count - nPumps - nValves;

                sh.AddData(Text.FMT21a, nReservoirs);
                sh.AddData(Text.FMT21b, nTanks);
                sh.AddData(Text.FMT22, nPipes);
                sh.AddData(Text.FMT23, nPumps);
                sh.AddData(Text.FMT24, nValves);
                sh.AddData(Text.FMT25, net.FormFlag.ParseStr());

                sh.AddData(Text.FMT26, net.HStep.GetClockTime());
                sh.AddData(Text.FMT27, net.HAcc);
                sh.AddData(Text.FMT27a, net.CheckFreq);
                sh.AddData(Text.FMT27b, net.MaxCheck);
                sh.AddData(Text.FMT27c, net.DampLimit);
                sh.AddData(Text.FMT28, net.MaxIter);

                switch (net.Duration == 0 ? QualType.NONE : net.QualFlag)
                {
                case QualType.NONE:
                    sh.AddData(Text.FMT29, "None");
                    break;

                case QualType.CHEM:
                    sh.AddData(Text.FMT30, net.ChemName);
                    break;

                case QualType.TRACE:
                    sh.AddData(Text.FMT31, "Trace From Node", net.GetNode(net.TraceNode).Name);
                    break;

                case QualType.AGE:
                    sh.AddData(Text.FMT32, "Age");
                    break;
                }

                if (net.QualFlag != QualType.NONE && net.Duration > 0)
                {
                    sh.AddData(Text.FMT33, "Time Step", net.QStep.GetClockTime());
                    sh.AddData(
                        Text.FMT34,
                        "Tolerance",
                        fMap.RevertUnit(FieldType.QUALITY, net.Ctol),
                        fMap.GetField(FieldType.QUALITY).Units);
                }

                sh.AddData(Text.FMT36, net.SpGrav);
                sh.AddData(Text.FMT37a, net.Viscos / Constants.VISCOS);
                sh.AddData(Text.FMT37b, net.Diffus / Constants.DIFFUS);
                sh.AddData(Text.FMT38, net.DMult);
                sh.AddData(
                    Text.FMT39,
                    fMap.RevertUnit(FieldType.TIME, net.Duration),
                    fMap.GetField(FieldType.TIME).Units);

                if (msxFile != null && msx != null)
                {
                    sh.AddData("");
                    sh.AddData("MSX data file", msxFile);
                    sh.AddData("Species");
                    Species[] spe = msx.Network.Species;
                    for (int i = 1; i < msx.Network.Species.Length; i++)
                    {
                        sh.AddData(spe[i].Id, spe[i].Units);
                    }
                }
            }
            catch (IOException) {}
            catch (ENException e) {
                Debug.Print(e.ToString());
            }
        }