示例#1
0
def test_program_type_setability():
    """Test the setting of properties of ProgramType."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office,
                                   None, schedule_types.fractional)
    light_schedule = occ_schedule.duplicate()
    light_schedule.identifier = 'Office Lighting-Equip Schedule'
    light_schedule.default_day_schedule.values = [0.25, 1, 0.25]
    equip_schedule = light_schedule.duplicate()
    inf_schedule = ScheduleRuleset.from_constant_value(
        'Infiltration Schedule', 1, schedule_types.fractional)
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating Schedule', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling Schedule', 24, schedule_types.temperature)

    people = People('Open Office People', 0.05, occ_schedule)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule)
    infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program')

    assert office_program.identifier == 'Open Office Program'
    office_program.identifier = 'Office Program'
    assert office_program.identifier == 'Office Program'
    assert office_program.people is None
    office_program.people = people
    assert office_program.people == people
    assert office_program.lighting is None
    office_program.lighting = lighting
    assert office_program.lighting == lighting
    assert office_program.electric_equipment is None
    office_program.electric_equipment = equipment
    assert office_program.electric_equipment == equipment
    assert office_program.infiltration is None
    office_program.infiltration = infiltration
    assert office_program.infiltration == infiltration
    assert office_program.ventilation is None
    office_program.ventilation = ventilation
    assert office_program.ventilation == ventilation
    assert office_program.setpoint is None
    office_program.setpoint = setpoint
    assert office_program.setpoint == setpoint

    with pytest.raises(AssertionError):
        office_program.people = lighting
    with pytest.raises(AssertionError):
        office_program.lighting = equipment
    with pytest.raises(AssertionError):
        office_program.electric_equipment = people
    with pytest.raises(AssertionError):
        office_program.infiltration = people
    with pytest.raises(AssertionError):
        office_program.ventilation = setpoint
    with pytest.raises(AssertionError):
        office_program.setpoint = ventilation
示例#2
0
def test_program_type_lockability():
    """Test the lockability of ProgramType objects."""
    simple_office = ScheduleDay('Simple Weekday Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])
    light_schedule = ScheduleRuleset('Office Lighting-Equip Schedule', simple_office,
                                     None, schedule_types.fractional)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    led_lighting = Lighting('LED Office Lighting', 5, light_schedule)
    office_program = ProgramType('Open Office Program', lighting=lighting)

    office_program.lighting.watts_per_area = 6
    office_program.lock()
    with pytest.raises(AttributeError):
        office_program.lighting.watts_per_area = 8
    with pytest.raises(AttributeError):
        office_program.lighting = led_lighting
    office_program.unlock()
    office_program.lighting.watts_per_area = 8
    office_program.lighting = led_lighting
示例#3
0
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    # get the base program type
    if base_program_ is None:
        program = ProgramType(clean_and_id_ep_string(_name))
        program.display_name = _name
    else:
        if isinstance(base_program_, str):
            base_program_ = program_type_by_identifier(base_program_)
        program = base_program_.duplicate()
        program.identifier = clean_and_id_ep_string(_name)
        program.display_name = _name
    
    # go through each input load and assign it to the set
    if _people_ is not None:
        program.people = _people_
    if _lighting_ is not None:
        program.lighting = _lighting_
    if _electric_equip_ is not None:
        program.electric_equipment = _electric_equip_
    if _gas_equip_ is not None:
        program.gas_equipment = _gas_equip_
    if _infiltration_ is not None:
        program.infiltration = _infiltration_
    if _ventilation_ is not None:
        program.ventilation = _ventilation_
    if _setpoint_ is not None:
        program.setpoint = _setpoint_