Skip to content

Commit

Permalink
Merge pull request #10231 from jcyuan2020/N3_endUseCat_SOV_wrapper
Browse files Browse the repository at this point in the history
SetupOutputVariable wrapper to use enum type parameters (endUseCategory, ReportingFrequency, and eResouceType)
  • Loading branch information
Myoldmopar authored Nov 2, 2023
2 parents 6cff1f7 + 77246af commit f511c09
Show file tree
Hide file tree
Showing 9 changed files with 625 additions and 46 deletions.
6 changes: 5 additions & 1 deletion scripts/dev/check_for_malformed_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def process_enum_str(input_str: str, file_name: str, line_no: int, print_errors:
"CsvParser.hh:Token",
"IdfParser.hh:Token",
"OutputProcessor.hh:ReportingFrequency",
"OutputProcessor.hh:ReportFreqSOV",
"HVACInterfaceManager.cc:UpdateType",
"DataHeatBalance.hh:PERptVars",
]
Expand Down Expand Up @@ -149,7 +150,10 @@ def process_enum_str(input_str: str, file_name: str, line_no: int, print_errors:
# check for proper casing
if str(name[0]).islower():
# exceptions listed by <FILE>:<ENUM NAME>
exceptions = ["DataGlobalConstants.hh:eResource", "DataGlobalConstants.hh:eFuel", "DataGlobalConstants.hh:ePollutant"]
exceptions = [
"DataGlobalConstants.hh:eResource", "DataGlobalConstants.hh:eFuel",
"DataGlobalConstants.hh:ePollutant", "OutputProcessor.hh:eResourceSOV"
]
if f"{file_name}:{name}" not in exceptions:
error_str += "\tenum name must begin with upper case letter\n"

Expand Down
12 changes: 6 additions & 6 deletions src/EnergyPlus/BaseboardElectric.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ namespace BaseboardElectric {
OutputProcessor::SOVStoreType::Summed,
thisBaseboard.EquipName,
{},
"ENERGYTRANSFER",
"BASEBOARD",
eResourceSOV::EnergyTransfer,
EndUseCatSOV::Baseboard,
{},
"System");
GroupSOV::HVAC); // "System");

SetupOutputVariable(state,
"Baseboard Total Heating Rate",
Expand All @@ -373,10 +373,10 @@ namespace BaseboardElectric {
OutputProcessor::SOVStoreType::Summed,
thisBaseboard.EquipName,
{},
"Electricity",
"HEATING",
eResourceSOV::Electricity,
EndUseCatSOV::Heating,
{},
"System");
GroupSOV::HVAC); // "System");

SetupOutputVariable(state,
"Baseboard Electricity Rate",
Expand Down
12 changes: 6 additions & 6 deletions src/EnergyPlus/BaseboardRadiator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ namespace BaseboardRadiator {
OutputProcessor::SOVStoreType::Summed,
thisBaseboard.EquipID,
{},
"ENERGYTRANSFER",
"BASEBOARD",
eResourceSOV::EnergyTransfer,
EndUseCatSOV::Baseboard,
{},
"System");
GroupSOV::HVAC); // "System");

SetupOutputVariable(state,
"Baseboard Hot Water Energy",
Expand All @@ -451,10 +451,10 @@ namespace BaseboardRadiator {
OutputProcessor::SOVStoreType::Summed,
thisBaseboard.EquipID,
{},
"PLANTLOOPHEATINGDEMAND",
"BASEBOARD",
eResourceSOV::PlantLoopHeatingDemand,
EndUseCatSOV::Baseboard,
{},
"System");
GroupSOV::HVAC); // "System");

