""" 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: """ 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 } # usage function_to_usage = { 'full service restaurant': cte.RESTAURANT, 'high-rise apartment': cte.RESIDENTIAL, 'hospital': cte.HEALTH_CARE, 'large hotel': cte.HOTEL, 'large office': cte.OFFICE_ADMINISTRATION, 'medium office': cte.OFFICE_ADMINISTRATION, 'midrise apartment': cte.RESIDENTIAL, '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, 'residential': cte.RESIDENTIAL } @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.") @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]