| 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; |
no test coverage detected