def run_update(self): #check if the flow rates are legit numbers, if not set to zero self.runbtn.setChecked(1) self.stopbtn.setChecked(0) rates = {} for pump in self.rates: if str(self.rates[pump].text()).strip()[1:].isdigit(): #kinda a hack to allow negative numbers rates[pump] = str(self.rates[pump].text()).strip() else: rates[pump] = '0' self.rates[pump].setText('0') if self.curr_state=='Running': new_era.stop_all(self.ser) new_era.set_rates(self.ser,rates) new_era.run_all(self.ser) actual_rates = new_era.get_rates(self.ser,rates.keys()) self.commandbar.setText('Last command: update '+', '.join(['p%i=%s'%(p,actual_rates[p]) for p in actual_rates])) [self.currflow[pump].setText(actual_rates[pump]+' ul/hr') for pump in actual_rates] if self.curr_state=='Stopped': new_era.set_rates(self.ser,rates) new_era.run_all(self.ser) self.curr_state = 'Running' self.statusbar.setText('Status: '+self.curr_state) actual_rates = new_era.get_rates(self.ser,rates.keys()) self.commandbar.setText('Last command: run '+', '.join(['p%i=%s'%(p,actual_rates[p]) for p in actual_rates])) [self.currflow[pump].setText(actual_rates[pump]+' ul/hr') for pump in actual_rates]
def run_update(self): #check if the flow rates are legit numbers, if not set to zero self.runbtn.setChecked(1) self.stopbtn.setChecked(0) rates = {} volumes = {} for pump in self.rates: if str(self.rates[pump].text()).strip()[1:].isdigit( ): #kinda a hack to allow negative numbers rates[pump] = str(self.rates[pump].text()).strip() else: rates[pump] = '0' self.rates[pump].setText('0') # if the pump volume is set if str(self.volume[pump].text()).strip()[1:].isdigit(): volumes[pump] = str(self.volume[pump].text()).strip() else: volumes[pump] = '0' print(('rate of pump ' + str(pump))) print((rates[pump])) # added by Dan on 04/05 if self.curr_state == 'Running': new_era.stop_all(self.ser) new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) actual_rates = new_era.get_rates(self.ser, list(rates.keys())) self.commandbar.setText('Last command: update ' + ', '.join( ['p%i=%s' % (p, actual_rates[p]) for p in actual_rates])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ] if self.curr_state == 'Stopped': new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) self.curr_state = 'Running' self.statusbar.setText('Status: ' + self.curr_state) actual_rates = new_era.get_rates(self.ser, list(rates.keys())) self.commandbar.setText('Last command: run ' + ', '.join( ['p%i=%s' % (p, actual_rates[p]) for p in actual_rates])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ]
def run_update(self): #check if the flow rates are legit numbers, if not set to zero self.runbtn.setChecked(1) self.stopbtn.setChecked(0) rates = {} for pump in self.rates: if isfloat(self.rates[pump].text()): rates[pump] = str(self.rates[pump].text()).strip() else: rates[pump] = '0' self.rates[pump].setText('0') self.timer.stop() self.label_time.setText('-:--:--') self.timerbtn.setChecked(0) if self.curr_state == 'Running': new_era.stop_all(self.ser) new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) actual_rates = new_era.get_rates(self.ser, rates.keys()) self.commandbar.setText('Last command: update ' + ', '.join( ['p%i=%s' % (p, actual_rates[p]) for p in actual_rates])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ] if self.curr_state == 'Stopped': new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) self.curr_state = 'Running' self.statusbar.setText('Status: ' + self.curr_state) actual_rates = new_era.get_rates(self.ser, rates.keys()) self.commandbar.setText('Last command: run ' + ', '.join( ['p%i=%s' % (p, actual_rates[p]) for p in actual_rates])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ]
def prime_pumps(self,pump): if self.curr_state == 'Stopped': if pump not in self.prime_state: # currently not priming new_era.prime(self.ser,pump) self.commandbar.setText('Last command: priming pump %i'%pump) self.statusbar.setText('Status: Priming') self.prime_state.add(pump)# add to prime state else: # currently priming new_era.stop_pump(self.ser,pump) self.commandbar.setText('Last command: stopped pump %i'%pump) self.prime_state.remove(pump)# remove prime state if len(self.prime_state)==0: self.statusbar.setText('Status: Stopped')# if this is the last one, show status=Stopped actual_rates = new_era.get_rates(self.ser,self.rates.keys()) self.currflow[pump].setText(actual_rates[pump]+' ul/hr') else: self.commandbar.setText("Can't prime pump while running") self.prime_btns[pump].setChecked(0)
def prime_pumps(self, pump): if self.curr_state == 'Stopped': if pump not in self.prime_state: # currently not priming new_era.prime(self.ser, pump) self.commandbar.setText('Last command: priming pump %i' % pump) self.statusbar.setText('Status: Priming') self.prime_state.add(pump) # add to prime state else: # currently priming new_era.stop_pump(self.ser, pump) self.commandbar.setText('Last command: stopped pump %i' % pump) self.prime_state.remove(pump) # remove prime state if len(self.prime_state) == 0: self.statusbar.setText( 'Status: Stopped' ) # if this is the last one, show status=Stopped actual_rates = new_era.get_rates(self.ser, self.rates.keys()) self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') else: self.commandbar.setText("Can't prime pump while running") self.prime_btns[pump].setChecked(0)
def run_update_timer(self): #check if the flow rates are legit numbers, if not set to zero self.timerbtn.setChecked(1) self.stopbtn.setChecked(0) rates = {} for pump in self.rates: if isfloat(self.rates[pump].text()): rates[pump] = str(self.rates[pump].text()).strip() else: rates[pump] = '0' self.rates[pump].setText('0') # check time input is valid if isfloat(self.timein.text()): if float(self.timein.text()) > 0: # set the pumps if self.curr_state == 'Running': new_era.stop_all(self.ser) new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) actual_rates = new_era.get_rates(self.ser, rates.keys()) self.commandbar.setText('Last command: update ' + ', '.join([ 'p%i=%s' % (p, actual_rates[p]) for p in actual_rates ])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ] if self.curr_state == 'Stopped': new_era.set_rates(self.ser, rates) new_era.run_all(self.ser) self.curr_state = 'Running' self.statusbar.setText('Status: ' + self.curr_state) actual_rates = new_era.get_rates(self.ser, rates.keys()) self.commandbar.setText('Last command: run ' + ', '.join([ 'p%i=%s' % (p, actual_rates[p]) for p in actual_rates ])) [ self.currflow[pump].setText(actual_rates[pump] + ' ul/hr') for pump in actual_rates ] # connect the button to the start method ... self.time = float(self.timein.text()) * 60 text = "%d:%02d:%02d" % (self.time / 3600, self.time / 60 % 60, self.time % 60) self.label_time.setText(text) self.timer = QtCore.QTimer() self.startTimerDisplay() # connect timer to the update method self.timer.timeout.connect(self.updateTimerDisplay) else: self.commandbar.setText("Not a valid timer input") self.timerbtn.setChecked(0) self.stopbtn.setChecked(1) else: self.commandbar.setText("Not a valid timer input") self.timerbtn.setChecked(0) self.stopbtn.setChecked(1)