2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
Usage helper
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2022-04-08 09:35:33 -04:00
|
|
|
Copyright © 2022 Concordia CERC group
|
|
|
|
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
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',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.SINGLE_FAMILY_HOUSE: 'Single family house',
|
|
|
|
cte.MULTI_FAMILY_HOUSE: 'Multi-family house',
|
|
|
|
cte.EDUCATION: 'education',
|
|
|
|
cte.SCHOOL_WITHOUT_SHOWER: 'school without shower',
|
|
|
|
cte.SCHOOL_WITH_SHOWER: 'school with shower',
|
|
|
|
cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'retail',
|
|
|
|
cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'retail shop / refrigerated food',
|
2021-06-10 10:48:30 -04:00
|
|
|
cte.HOTEL: 'hotel',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.HOTEL_MEDIUM_CLASS: 'hotel (Medium-class)',
|
|
|
|
cte.DORMITORY: 'dormitory',
|
|
|
|
cte.INDUSTRY: 'industry',
|
|
|
|
cte.RESTAURANT: 'restaurant',
|
2021-06-10 10:48:30 -04:00
|
|
|
cte.HEALTH_CARE: 'health care',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.RETIREMENT_HOME_OR_ORPHANAGE: 'Home for the aged or orphanage',
|
|
|
|
cte.OFFICE_AND_ADMINISTRATION: 'office and administration',
|
|
|
|
cte.EVENT_LOCATION: 'event location',
|
2021-06-10 10:48:30 -04:00
|
|
|
cte.HALL: 'hall',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.SPORTS_LOCATION: 'sport location',
|
|
|
|
cte.LABOR: 'Labor',
|
|
|
|
cte.GREEN_HOUSE: 'green house',
|
|
|
|
cte.NON_HEATED: 'non-heated'}
|
2021-05-26 18:17:23 -04:00
|
|
|
|
|
|
|
@staticmethod
|
2022-03-24 16:51:01 -04:00
|
|
|
def hft_from_libs_usage(usage):
|
2021-05-26 18:17:23 -04:00
|
|
|
"""
|
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-24 16:51:01 -04:00
|
|
|
sys.stderr.write('Error: keyword not found to translate from libs_usage to hft usage.\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',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.SINGLE_FAMILY_HOUSE: 'BA Multifamily',
|
|
|
|
cte.MULTI_FAMILY_HOUSE: 'BA Multifamily',
|
|
|
|
cte.EDUCATION: 'BA School/University',
|
|
|
|
cte.SCHOOL_WITHOUT_SHOWER: 'BA School/University',
|
|
|
|
cte.SCHOOL_WITH_SHOWER: 'BA School/University',
|
|
|
|
cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'BA Retail',
|
|
|
|
cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'BA Retail',
|
2021-11-11 17:25:53 -05:00
|
|
|
cte.HOTEL: 'BA Hotel',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.HOTEL_MEDIUM_CLASS: 'BA Hotel',
|
|
|
|
cte.DORMITORY: 'BA Dormitory',
|
|
|
|
cte.INDUSTRY: 'BA Manufacturing Facility',
|
|
|
|
cte.RESTAURANT: 'BA Dining: Family',
|
2021-11-11 17:25:53 -05:00
|
|
|
cte.HEALTH_CARE: 'BA Hospital',
|
2022-03-24 16:51:01 -04:00
|
|
|
cte.RETIREMENT_HOME_OR_ORPHANAGE: 'BA Multifamily',
|
|
|
|
cte.OFFICE_AND_ADMINISTRATION: 'BA Office',
|
|
|
|
cte.EVENT_LOCATION: 'BA Convention Center',
|
|
|
|
cte.HALL: 'BA Convention Center',
|
|
|
|
cte.SPORTS_LOCATION: 'BA Sports Arena',
|
|
|
|
cte.LABOR: 'BA Gymnasium',
|
|
|
|
cte.GREEN_HOUSE: cte.GREEN_HOUSE,
|
|
|
|
cte.NON_HEATED: cte.NON_HEATED
|
|
|
|
}
|
2022-03-17 18:49:44 -04:00
|
|
|
|
|
|
|
_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',
|
2022-05-18 22:51:55 -04:00
|
|
|
'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'}
|
|
|
|
|
|
|
|
_comnet_schedules_key_to_usage = {
|
|
|
|
'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',
|
2022-03-17 18:49:44 -04:00
|
|
|
'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
|
2022-03-24 16:51:01 -04:00
|
|
|
def comnet_from_libs_usage(usage):
|
2021-11-11 17:25:53 -05:00
|
|
|
"""
|
|
|
|
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:
|
2022-03-24 16:51:01 -04:00
|
|
|
sys.stderr.write('Error: keyword not found to translate from libs_usage to comnet usage.\n')
|
2022-03-17 18:49:44 -04:00
|
|
|
|
|
|
|
@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')
|