SetupOutputVariable(state,
"Baseboard Total Heating Rate",
Expand Down
12 changes: 6 additions & 6 deletions src/EnergyPlus/Boilers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ void BoilerSpecs::SetupOutputVars(EnergyPlusData &state)
OutputProcessor::SOVStoreType::Summed,
this->Name,
{},
"ENERGYTRANSFER",
"BOILERS",
eResourceSOV::EnergyTransfer,
EndUseCatSOV::Boilers,
{},
"Plant");
GroupSOV::Plant);
SetupOutputVariable(state,
format("Boiler {} Rate", sFuelType),
OutputProcessor::Unit::W,
Expand Down Expand Up @@ -442,10 +442,10 @@ void BoilerSpecs::SetupOutputVars(EnergyPlusData &state)
OutputProcessor::SOVStoreType::Summed,
this->Name,
{},
"ELECTRICITY",
"Heating",
eResourceSOV::Electricity,
EndUseCatSOV::Heating,
"Boiler Parasitic",
"Plant");
GroupSOV::Plant);
if (this->FuelType != Constant::eFuel::Electricity) {
SetupOutputVariable(state,
format("Boiler Ancillary {} Rate", sFuelType),
Expand Down
18 changes: 9 additions & 9 deletions src/EnergyPlus/CoolTower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ namespace CoolTower {
OutputProcessor::SOVStoreType::Summed,
Zone(state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr).Name,
{},
"Electricity",
"Cooling",
eResourceSOV::Electricity,
EndUseCatSOV::Cooling,
{},
"System");
GroupSOV::HVAC); //"System");
if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyMode == WaterSupplyMode::FromMains) {
SetupOutputVariable(state,
"Zone Cooltower Water Volume",
Expand All @@ -560,10 +560,10 @@ namespace CoolTower {
OutputProcessor::SOVStoreType::Summed,
Zone(state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr).Name,
{},
"MainsWater",
"Cooling",
eResourceSOV::MainsWater,
EndUseCatSOV::Cooling,
{},
"System");
GroupSOV::HVAC); // "System");
} else if (state.dataCoolTower->CoolTowerSys(CoolTowerNum).CoolTWaterSupplyMode == WaterSupplyMode::FromTank) {
SetupOutputVariable(state,
"Zone Cooltower Water Volume",
Expand All @@ -587,10 +587,10 @@ namespace CoolTower {
OutputProcessor::SOVStoreType::Summed,
Zone(state.dataCoolTower->CoolTowerSys(CoolTowerNum).ZonePtr).Name,
{},
"MainsWater",
"Cooling",
eResourceSOV::MainsWater,
EndUseCatSOV::Cooling,
{},
"System");
GroupSOV::HVAC); // "System");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/EarthTube.cc
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,10 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i
OutputProcessor::SOVStoreType::NonState,
zone.Name,
{},
"Electricity",
eResourceSOV::Electricity,
{},
{},
"Building");
GroupSOV::Building);
SetupOutputVariable(state,
"Earth Tube Fan Electricity Rate",
OutputProcessor::Unit::W,
Expand Down
136 changes: 136 additions & 0 deletions src/EnergyPlus/OutputProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4273,6 +4273,93 @@ namespace OutputProcessor {

} // namespace OutputProcessor

void SetupOutputVariable(EnergyPlusData &state,
std::string_view const VariableName, // String Name of variable (with units)
OutputProcessor::Unit VariableUnit, // Actual units corresponding to the actual variable
Real64 &ActualVariable, // Actual Variable, used to set up pointer
OutputProcessor::SOVTimeStepType TimeStepTypeKey, // Zone, HeatBalance=1, HVAC, System, Plant=2
OutputProcessor::SOVStoreType VariableTypeKey, // State, Average=1, NonState, Sum=2
std::string_view const KeyedValue // Associated Key for this variable
)
{
SetupOutputVariable(state, VariableName, VariableUnit, ActualVariable, TimeStepTypeKey, VariableTypeKey, KeyedValue, "");
}

void SetupOutputVariable(EnergyPlusData &state,
std::string_view const VariableName, // String Name of variable (with units)
OutputProcessor::Unit VariableUnit, // Actual units corresponding to the actual variable
Real64 &ActualVariable, // Actual Variable, used to set up pointer
OutputProcessor::SOVTimeStepType TimeStepTypeKey, // Zone, HeatBalance=1, HVAC, System, Plant=2
OutputProcessor::SOVStoreType VariableTypeKey, // State, Average=1, NonState, Sum=2
std::string_view const KeyedValue, // Associated Key for this variable
ReportFreqSOV ReportFreq, // Internal use -- causes reporting at this freqency
eResourceSOV ResourceTypeKey, // Meter Resource Type (Electricity, Gas, etc)
EndUseCatSOV EndUseKey, // Meter End Use Key (Lights, Heating, Cooling, etc)
std::string_view const EndUseSubKey, // Meter End Use Sub Key (General Lights, Task Lights, etc)
GroupSOV GroupKey, // Meter Super Group Key (Building, System, Plant)
std::string_view const ZoneKey, // Meter Zone Key (zone name)
int const ZoneMult, // Zone Multiplier, defaults to 1
int const ZoneListMult, // Zone List Multiplier, defaults to 1
int const indexGroupKey, // Group identifier for SQL output
std::string_view const customUnitName, // the custom name for the units from EMS definition of units
std::string_view const SpaceType // Space type (applicable for Building group only)
)
{
std::string locReportFreq = "";
std::string locResourceTypeKey = "";
std::string locEndUseKey = "";
std::string locGroupKey = "";

if (ReportFreq == ReportFreqSOV::Num) {
// Fatal error warning message
ShowFatalError(state, "Invalid Resource Type.");
} else if (ReportFreq == ReportFreqSOV::EachCall) // This is valid
{
locReportFreq = "DETAILED";
} else {
locReportFreq = ReporFreqSOVNames[static_cast<int>(ReportFreq)];
}

if (ResourceTypeKey == eResourceSOV::Invalid || ResourceTypeKey == eResourceSOV::Num) {
// Fatal error warning message
ShowFatalError(state, "Invalid Resource Type.");
} else {
locResourceTypeKey = eResourceSOVNames[static_cast<int>(ResourceTypeKey)];
}

if (EndUseKey == EndUseCatSOV::Invalid || EndUseKey == EndUseCatSOV::Num) {
// Fatal error warning message
ShowFatalError(state, "Invalid End Use Category.");
} else {
locEndUseKey = endUseCatSOVNames[static_cast<int>(EndUseKey)];
}

if (GroupKey == GroupSOV::Invalid || GroupKey == GroupSOV::Num) {
ShowFatalError(state, "Invalid Group Type.");
} else {
locGroupKey = GroupSOVNames[static_cast<int>(GroupKey)];
}

SetupOutputVariable(state,
VariableName,
VariableUnit,
ActualVariable,
TimeStepTypeKey,
VariableTypeKey,
KeyedValue,
locReportFreq,
locResourceTypeKey,
locEndUseKey,
EndUseSubKey,
locGroupKey,
ZoneKey,
ZoneMult,
ZoneListMult,
indexGroupKey,
customUnitName,
SpaceType);
}

// TODO: Probably move these to a different location

void SetupOutputVariable(EnergyPlusData &state,
Expand Down Expand Up @@ -4517,6 +4604,55 @@ void SetupOutputVariable(EnergyPlusData &state,
}
}

void SetupOutputVariable(EnergyPlusData &state,
std::string_view const VariableName, // String Name of variable
OutputProcessor::Unit const VariableUnit, // Actual units corresponding to the actual variable
int &ActualVariable, // Actual Variable, used to set up pointer
OutputProcessor::SOVTimeStepType const TimeStepTypeKey, // Zone, HeatBalance=1, HVAC, System, Plant=2
OutputProcessor::SOVStoreType const VariableTypeKey, // State, Average=1, NonState, Sum=2
std::string_view const KeyedValue // Associated Key for this variable
)
{
SetupOutputVariable(state,
VariableName, // String Name of variable
VariableUnit, // Actual units corresponding to the actual variable
ActualVariable, // Actual Variable, used to set up pointer
TimeStepTypeKey, // Zone, HeatBalance=1, HVAC, System, Plant=2
VariableTypeKey, // State, Average=1, NonState, Sum=2
KeyedValue, // Associated Key for this variable
"" // Internal use -- causes reporting at this freqency
// indexGroupKey // Group identifier for SQL output
);
}

void SetupOutputVariable(EnergyPlusData &state,
std::string_view const VariableName, // String Name of variable
OutputProcessor::Unit const VariableUnit, // Actual units corresponding to the actual variable
int &ActualVariable, // Actual Variable, used to set up pointer
OutputProcessor::SOVTimeStepType const TimeStepTypeKey, // Zone, HeatBalance=1, HVAC, System, Plant=2
OutputProcessor::SOVStoreType const VariableTypeKey, // State, Average=1, NonState, Sum=2
std::string_view const KeyedValue, // Associated Key for this variable
OutputProcessor::ReportingFrequency const ReportFreq, // Internal use -- causes reporting at this freqency
int const indexGroupKey // Group identifier for SQL output
)
{
if (ReportFreq == OutputProcessor::ReportingFrequency::EachCall) // This is valid
{
SetupOutputVariable(
state, VariableName, VariableUnit, ActualVariable, TimeStepTypeKey, VariableTypeKey, KeyedValue, "DETAILED", indexGroupKey);
} else {
SetupOutputVariable(state,
VariableName,
VariableUnit,
ActualVariable,
TimeStepTypeKey,
VariableTypeKey,
KeyedValue,
OutputProcessor::ReportingFrequencyNames[static_cast<int>(ReportFreq)],
indexGroupKey);
}
}

void SetupOutputVariable(EnergyPlusData &state,
std::string_view const VariableName, // String Name of variable
OutputProcessor::Unit const VariableUnit, // Actual units corresponding to the actual variable
Expand Down
Loading

5 comments on commit f511c09

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-MacOS-10.17-clang-14.0.0: OK (2752 of 2752 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (2773 of 2773 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2751 of 2751 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1965 of 1965 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (789 of 789 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.