class LightString(object): def __init__(self, model_name, s_id, r_id): self.id = s_id self.total_wattage = MODEL_WATTAGE[model_name] self.receptacle = Receptacle(15, r_id) self.model_id = LIGHT_STRING_MODELS[model_name] def get_id(self): return self.id def get_amp_rating(self): return float(MAX_RESIDENTIAL_LIGHT_STRING_WIRE_WATTAGE / RESIDENTIAL_LINE_VOLTAGE) def get_light_string_by_id(self, light_string_id): if light_string_id == self.id: return self else: return self.receptacle.get_light_string_by_id(light_string_id) def get_splitter_by_id(self, splitter_id): return self.receptacle.get_splitter_by_id(splitter_id) def get_receptacle_by_id(self, receptacle_id): if True == DEBUG: print('LightString.get_receptacle_by_id: rid:{0}'.format(receptacle_id)) return self.receptacle.get_receptacle_by_id(receptacle_id) def get_amp_load(self): amp_load = float(self.total_wattage / RESIDENTIAL_LINE_VOLTAGE) amp_load += self.receptacle.get_amp_load() return amp_load
class LightString(object): def __init__(self, model_name, s_id, r_id): self.id = s_id self.total_wattage = MODEL_WATTAGE[model_name] self.receptacle = Receptacle(15, r_id) self.model_id = LIGHT_STRING_MODELS[model_name] def get_id(self): return self.id def get_amp_rating(self): return float(MAX_RESIDENTIAL_LIGHT_STRING_WIRE_WATTAGE / RESIDENTIAL_LINE_VOLTAGE) def get_light_string_by_id(self, light_string_id): if light_string_id == self.id: return self else: return self.receptacle.get_light_string_by_id(light_string_id) def get_splitter_by_id(self, splitter_id): return self.receptacle.get_splitter_by_id(splitter_id) def get_receptacle_by_id(self, receptacle_id): if True == DEBUG: print('LightString.get_receptacle_by_id: rid:{0}'.format( receptacle_id)) return self.receptacle.get_receptacle_by_id(receptacle_id) def get_amp_load(self): amp_load = float(self.total_wattage / RESIDENTIAL_LINE_VOLTAGE) amp_load += self.receptacle.get_amp_load() return amp_load
class Outlet(object): def __init__(self, model_name, o_id, r_ids): self.id = o_id self.amp_rating = OUTLET_MODELS[model_name] self.r1 = Receptacle(self.amp_rating, r_ids[0]) self.r2 = Receptacle(self.amp_rating, r_ids[1]) def get_id(self): return self.id def get_amp_rating(self): return self.amp_rating def add_outlet(self, outlet): self.outlets.append(outlets) def get_light_string_by_id(self, light_string_id): ls = self.r1.get_light_string_by_id(light_string_id) if None == ls: ls = self.r2.get_light_string_by_id(light_string_id) return ls def get_splitter_by_id(self, splitter_id): sp = self.r1.get_splitter_by_id(splitter_id) if None == sp: sp = self.r2.get_splitter_by_id(splitter_id) return sp def get_receptacle_by_id(self, receptacle_id): if True == DEBUG: print('Outlet.get_receptacle_by_id: rid:{0}'.format(receptacle_id)) r = self.r1.get_receptacle_by_id(receptacle_id) if None == r: r = self.r2.get_receptacle_by_id(receptacle_id) return r def get_amp_load(self): amp_load = 0.0 amp_load += self.r1.get_amp_load() amp_load += self.r2.get_amp_load() return amp_load def get_max_receptacle_amp_load(self): r1_amp_load = 0.0 + self.r1.get_amp_load() r2_amp_load = 0.0 + self.r2.get_amp_load() return max([r1_amp_load, r2_amp_load])
def __init__(self, model_name, s_id, r_ids): self.id = s_id self.total_amp_rating = 15 self.receptacle_amp_rating = 0 self.receptacle_count = SPLITTER_MODELS[model_name] self.receptacles = [] for idx in range(self.receptacle_count): self.receptacles.append(Receptacle(15, r_ids[idx])) if True == DEBUG: print( 'Splitter.__init__() created model_name:{0}, id:{1}, receptacles:{2}' .format(model_name, self.id, self.receptacles))
def __init__(self, model_name, s_id, r_id): self.id = s_id self.total_wattage = MODEL_WATTAGE[model_name] self.receptacle = Receptacle(15, r_id) self.model_id = LIGHT_STRING_MODELS[model_name]
def __init__(self, model_name, o_id, r_ids): self.id = o_id self.amp_rating = OUTLET_MODELS[model_name] self.r1 = Receptacle(self.amp_rating, r_ids[0]) self.r2 = Receptacle(self.amp_rating, r_ids[1])