Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[F] Status bar, Time left of block timer
GUI -  add server status, mode, time and block timer in status bar

Server - add logic to pass block timer to gui
  • Loading branch information
sedevc committed Jul 15, 2015
1 parent 6d2f2d8 commit 21020f3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
6 changes: 3 additions & 3 deletions abio.py
Expand Up @@ -34,7 +34,7 @@ def decrease_voltage(self, decrease_value):
self.s.ao_set_value(self.analog_pin, self.voltage)
def get_rpm(self):
temp = self.translate(self.voltage)
if temp < 1.2 or self.contactor == False:
if temp < 244 or self.contactor == False:
return 0
elif temp > 2200:
return 2200
Expand Down Expand Up @@ -104,8 +104,8 @@ def __init__(self):
self.data = ""
def get(self):
return self.data
def put(self, tank_temp, boiler_temp, fire_temp, fan_rpm):
self.data = json.dumps({'TANK': tank_temp, 'BOILER': boiler_temp, 'FIRE': fire_temp, 'FAN RPM': fan_rpm, })
def put(self, tank_temp, boiler_temp, fire_temp, fan_rpm, mode, time_left):
self.data = json.dumps({'TANK': tank_temp, 'BOILER': boiler_temp, 'FIRE': fire_temp, 'FAN RPM': fan_rpm, 'AUTO': mode, 'TIMER': time_left})

def startWebbServer(a):
@route('/api/status')
Expand Down
4 changes: 2 additions & 2 deletions cfg/openBC.cfg
Expand Up @@ -41,15 +41,15 @@ man_fan_forward_gpio = 4
reset_gpio = 5

[timers]
block_time = 113
block_time = 210
block_time_idle = 300
run_time_fan_idle = 30
run_time_screw = 2
run_time_screw_idle = 5
log_block_time = 15

[limits]
tank_set_temp = 27
tank_set_temp = 24
boiler_set_temp = 35
fire_set_temp = 237
lambda_set_value = 0.9
Expand Down
28 changes: 21 additions & 7 deletions gui.py
Expand Up @@ -2,8 +2,7 @@
# -*- coding: utf-8 -*-
from Tkinter import *
import Tkinter as tk
import ttk as ttk
import PIL, tkFont, socket, json, os, urllib, ConfigParser
import PIL, tkFont, socket, json, os, urllib, ConfigParser, ttk
from time import gmtime, strftime
from openbccfg import OpenBCcfg

Expand All @@ -29,6 +28,11 @@ def task():
bTempVar.set(str(int(result['BOILER'])) + "℃")
fTempVar.set(str(int(result['FIRE'])) + "℃")
fanRpmVar.set(str(int(result['FAN RPM'])) + "rpm")
timeLeftVar.set( "BLOCK TIMER " + str(int(result['TIMER'])) + " (S)")
if result['AUTO'] == 0:
serverModeVar.set("MODE: MANUAL")
else:
serverModeVar.set("MODE: AUTO ")
serverStatusVar.set("ONLINE")
print result
except:
Expand All @@ -47,6 +51,7 @@ def GetScaleValues():
blockTimeInt.set(int(OB.BLOCK_TIME))
screwRuntimeInt.set(int(OB.RUN_TIME_SCREW))


def SetScaleValues():
OB.TANK_SET_TEMP = str(tScaleInt.get())
OB.BOILER_SET_TEMP = str(bScaleInt.get())
Expand All @@ -70,8 +75,9 @@ def SetScaleValues():
fanRpmVar = StringVar()
timeStatusVar = StringVar()
serverStatusVar = StringVar()
serverModeVar = StringVar()
timeStatusVar.set(str(strftime("%Y-%m-%d %H:%M:%S", gmtime())))

timeLeftVar = StringVar()


tScaleInt = IntVar()
Expand Down Expand Up @@ -138,11 +144,19 @@ def SetScaleValues():
statusBar = Label(status, bd=1, relief=SUNKEN, anchor=W, font=("Helvetica", 10))
statusBar.pack(side=BOTTOM ,fill=X)

timeStatus = Label(statusBar, textvariable=timeStatusVar, bd=1, relief=SUNKEN, anchor=W, font=("Helvetica", 10))
timeStatus.pack(side=LEFT)
timeStatus = Label(statusBar, textvariable=timeStatusVar, bd=1, relief=SUNKEN, anchor=CENTER, font=("Helvetica", 10))
timeStatus.pack(side=LEFT, ipadx=10)

