def __init__(self): """Creates a freshroastsr700 object passing in methods included in this class.""" self.recipes = recipe.Recipe() self.roaster = freshroastsr700.freshroastsr700(self.update_data, self.next_state, thermostat=True) self.total_steps = self.recipes.get_num_recipe_sections()
def __init__(self): """Set up application, styles, fonts, and global object.""" # app self.app = QtWidgets.QApplication(sys.argv) # fonts # QtGui.QFontDatabase.addApplicationFont( # "static/fonts/asap/asap-regular.ttf") qba = QtCore.QByteArray( utils.get_resource_string("static/fonts/asap/asap-regular.ttf")) QtGui.QFontDatabase.addApplicationFontFromData(qba) # QtGui.QFontDatabase.addApplicationFont( # "static/fonts/asap/asap-bold.ttf") qba = QtCore.QByteArray( utils.get_resource_string("static/fonts/asap/asap-bold.ttf")) QtGui.QFontDatabase.addApplicationFontFromData(qba) # QtGui.QFontDatabase.addApplicationFont( # "static/fonts/asap/asap-bold-italic.ttf") qba = QtCore.QByteArray( utils.get_resource_string( "static/fonts/asap/asap-bold-italic.ttf")) QtGui.QFontDatabase.addApplicationFontFromData(qba) # QtGui.QFontDatabase.addApplicationFont( # "static/fonts/asap/asap-italic.ttf") qba = QtCore.QByteArray( utils.get_resource_string("static/fonts/asap/asap-italic.ttf")) QtGui.QFontDatabase.addApplicationFontFromData(qba) # styles style = utils.get_resource_string("static/mainStyle.css").decode( "utf-8") style = style.replace( 'static/images/downArrow.png', pathlib.Path( utils.get_resource_filename( 'static/images/downArrow.png')).as_posix()) style = style.replace( 'static/images/upArrow.png', pathlib.Path( utils.get_resource_filename( 'static/images/upArrow.png')).as_posix()) QtWidgets.QApplication.setStyleSheet(self.app, style) # copy recipes to user folder, if it doesn't exist # (to prevent overwriting pre-existing user data!) self.check_user_folder() # initialize recipe amd roaster object self.roaster = freshroastsr700.freshroastsr700(thermostat=True) self.recipes = recipe.Recipe(self.roaster, self) if (not self.roaster.set_state_transition_func( self.recipes.move_to_next_section)): # signal an error somehow logging.error( "OpenroastApp.__init__ failed to set state transition " "callback. This won't work.")
# -*- coding: utf-8 -*- # Copyright (c) 2015-2016 Mark Spicer # Made available under the MIT license. import time import freshroastsr700 # Create a roaster object. roaster = freshroastsr700.freshroastsr700() # Conenct to the roaster. roaster.connect() # Set variables. roaster.heat_setting = 3 roaster.fan_speed = 9 roaster.time_remaining = 20 # Begin roasting. roaster.roast() # This ensures the example script does not end before the roast. time.sleep(30) # Disconnect from the roaster. roaster.disconnect()
import os import sys import shutil import freshroastsr700 from PyQt5 import QtWidgets from PyQt5 import QtGui from openroast import tools from openroast.views import mainwindow from openroast.controllers import recipe recipes = recipe.Recipe() roaster = freshroastsr700.freshroastsr700( thermostat=True, state_transition_func=recipes.move_to_next_section) class Openroast(object): """Main application class.""" def __init__(self): """Set up application, styles, fonts, and global object.""" self.app = QtWidgets.QApplication(sys.argv) QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-regular.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-bold.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-bold-italic.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-italic.ttf")
def __init__(self): """Creates a freshroastsr700 object passing in methods included in this class.""" self.roaster = freshroastsr700.freshroastsr700( self.update_data, self.next_state, thermostat=True)
def __init__(self, kp=0.06, ki=0.0075, kd=0.01): """Creates a freshroastsr700 object passing in methods included in this class. Set the PID values above to set them in the freshroastsr700 object.""" self.roaster = freshroastsr700.freshroastsr700(self.update_data, self.next_state, thermostat=True, kp=kp, ki=ki, kd=kd) # test vector for driving sr700 # quick recipe simulation # self.recipe = [ # { # 'time_remaining': 60, # 'target_temp': 350, # 'fan_speed': 9, # 'state': 'roasting' # }, # { # 'time_remaining': 60, # 'target_temp': 390, # 'fan_speed': 5, # 'state': 'roasting' # }, # { # 'time_remaining': 30, # 'target_temp': 420, # 'fan_speed': 5, # 'state': 'roasting' # }, # { # 'time_remaining': 60, # 'target_temp': 450, # 'fan_speed': 5, # 'state': 'roasting' # }, # { # 'time_remaining': 60, # 'target_temp': 480, # 'fan_speed': 3, # 'state': 'roasting' # }, # { # 'time_remaining': 60, # 'target_temp': 500, # 'fan_speed': 3, # 'state': 'roasting' # }, # { # 'time_remaining': 60, # 'target_temp': 150, # 'fan_speed': 9, # 'state': 'cooling' # }, # { # 'time_remaining': 1, # 'target_temp': 150, # 'fan_speed': 1, # 'state': 'idle' # } # ] # for dialing in pid params - 3 min. short cycle self.recipe = [{ 'time_remaining': 60, 'target_temp': 300, 'fan_speed': 9, 'state': 'roasting' }, { 'time_remaining': 60, 'target_temp': 350, 'fan_speed': 5, 'state': 'roasting' }, { 'time_remaining': 60, 'target_temp': 400, 'fan_speed': 5, 'state': 'roasting' }, { 'time_remaining': 60, 'target_temp': 450, 'fan_speed': 4, 'state': 'roasting' }, { 'time_remaining': 30, 'target_temp': 150, 'fan_speed': 9, 'state': 'cooling' }, { 'time_remaining': 1, 'target_temp': 150, 'fan_speed': 1, 'state': 'idle' }] # to set up process to begin, call next state to load first state self.active_recipe_item = -1 # open file to write temps in CSV format self.file = open("sr700_pid_tune.csv", "w") self.file.write("Time,crntTemp,targetTemp,heaterLevel\n") # get start timestamp self.start_time = datetime.datetime.now()
# Roastero, released under GPLv3 import os import sys import shutil import freshroastsr700 from PyQt5 import QtWidgets from PyQt5 import QtGui from openroast import tools from openroast.views import mainwindow from openroast.controllers import recipe recipes = recipe.Recipe() roaster = freshroastsr700.freshroastsr700( thermostat=True, state_transition_func=recipes.move_to_next_section) class Openroast(object): """Main application class.""" def __init__(self): """Set up application, styles, fonts, and global object.""" self.app = QtWidgets.QApplication(sys.argv) QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-regular.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-bold.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-bold-italic.ttf") QtGui.QFontDatabase.addApplicationFont( "static/fonts/asap/asap-italic.ttf")
def setUp(self): self.roaster = freshroastsr700.freshroastsr700()
import logging from sr700api.version import __version__ import freshroastsr700 from sr700api import utils as utils import logging logging.basicConfig(filename='sr700_restserver.log', level=logging.WARNING) app = Flask(__name__) api = Api(app) # shut down werkzeug logging log = logging.getLogger('werkzeug') log.setLevel(logging.CRITICAL) # hardware interface device_sr700 = freshroastsr700.freshroastsr700(ext_sw_heater_drive=True) # attempt to connect to sr700 device, or connect # later if not plugged in yet... device_sr700.auto_connect() class TestEndpoint(Resource): def get(self): return {'project': 'sr700api', 'version': __version__} class BeanTemperature(Resource): def get(self): if device_bt.is_connected(): probe_t, fault, junc_t, scv, scg, oc = device_bt.read() return {
def setUp(self): self.roaster = freshroastsr700.freshroastsr700(thermostat=True)