def transition(self, core_object, dependent_objects): # pragma no cover # remove F2 and F3 [2] and [3] : "Control Variable" and "Schedule Name" new_idf_fields = core_object.fields del new_idf_fields[1] # remove F2, which is index 1 del new_idf_fields[1] # remove F3, which is index 1 since F2 was already removed new_object = IDFObject([core_object.object_name] + new_idf_fields) return TransitionReturn([new_object])
def complex_output_operation(self, full_object, dependent_objects): if full_object.object_name.upper() == self.OV: # do daylighting stuff original_fields = full_object.fields new_fields = original_fields is_delight_out_var = False daylight_ref_pts = build_ref_pt_list( dependent_objects["DAYLIGHTING:DELIGHT:REFERENCEPOINT"], dependent_objects["DAYLIGHTING:DELIGHT:CONTROLS"]) if original_fields[0] != "*" and original_fields[1].startswith( "Daylighting Reference Point"): for ref_pt in daylight_ref_pts: if ref_pt.ref_pt_name.upper() == original_fields[0].upper( ): is_delight_out_var = True break if not is_delight_out_var: new_fields[0] = original_fields[0] + "_DaylCtrl" if original_fields[0] != "*" and original_fields[1].startswith( "Daylighting Lighting Power Multiplier"): for ref_pt in daylight_ref_pts: if ref_pt.control_name.upper() == original_fields[0].upper( ): is_delight_out_var = True break if not is_delight_out_var: new_fields[0] = original_fields[0] + "_DaylCtrl" new_object = IDFObject([full_object.object_name] + new_fields) return [new_object] else: # pragma no cover # this section really isn't needed as this function is only called for registered types anyway return None
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields new_idf_fields = original_idf_fields new_idf_fields.insert(2, "") new_coil_object = IDFObject(["Coil:Heating:Fuel"] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_coil_object])
def transition(self, core_object, dependent_objects): # pragma no cover daylight_ref_pts = build_ref_pt_list(dependent_objects["DAYLIGHTING:DELIGHT:REFERENCEPOINT"], dependent_objects["DAYLIGHTING:DELIGHT:CONTROLS"]) original_idf_fields = core_object.fields new_idf_fields = list() new_idf_fields.append("Daylighting:Controls") new_idf_fields.append(original_idf_fields[0]) # 0 new_idf_fields.append(original_idf_fields[1]) # 1 new_idf_fields.append("DElight") # 2 new_idf_fields.append("") # 3 if original_idf_fields[4] == "1": new_idf_fields.append("Continuous") # 4 elif original_idf_fields[4] == "2": new_idf_fields.append("Stepped") # 4 elif original_idf_fields[4] == "3": new_idf_fields.append("ContinuousOff") # 4 else: new_idf_fields.append("Continuous") # 4 new_idf_fields.append(original_idf_fields[3]) # 5 new_idf_fields.append(original_idf_fields[4]) # 6 if original_idf_fields[5] == "0": new_idf_fields.append("") # 7 else: new_idf_fields.append(original_idf_fields[5]) # 7 new_idf_fields.append(original_idf_fields[6]) # 8 new_idf_fields.append("") # 9 new_idf_fields.append("0") # 10 new_idf_fields.append("") # 11 new_idf_fields.append(original_idf_fields[7]) # 12 for ref_pt in daylight_ref_pts: if ref_pt.control_name.upper() == original_idf_fields[0].upper(): new_idf_fields.append(ref_pt.ref_pt_name) new_idf_fields.append(ref_pt.frac_zone) new_idf_fields.append(ref_pt.illum_set_pt) return TransitionReturn([IDFObject(new_idf_fields)])
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields new_object_name = "AirTerminal:SingleDuct:Mixer" new_idf_fields = original_idf_fields new_idf_fields.insert(6, "InletSide") new_mixer_object = IDFObject([new_object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_mixer_object])
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields # need to just add a new field F2, (index 1 here), blank new_idf_fields = original_idf_fields new_idf_fields.insert(1, "") new_equip_object = IDFObject([core_object.object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_equip_object])
def expand(self, idd_structure, idf_structure): new_idf_structure = IDFStructure("") new_idf_structure.objects = [] for object in idf_structure.objects: if object.object_name == 'HVACTemplate:Something': new_idf_object = IDFObject(['Something', 'NewField1']) new_idf_structure.objects.append(new_idf_object) else: new_idf_structure.objects.append(object) p = new_idf_structure.whole_idf_string(idd_structure) return p
def transition(self, core_object, dependent_objects): # pragma no cover # if F2 is Gas, change to "NaturalGas"; if F2 is LPG, change to "PropaneGas" original_idf_fields = core_object.fields new_idf_fields = original_idf_fields if original_idf_fields[1].upper() == "GAS": new_idf_fields[1] = "NaturalGas" elif original_idf_fields[1].upper() == "PROPANEGAS": new_idf_fields[1] = "PropaneGas" new_equip_object = IDFObject([core_object.object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_equip_object])
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields new_idf_fields = original_idf_fields if new_idf_fields[2].upper() in [ "AIRTERMINAL:SINGLEDUCT:INLETSIDEMIXER", "AIRTERMINAL:SINGLEDUCT:SUPPLYSIDEMIXER" ]: new_idf_fields[2] = "AirTerminal:SingleDuct:Mixer" new_unit_object = IDFObject([core_object.object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_unit_object])
def transition(self, core_object, dependent_objects): # pragma no cover # F4: Outdoor Air Dryblub Temperature, Outdoor Air Wetblub Temperature; correct spelling from "blub" to "bulb" original_idf_fields = core_object.fields new_idf_fields = original_idf_fields if original_idf_fields[3].upper() == "OUTDOOR AIR DRYBLUB TEMPERATURE": new_idf_fields[3] = "Outdoor Air Drybulb Temperature" elif original_idf_fields[3].upper( ) == "OUTDOOR AIR WETBLUB TEMPERATURE": new_idf_fields[3] = "Outdoor Air Wetbulb Temperature" new_equip_object = IDFObject([core_object.object_name] + new_idf_fields) return TransitionReturn([new_equip_object])
def transition(self, core_object, dependent_objects): # pragma no cover daylight_ref_pts = build_ref_pt_list(dependent_objects["DAYLIGHTING:DELIGHT:REFERENCEPOINT"], dependent_objects["DAYLIGHTING:DELIGHT:CONTROLS"]) original_idf_fields = core_object.fields new_idf_fields = list() new_idf_fields.append("Daylighting:ReferencePoint") new_idf_fields.append(original_idf_fields[0]) # 0 for ref_pt in daylight_ref_pts: if ref_pt.control_name.upper() == original_idf_fields[1].upper(): new_idf_fields.append(ref_pt.zone_name) break new_idf_fields.append(original_idf_fields[2]) new_idf_fields.append(original_idf_fields[3]) new_idf_fields.append(original_idf_fields[4]) return TransitionReturn([IDFObject(new_idf_fields)])
def transition(self, core_object, dependent_objects): """ This method can be implemented by derived classes if necessary, but should capture the entire transition functionality just using the other required <must-override> methods in this class. This function first scans all the variable names in the current locations, and renames as needed. Then this function checks if this object type needs a complex transition, and if so, calls the appropriate derived method. This method then returns a full IDFObject instance. :param core_object: The original object to be replaced :param dependent_objects: A dictionary of dependent objects :return: A list of new IDFObject instances, typically just one though """ original_idf_fields = core_object.fields obj_name_upper = core_object.object_name.upper() # first just copy all fields into a new list new_idf_fields = original_idf_fields # then go through and do simple renames of the variables in the expected locations indexes = self.get_standard_indexes_from_object(obj_name_upper) if indexes is None: module_logger.warn("no indexes for output object: {}".format( core_object.object_name)) # pragma no cover else: for i in indexes: try: original_idf_fields[i] except IndexError: # pragma no cover this could be covered if the idf tests were larger break maybe_new_name = self.simple_name_swap( original_idf_fields[i].upper()) if maybe_new_name: # pragma no cover -- add in once we have a transition rule that does a swap new_idf_fields[i] = maybe_new_name # and create a temporary object new_variable_object = IDFObject([core_object.object_name] + new_idf_fields) # then do complex operations if needed if obj_name_upper in self.get_complex_operation_types(): new_variable_objects = self.complex_output_operation( new_variable_object, dependent_objects) else: new_variable_objects = [new_variable_object] # and finally return whatever we ended up with return TransitionReturn(new_variable_objects)
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields new_idf_fields = [original_idf_fields[0]] old_field_2 = original_idf_fields[1] old_d_empd = float(original_idf_fields[1]) old_a = float(original_idf_fields[2]) old_b = float(original_idf_fields[3]) old_c = float(original_idf_fields[4]) old_d = float(original_idf_fields[5]) empd_material_name = original_idf_fields[0] material = [x for x in dependent_objects["MATERIAL"] if x.fields[0].upper() == empd_material_name.upper()][0] old_density_material = float(material.fields[4]) new_mu = self.calculate_mu_empd(old_d_empd, old_a, old_b, old_c, old_d, old_density_material) new_idf_fields.append(str(new_mu)) new_idf_fields.extend(original_idf_fields[2:6]) new_idf_fields.append(old_field_2) new_idf_fields.extend(["0.0"] * 3) new_empd_object = IDFObject([core_object.object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_empd_object])
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields # we need to remove F2, F8, F13, F18, .... # these would be, zero based, 1, 7, 12, 17, 22, .... indeces_to_remove = [1] num_fields = len(core_object.fields) i_to_remove = 2 while True: i_to_remove += 5 if i_to_remove < num_fields: # pragma no cover indeces_to_remove.append(i_to_remove) else: break new_idf_fields = [ i for j, i in enumerate(original_idf_fields) if j not in indeces_to_remove ] new_branch_object = IDFObject([core_object.object_name] + new_idf_fields) # return a list since some transitions may split/add new objects return TransitionReturn([new_branch_object])
def transition(self, core_object, dependent_objects): # pragma no cover # If F16 is "Reverse" and both F17 and F18 (N7 and N8) are blank, do nothing. # If F16 is "reverse" and either F17 or F18 is not blank, replace "Reverse" with" ReverseWithLimits". original_idf_fields = core_object.fields original_f16 = original_idf_fields[15] try: original_f17 = original_idf_fields[16] except IndexError: original_f17 = "" try: original_f18 = original_idf_fields[17] except IndexError: original_f18 = "" new_idf_fields = original_idf_fields if original_f16.upper() == "REVERSE": if original_f17 == "" and original_f18 == "": # do nothing pass else: new_idf_fields[15] = "ReverseWithLimits" new_terminal_object = IDFObject([core_object.object_name] + new_idf_fields) return TransitionReturn([new_terminal_object])
def transition(self, core_object, dependent_objects): # pragma no cover # remove F33 = [32] : Chiller Flow Mode new_idf_fields = core_object.fields del new_idf_fields[32] new_object = IDFObject([core_object.object_name] + new_idf_fields) return TransitionReturn([new_object])
def transition(self, core_object, dependent_objects): # pragma no cover original_idf_fields = core_object.fields new_idf_fields = list() new_idf_fields.append(original_idf_fields[0] + "_DaylCtrl") # 0 new_idf_fields.append(original_idf_fields[0]) # 1 new_idf_fields.append("SplitFlux") # 2 try: new_idf_fields.append(original_idf_fields[19]) # 3 except IndexError: new_idf_fields.append("") if original_idf_fields[12] == "1": new_idf_fields.append("Continuous") # 4 elif original_idf_fields[12] == "2": new_idf_fields.append("Stepped") # 4 elif original_idf_fields[12] == "3": new_idf_fields.append("ContinuousOff") # 4 else: new_idf_fields.append("Continuous") # 4 new_idf_fields.append(original_idf_fields[15]) # 5 new_idf_fields.append(original_idf_fields[16]) # 6 if original_idf_fields[17] == "0": new_idf_fields.append("") # 7 else: new_idf_fields.append(original_idf_fields[17]) # 7 new_idf_fields.append(original_idf_fields[18]) # 8 new_idf_fields.append(original_idf_fields[0] + "_DaylRefPt1") # 9 new_idf_fields.append(original_idf_fields[13]) # 10 new_idf_fields.append(original_idf_fields[14]) # 11 new_idf_fields.append("") # 12 new_idf_fields.append(original_idf_fields[0] + "_DaylRefPt1") # 13 new_idf_fields.append(original_idf_fields[8]) # 14 new_idf_fields.append(original_idf_fields[10]) # 15 if original_idf_fields[1] == "2": new_idf_fields.append(original_idf_fields[0] + "_DaylRefPt2") # 16 new_idf_fields.append(original_idf_fields[9]) # 17 new_idf_fields.append(original_idf_fields[11]) # 18 new_control_object = IDFObject([core_object.object_name] + new_idf_fields) objects_to_write = [new_control_object] ref_pt_fields = list() ref_pt_fields.append("Daylighting:ReferencePoint") ref_pt_fields.append(original_idf_fields[0] + "_DaylRefPt1") ref_pt_fields.append(original_idf_fields[0]) ref_pt_fields.append(original_idf_fields[2]) ref_pt_fields.append(original_idf_fields[3]) ref_pt_fields.append(original_idf_fields[4]) ref_pt_object_1 = IDFObject(ref_pt_fields) objects_to_write.append(ref_pt_object_1) if original_idf_fields[1] == "2": ref_pt_fields = list() ref_pt_fields.append("Daylighting:ReferencePoint") ref_pt_fields.append(original_idf_fields[0] + "_DaylRefPt2") ref_pt_fields.append(original_idf_fields[0]) ref_pt_fields.append(original_idf_fields[5]) ref_pt_fields.append(original_idf_fields[6]) ref_pt_fields.append(original_idf_fields[7]) ref_pt_object_1 = IDFObject(ref_pt_fields) objects_to_write.append(ref_pt_object_1) return TransitionReturn(objects_to_write)
def transition(self, core_object, dependent_objects): # pragma no cover new_idf_fields = core_object.fields del new_idf_fields[self.field_to_remove] new_object = IDFObject([core_object.object_name] + new_idf_fields) return TransitionReturn([new_object])
def transition(self, core_object, dependent_objects): new_idf_fields = [self.end_version_id] new_version_object = IDFObject([core_object.object_name] + new_idf_fields) return base_rule.TransitionReturn([new_version_object])