GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 19 / 0 / 19
Functions: 100.0% 3 / 0 / 3
Branches: 75.0% 15 / 0 / 20

src/airflow/contam/PrjDefines.hpp
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 #ifndef AIRFLOW_CONTAM_PRJDEFINES_HPP
7 #define AIRFLOW_CONTAM_PRJDEFINES_HPP
8
9 #include <string>
10 #include <sstream>
11
12 using PRJFLOAT = std::string;
13
14 namespace openstudio::contam {
15
16 template <typename DesiredType, typename InputType>
17 4108 DesiredType to(const InputType& inp) {
18
1/1
✓ Branch 1 taken 4108 times.
4108 std::stringstream ss;
19
2/2
✓ Branch 1 taken 4108 times.
✓ Branch 4 taken 4108 times.
4108 ss.imbue(std::locale::classic());
20
1/1
✓ Branch 1 taken 4108 times.
4108 ss.str(inp);
21 DesiredType o;
22
1/1
✓ Branch 1 taken 4108 times.
4108 ss >> o;
23
6/10
✓ Branch 1 taken 4107 times.
✓ Branch 2 taken 1 time.
✓ Branch 4 taken 4107 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4107 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 4107 times.
4108 if (!ss.eof() || ss.fail()) {
24 1 throw std::bad_cast();
25 }
26 4107 return o;
27 4108 }
28
29 template <typename DesiredType, typename InputType>
30 4108 bool is_valid(const InputType& input) {
31 try {
32
1/1
✓ Branch 1 taken 4107 times.
4108 to<DesiredType>(input);
33 4107 return true;
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 } catch (const std::bad_cast&) {
35 1 return false;
36 }
37 }
38
39 template <typename DesiredType, typename InputType, typename DestinationType>
40 2128 bool assign_if_valid(const InputType& input, DestinationType& dest) {
41
2/2
✓ Branch 1 taken 2127 times.
✓ Branch 2 taken 1 time.
2128 if (is_valid<DesiredType>(input)) {
42 2127 dest = input;
43 2127 return true;
44 } else {
45 1 return false;
46 }
47 }
48
49 } // namespace openstudio::contam
50
51 #define ANY_TO_STR openstudio::toString
52
53 // CONTAM icon definitions
54 #define FLOW_E 1 /* flow arrow - pointing east */
55 #define FLOW_W 2 /* flow arrow - pointing west */
56 #define FLOW_N 3 /* flow arrow - pointing north */
57 #define FLOW_S 4 /* flow arrow - pointing south */
58 #define ZONE_ST 5 /* zone - standard */
59 #define ZONE_PH 6 /* zone - phantom */
60 #define ZONE_AM 7 /* zone - ambient */
61 #define CONT_SS_C93 8 /* contaminant source/sink (C93) */
62 #define WL_EW 11 /* wall - east/west */
63 #define WL_NS 12 /* wall - north/south */
64 #define WL_ES 14 /* wall - northwest corner */
65 #define WL_SW 15 /* wall - northeast corner */
66 #define WL_NW 16 /* wall - southeast corner */
67 #define WL_NE 17 /* wall - southwest corner */
68 #define WL_NES 18 /* walls - to north, east, and south */
69 #define WL_ESW 19 /* walls - to east, south, and west */
70 #define WL_NSW 20 /* walls - to south, west, and north */
71 #define WL_NEW 21 /* walls - to west, north, and east */
72 #define WL_NESW 22 /* wall quad corner */
73 #define OPNG 23 /* opening - 1-way airflow */
74 #define DOOR 24 /* opening - 2-way airflow */
75 #define LG_OPNG 25 /* large 1-way opening */
76 #define LG_DOOR 27 /* large 2-way opening */
77 #define FAN_E 28 /* fan - flow to the east */
78 #define FAN_W 29 /* fan - flow to the west */
79 #define FAN_N 30 /* fan - flow to the north */
80 #define FAN_S 31 /* fan - flow to the south */
81 #define NOTE 42 /* note - '*' */
82 #define BOX_S 128 /* box - AHS supply */
83 #define BOX_R 129 /* box - AHS return */
84 #define S_AHS 130 /* simple AHS zones/element */
85 #define PEXP 131 /* personal exposure */
86 #define PERSON 132 /* personal activity (future) */
87 #define CONT_SS 133 /* contaminant source/sink (C95) */
88 #define CONT_RX 134 /* contaminant reaction (future) */
89 #define WMS_EW 136 /* mass layers - east/west, floor */
90 #define WMS_NS 137 /* mass layers - north/south */
91 #define WDW_EW 138 /* window layers - east/west, floor */
92 #define WDW_NS 139 /* window layers - north/south */
93 #define GEN_MASS 140 /* generic zone mass */
94 #define RAD_INT 141 /* radiant interchange */
95 #define HEAT_SRC 142 /* heat source */
96 #define DCT_EW 143 /* duct (not saved) - east/west */
97 #define DCT_NS 144 /* duct (not saved) - north/south */
98 #define DCT_EWk 145 /* duct (saved) - east/west */
99 #define DCT_NSk 146 /* duct (saved) - north/south */
100 #define DCT_ES 147 /* duct - east/south */
101 #define DCT_SW 148 /* duct - south/west */
102 #define DCT_NW 149 /* duct - north/west */
103 #define DCT_NE 150 /* duct - north/east */
104 #define DCT_X 151 /* duct crossing */
105 #define DCT_EWg 152 /* duct - east/west - grouping icon (future) */
106 #define DCT_NSg 153 /* duct - north/south - grouping icon (future) */
107 #define DCT_NSn 154 /* duct - north/south - north positive */
108 #define DCT_EWe 155 /* duct - east/west - east positive */
109 #define DCT_NSs 156 /* duct - north/south - south positive */
110 #define DCT_EWw 157 /* duct - east/west - west positive */
111 #define JCT 158 /* junction */
112 #define JCT_CA 159 /* junction - connected to level above */
113 #define JCT_CB 160 /* junction - connected to level below */
114 #define JCT_CAB 161 /* junction - connected above & below */
115 #define IOJ 162 /* junction terminal */
116 #define IOJ_CA 163 /* terminal - connected to level above */
117 #define IOJ_CB 164 /* terminal - connected to level below */
118 #define CL_EW 168 /* control link (not saved) - east/west */
119 #define CL_NS 169 /* control link (not saved) - north/south */
120 #define CL_EWk 170 /* control link (saved) - east/west */
121 #define CL_NSk 171 /* control link (saved) - north/south */
122 #define CL_ES 172 /* control link - east/south */
123 #define CL_SW 173 /* control link - south/west */
124 #define CL_NW 174 /* control link - north/west */
125 #define CL_NE 175 /* control link - north/east */
126 #define CL_X 176 /* control link - cross-over */
127 #define CA_N 177 /* control actuator - point to north */
128 #define CA_E 178 /* control actuator - point to east */
129 #define CA_S 179 /* control actuator - point to south */
130 #define CA_W 180 /* control actuator - point to west */
131 #define CS_N 181 /* control sensor - point to north */
132 #define CS_E 182 /* control sensor - point to east */
133 #define CS_S 183 /* control sensor - point to south */
134 #define CS_W 184 /* control sensor - point to west */
135 #define CTRLN 185 /* control node */
136 #define CTRLP 186 /* phantom control node */
137 #define CTRLS 187 /* super control node */
138 #define CTRLO 188 /* super element output control node */
139 #define CTRLI 189 /* super element input control node */
140 #define RADIO_Y 210 /* D2 322 box with dot inside */
141 #define RADIO_N 211 /* D3 323 empty box */
142 #define BUTTON 212 /* D4 324 pushbutton */
143 #define CHECK_L 213 /* D5 325 left side of check box */
144 #define CHECK_Y 214 /* D6 326 check box - yes */
145 #define CHECK_R 215 /* D7 327 right side of check box */
146 #define CHECK_N 216 /* D8 330 check box */
147 #define BLOCK 219 /* DB 333 full block */
148 #define BLOCK_B 220 /* DC 334 bottom block */
149 #define BLOCK_C 222 /* DE 335 center block */
150 #define BLOCK_T 223 /* DF 336 top block */
151 #define SIMGA 228 /* E4 344 Greek */
152 #define MU 230 /* E6 346 Greek */
153 #define OMEGA 234 /* EA 352 Greek omega */
154 #define DELTA 235 /* EB 353 Greek DELTA */
155 #define PLSMN 241 /* F1 361 */
156 #define GTEQ 242 /* F2 362 */
157 #define LTEQ 243 /* F3 363 */
158 #define SUB_M 244 /* F4 364 subscript m */
159 #define SUB_N 245 /* F5 365 subscript n */
160 #define APPROX 247 /* F7 367 approx */
161 #define DEGRS 248 /* F8 370 degrees */
162 #define EXP_4 249 /* F9 371 exponent 4 */
163 #define EXP_3 250 /* FA 372 exponent 3 */
164 #define SQRT 251 /* FB 373 square root */
165 #define EXP_N 252 /* FC 374 exponent n */
166 #define EXP_2 253 /* FD 375 exponent 2 */
167 #define SUB_2 254 /* FE 376 subscript 2 */
168
169 namespace openstudio {
170 namespace contam {
171
172 enum PathFlags
173 {
174 WIND = 0x0001, // Path is subject to wind pressure
175 WPC_P = 0x0002, // Path uses WPC file pressure
176 WPC_C = 0x0004, // Path uses WPC file contaminants
177 WPC_F = 0x0006, // Path uses WPC pressure or contaminants
178 AHS_S = 0x0008, // Path is a system (supply or return) flow path
179 AHS_R = 0x0010, // Path is a recirculation flow path
180 AHS_O = 0x0020, // Path is an outside air flow path
181 AHS_X = 0x0040, // Path is an exhaust flow path
182 AHS_P = 0x0078, // Path is any AHS path
183 LIM_P = 0x0080, // Path is pressure limited
184 LIM_F = 0x0100, // Path is flow limited
185 FAN_F = 0x0200
186 }; // Path is a constant flow fan element
187
188 enum ZoneFlags
189 {
190 // Zone flag bit 1; variable pressure
191 VAR_P = 0x0001,
192 NVAR_P = 0xFFFE,
193 // Zone flag bit 2; variable contaminants
194 VAR_C = 0x0002,
195 NVAR_C = 0xFFFD,
196 // Zone flag bit 3; variable temperature
197 VAR_T = 0x0004,
198 NVAR_T = 0xFFFB,
199 // Zone flag bit 4; system zone: to avoid zone volume check
200 SYS_N = 0x0008,
201 NSYS_N = 0xFFF7,
202 // Zone flag bit 5; un|conditioned space: to compute air change rate
203 UNCZN = 0x0010, // flags | UNCZN to indicate unconditioned zone
204 SETCZN = 0xFFEF, // flags & SETCZN to indicate conditioned zone
205 // Zone flag bit 6; CFD zone
206 CFDZN = 0x0020, // flags | CFDZN to set CFD zone / flags & CFDZN to test for CFD zone
207 NCFDZN = 0xFFDF, // flags & NCFDZN to unset CFD zone
208 FLAG_N = 0x003F
209 }; // all zone flag bits, used in PrjRead()
210
211 } // namespace contam
212 } // namespace openstudio
213
214 #endif // AIRFLOW_CONTAM_PRJDEFINES_HPP
215