Skip to content

Commit

Permalink
[F] more setings
Browse files Browse the repository at this point in the history
  • Loading branch information
sedevc committed Jul 13, 2015
1 parent f4550ec commit c8af9e9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 54 deletions.
12 changes: 6 additions & 6 deletions cfg/openBC.cfg
Expand Up @@ -41,18 +41,18 @@ man_fan_forward_gpio = 4
reset_gpio = 5

[timers]
block_time = 100
block_time = 52
block_time_idle = 300
run_time_fan_idle = 30
run_time_screw = 3
run_time_screw = 5
run_time_screw_idle = 5
log_block_time = 15

[limits]
tank_set_temp = 30
boiler_set_temp = 85
fire_set_temp = 300
lambda_set_value = 1.34
tank_set_temp = 19
boiler_set_temp = 35
fire_set_temp = 90
lambda_set_value = 0.92
idle_fire_set_temp = 200

[fan]
Expand Down
65 changes: 34 additions & 31 deletions gui.py
Expand Up @@ -13,9 +13,8 @@
CFG_FILE = "openBC.cfg"
CFG = os.path.dirname(os.path.abspath(__file__)) + CFG_PATH + CFG_FILE

OB = OpenBCcfg(CFG) # Read config file.
OB.readConfigFile()

OB = OpenBCcfg(CFG) # Read config file.
#################################################################
######################### GUI ###################################
#################################################################
Expand All @@ -38,19 +37,23 @@ def task():


def GetScaleValues():

OB.readConfigFile()
tScaleInt.set(int(OB.TANK_SET_TEMP))
bScaleInt.set(int(OB.BOILER_SET_TEMP))
fScaleInt.set(int(OB.FIRE_SET_TEMP))
lScaleFloat.set(float(OB.LAMBDA_SET_VALUE))
blockTimeInt.set(int(OB.BLOCK_TIME))
screwRuntimeInt.set(int(OB.RUN_TIME_SCREW))

def SetScaleValues():
config = ConfigParser.RawConfigParser()
config.set('limits', 'tank_set_temp', '15')
config.set('limits', 'boiler_set_temp', '40')
config.set('limits', 'fire_set_temp', '300')
config.set('limits', 'lambda_set_value', '1.34')
with open(CFG, 'ab') as configfile:
config.write(configfile)
OB.TANK_SET_TEMP = str(tScaleInt.get())
OB.BOILER_SET_TEMP = str(bScaleInt.get())
OB.FIRE_SET_TEMP = str(fScaleInt.get())
OB.LAMBDA_SET_VALUE = str(lScaleFloat.get())
OB.BLOCK_TIME = str(blockTimeInt.get())
OB.RUN_TIME_SCREW = str(screwRuntimeInt.get())
OB.WriteConfigFile()

# ----------- GUI ROOT ------------ #

Expand All @@ -69,6 +72,8 @@ def SetScaleValues():
bScaleInt = IntVar()
fScaleInt = IntVar()
lScaleFloat = DoubleVar()
blockTimeInt = IntVar()
screwRuntimeInt = IntVar()


tTempVar.set(0)
Expand Down Expand Up @@ -125,43 +130,41 @@ def SetScaleValues():

# ---------- Slides ------------- #

tankLabel = Label(settings, font=("Helvetica", 14), text="Tank target ℃")
tankLabel = Label(settings, font=("Helvetica", 13), text="Tank target ℃")
tankLabel.grid(sticky=SE, row=0, column=0)

tankScale = Scale(settings, variable=tScaleInt, takefocus=0, from_=0, to=100, length=600, width="25", orient=HORIZONTAL)

tankScale.grid(padx=20, pady=0,row=0, column=1)
#########
boilerLabel = Label(settings, font=("Helvetica", 14), text="Boiler target ℃")
boilerLabel = Label(settings, font=("Helvetica", 13), text="Boiler target ℃")
boilerLabel.grid(sticky=SE, row=1, column=0)

boilerScale = Scale(settings, variable=bScaleInt, takefocus=0, from_=0, to=100, length=600, width="25", orient=HORIZONTAL)

