2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
Usage helper
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
|
|
|
"""
|
|
|
|
import sys
|
2021-06-10 10:48:30 -04:00
|
|
|
import helpers.constants as cte
|
2021-05-26 18:17:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
class UsageHelper:
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2021-08-30 14:39:24 -04:00
|
|
|
Usage helper class
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
2022-03-17 18:49:44 -04:00
|
|
|
_usage_to_hft = {
|
2021-06-10 10:48:30 -04:00
|
|
|
cte.RESIDENTIAL: 'residential',
|
|
|
|
cte.INDUSTRY: 'industry',
|
|
|
|
cte.OFFICE_ADMINISTRATION: 'office and administration',
|
|
|
|
cte.HOTEL: 'hotel',
|
|
|
|
cte.HEALTH_CARE: 'health care',
|
|
|
|
cte.RETAIL: 'retail',
|
|
|
|
cte.HALL: 'hall',
|
|
|
|
cte.RESTAURANT: 'restaurant',
|
2022-03-17 18:49:44 -04:00
|
|
|
cte.EDUCATION: 'education'}
|
2021-05-26 18:17:23 -04:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def hft_from_usage(usage):
|
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
Get HfT usage from the given internal usage key
|
2021-05-26 18:17:23 -04:00
|
|
|
:param usage: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
try:
|
2022-03-17 18:49:44 -04:00
|
|
|
return UsageHelper._usage_to_hft[usage]
|
2021-05-26 18:17:23 -04:00
|
|
|
except KeyError:
|
2022-03-17 18:49:44 -04:00
|
|
|
sys.stderr.write('Error: keyword not found.\n')
|
2021-11-11 17:25:53 -05:00
|
|
|
|
2022-03-17 18:49:44 -04:00
|
|
|
_usage_to_comnet = {
|
2021-11-11 17:25:53 -05:00
|
|
|
cte.RESIDENTIAL: 'BA Multifamily',
|
|
|
|
cte.INDUSTRY: 'BA Manufacturing Facility',
|
|
|
|
cte.OFFICE_ADMINISTRATION: 'BA Office',
|
|
|
|
cte.HOTEL: 'BA Hotel',
|
|
|
|
cte.HEALTH_CARE: 'BA Hospital',
|
|
|
|
cte.RETAIL: 'BA Retail',
|
|
|
|
cte.HALL: 'BA Town Hall',
|
|
|
|
cte.RESTAURANT: 'BA Dining: Bar Lounge/Leisure',
|
2022-03-17 18:49:44 -04:00
|
|
|
cte.EDUCATION: 'BA School/University'}
|
|
|
|
|
|
|
|
_comnet_schedules_key_to_comnet_schedules = {
|
|
|
|
'C-1 Assembly': 'C-1 Assembly',
|
|
|
|
'C-2 Public': 'C-2 Health',
|
|
|
|
'C-3 Hotel Motel': 'C-3 Hotel',
|
|
|
|
'C-4 Manufacturing': 'C-4 Manufacturing',
|
|
|
|
'C-5 Office': 'C-5 Office',
|
|
|
|
'C-6 Parking Garage': 'C-6 Parking',
|
|
|
|
'C-7 Restaurant': 'C-7 Restaurant',
|
|
|
|
'C-8 Retail': 'C-8 Retail',
|
|
|
|
'C-9 Schools': 'C-9 School',
|
|
|
|
'C-10 Warehouse': 'C-10 Warehouse',
|
|
|
|
'C-11 Laboratory': 'C-11 Lab',
|
|
|
|
'C-12 Residential': 'C-12 Residential',
|
|
|
|
'C-13 Data Center': 'C-13 Data',
|
|
|
|
'C-14 Gymnasium': 'C-14 Gymnasium'}
|
2021-11-11 17:25:53 -05:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def comnet_from_usage(usage):
|
|
|
|
"""
|
|
|
|
Get Comnet usage from the given internal usage key
|
|
|
|
:param usage: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
try:
|
2022-03-17 18:49:44 -04:00
|
|
|
return UsageHelper._usage_to_comnet[usage]
|
|
|
|
except KeyError:
|
|
|
|
sys.stderr.write('Error: keyword not found.\n')
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def schedules_key(usage):
|
|
|
|
"""
|
|
|
|
Get Comnet schedules key from the list found in the Comnet usage file
|
|
|
|
:param usage: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
return UsageHelper._comnet_schedules_key_to_comnet_schedules[usage]
|
2021-11-11 17:25:53 -05:00
|
|
|
except KeyError:
|
2022-03-17 18:49:44 -04:00
|
|
|
sys.stderr.write('Error: Comnet keyword not found. An update of the Comnet files might have been '
|
|
|
|
'done changing the keywords.\n')
|