city_retrofit/imports/schedules/helpers/schedules_helper.py

58 lines
1.6 KiB
Python
Raw Normal View History

"""
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
import helpers.constants as cte
class SchedulesHelper:
2021-08-27 12:51:30 -04:00
"""
Schedules helper
"""
usage_to_comnet = {
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'
}
comnet_default_value = 'C-12 Residential'
comnet_to_data_type = {
'Fraction': cte.FRACTION,
'OnOff': cte.ON_OFF,
'Temperature': cte.TEMPERATURE
}
@staticmethod
def comnet_from_usage(usage):
"""
Get Comnet usage from the given internal usage key
: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
@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.")