Skip to content

Commit fc3959c

Browse files
committed
More object orientation and unification. Eliminate hopefully redundant NotFound enum.
1 parent 12ed421 commit fc3959c

File tree

4 files changed

+100
-96
lines changed

4 files changed

+100
-96
lines changed

src/EnergyPlus/OutputProcessor.cc

Lines changed: 62 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,8 @@ namespace OutputProcessor {
545545
}
546546
}
547547

548-
std::string ProduceMinMaxString([[maybe_unused]] Real64 value,
549-
int const date, // Date of min/max
550-
ReportFreq const freq // Reporting Frequency
548+
std::string produceDateString(int const date, // Date of min/max
549+
ReportFreq const freq // Reporting Frequency
551550
)
552551
{
553552

@@ -1802,15 +1801,7 @@ namespace OutputProcessor {
18021801
}
18031802

18041803
if (periodTS.Rpt) {
1805-
WriteReportMeterData(state,
1806-
periodTS.RptNum,
1807-
periodTS.Value,
1808-
ReportFreq::TimeStep,
1809-
-1.0, // MinValue
1810-
-1, // MinValueDate
1811-
-1.0, // MaxValue
1812-
-1, // MaxValueDate
1813-
periodTS.RptFO);
1804+
periodTS.WriteReportData(state, ReportFreq::TimeStep);
18141805
rfMetersTS.pushVariableValue(periodTS.RptNum, periodTS.Value);
18151806
}
18161807

@@ -1943,16 +1934,7 @@ namespace OutputProcessor {
19431934
}
19441935

19451936
if (period.Rpt) {
1946-
WriteReportMeterData(state,
1947-
period.RptNum,
1948-
period.Value,
1949-
freq,
1950-
(freq == ReportFreq::Hour) ? -1.0 : period.MinVal,
1951-
(freq == ReportFreq::Hour) ? -1 : period.MinValDate,
1952-
(freq == ReportFreq::Hour) ? -1.0 : period.MaxVal,
1953-
(freq == ReportFreq::Hour) ? -1 : period.MaxValDate,
1954-
period.RptFO); // EnergyMeters(Loop)%HRMinVal, EnergyMeters(Loop)%HRMinValDate, & |
1955-
// EnergyMeters(Loop)%HRMaxVal, EnergyMeters(Loop)%HRMaxValDate, &
1937+
period.WriteReportData(state, freq);
19561938
rfMeters.pushVariableValue(period.RptNum, period.Value);
19571939
period.Value = 0.0;
19581940

@@ -2696,23 +2678,14 @@ namespace OutputProcessor {
26962678
}
26972679
} // WriteCumulativeReportMeterData()
26982680

2699-
void WriteReportMeterData(EnergyPlusData &state,
2700-
int const reportID, // The variable's report ID
2701-
Real64 const repValue, // The variable's value
2702-
ReportFreq const freq, // The variable's reporting interval (e.g., hourly)
2703-
Real64 const minValue, // The variable's minimum value during the reporting interval
2704-
int const minValueDate, // The date the minimum value occurred
2705-
Real64 const maxValue, // The variable's maximum value during the reporting interval
2706-
int const maxValueDate, // The date of the maximum value
2707-
bool const meterOnlyFlag // Indicates whether the data is for the meter file only
2681+
void MeterPeriod::WriteReportData(EnergyPlusData &state,
2682+
ReportFreq const freq
27082683
)
27092684
{
27102685

27112686
// SUBROUTINE INFORMATION:
27122687
// AUTHOR Greg Stark
27132688
// DATE WRITTEN July 2008
2714-
// MODIFIED na
2715-
// RE-ENGINEERED na
27162689

27172690
// PURPOSE OF THIS SUBROUTINE:
27182691
// This subroutine writes for the non-cumulative meter data to the output files and
@@ -2722,49 +2695,49 @@ namespace OutputProcessor {
27222695

27232696
std::string NumberOut;
27242697

2725-
if (repValue == 0.0) {
2698+
if (Value == 0.0) {
27262699
NumberOut = "0.0";
27272700
} else {
27282701
char tmp[128];
2729-
dtoa(repValue, tmp);
2702+
dtoa(Value, tmp);
27302703
NumberOut = std::string(tmp);
27312704
}
27322705

27332706
if (sql) {
27342707
sql->createSQLiteReportDataRecord(
2735-
reportID, repValue, freq, minValue, minValueDate, maxValue, maxValueDate, state.dataGlobal->MinutesPerTimeStep);
2708+
RptNum, Value, freq, MinVal, MinValDate, MaxVal, MaxValDate, state.dataGlobal->MinutesPerTimeStep);
27362709
}
27372710

27382711
if ((freq == ReportFreq::EachCall) || (freq == ReportFreq::TimeStep) || (freq == ReportFreq::Hour)) { // -1, 0, 1
27392712
if (state.files.mtr.good()) {
2740-
print(state.files.mtr, "{},{}\n", reportID, NumberOut);
2713+
print(state.files.mtr, "{},{}\n", RptNum, NumberOut);
27412714
}
27422715
++state.dataGlobal->StdMeterRecordCount;
2743-
if (state.files.eso.good() && !meterOnlyFlag) {
2744-
print(state.files.eso, "{},{}\n", reportID, NumberOut);
2716+
if (state.files.eso.good() && !RptFO) {
2717+
print(state.files.eso, "{},{}\n", RptNum, NumberOut);
27452718
++state.dataGlobal->StdOutputRecordCount;
27462719
}
27472720
} else { // if ( ( reportingInterval == ReportDaily ) || ( reportingInterval == ReportMonthly ) || ( reportingInterval == ReportSim ) ) {
27482721
// // 2, 3, 4
27492722
// Append the min and max strings with date information
27502723
char minValString[128], maxValString[128];
2751-
dtoa(minValue, minValString);
2752-
dtoa(maxValue, maxValString);
2724+
dtoa(MinVal, minValString);
2725+
dtoa(MaxVal, maxValString);
27532726

2754-
std::string minDateString = ProduceMinMaxString(minValue, minValueDate, freq);
2755-
std::string maxDateString = ProduceMinMaxString(maxValue, maxValueDate, freq);
2727+
std::string minDateString = produceDateString(MinValDate, freq);
2728+
std::string maxDateString = produceDateString(MaxValDate, freq);
27562729

27572730
if (state.files.mtr.good()) {
2758-
print(state.files.mtr, "{},{},{},{},{},{}\n", reportID, NumberOut, minValString, minDateString, maxValString, maxDateString);
2731+
print(state.files.mtr, "{},{},{},{},{},{}\n", RptNum, NumberOut, minValString, minDateString, maxValString, maxDateString);
27592732
}
27602733

27612734
++state.dataGlobal->StdMeterRecordCount;
2762-
if (state.files.eso.good() && !meterOnlyFlag) {
2763-
print(state.files.eso, "{},{},{},{},{},{}\n", reportID, NumberOut, minValString, minDateString, maxValString, maxDateString);
2735+
if (state.files.eso.good() && !RptFO) {
2736+
print(state.files.eso, "{},{},{},{},{},{}\n", RptNum, NumberOut, minValString, minDateString, maxValString, maxDateString);
27642737
++state.dataGlobal->StdOutputRecordCount;
27652738
}
27662739
}
2767-
} // WriteReportMeterData()
2740+
} // MeterPeriod::WriteReportData()
27682741

27692742
void WriteNumericData(EnergyPlusData &state,
27702743
int const reportID, // The variable's reporting ID
@@ -3048,8 +3021,8 @@ namespace OutputProcessor {
30483021
dtoa(MinValue, minValString);
30493022
dtoa(MaxValue, maxValString);
30503023

3051-
std::string minDateString = ProduceMinMaxString(MinValue, minValueDate, freq);
3052-
std::string maxDateString = ProduceMinMaxString(MaxValue, maxValueDate, freq);
3024+
std::string minDateString = produceDateString(minValueDate, freq);
3025+
std::string maxDateString = produceDateString(maxValueDate, freq);
30533026

30543027
print(state.files.eso, "{},{},{},{},{},{}\n", ReportID, NumberOut, minValString, minDateString, maxValString, maxDateString);
30553028
}
@@ -3499,37 +3472,51 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co
34993472

35003473
// Main "Record Keeping" Loops for R and I variables
35013474
for (auto *var : op->outVars) {
3502-
if (var->varType != VariableType::Real) continue;
3475+
#ifdef GET_OUT
3476+
if (var->varType != VariableType::Real) continue;
3477+
#endif // GET_OUT
35033478
if (var->timeStepType != t_TimeStepTypeKey) continue;
35043479

3505-
OutVarReal *rVar = dynamic_cast<OutVarReal *>(var);
3506-
assert(rVar != nullptr);
3480+
Real64 value = (var->varType == VariableType::Real) ?
3481+
*(dynamic_cast<OutVarReal *>(var))->Which :
3482+
*(dynamic_cast<OutVarInt *>(var))->Which;
35073483

35083484
var->Stored = true;
35093485

3510-
if (rVar->storeType == StoreType::Average) {
3511-
Real64 CurVal = (*rVar->Which) * rxTime;
3486+
if (var->storeType == StoreType::Average) {
3487+
Real64 CurVal = value * rxTime;
35123488
// TODO: Is this correct? Integer logic is different
3513-
if ((*rVar->Which) > var->MaxValue) {
3514-
var->MaxValue = (*rVar->Which);
3515-
var->maxValueDate = MDHM;
3516-
}
3517-
if ((*rVar->Which) < var->MinValue) {
3518-
var->MinValue = (*rVar->Which);
3519-
var->minValueDate = MDHM;
3489+
if (var->varType == VariableType::Real) {
3490+
if (value > var->MaxValue) {
3491+
var->MaxValue = value;
3492+
var->maxValueDate = MDHM;
3493+
}
3494+
if (value < var->MinValue) {
3495+
var->MinValue = value;
3496+
var->minValueDate = MDHM;
3497+
}
3498+
} else { // var->varType == VariableType::Integer
3499+
if (CurVal > var->MaxValue) {
3500+
var->MaxValue = CurVal;
3501+
var->maxValueDate = MDHM;
3502+
}
3503+
if (CurVal < var->MinValue) {
3504+
var->MinValue = CurVal;
3505+
var->minValueDate = MDHM;
3506+
}
35203507
}
35213508
var->TSValue += CurVal;
35223509
var->EITSValue = var->TSValue; // CR - 8481 fix - 09/06/2011
35233510
} else {
3524-
if ((*rVar->Which) > rVar->MaxValue) {
3525-
rVar->MaxValue = (*rVar->Which);
3526-
rVar->maxValueDate = MDHM;
3511+
if (value > var->MaxValue) {
3512+
var->MaxValue = value;
3513+
var->maxValueDate = MDHM;
35273514
}
3528-
if ((*rVar->Which) < rVar->MinValue) {
3529-
rVar->MinValue = (*rVar->Which);
3530-
rVar->minValueDate = MDHM;
3515+
if (value < var->MinValue) {
3516+
var->MinValue = value;
3517+
var->minValueDate = MDHM;
35313518
}
3532-
var->TSValue += (*rVar->Which);
3519+
var->TSValue += value;
35333520
var->EITSValue = var->TSValue; // CR - 8481 fix - 09/06/2011
35343521
}
35353522

@@ -3573,14 +3560,15 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co
35733560
TimePrint = false;
35743561
}
35753562

3576-
WriteNumericData(state, var->ReportID, *rVar->Which);
3563+
WriteNumericData(state, var->ReportID, value);
35773564
++state.dataGlobal->StdOutputRecordCount;
35783565

35793566
if (rf->timeSeriesEnabled()) {
3580-
rf->detailedTSData[(int)t_TimeStepTypeKey].pushVariableValue(var->ReportID, *rVar->Which);
3567+
rf->detailedTSData[(int)t_TimeStepTypeKey].pushVariableValue(var->ReportID, value);
35813568
}
35823569
} // for (var)
35833570

3571+
#ifdef GET_OUT
35843572
for (auto *var : op->outVars) {
35853573
if (var->varType != VariableType::Integer) continue;
35863574
if (var->timeStepType != t_TimeStepTypeKey) continue;
@@ -3662,7 +3650,8 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co
36623650
rf->detailedTSData[(int)t_TimeStepTypeKey].pushVariableValue(iVar->ReportID, *iVar->Which);
36633651
}
36643652
} // for (var)
3665-
3653+
#endif // GET_OUT
3654+
36663655
if (t_TimeStepTypeKey == TimeStepType::System) return; // All other stuff happens at the "zone" time step call to this routine.
36673656

36683657
// TimeStep Block (Report on Zone TimeStep)
@@ -3908,11 +3897,6 @@ void UpdateDataandReport(EnergyPlusData &state, OutputProcessor::TimeStepType co
39083897
if (var->varType != VariableType::Integer) continue;
39093898
if (var->timeStepType != TimeStepType::Zone && var->timeStepType != TimeStepType::System) continue;
39103899

3911-
// ReportNow=.TRUE.
3912-
// IF (RVar%SchedPtr > 0) &
3913-
// ReportNow=(GetCurrentScheduleValue(state, RVar%SchedPtr) /= 0.0) !SetReportNow(RVar%SchedPtr)
3914-
3915-
// IF (ReportNow) THEN
39163900
if (var->tsStored) {
39173901
if (var->storeType == StoreType::Average) {
39183902
var->Value /= double(var->thisTSCount);
@@ -4752,7 +4736,7 @@ void GetVariableKeyCountandType(EnergyPlusData &state,
47524736
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
47534737
auto &op = state.dataOutputProcessor;
47544738

4755-
varType = VariableType::NotFound;
4739+
varType = VariableType::Invalid;
47564740
numKeys = 0;
47574741
storeType = StoreType::Average;
47584742
timeStepType = TimeStepType::Zone;
@@ -5055,6 +5039,7 @@ void ProduceRDDMDD(EnergyPlusData &state)
50555039

50565040
if (ddVar->ReportedOnDDFile) continue;
50575041

5042+
static constexpr std::array<std::string_view, (int)TimeStepType::Num> timeStepNamesLocal = {"Zone", "HVAC"};
50585043
std::string_view timeStepName = timeStepTypeNames[(int)ddVar->timeStepType];
50595044
std::string_view storeTypeName = storeTypeNames[(int)ddVar->storeType];
50605045
std::string_view varName = ddVar->name;

src/EnergyPlus/OutputProcessor.hh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ namespace OutputProcessor {
539539
MinVal = MinSetValue;
540540
MinValDate = 0;
541541
}
542+
543+
void WriteReportData(EnergyPlusData &state, ReportFreq freq);
542544
};
543545

544546
struct Meter
@@ -627,9 +629,8 @@ namespace OutputProcessor {
627629

628630
ReportFreq determineFrequency(EnergyPlusData &state, std::string_view const FreqString);
629631

630-
std::string ProduceMinMaxString(std::string &String, // Current value
631-
int DateValue, // Date of min/max
632-
ReportFreq freq // Reporting Frequency
632+
std::string produceDateString(int DateValue, // Date of min/max
633+
ReportFreq freq // Reporting Frequency
633634
);
634635

635636
// *****************************************************************************
@@ -754,6 +755,7 @@ namespace OutputProcessor {
754755
bool meterOnlyFlag // A flag that indicates if the data should be written to standard output
755756
);
756757

758+
#ifdef GET_OUT
757759
void WriteReportMeterData(EnergyPlusData &state,
758760
int reportID, // The variable's report ID
759761
Real64 repValue, // The variable's value
@@ -764,7 +766,8 @@ namespace OutputProcessor {
764766
int maxValueDate, // The date of the maximum value
765767
bool meterOnlyFlag // Indicates whether the data is for the meter file only
766768
);
767-
769+
#endif // GET_OUT
770+
768771
void WriteNumericData(EnergyPlusData &state,
769772
int reportID, // The variable's reporting ID
770773
Real64 repValue // The variable's value

src/EnergyPlus/OutputReportTabular.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void InitializeTabularMonthly(EnergyPlusData &state)
623623
// call the key count function but only need count during this pass
624624
int KeyCount = 0;
625625
GetVariableKeyCountandType(state, curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar);
626-
if (TypeVar == OutputProcessor::VariableType::NotFound) { // TODO: This NotFound thing has to go
626+
if (TypeVar == OutputProcessor::VariableType::Invalid) { // TODO: This NotFound thing has to go
627627
if (!ort->MonthlyInput(TabNum).isNamedMonthly) {
628628
++state.dataOutRptTab->ErrCount1;
629629
}

0 commit comments

Comments
 (0)