コード例 #1
0
ファイル: real_time_core.py プロジェクト: juanchitot/domo
    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()
コード例 #2
0
ファイル: domotica.py プロジェクト: juanchitot/domo
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)
コード例 #3
0
ファイル: real_time_core.py プロジェクト: juanchitot/domo
    def test_dump(self):
        real_time_core = RealTimeCore.get_instance()
        
        channel_0 = Bus(0,False)
        channel_1 = Bus(1,True)
        
        channel_0.add_card(Digital(channel_0.channel_id,2))
        channel_0.add_card(Digital(channel_0.channel_id,4))
        channel_0.add_card(Digital(channel_0.channel_id,6))
        
        channel_1.add_card(Digital(channel_1.channel_id,2))
        channel_1.add_card(Digital(channel_1.channel_id,2))
        channel_1.add_card(Digital(channel_1.channel_id,6))
        
        real_time_core.add_channel(channel_0,False)
        real_time_core.add_channel(channel_1,False)
#         -------------------------------------------------
        boolean = BooleanEvent('Bus_0_I_02_00')
        boolean_2 = BooleanEvent('Bus_0_O_02_00',reverse=True)
        comp = CompositeEvent('%d and %d',[boolean,boolean_2],False)
        comp.name = 'Se detecto movimiento'     
        
        comp.pause_delta = timedelta(seconds=5)        
        comp.paused_mode = True
        
        #prendo este led    
        action = SetterAction(['Bus_0_O_02_00'],SetterAction.MODE_SET)        
        action.name = 'Prender luces'
        real_time_core.map_event(comp,action)
#         -------------------------------------------------
        boolean = BooleanEvent('Bus_0_I_02_01')
        boolean_2 = BooleanEvent('Bus_0_O_02_01',reverse=True)
        comp = CompositeEvent('%d and %d',[boolean,boolean_2],False)
        comp.name = 'Se detecto movimiento'     
        
        comp.pause_delta = timedelta(seconds=5)        
        comp.paused_mode = True
        
        #prendo este led    
        action = SetterAction(['Bus_0_O_02_01'],SetterAction.MODE_SET)        
        action.name = 'Prender luces'
        real_time_core.map_event(comp,action)
#         -------------------------------------------------


        real_time_core.start_listener()
        real_time_core.start_executer()
        time.sleep(10)
        real_time_core.shutdown()
        
        print yaml.dump_all([real_time_core],explicit_start=True)
コード例 #4
0
ファイル: dump_tst.py プロジェクト: juanchitot/domo
#!/usr/bin/python

from channel.bus import Bus
from channel.digital import Digital
import yaml
b = Bus(0,False)
b.add_card(Digital(b.channel_id,0))
b.add_card(Digital(b.channel_id,2))        

b1 = Bus(1,True)
b1.add_card(Digital(b1.channel_id,0))
b1.add_card(Digital(b1.channel_id,0))        
b1.add_card(Digital(b1.channel_id,0))
b1.add_card(Digital(b1.channel_id,0))        



#print yaml.dump([b,b1])
print   "--------------"
yaml.dump(yaml.load(yaml.dump([b,b1])))