tbd 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +3 -0
- data/.github/workflows/pull_request.yml +72 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/LICENSE.md +21 -0
- data/README.md +154 -0
- data/Rakefile +60 -0
- data/json/midrise.json +64 -0
- data/json/tbd_5ZoneNoHVAC.json +19 -0
- data/json/tbd_5ZoneNoHVAC_btap.json +91 -0
- data/json/tbd_seb_n2.json +41 -0
- data/json/tbd_seb_n4.json +57 -0
- data/json/tbd_warehouse10.json +24 -0
- data/json/tbd_warehouse5.json +37 -0
- data/lib/measures/tbd/LICENSE.md +21 -0
- data/lib/measures/tbd/README.md +136 -0
- data/lib/measures/tbd/README.md.erb +42 -0
- data/lib/measures/tbd/docs/.gitkeep +1 -0
- data/lib/measures/tbd/measure.rb +327 -0
- data/lib/measures/tbd/measure.xml +460 -0
- data/lib/measures/tbd/resources/geo.rb +714 -0
- data/lib/measures/tbd/resources/geometry.rb +351 -0
- data/lib/measures/tbd/resources/model.rb +1431 -0
- data/lib/measures/tbd/resources/oslog.rb +381 -0
- data/lib/measures/tbd/resources/psi.rb +2229 -0
- data/lib/measures/tbd/resources/tbd.rb +55 -0
- data/lib/measures/tbd/resources/transformation.rb +121 -0
- data/lib/measures/tbd/resources/ua.rb +986 -0
- data/lib/measures/tbd/resources/utils.rb +1636 -0
- data/lib/measures/tbd/resources/version.rb +3 -0
- data/lib/measures/tbd/tests/tbd_full_PSI.json +17 -0
- data/lib/measures/tbd/tests/tbd_tests.rb +222 -0
- data/lib/tbd/geo.rb +714 -0
- data/lib/tbd/psi.rb +2229 -0
- data/lib/tbd/ua.rb +986 -0
- data/lib/tbd/version.rb +25 -0
- data/lib/tbd.rb +93 -0
- data/sponsors/canada.png +0 -0
- data/sponsors/quebec.png +0 -0
- data/tbd.gemspec +43 -0
- data/tbd.schema.json +571 -0
- data/v291_MacOS.md +110 -0
- metadata +191 -0
@@ -0,0 +1,381 @@
|
|
1
|
+
# BSD 3-Clause License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2022, Denis Bourgeois
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
10
|
+
# list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# 3. Neither the name of the copyright holder nor the names of its
|
17
|
+
# contributors may be used to endorse or promote products derived from
|
18
|
+
# this software without specific prior written permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
module OSlg
|
32
|
+
DEBUG = 1
|
33
|
+
INFO = 2
|
34
|
+
WARN = 3
|
35
|
+
ERROR = 4
|
36
|
+
FATAL = 5
|
37
|
+
|
38
|
+
@@logs = []
|
39
|
+
@@level = INFO
|
40
|
+
@@status = 0
|
41
|
+
|
42
|
+
@@tag = []
|
43
|
+
@@tag[0 ] = ""
|
44
|
+
@@tag[DEBUG] = "DEBUG"
|
45
|
+
@@tag[INFO ] = "INFO"
|
46
|
+
@@tag[WARN ] = "WARNING"
|
47
|
+
@@tag[ERROR] = "ERROR"
|
48
|
+
@@tag[FATAL] = "FATAL"
|
49
|
+
|
50
|
+
@@msg = []
|
51
|
+
@@msg[0 ] = ""
|
52
|
+
@@msg[DEBUG] = "Debugging ..."
|
53
|
+
@@msg[INFO ] = "Success! No errors, no warnings"
|
54
|
+
@@msg[WARN ] = "Partial success, raised non-fatal warnings"
|
55
|
+
@@msg[ERROR] = "Partial success, encountered non-fatal errors"
|
56
|
+
@@msg[FATAL] = "Failure, triggered fatal errors"
|
57
|
+
|
58
|
+
##
|
59
|
+
# Return log entries.
|
60
|
+
#
|
61
|
+
# @return [Array] current log entries
|
62
|
+
def logs
|
63
|
+
@@logs
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# Return current log level.
|
68
|
+
#
|
69
|
+
# @return [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
70
|
+
def level
|
71
|
+
@@level
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Return current log status.
|
76
|
+
#
|
77
|
+
# @return [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
78
|
+
def status
|
79
|
+
@@status
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Return whether current status is DEBUG
|
84
|
+
#
|
85
|
+
# @return [Bool] true if DEBUG
|
86
|
+
def debug?
|
87
|
+
@@status == DEBUG
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Return whether current status is INFO
|
92
|
+
#
|
93
|
+
# @return [Bool] true if INFO
|
94
|
+
def info?
|
95
|
+
@@status == INFO
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Return whether current status is WARN
|
100
|
+
#
|
101
|
+
# @return [Bool] true if WARN
|
102
|
+
def warn?
|
103
|
+
@@status == WARN
|
104
|
+
end
|
105
|
+
|
106
|
+
##
|
107
|
+
# Return whether current status is ERROR
|
108
|
+
#
|
109
|
+
# @return [Bool] true if ERROR
|
110
|
+
def error?
|
111
|
+
@@status == ERROR
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Return whether current status is FATAL
|
116
|
+
#
|
117
|
+
# @return [Bool] true if FATAL
|
118
|
+
def fatal?
|
119
|
+
@@status == FATAL
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Return string equivalent of level
|
124
|
+
#
|
125
|
+
# @param level [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
126
|
+
#
|
127
|
+
# @return [String] "DEBUG", "INFO", "WARN", "ERROR" or "FATAL"
|
128
|
+
def tag(level)
|
129
|
+
return @@tag[level] if level >= DEBUG && level <= FATAL
|
130
|
+
""
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Return preset OSlg message linked to status.
|
135
|
+
#
|
136
|
+
# @param status [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
137
|
+
#
|
138
|
+
# @return [String] preset OSlg message
|
139
|
+
def msg(status)
|
140
|
+
return @@msg[status] if status >= DEBUG && status <= FATAL
|
141
|
+
""
|
142
|
+
end
|
143
|
+
|
144
|
+
##
|
145
|
+
# Set level.
|
146
|
+
#
|
147
|
+
# @param level [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
148
|
+
#
|
149
|
+
# @return [Integer] current level
|
150
|
+
def reset(level)
|
151
|
+
@@level = level if level >= DEBUG && level <= FATAL
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Log new entry.
|
156
|
+
#
|
157
|
+
# @param level [Integer] DEBUG, INFO, WARN, ERROR or FATAL
|
158
|
+
# @param message [String] user-provided message
|
159
|
+
#
|
160
|
+
# @return [Integer] current status
|
161
|
+
def log(level = DEBUG, message = "")
|
162
|
+
if level >= DEBUG && level <= FATAL && level >= @@level
|
163
|
+
@@logs << {level: level, message: message}
|
164
|
+
@@status = level if level > @@status
|
165
|
+
end
|
166
|
+
@@status
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Log template 'invalid object' message and return user-set object.
|
171
|
+
#
|
172
|
+
# @param id [String] invalid object identifier
|
173
|
+
# @param mth [String] calling method identifier
|
174
|
+
# @param ord [Integer] calling method argument order number of obj (optional)
|
175
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
176
|
+
# @param res [Object] what to return (optional)
|
177
|
+
#
|
178
|
+
# @return [Object] return object if specified by user
|
179
|
+
# @return [Nil] nil if return object undefined
|
180
|
+
def invalid(id = "", mth = "", ord = 0, lvl = DEBUG, res = nil)
|
181
|
+
return res unless id.respond_to?(:to_s)
|
182
|
+
return res unless mth.respond_to?(:to_s)
|
183
|
+
return res unless ord.respond_to?(:to_i)
|
184
|
+
return res unless lvl.respond_to?(:to_i)
|
185
|
+
|
186
|
+
id = id.to_s.strip
|
187
|
+
mth = mth.to_s.strip
|
188
|
+
ord = ord.to_i
|
189
|
+
lvl = lvl.to_i
|
190
|
+
|
191
|
+
id = id[0...60] + " ..." if id.length > 60
|
192
|
+
return res if id.empty?
|
193
|
+
|
194
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
195
|
+
return res if mth.empty?
|
196
|
+
|
197
|
+
msg = "Invalid '#{id}' "
|
198
|
+
msg += "arg ##{ord} " if ord > 0
|
199
|
+
msg += "(#{mth})"
|
200
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
201
|
+
res
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# Log template 'instance/class mismatch' message and return user-set object.
|
206
|
+
#
|
207
|
+
# @param id [String] mismatched object identifier
|
208
|
+
# @param obj [Object] object to validate
|
209
|
+
# @param cl [Class] target class
|
210
|
+
# @param mth [String] calling method identifier
|
211
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
212
|
+
# @param res [Object] what to return (optional)
|
213
|
+
#
|
214
|
+
# @return [Object] return object if specified by user
|
215
|
+
# @return [Nil] nil if return object undefined
|
216
|
+
def mismatch(id = "", obj = nil, cl = nil, mth = "", lvl = DEBUG, res = nil)
|
217
|
+
return res unless id.respond_to?(:to_s)
|
218
|
+
return res unless cl.is_a?(Class)
|
219
|
+
return res if obj.is_a?(cl)
|
220
|
+
return res unless mth.respond_to?(:to_s)
|
221
|
+
return res unless lvl.respond_to?(:to_i)
|
222
|
+
|
223
|
+
mth = mth.to_s.strip
|
224
|
+
id = id.to_s.strip
|
225
|
+
lvl = lvl.to_i
|
226
|
+
|
227
|
+
id = id[0...60] + " ..." if id.length > 60
|
228
|
+
return res if id.empty?
|
229
|
+
|
230
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
231
|
+
return res if mth.empty?
|
232
|
+
|
233
|
+
msg = "'#{id}' #{obj.class}? expecting #{cl} (#{mth})"
|
234
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
235
|
+
res
|
236
|
+
end
|
237
|
+
|
238
|
+
##
|
239
|
+
# Log template 'missing hash key' message and return user-set object.
|
240
|
+
#
|
241
|
+
# @param id [String] Hash identifier
|
242
|
+
# @param hsh [Hash] hash to validate
|
243
|
+
# @param key [Object] missing key
|
244
|
+
# @param mth [String] calling method identifier
|
245
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
246
|
+
# @param res [Object] what to return (optional)
|
247
|
+
#
|
248
|
+
# @return [Object] return object if specified by user
|
249
|
+
# @return [Nil] nil if return object undefined
|
250
|
+
def hashkey(id = "", hsh = {}, key = "", mth = "", lvl = DEBUG, res = nil)
|
251
|
+
return res unless id.respond_to?(:to_s)
|
252
|
+
return res unless hsh.is_a?(Hash)
|
253
|
+
return res if hsh.key?(key)
|
254
|
+
return res unless mth.respond_to?(:to_s)
|
255
|
+
return res unless lvl.respond_to?(:to_i)
|
256
|
+
|
257
|
+
id = id.to_s.strip
|
258
|
+
mth = mth.to_s.strip
|
259
|
+
lvl = lvl.to_i
|
260
|
+
|
261
|
+
id = id[0...60] + " ..." if id.length > 60
|
262
|
+
return res if id.empty?
|
263
|
+
|
264
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
265
|
+
return res if mth.empty?
|
266
|
+
|
267
|
+
msg = "Missing '#{key}' key in '#{id}' Hash (#{mth})"
|
268
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
269
|
+
res
|
270
|
+
end
|
271
|
+
|
272
|
+
##
|
273
|
+
# Log template 'empty (uninitialized)' message and return user-set object.
|
274
|
+
#
|
275
|
+
# @param id [String] empty object identifier
|
276
|
+
# @param mth [String] calling method identifier
|
277
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
278
|
+
# @param res [Object] what to return (optional)
|
279
|
+
#
|
280
|
+
# @return [Object] return object if specified by user
|
281
|
+
# @return [Nil] nil if return object undefined
|
282
|
+
def empty(id = "", mth = "", lvl = DEBUG, res = nil)
|
283
|
+
return res unless id.respond_to?(:to_s)
|
284
|
+
return res unless mth.respond_to?(:to_s)
|
285
|
+
return res unless lvl.respond_to?(:to_i)
|
286
|
+
|
287
|
+
id = id.to_s.strip
|
288
|
+
mth = mth.to_s.strip
|
289
|
+
lvl = lvl.to_i
|
290
|
+
|
291
|
+
id = id[0...60] + " ..." if id.length > 60
|
292
|
+
return res if id.empty?
|
293
|
+
|
294
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
295
|
+
return res if mth.empty?
|
296
|
+
|
297
|
+
msg = "Empty '#{id}' (#{mth})"
|
298
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
299
|
+
res
|
300
|
+
end
|
301
|
+
|
302
|
+
##
|
303
|
+
# Log template 'near zero' message and return user-set object.
|
304
|
+
#
|
305
|
+
# @param id [String] zero object identifier
|
306
|
+
# @param mth [String] calling method identifier
|
307
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
308
|
+
# @param res [Object] what to return (optional)
|
309
|
+
#
|
310
|
+
# @return [Object] return object if specified by user
|
311
|
+
# @return [Nil] nil if return object undefined
|
312
|
+
def zero(id = "", mth = "", lvl = DEBUG, res = nil)
|
313
|
+
return res unless id.respond_to?(:to_s)
|
314
|
+
return res unless mth.respond_to?(:to_s)
|
315
|
+
return res unless lvl.respond_to?(:to_i)
|
316
|
+
|
317
|
+
id = id.to_s.strip
|
318
|
+
mth = mth.to_s.strip
|
319
|
+
ord = ord.to_i
|
320
|
+
lvl = lvl.to_i
|
321
|
+
|
322
|
+
id = id[0...60] + " ..." if id.length > 60
|
323
|
+
return res if id.empty?
|
324
|
+
|
325
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
326
|
+
return res if mth.empty?
|
327
|
+
|
328
|
+
msg = "Zero '#{id}' (#{mth})"
|
329
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
330
|
+
res
|
331
|
+
end
|
332
|
+
|
333
|
+
##
|
334
|
+
# Log template 'negative' message and return user-set object.
|
335
|
+
#
|
336
|
+
# @param id [String] negative object identifier
|
337
|
+
# @param mth [String] calling method identifier
|
338
|
+
# @param lvl [Integer] DEBUG, INFO, WARN, ERROR or FATAL (optional)
|
339
|
+
# @param res [Object] what to return (optional)
|
340
|
+
#
|
341
|
+
# @return [Object] return object if specified by user
|
342
|
+
# @return [Nil] nil if return object undefined
|
343
|
+
def negative(id = "", mth = "", lvl = DEBUG, res = nil)
|
344
|
+
return res unless id.respond_to?(:to_s)
|
345
|
+
return res unless mth.respond_to?(:to_s)
|
346
|
+
return res unless lvl.respond_to?(:to_i)
|
347
|
+
|
348
|
+
id = id.to_s.strip
|
349
|
+
mth = mth.to_s.strip
|
350
|
+
ord = ord.to_i
|
351
|
+
lvl = lvl.to_i
|
352
|
+
|
353
|
+
id = id[0...60] + " ..." if id.length > 60
|
354
|
+
return res if id.empty?
|
355
|
+
|
356
|
+
mth = mth[0...60] + " ..." if mth.length > 60
|
357
|
+
return res if mth.empty?
|
358
|
+
|
359
|
+
msg = "Negative '#{id}' (#{mth})"
|
360
|
+
log(lvl, msg) if lvl >= DEBUG && lvl <= FATAL
|
361
|
+
res
|
362
|
+
end
|
363
|
+
|
364
|
+
##
|
365
|
+
# Reset log status and entries.
|
366
|
+
#
|
367
|
+
# @return [Integer] current level
|
368
|
+
def clean!
|
369
|
+
@@status = 0
|
370
|
+
@@logs = []
|
371
|
+
@@level
|
372
|
+
end
|
373
|
+
|
374
|
+
##
|
375
|
+
# Callback when other modules extend OSlg
|
376
|
+
#
|
377
|
+
# @param base [Object] instance or class object
|
378
|
+
def self.extended(base)
|
379
|
+
base.send(:include, self)
|
380
|
+
end
|
381
|
+
end
|