Пример #1
0
    def control_temp_interval(self):
        ''' returns true when finished '''
        if self.state == 'INIT':
            self.set_state('Init', stage=self.cur_idx + 1)
            self.set_temp, self.set_dura = self._get_temp_dura()
            if self.control_temp() == True:
                self.state = 'WAITING'
                self.wait_start = datetime.datetime.now()
        elif self.state == 'WAITING':
            td_sec = timedelta2sec(datetime.datetime.now() - self.wait_start)
            self.set_state('Cooking',
                           stage=self.cur_idx + 1,
                           extended='%d von %d sek' % (td_sec, self.set_dura))
            self.set_temp, self.set_dura = self._get_temp_dura()
            self.control_temp()
            if td_sec < self.set_dura:
                # We are not finished
                return

            # We are finished with the current stage, is there more to do?
            if self.method == 'K1' or len(self.temp_list) <= self.cur_idx + 1:
                # Nothing more to do
                self.state = 'FINISHED'
                return
            # Yes we have another stage
            self.cur_idx += 1
            self.set_temp, self.set_dura = self._get_temp_dura()
            self.state = 'INIT'

        elif self.state == 'FINISHED':
            self.set_state('Finished')
            wq.all_off()
            return True
        else:
            raise RuntimeError('TPC: Unknown state %s' % self.state)
Пример #2
0
 def run(self):
     """ Run is is the main worker loop for the data looger thread. It has
         to be started through threading.start()
     """
     while 42:
         sleepduration = self.log_interval
         if self.log_flag:
             # If we run the first time store start time as reference
             now = datetime.datetime.now()
             if self.time_start is None:
                 self.time_start = now
             self.set_state('Logging')
             delta = timedelta2sec(now - self.time_start)
             entry = {}
             entry['time'] = delta
             entry['tempk1'] = self.status['tempk1']
             entry['tempk2'] = self.status['tempk2']
             entry['settempk1'] = self.status['settempk1']
             entry['settempk2'] = self.status['settempk2']
             entry['pump1'] = self.status['pump1']
             entry['pump2'] = self.status['pump2']
             entry['heater'] = self.status['heater']
             self.data['list'].append(entry)
             # print 'DLT: record length %d.' % (len(self.data['list']))
         else:
             self.set_state('Idle')
         while sleepduration > 0:
             if self.exit_flag:
                 self.set_state('Not running')
                 return
             time.sleep(config.THREAD_SLEEP_INT)
             sleepduration -= config.THREAD_SLEEP_INT
Пример #3
0
 def run(self):
     """ Run is is the main worker loop for the data looger thread. It has
         to be started through threading.start()
     """
     while 42:
         sleepduration = self.log_interval
         if self.log_flag:
             # If we run the first time store start time as reference
             now = datetime.datetime.now()
             if self.time_start is None:
                 self.time_start = now
             self.set_state('Logging')
             delta = timedelta2sec(now - self.time_start)
             entry = {}
             entry['time'] = delta
             entry['tempk1'] = self.status['tempk1']
             entry['tempk2'] = self.status['tempk2']
             entry['settempk1'] = self.status['settempk1']
             entry['settempk2'] = self.status['settempk2']
             entry['pump1'] = self.status['pump1']
             entry['pump2'] = self.status['pump2']
             entry['heater'] = self.status['heater']
             self.data['list'].append(entry)
             # print 'DLT: record length %d.' % (len(self.data['list']))
         else:
             self.set_state('Idle')
         while sleepduration > 0:
             if self.exit_flag:
                 self.set_state('Not running')
                 return
             time.sleep(config.THREAD_SLEEP_INT)
             sleepduration -= config.THREAD_SLEEP_INT
Пример #4
0
 def start(self):
     if self.state == 'INIT':
         heater_off_K2()
         self.waituntil = datetime.datetime.now() + \
             datetime.timedelta(seconds=config.BLUBBER_INT)
         self.state = 'WAITING'
     elif self.state == 'WAITING':
         td2wait = timedelta2sec(self.waituntil - datetime.datetime.now())
         self.set_state('Waiting for %d s' % td2wait)
         if td2wait < 0:
             self.waituntil = datetime.datetime.now() + \
                 datetime.timedelta(seconds=config.BLUBBER_DURA)
             # Finally start blubbering
             heater_on_K2()
             self.state = 'BLUBBERING'
             self.set_state('Blubbering')
     elif self.state == 'BLUBBERING':
         td2wait = timedelta2sec(self.waituntil - datetime.datetime.now())
         self.set_state('Blubbering for %f s' % td2wait)
         if td2wait < 0:
             # We're done stop blubbering
             self.reset()
     else:
         raise RuntimeError('BM: Unknown state %s' % self.state)
Пример #5
0
 def run(self):
     """ Run is is the main worker loop for the data looger thread. It has
         to be started through threading.start()
     """
     while 42:
         sleepduration = self.log_interval
         if self.log_flag:
             # If we run the first time store start time as reference
             now = datetime.datetime.now()
             if self.time_start is None:
                 self.time_start = now
             self.set_state('Running')
             delta = timedelta2sec(now - self.time_start)
             entry = {}
             entry['time'] = delta
             # Put together a status string
             entry['state'] = (
                 self.status['cook_state'][0] +
                 str(self.status['cook_state_stage']) + '-' +
                 self.status['pct_state'][0] + '-' +
                 self.status['wqt_state'][0] + '-' +
                 self.status['dlt_state'][0] + '-' +
                 self.status['tmt_state'][0] + '-' +
                 self.status['bm_state'][0])
             entry['tempk1'] = self.status['tempk1']
             entry['tempk2'] = self.status['tempk2']
             entry['settempk1'] = self.status['settempk1']
             entry['settempk2'] = self.status['settempk2']
             entry['pump1'] = self.status['pump1']
             entry['pump2'] = self.status['pump2']
             entry['heater'] = self.status['heater']
             self.data['list'].append(entry)
             # Write log size back to global status dict
             self.status['log_size'] = getsize(self.data)
         else:
             self.set_state('Idle')
         while sleepduration > 0:
             if self.exit_flag:
                 self.set_state('Not running')
                 return
             time.sleep(config.THREAD_SLEEP_INT)
             sleepduration -= config.THREAD_SLEEP_INT