Beispiel #1
0
class TempCollector(StatCollector):

    def __init__(self):
        self.window = Window()
        self.name = 'temp'
        self.file = settings.temp_file

        os.system('modprobe w1-gpio')
        os.system('modprobe w1-therm')
        self.base_dir = '/sys/bus/w1/devices/'
        self.device_folder = glob.glob(self.base_dir + '28*')[0]
        self.device_file = self.device_folder + '/w1_slave'
        

    def read_temp_raw(self):
        with open(self.device_file, 'r') as f:
            return f.readlines()

    def collect(self, bus):
        lines = self.read_temp_raw()
        while lines[0].strip()[-3:] != 'YES':
            time.sleep(0.2)
            lines = self.read_temp_raw()
        equals_pos = lines[1].find('t=')
        if equals_pos != -1:
            temp_string = lines[1][equals_pos+2:]
            temp_c = float(temp_string) / 1000.0
            temp_f = temp_c * 9.0 / 5.0 + 32.0
            self.window.add(temp_f)
Beispiel #2
0
class LevelCollector(StatCollector):

    def __init__(self):
        self.window = Window()
        self.name = 'level'
        self.file = settings.level_file
        

    def collect(self, bus):
        bus.write_byte_data(DEVICE_ADDRESS, 0, 81)
        sleep(.1)
        distance = bus.read_word_data(DEVICE_ADDRESS, 2) / 255
        min_distance = bus.read_word_data(DEVICE_ADDRESS, 4) / 255
        self.window.add(distance)
Beispiel #3
0
    def __init__(self):
        self.window = Window()
        self.name = 'temp'
        self.file = settings.temp_file

        os.system('modprobe w1-gpio')
        os.system('modprobe w1-therm')
        self.base_dir = '/sys/bus/w1/devices/'
        self.device_folder = glob.glob(self.base_dir + '28*')[0]
        self.device_file = self.device_folder + '/w1_slave'
Beispiel #4
0
class PHCollector(StatCollector):

    def __init__(self):
        self.window = Window()
        self.name = 'ph'
        self.file = settings.ph_file
        

    def collect(self, bus):
        #reload config...slower, but allows changes on teh fly
        self.load()


        bytes = bus.read_i2c_block_data(DEVICE_ADDRESS, 1)
        hi = bytes[0]
        lo = bytes[1]
        adc_res = (hi * 256.0) + lo
        ph = self.calculate_ph(adc_res)
        self.window.add(ph)

    def load(self):
        with open(settings.ph_calibration, 'r') as f:
            calibration = json.loads(f.read())
            for key, value in calibration.iteritems():
                setattr(self, key, value)
        self.calculate_slope()

    def calculate_slope(self):
        self.ph_step = ((((self.v_ref * (self.ph7_cal - self.ph4_cal)) / 4096.0) * 1000.0) / self.op_amp_gain) / 3


    def calculate_ph(self, res):
        millivolts = (res / 4096.0) * self.v_ref * 1000.0
        temp = ((((self.v_ref * self.ph7_cal) / 4096.0) * 1000.0) - millivolts) / self.op_amp_gain
        ph = 7.0 - (temp / self.ph_step)
        return ph
Beispiel #5
0
	def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)

		# GUI
		self.ui = Ui_MainUI()
		self.ui.setupUi(self)

		# GUI position
		self.setGeometry(Window.centered_position(self.geometry()))

		# DAO
		#self.configDAO = ConfigDAO()

		# Controllers
		#self.propertiesBC = PropertiesBC()

		# Signals
		QtCore.QObject.connect(self.ui.pushButton,   QtCore.SIGNAL("clicked()"), self.search)
Beispiel #6
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        # GUI
        self.ui = Ui_MainUI()
        self.ui.setupUi(self)

        # GUI position
        self.setGeometry(Window.centered_position(self.geometry()))

        # DAO
        #self.configDAO = ConfigDAO()

        # Controllers
        #self.propertiesBC = PropertiesBC()

        # Signals
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),
                               self.search)
Beispiel #7
0
 def __init__(self):
     self.window = Window()
     self.name = 'level'
     self.file = settings.level_file
Beispiel #8
0
 def __init__(self):
     self.window = Window()
     self.name = 'ph'
     self.file = settings.ph_file