""" 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': 'restaurant', 'high-rise apartment': cte.RESIDENTIAL, 'hospital': 'health care', 'large hotel': 'hotel', 'large office': 'office and administration', 'medium office': 'office and administration', 'midrise apartment': cte.RESIDENTIAL, 'outpatient healthcare': 'health care', 'primary school': 'education', 'quick service restaurant': 'restaurant', 'secondary school': 'education', 'small hotel': 'hotel', 'small office': 'office and administration', 'stand-alone-retail': 'retail', 'strip mall': 'hall', 'supermarket': 'retail', 'warehouse': '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]