def test(self): real_time_core = RealTimeCore.get_instance() # Modo simulacion channel_0 = Bus(0,False) # channel_1 = Bus(1,True) channel_0.add_card(Digital(channel_0.channel_id,2)) # channel_0.add_card(2,'Digital') # channel_0.add_card(6,'Digital') # channel_0.add_card(16,'Digital') # channel_0.add_card(33,'Analogic') # channel_0.add_card(40,'Analogic') # channel_0.add_card(56,'Analogic') # channel_0.add_card(120,'Analogic') # channel_1.add_card(0,'Digital') # channel_1.add_card(2,'Digital') # channel_1.add_card(6,'Digital') # channel_1.add_card(16,'Digital') # channel_1.add_card(33,'Analogic') # channel_1.add_card(40,'Analogic') # channel_1.add_card(56,'Analogic') # channel_1.add_card(120,'Analogic') channel_0.test_cards_speeds() # channel_1.test_cards_speeds() try : real_time_core.add_channel(channel_0,True) except DomoticaException, e: e.log()
def test_save(): d = Domotica() # Modo simulacion channel_0 = Bus(0,False) channel_0.add_card(Digital(channel_0.channel_id,2)) channel_0.test_cards_speeds() try : d.RTCore.add_channel(channel_0,True) except DomoticaException, e: e.log() boolean = BooleanEvent(None,'Bus_0_I_02_01') boolean_2 = BooleanEvent(None,'Bus_0_O_02_01',reverse=True) comp = CompositeEvent(None,'%d and %d',[boolean,boolean_2],None,False) comp.name = 'Se detecto movimiento' comp.pause_delta = timedelta(seconds=5) comp.paused_mode = True #prendo este led action = SetterAction(None,['Bus_0_O_02_01'],SetterAction.MODE_SET) action.name = 'Prender luces' d.RTCore.map_event(comp,action) boolean = BooleanEvent(None,'Bus_0_I_02_01',reverse=True) timer = TimerEvent(None,None,timedelta(seconds=5),None) timer.name = 'Timer de 15 segundos sin movimiento' reset_condition = Template('not $%s' % boolean.get_event_id()) comp = CompositeEvent(None,'%d and %d',[boolean,timer],True,reset_condition) comp.name = 'Hace 15 segundos que no hay movimiento' out_ports = ['Bus_0_O_02_01'] action = SetterAction(None,out_ports,SetterAction.MODE_CLEAR) action.name = 'Apagar luces' d.RTCore.map_event(comp,action) d.RTCore.start_executer() time.sleep(2) d.RTCore.start_listener() raw_input("Presiones una tecla para termiar el programa") #real_time_core.stop_channel(channel_0.channel_id) d.RTCore.shutdown() try: d.conf.save_configuration(d.RTCore) except ConfiguratorException, e: e.log(self.logger_instance)