2021-05-26 18:17:23 -04:00
|
|
|
"""
|
|
|
|
Schedules helper
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
|
|
contributors 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 SchedulesHelper:
|
2021-08-27 12:51:30 -04:00
|
|
|
"""
|
|
|
|
Schedules helper
|
|
|
|
"""
|
2021-05-26 18:17:23 -04:00
|
|
|
usage_to_comnet = {
|
2021-06-10 10:48:30 -04:00
|
|
|
cte.RESIDENTIAL: 'C-12 Residential',
|
|
|
|
cte.INDUSTRY: 'C-10 Warehouse',
|
|
|
|
cte.OFFICE_ADMINISTRATION: 'C-5 Office',
|
|
|
|
cte.HOTEL: 'C-3 Hotel',
|
|
|
|
cte.HEALTH_CARE: 'C-2 Health',
|
|
|
|
cte.RETAIL: 'C-8 Retail',
|
|
|
|
cte.HALL: 'C-8 Retail',
|
|
|
|
cte.RESTAURANT: 'C-7 Restaurant',
|
|
|
|
cte.EDUCATION: 'C-9 School'
|
2021-05-26 18:17:23 -04:00
|
|
|
}
|
|
|
|
comnet_default_value = 'C-12 Residential'
|
|
|
|
|
2021-09-01 12:14:48 -04:00
|
|
|
comnet_to_data_type = {
|
|
|
|
'Fraction': cte.FRACTION,
|
|
|
|
'OnOff': cte.ON_OFF,
|
|
|
|
'Temperature': cte.TEMPERATURE
|
|
|
|
}
|
|
|
|
|
2021-09-16 13:45:27 -04:00
|
|
|
# usage
|
|
|
|
function_to_usage = {
|
2021-11-11 17:27:19 -05:00
|
|
|
'full service restaurant': cte.RESTAURANT,
|
2021-09-16 13:45:27 -04:00
|
|
|
'high-rise apartment': cte.RESIDENTIAL,
|
2021-11-11 17:27:19 -05:00
|
|
|
'hospital': cte.HEALTH_CARE,
|
|
|
|
'large hotel': cte.HOTEL,
|
|
|
|
'large office': cte.OFFICE_ADMINISTRATION,
|
|
|
|
'medium office': cte.OFFICE_ADMINISTRATION,
|
2021-09-16 13:45:27 -04:00
|
|
|
'midrise apartment': cte.RESIDENTIAL,
|
2021-11-11 17:27:19 -05:00
|
|
|
'outpatient healthcare': cte.HEALTH_CARE,
|
|
|
|
'primary school': cte.EDUCATION,
|
|
|
|
'quick service restaurant': cte.RESTAURANT,
|
|
|
|
'secondary school': cte.EDUCATION,
|
|
|
|
'small hotel': cte.HOTEL,
|
|
|
|
'small office': cte.OFFICE_ADMINISTRATION,
|
|
|
|
'stand-alone-retail': cte.RETAIL,
|
|
|
|
'strip mall': cte.HALL,
|
|
|
|
'supermarket': cte.RETAIL,
|
|
|
|
'warehouse': cte.INDUSTRY,
|
2021-09-16 13:45:27 -04:00
|
|
|
'residential': cte.RESIDENTIAL
|
|
|
|
}
|
|
|
|
|
2021-05-26 18:17:23 -04:00
|
|
|
@staticmethod
|
|
|
|
def comnet_from_usage(usage):
|
|
|
|
"""
|
2021-06-03 15:56:59 -04:00
|
|
|
Get Comnet usage from the given internal usage key
|
2021-05-26 18:17:23 -04:00
|
|
|
:param usage: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
return SchedulesHelper.usage_to_comnet[usage]
|
|
|
|
except KeyError:
|
|
|
|
sys.stderr.write('Error: keyword not found. Returned default Comnet schedules "residential"\n')
|
|
|
|
return SchedulesHelper.comnet_default_value
|
2021-09-01 12:14:48 -04:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def data_type_from_comnet(comnet_data_type):
|
|
|
|
"""
|
|
|
|
Get data_type from the Comnet data type definitions
|
|
|
|
:param comnet_data_type: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
return SchedulesHelper.comnet_to_data_type[comnet_data_type]
|
|
|
|
except KeyError:
|
|
|
|
raise ValueError(f"Error: comnet data type keyword not found.")
|
2021-09-16 13:45:27 -04:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def usage_from_function(building_function):
|
|
|
|
"""
|
|
|
|
Get the internal usage for the given internal building function
|
|
|
|
:param building_function: str
|
|
|
|
:return: str
|
|
|
|
"""
|
|
|
|
return SchedulesHelper.function_to_usage[building_function]
|