MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / modelConsumptionValues

Method modelConsumptionValues

src/model/UtilityBill.cpp:1090–1144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1088 }
1089
1090 Vector BillingPeriod::modelConsumptionValues() const {
1091 model::Model model = getImpl<detail::UtilityBill_Impl>()->model();
1092
1093 boost::optional<RunPeriod> runPeriod = model.runPeriod();
1094 if (!runPeriod) {
1095 return {};
1096 }
1097
1098 boost::optional<model::YearDescription> yd = model.yearDescription();
1099 if (!yd) {
1100 return {};
1101 }
1102
1103 boost::optional<int> calendarYear = yd->calendarYear();
1104 if (!calendarYear) {
1105 return {};
1106 }
1107
1108 Vector result;
1109
1110 OutputMeter meter = getImpl<detail::UtilityBill_Impl>()->consumptionMeter();
1111
1112 Date runPeriodStartDate = Date(runPeriod->getBeginMonth(), runPeriod->getBeginDayOfMonth(), *calendarYear);
1113 Date runPeriodEndDate = Date(runPeriod->getEndMonth(), runPeriod->getEndDayOfMonth(), *calendarYear);
1114
1115 boost::optional<openstudio::TimeSeries> timeseries = meter.getData(runPeriod->name().get());
1116 if (timeseries) {
1117 result = Vector(this->numberOfDays());
1118
1119 double outOfRangeValue = std::numeric_limits<double>::min();
1120 timeseries->setOutOfRangeValue(outOfRangeValue);
1121
1122 unsigned i = 0;
1123 Date date = this->startDate();
1124 Date endDate = this->endDate();
1125 while (date <= endDate) {
1126
1127 // Since E+ v8.9.0, sql has year field
1128 DateTime dateTime(date, Time(1));
1129
1130 double value = timeseries->value(dateTime);
1131 if (value == outOfRangeValue) {
1132 LOG(Debug, "Could not find value of timeseries at dateTime " << dateTime);
1133 return {};
1134 } else {
1135 result[i] = value;
1136 }
1137
1138 ++i;
1139 date += Time(1);
1140 }
1141 }
1142
1143 return result;
1144 }
1145
1146 boost::optional<double> BillingPeriod::modelConsumption() const {
1147 boost::optional<double> result;

Callers 1

modelConsumptionMethod · 0.95

Calls 15

numberOfDaysMethod · 0.95
startDateMethod · 0.95
endDateMethod · 0.95
runPeriodMethod · 0.80
yearDescriptionMethod · 0.80
consumptionMeterMethod · 0.80
getBeginMonthMethod · 0.80
getBeginDayOfMonthMethod · 0.80
getEndMonthMethod · 0.80
getEndDayOfMonthMethod · 0.80
DateClass · 0.70
TimeClass · 0.70

Tested by

no test coverage detected