예제 #1
0
 def __init__(self, dataexchange, pin, freq):
     # initializing the super class
     SiSThread.__init__(self,dataexchange)
     gpio.setup("pin")        
     self.gpi = gpio.OutputGpio(pin)
     self.freq = freq
     self.interval = int((1/self.freq)/2)
예제 #2
0
 def run(self):
     """
     the threading main loop in dependency of the exchanged programstate variable.
     counts the ticks with a switch condition, meaning a count will only be 
     recongnized as such when the value switches from High to Low.
     ###
     RETURNS (void)
     """
     self.exchange.log("[+] running Geiger Thread")
     # main loop with exchanged programstate condition
     t_start = time.time()
     # condition to add a count. will only add a count, if there has been a change
     # in value, meianing whenever the previous value was 0 and the claue then changed
     # to True
     prev_value = 0
     try:
         while self.exchange.programstate:
             # the time difference, later being checked with the interval variable
             t_delta = time.time() - t_start
             if self.port.get_state() == 1 and prev_value == 0:
                 prev_value = 1
             elif self.port.get_state() == 0 and prev_value == 1:
                 prev_value = 0
                 self.count += 1
             if t_delta >= self.interval:
                 # udpadating the exchanged geiger value and resetting the count variable
                 self._update_data()
                 t_start = time.time()
     finally:
         self.exchange.log("[*] terminated Geiger Thread")
         gpio.cleanup()
예제 #3
0
 def __init__(self, dataexchange, pin, interval=30, name="GeigerCounter", factor=5.5):
     SiSThread.__init__(self, dataexchange)
     self.name = name
     self.exchange.register_sensor(self.name)
     self.interval = 30
     gpio.setup("Pin")
     self.port = gpio.InputGpio(pin)
     self.count = 0
     self.factor = factor
예제 #4
0
 def run(self):
     """
     actually starting the animations
     ###
     RETURNS (void)
     """
     # the amount of repetitions 
     try:
         while (True):
             self.raindrops(20, 100)
             self.pause()
             self.vertical_lines(3, 150)
             self.pause()
             self.horizontal_lines(3, 150)
             self.pause()
             self.inverting_chess(8, 100)
             self.pause()
             self.rings(8, 100)
             self.pause()
     except:
         io.cleanup()
         sys.exit()