src/isomodel/TimeFrame.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "TimeFrame.hpp" | ||
| 7 | #include <cassert> | ||
| 8 | |||
| 9 | namespace openstudio { | ||
| 10 | namespace isomodel { | ||
| 11 | |||
| 12 | 3 | TimeFrame::TimeFrame() { | |
| 13 | 3 | int i = 0; | |
| 14 | 3 | int j = 0; | |
| 15 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 3 times.
|
39 | for (int I = 1; I <= 12; I++) { |
| 16 | 36 | int dim = monthLength(I); | |
| 17 |
2/2✓ Branch 0 taken 1095 times.
✓ Branch 1 taken 36 times.
|
1131 | for (int J = 1; J <= dim; J++) { |
| 18 | 1095 | j++; | |
| 19 |
2/2✓ Branch 0 taken 26280 times.
✓ Branch 1 taken 1095 times.
|
27375 | for (int K = 1; K <= 24; K++) { |
| 20 | assert(i < TIMESLICES); | ||
| 21 | 26280 | Hour[i] = K; | |
| 22 | 26280 | Day[i] = J; | |
| 23 | 26280 | Month[i] = I; | |
| 24 | 26280 | YTD[i++] = j; | |
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | 3 | } | |
| 29 | |||
| 30 | 72 | int TimeFrame::monthLength(int month) { | |
| 31 |
3/3✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 42 times.
|
72 | switch (month) { |
| 32 | 6 | case 2: | |
| 33 | 6 | return 28; | |
| 34 | 24 | case 9: | |
| 35 | case 4: | ||
| 36 | case 6: | ||
| 37 | case 11: | ||
| 38 | 24 | return 30; | |
| 39 | 42 | default: | |
| 40 | 42 | return 31; | |
| 41 | } | ||
| 42 | } | ||
| 43 | } // namespace isomodel | ||
| 44 | } // namespace openstudio | ||
| 45 |