EPANET  3.0
EPANET Development Project
outputfile.h
1 /* EPANET 3
2  *
3  * Copyright (c) 2016 Open Water Analytics
4  * Licensed under the terms of the MIT License (see the LICENSE file for details).
5  *
6  */
7 
10 
11 #ifndef OUTPUTFILE_H_
12 #define OUTPUTFILE_H_
13 
14 #include <fstream>
15 #include <string>
16 
17 class Network;
18 class ReportWriter;
19 
20 const int IntSize = sizeof(int);
21 const int FloatSize = sizeof(float);
22 const int NumSysVars = 21;
23 const int NumNodeVars = 6;
24 const int NumLinkVars = 7;
25 const int NumPumpVars = 6;
26 
29 
31 {
32  public:
33  OutputFile();
34  ~OutputFile();
35 
36  int open(const std::string fileName, Network* nw);
37  void close();
38 
39  int initWriter();
40  int writeEnergyResults(double totalHrs, double peakKwatts);
41  int writeNetworkResults();
42 
43  int initReader();
44  void seekEnergyOffset();
45  void readEnergyResults(int* pumpIndex);
46  void readEnergyDemandCharge(float* demandCharge);
47  void seekNetworkOffset();
48  void readNodeResults();
49  void readLinkResults();
50  void skipNodeResults();
51  void skipLinkResults();
52 
53  friend ReportWriter;
54 
55  private:
56  std::string fname;
57  std::ofstream fwriter;
58  std::ifstream freader;
59  Network* network;
60  int nodeCount;
61  int linkCount;
62  int pumpCount;
63  int timePeriodCount;
64  int reportStart;
65  int reportStep;
66  int energyResultsOffset;
67  int networkResultsOffset;
68  float nodeResults[NumNodeVars];
69  float linkResults[NumLinkVars];
70  float pumpResults[NumPumpVars];
71  void writeNodeResults();
72  void writeLinkResults();
73 };
74 
75 #endif
Definition: reportwriter.h:24
Manages the writing and reading of analysis results to a binary file.
Definition: outputfile.h:30
Contains the data elements that describe a pipe network.
Definition: network.h:41