Beispiel #1
0
    def _stop_wf(self):
        pi.wave_tx_stop()
        if self._wid is not None:
            logger.info('Stopping waveform {}'.format(self._chain_idx))

            pi.wave_delete(self._wid)
            self._wid = None
Beispiel #2
0
def main():
    logger.info('Starting pittld {}'.format(pittld.__version__))

    lcd.start()
    inet.start()
    driver.start()
    manager.start()
Beispiel #3
0
    def await_client(self, s):
        while True:
            client, addr = s.accept()
            self.client = client

            logger.info('Accepted connection from {}:{}'.format(*addr))
            self.handle_client(client, addr)
            logger.info('{}:{} disconnected'.format(*addr))
Beispiel #4
0
    def run(self):
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
            s.bind((HOST, PORT))
            s.listen(0)
            addr = s.getsockname()
            logger.info('Awaiting connection on {}:{}'.format(*addr))

            self.await_client(s)
Beispiel #5
0
 def stage_timing(self, data):
     try:
         self.staged_timing = Timing(*data)
     except Exception as e:
         logger.error(e)
         raise DriverException('Object to be staged could '
                               'not be interpreted as timing')
     self.staged_seq = None
     logger.info('Staged timing {} '
                 '(and reset sequence)'.format(self.staged_timing))
Beispiel #6
0
    def _start_wf(self):
        self._stop_wf()

        logger.info('Starting waveform {}'.format(self._chain_idx))

        if self._staged_wf is not None:
            pi.wave_add_generic(self._staged_wf)
            self._wid = pi.wave_create()
            self._wf_start = time.time()
            pi.wave_send_once(self._wid)
            self._staged_wf = None
        else:
            raise DriverException('No staged waveform found.')
Beispiel #7
0
    def run(self):
        logger.info('Starting pigpio driver service')

        while not self._kill:
            self._display()

            if self._chain and self._chain_idx < len(self._chain) - 1:
                if self._staged_wf is None and self.wf_progress() >= 0.5:
                    self._stage_wf(self._chain_idx + 1)
                elif self.wf_progress() >= 1.0:
                    self._stop_wf()
                    self._chain_idx += 1
                    self._start_wf()
            elif self.wf_progress() >= 1.0:
                self.stop_seq()
Beispiel #8
0
    def run(self):
        logger.info('Starting lcd driver service')

        t0 = time.time()
        while True:
            for i in 0, 1:
                try:
                    buffer = self._row[i].get_nowait()
                    logger.debug('Retrieved new buffer {} in row {}'.format(
                        buffer, i))
                    self._buffer[i] = buffer
                    self._idx[i] = 0
                except queue.Empty:
                    pass

            t1 = time.time()
            if t1 - t0 > DELAY:
                t0 = t1
                self.reset()
                time.sleep(0.2)
                self._update_display()
Beispiel #9
0
    def start_seq(self):
        if self.staged_timing is None:
            raise DriverException('No timing staged')
        if self.staged_seq is None:
            raise DriverException('No sequence staged')
        if self._chain is not None:
            raise DriverException('Sequence already in progress')
        logger.info('Committing and starting sequence')

        self.committed_timing = self.staged_timing
        self.committed_seq = self.staged_seq

        self._chain = split(self.committed_seq,
                            self.committed_timing.resolution)
        logger.debug('Sequence split into '
                     'chain with {} sub-sequence(s)'.format(len(self._chain)))

        self.started = time.time()
        self._chain_idx = 0
        self._stage_wf(self._chain_idx)
        self._start_wf()
Beispiel #10
0
    def run(self):
        logger.info('Starting inet service')
        while not self._kill:
            # Check that there aren't any low-level network config problems
            ifs = netifaces.interfaces()
            if not (IF.ETH.value in ifs and IF.WLAN.value in ifs):
                raise InetError('Raspberry Pi is not recognizing both '
                                'ethernet and wlan interfaces.')

            eth_addr = address(IF.ETH.value)
            wlan_addr = address(IF.WLAN.value)
            primary_addr = eth_addr or wlan_addr

            if eth_addr:
                buffer = ['using ethernet', eth_addr]
                primary_if = IF.ETH
            elif wlan_addr:
                buffer = ['using wifi', wlan_addr]
                primary_if = IF.WLAN
            else:
                buffer = ['no internet :(']
                primary_if = IF.NONE

            if self._addr != primary_addr or self._if != primary_if:
                logger.info('Pi changed primary '
                            'inet if to {}'.format(primary_if))
                logger.info('Address is now '
                            '{}'.format(primary_addr or 'nothing'))
                self._lcd_svc.put(0, buffer)

                self._addr = primary_addr
                self._if = primary_if

            time.sleep(DELAY)
Beispiel #11
0
    def _stage_wf(self, idx):
        logger.info('Staging waveform {}'.format(idx))

        self._staged_wf = waveform(self._chain[idx],
                                   self.committed_timing.resolution)
Beispiel #12
0
 def stage_seq_reg(self):
     if self.staged_timing is None:
         raise DriverException('No timing staged')
     self.staged_seq = regular_sequence(self.staged_timing.digital.total,
                                        self.staged_timing.digital.exposure)
     logger.info('Staged regular sequence')