Example #1
0
 def event_disable_at_time(self, conn):
     while True:
         nowtime = time.strftime("%I:%M %p", time.localtime())
         if self.trigger == nowtime:
             conn.send("eventchange:"+self.who+":disable")
             gui.change_event_state(self.who, 0)
         time.sleep(60)
Example #2
0
 def stop_event(self):
     if self.event_process != None:
         cur.execute("""DELETE FROM helper_processes WHERE pid = %s""",(self.event_process.pid))
         con.commit()
         self.event_process.terminate()
         self.event_process = None
     gui.change_event_state(self.id, 0)
     self.keep_piping = False
     if self.has_input:
         inputs[self.trigger].start_input_idle()
Example #3
0
 def event_disable_on_input(self, conn):
     while True:
         GPIO.wait_for_edge(int(self.trigger), GPIO.RISING)
         conn.send("inputchange:"+self.trigger+":on")
         gui.change_input_state(self.trigger, 1, "reg")
         conn.send("eventchange:"+self.who+":disable")
         gui.change_event_state(self.who, 0)
         GPIO.wait_for_edge(int(self.trigger), GPIO.FALLING)
         conn.send("inputchange:"+self.trigger+":off")
         gui.change_input_state(self.trigger, 0, "reg")
Example #4
0
    def run_event(self):
        if self.action == "output_toggle_on_input_timeout":
            self.event_process = Process(target=self.output_toggle_on_input_timeout, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "output_toggle_on_input":
            self.event_process = Process(target=self.output_toggle_on_input, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "output_off_on_input":
            self.event_process = Process(target=self.output_off_on_input, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "output_on_on_input":
            self.event_process = Process(target=self.output_on_on_input, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "event_disable_on_input":
            self.event_process = Process(target=self.event_disable_on_input, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "event_enable_on_input":
            self.event_process = Process(target=self.event_enable_on_input, args=(self.child_conn,))
            self.has_input = True
            globals.inputs[self.trigger].event_id = self.id
            globals.inputs[self.trigger].stop_input_idle()

        elif self.action == "output_on_at_time":
            self.event_process = Process(target=self.output_on_at_time, args=(self.child_conn,))
        elif self.action == "output_off_at_time":
            self.event_process = Process(target=self.output_off_at_time, args=(self.child_conn,))
        elif self.action == "event_enable_at_time":
            self.event_process = Process(target=self.event_enable_at_time, args=(self.child_conn,))
        elif self.action == "event_disable_at_time":
            self.event_process = Process(target=self.event_disable_at_time, args=(self.child_conn,))
        time.sleep(1)
        self.event_process.start()
        globals.cur.execute(
            'INSERT INTO helper_processes VALUES (%s,"%s",%s)' % (self.event_process.pid, "event", self.id)
        )
        globals.con.commit()
        gui.change_event_state(self.id, 1)