boilerScale.grid(padx=20, pady=0,row=1, column=1)
##########
fireLabel = Label(settings, font=("Helvetica", 14), text="Fire target ℃")
fireLabel = Label(settings, font=("Helvetica", 13), text="Fire target ℃")
fireLabel.grid(sticky=SE, row=2, column=0)

fireScale = Scale(settings, variable=fScaleInt, takefocus=0, from_=0, to=800, length=600, width="25", orient=HORIZONTAL)

fireScale.grid(padx=20, pady=0,row=2, column=1)
##########
lambdaLabel = Label(settings, font=("Helvetica", 14), text="Lambda target λ")
lambdaLabel = Label(settings, font=("Helvetica", 13), text="Lambda target λ")
lambdaLabel.grid(sticky=SE, row=3, column=0)

lambdaScale = Scale(settings, variable=lScaleFloat, takefocus=0, from_=0.65, to=1.6, resolution=0.02, length=600, width="25", orient=HORIZONTAL)

lambdaScale.grid(padx=20, pady=0,row=3, column=1)


setButton = Button(settings, command=SetScaleValues, text='SET')
#setButton.pack(side='left', anchor='nw', padx=3, pady=5)
setButton.grid(sticky=SE, padx=5, pady=25, row=4, column=0)

setButton = Button(settings, command=GetScaleValues, text='GET')
#setButton.pack(side='left', anchor='nw', padx=3, pady=5)
setButton.grid(sticky=SW, padx=5, pady=25, row=4, column=0)

##########
blockTimeLabel = Label(settings, font=("Helvetica", 13), text="Block time screw(s)")
blockTimeLabel.grid(sticky=SE, row=4, column=0)
blockTimeScale = Scale(settings, variable=blockTimeInt, takefocus=0, from_=0, to=800, length=600, width="25", orient=HORIZONTAL)
blockTimeScale.grid(padx=20, pady=0,row=4, column=1)
###########
screwRuntimeLabel = Label(settings, font=("Helvetica", 13), text="Screw run time(s)")
screwRuntimeLabel.grid(sticky=SE, row=5, column=0)
screwRuntimeScale = Scale(settings, variable=screwRuntimeInt, takefocus=0, from_=0, to=20, length=600, width="25", orient=HORIZONTAL)
screwRuntimeScale.grid(padx=20, pady=0,row=5, column=1)
###########
setButton = Button(settings, command=SetScaleValues, text='Set')
setButton.grid(sticky=SE, padx=5, pady=25, row=6, column=0)
##########
setButton = Button(settings, command=GetScaleValues, text='Undo')
setButton.grid(sticky=SW, padx=5, pady=25, row=6, column=0)
# ------------------------------- #


Expand Down
20 changes: 3 additions & 17 deletions openbccfg.py
Expand Up @@ -3,11 +3,9 @@
class OpenBCcfg(object):

def __init__(self, file_name):

self.config = ConfigParser.RawConfigParser()
self.file_name = file_name



def readConfigFile(self):
self.config.read(self.file_name)

Expand Down Expand Up @@ -46,16 +44,14 @@ def readConfigFile(self):
self.BUTTON_MAN_SCREW_BACKWARD = self.config.get("control_button", "man_screw_backward_gpio")
self.BUTTON_MAN_FAN_FORWARD = self.config.get("control_button", "man_fan_forward_gpio")
self.BUTTON_RESET = self.config.get("control_button", "reset_gpio")



self.BLOCK_TIME = self.config.get("timers", "block_time")
self.BLOCK_TIME_IDLE = self.config.get("timers", "block_time_idle")
self.RUN_TIME_FAN_IDLE = self.config.get("timers", "run_time_fan_idle")
self.RUN_TIME_SCREW = self.config.get("timers", "run_time_screw")
self.RUN_TIME_SCREW_IDLE = self.config.get("timers", "run_time_screw_idle")
self.LOG_BLOCK_TIME = self.config.get("timers", "log_block_time")



self.TANK_SET_TEMP = self.config.get("limits", "tank_set_temp")
self.BOILER_SET_TEMP = self.config.get("limits", "boiler_set_temp")
self.FIRE_SET_TEMP = self.config.get("limits", "fire_set_temp")
Expand All @@ -80,8 +76,6 @@ def readConfigFile(self):
self.LOG_FILE_NAME = self.config.get("log", "file_name")

