Esempio n. 1
0
    def _upload(self, name: str,
                program: Loop,
                channels: Tuple[Optional[ChannelID], ...],
                markers: Tuple[Optional[ChannelID], ...],
                voltage_transformation: Tuple[Callable, ...],
                force: bool):
        assert self._idle_program_index

        if name in self._programs and not force:
            raise ProgramOverwriteException(name)

        # group markers in by channels
        markers = tuple(zip(markers[0::2], markers[1::2]))

        if self._amplitude_offset_handling == AWGAmplitudeOffsetHandling.IGNORE_OFFSET:
            offsets = None
        elif self._amplitude_offset_handling == AWGAmplitudeOffsetHandling.CONSIDER_OFFSET:
            offsets = self.device.get_offset()
        else:
            raise ValueError('{} is invalid as AWGAmplitudeOffsetHandling'.format(self._amplitude_offset_handling))

        tek_program = TektronixProgram(program, channels=channels, markers=markers,
                                       amplitudes=self.device.get_amplitude(),
                                       offsets=offsets,
                                       voltage_transformations=voltage_transformation,
                                       sample_rate=TimeType(self.sample_rate))

        self.logger.debug("Successfully parsed %s", name)

        if name in self._programs:
            self._unload(name)

        self._upload_parsed(name, tek_program)
Esempio n. 2
0
 def upload(self,
            name,
            program,
            channels,
            markers,
            voltage_transformation,
            force=False) -> None:
     if name in self.programs:
         if not force:
             raise ProgramOverwriteException(name)
         else:
             self.remove(name)
             self.upload(name, program)
     else:
         self._programs[name] = (program, channels, markers,
                                 voltage_transformation)