serverStatus = Label(statusBar, textvariable=serverStatusVar, bd=1, relief=SUNKEN, anchor=CENTER, font=("Helvetica", 10))
serverStatus.pack(side=RIGHT, ipadx=10)

serverMode = Label(statusBar, textvariable=serverModeVar, bd=1, relief=SUNKEN, anchor=CENTER, font=("Helvetica", 10))
serverMode.pack(side=LEFT, ipadx=10)

timeLeft = Label(statusBar, textvariable=timeLeftVar, bd=1, relief=SUNKEN, anchor=CENTER, font=("Helvetica", 10))
timeLeft.pack(side=LEFT, ipadx=10)


serverStatus = Label(statusBar, textvariable=serverStatusVar, bd=1, relief=SUNKEN, anchor=W, font=("Helvetica", 10))
serverStatus.pack(side=RIGHT)

# ------------------------------- #

Expand Down
9 changes: 5 additions & 4 deletions server.py
@@ -1,8 +1,7 @@
#!/usr/bin/env python

#!/usr/bin/env python
import socket, sys, time, json, threading
import logging, time, os, sys, os.path
import json, threading, logging, time, os, sys, os.path
from pid import Pid
from openbccfg import OpenBCcfg
from jsonrpclib import Server
Expand All @@ -25,6 +24,7 @@
TIMESTAMP_CFG = time.ctime(os.path.getmtime(CFG))
TEMP_SCREW_BLOCK_TIMER = time.time() # Read current time, need this for screw controll
TEMP_LOG_BLOCK_TIMER = time.time()
TIME_LEFT_OF_BLOCK_TIMER = 0

# Make sure all relay is deactivated
for x in xrange(1,9):
Expand Down Expand Up @@ -57,7 +57,7 @@

logging.info('%s', "Enter main loop")
while True:
q.put(TANK.get_temp(), BOILER.get_temp(), FIRE.get_temp(), int(FAN.get_rpm())) # UPPDATE VALUE FOR GUI
q.put(TANK.get_temp(), BOILER.get_temp(), FIRE.get_temp(), int(FAN.get_rpm()), S.input_get_value(OB.BUTTON_AUTO_MAN), TIME_LEFT_OF_BLOCK_TIMER)# UPPDATE VALUE FOR GUI
if not TIMESTAMP_CFG == time.ctime(os.path.getmtime(CFG)): # RELOAD CONFIG IF TIMESTAMP CHANGED
TIMESTAMP_CFG = time.ctime(os.path.getmtime(CFG))
OB.readConfigFile()
Expand All @@ -84,6 +84,7 @@
if not FAN.contactor: # ACTIVATE FAN
logging.info('%s', "FAN Activate contactor")
FAN.activate_contactor()
TIME_LEFT_OF_BLOCK_TIMER = int((int(TEMP_SCREW_BLOCK_TIMER) + int(OB.BLOCK_TIME)) - time.time())
if time.time() > (int(TEMP_SCREW_BLOCK_TIMER) + int(OB.BLOCK_TIME)): # TIMER BELOW BLOCKTIMER?
if FIRE.get_temp() <= float(OB.FIRE_SET_TEMP): # FIRE BELOW SET TEMP?
if TANK.get_temp() <= float(OB.TANK_SET_TEMP): # TANK BELOW SET TEMP?
Expand Down Expand Up @@ -115,7 +116,7 @@
FAN.set_voltage(int(OB.FAN_SAFE_MODE_SPEED))
logging.info('%s', "MAN Fan pressed")
while S.input_get_value(OB.BUTTON_MAN_FAN_FORWARD):
q.put(TANK.get_temp(), BOILER.get_temp(), FIRE.get_temp(), int(FAN.get_rpm())) # UPPDATE VALUE FOR GUI
q.put(TANK.get_temp(), BOILER.get_temp(), FIRE.get_temp(), int(FAN.get_rpm()), S.input_get_value(OB.BUTTON_AUTO_MAN), TIME_LEFT_OF_BLOCK_TIMER)# UPPDATE VALUE FOR GUI
if S.input_get_value(OB.BUTTON_RESET): # REBOOT (MAN FAN + RESET)
os.system("sudo reboot")
logging.info('%s', "MAN Fan released")
Expand Down

0 comments on commit 21020f3

Please sign in to comment.