def WriteConfigFile(self):


self.config.set('info', 'hw_name', self.HW_NAME)
self.config.set('info', 'ip', self.IP)
self.config.set('info', 'evok_url', self.EVOK_URL)
Expand All @@ -98,12 +92,10 @@ def WriteConfigFile(self):
self.config.set('tank_temp_sensor', 'file_name', self.TANK_TEMP_SENSOR_FILE_NAME)
self.config.set('tank_temp_sensor', 'id', self.TANK_TEMP_SENSOR_ID)


self.config.set('fire_temp_sensor', 'enabled', self.FIRE_TEMP_SENSOR_ENABLED)
self.config.set('fire_temp_sensor', 'type', self.FIRE_TEMP_SENSOR_TYPE)
self.config.set('fire_temp_sensor', 'analog_pin', self.FIRE_TEMP_SENSOR_ANALOG_PIN)


self.config.set('lambda_sensor', 'enabled', self.LAMBDA_SENSOR_ENABLED)
self.config.set('lambda_sensor', 'type', self.LAMBDA_SENSOR_TYPE)
self.config.set('lambda_sensor', 'port', self.LAMBDA_SENSOR_PORT)
Expand All @@ -112,7 +104,6 @@ def WriteConfigFile(self):
self.config.set('lambda_sensor', 'analog_pin', self.LAMBDA_SENSOR_ANALOG_PIN)
self.config.set('lambda_sensor', 'contactor_pin', self.LAMBDA_SENSOR_CONTACTOR_PIN)


self.config.set('control_button', 'contactor_pin', self.BUTTON_CONTACTOR_PIN)
self.config.set('control_button', 'emergency_stop_gpio', self.BUTTON_EMERGENCY_STOP)
self.config.set('control_button', 'auto_man_gpio', self.BUTTON_AUTO_MAN)
Expand All @@ -121,34 +112,29 @@ def WriteConfigFile(self):
self.config.set('control_button', 'man_fan_forward_gpio', self.BUTTON_MAN_FAN_FORWARD)
self.config.set('control_button', 'reset_gpio', self.BUTTON_RESET)


self.config.set('timers', 'block_time', self.BLOCK_TIME)
self.config.set('timers', 'block_time_idle', self.BLOCK_TIME_IDLE)
self.config.set('timers', 'run_time_fan_idle', self.RUN_TIME_FAN_IDLE)
self.config.set('timers', 'run_time_screw', self.RUN_TIME_SCREW)
self.config.set('timers', 'run_time_screw_idle', self.RUN_TIME_SCREW_IDLE)
self.config.set('timers', 'log_block_time', self.LOG_BLOCK_TIME)


self.config.set('limits', 'tank_set_temp', self.TANK_SET_TEMP)
self.config.set('limits', 'boiler_set_temp', self.BOILER_SET_TEMP)
self.config.set('limits', 'fire_set_temp', self.FIRE_SET_TEMP)
self.config.set('limits', 'lambda_set_value', self.LAMBDA_SET_VALUE)
self.config.set('limits', 'idle_fire_set_temp', self.IDLE_FIRE_SET_TEMP)


self.config.set('fan', 'enabled', self.FAN_ENABLED)
self.config.set('fan', 'type', self.FAN_TYPE)
self.config.set('fan', 'analog_pin', self.FAN_ANALOG_PIN)
self.config.set('fan', 'safe_mode_speed', self.FAN_SAFE_MODE_SPEED)
self.config.set('fan', 'contactor_pin', self.FAN_CONTACTOR_PIN)


self.config.set('screw', 'enabled', self.SCREW_ENABLED)
self.config.set('screw', 'type', self.SCREW_TYPE)
self.config.set('screw', 'contactor_pin', self.SCREW_CONTACTOR_PIN)


self.config.set('database', 'enabled', self.DATABASE_ENABLED)
self.config.set('database', 'type', self.DATABASE_TYPE)
self.config.set('database', 'db_name', self.DATABASE_NAME)
Expand Down

0 comments on commit c8af9e9

Please sign in to comment.