Changeset - cec321b6b72c
[Not reviewed]
default
0 2 0
matthewreed - 9 years ago 2016-07-23 17:53:42

Added timer debug config
2 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
hydrobot.py
Show inline comments
 
@@ -19,6 +19,7 @@ config = configparser.ConfigParser(allow
 
config.read("hydrobot.conf")
 
DEBUG_CAN = config.getboolean("debug", "can")
 
DEBUG_CAN_DETAIL = config.getboolean("debug", "can_detail")
 
DEBUG_TIMER = config.getboolean("debug", "timer")
 

	
 
class Database:
 
    
 
@@ -136,7 +137,6 @@ class CanBus:
 
    def set_output(self, module, output, state):
 
        msg = self.msgdb.lookup_message(module)
 
        msg.lookup_signal(output).value = state
 
        #print(msg)
 
        self.dev.send(msg.encode())
 
        
 
class Scheduler:
 
@@ -173,23 +173,22 @@ class Scheduler:
 
                    self.apscheduler.add_job(self.interval_off, trigger, [module, output, section + "_off", section + "_on", on_duration], id = section + "_off", weeks = off_duration[0], days = off_duration[1], hours = off_duration[2], minutes = off_duration[3], seconds = off_duration[4])
 
                    timer = self.apscheduler.add_job(self.interval_on, trigger, [module, output, section + "_off", section + "_on", off_duration], id = section + "_on", weeks = on_duration[0], days = on_duration[1], hours = on_duration[2], minutes = on_duration[3], seconds = on_duration[4])
 
                    timer.pause()
 
                    print(off_duration[4])
 
                    print(on_duration[4])
 
        
 
        
 
    def interval_off(self, module, output, timer_off, timer_on, on_duration):
 
        self.canbus.set_output(module, output, 1)
 
        self.apscheduler.get_job(timer_on).reschedule("interval", weeks = on_duration[0], days = on_duration[1], hours = on_duration[2], minutes = on_duration[3], seconds = on_duration[4])
 
        self.apscheduler.get_job(timer_on).resume()
 
        self.apscheduler.get_job(timer_off).pause()
 
        print("turning on " + timer_on + "! " + str(datetime.datetime.now().time()))
 
        if DEBUG_TIMER:
 
            print("Turning " + timer_on + "! " + str(datetime.datetime.now().time()))
 
        
 
    def interval_on(self, module, output, timer_off, timer_on, off_duration):
 
        self.canbus.set_output(module, output, 0)
 
        self.apscheduler.get_job(timer_off).reschedule("interval", weeks = off_duration[0], days = off_duration[1], hours = off_duration[2], minutes = off_duration[3], seconds = off_duration[4])
 
        self.apscheduler.get_job(timer_off).resume()
 
        self.apscheduler.get_job(timer_on).pause()
 
        print("turning off " + timer_off + "! " + str(datetime.datetime.now().time()))
 
        if DEBUG_TIMER:
 
            print("Turning " + timer_off + "! " + str(datetime.datetime.now().time()))
 
    
 
def func():
 
    print(1)
hydrobot_example.conf
Show inline comments
 
@@ -11,6 +11,7 @@ database: hydrobot
 
[debug]
 
can: True
 
can_detail: False
 
timer: False
 

	
 
[timer1]
 
module: RelayDriveOut
0 comments (0 inline, 0 general)