Example #1
0
 def set_trigger(self, ttype: microscope.TriggerType,
                 tmode: microscope.TriggerMode) -> None:
     if ttype is not microscope.TriggerType.HIGH:
         raise microscope.UnsupportedFeatureError(
             "the only trigger type supported is 'high'")
     if tmode is not microscope.TriggerMode.BULB:
         raise microscope.UnsupportedFeatureError(
             "the only trigger mode supported is 'bulb'")
 def set_trigger(self, ttype: microscope.TriggerType,
                 tmode: microscope.TriggerMode) -> None:
     if ttype is not microscope.TriggerType.SOFTWARE:
         raise microscope.UnsupportedFeatureError(
             "the only trigger type supported is software")
     if tmode is not microscope.TriggerMode.ONCE:
         raise microscope.UnsupportedFeatureError(
             "the only trigger mode supported is 'once'")
Example #3
0
 def set_trigger(
     self, ttype: microscope.TriggerType, tmode: microscope.TriggerMode
 ) -> None:
     if ttype is not microscope.TriggerType.SOFTWARE:
         raise microscope.UnsupportedFeatureError(
             "%s is not supported, only trigger type SOFTWARE" % ttype
         )
     if tmode is not microscope.TriggerMode.ONCE:
         raise microscope.UnsupportedFeatureError(
             "%s is not supported, only trigger mode ONCE" % tmode
         )
Example #4
0
 def set_trigger(self, ttype: microscope.TriggerType,
                 tmode: microscope.TriggerMode) -> None:
     if tmode is not microscope.TriggerMode.BULB:
         raise microscope.UnsupportedFeatureError(
             "the only trigger mode supported is 'bulb'")
     if ttype is microscope.TriggerType.SOFTWARE:
         self._conn.set_switch_state("N")
         self._should_be_on = True
     elif ttype is microscope.TriggerType.HIGH:
         self._conn.set_switch_state("F")
         self._should_be_on = False
     else:
         raise microscope.UnsupportedFeatureError(
             "trigger type supported must be 'SOFTWARE' or 'HIGH'")
Example #5
0
    def set_trigger(self, ttype: microscope.TriggerType,
                    tmode: microscope.TriggerMode) -> None:
        if tmode is not microscope.TriggerMode.ONCE:
            raise microscope.UnsupportedFeatureError(
                "%s not supported (only TriggerMode.ONCE)" % tmode)

        try:
            trg_source = TrgSourceMap(ttype)
        except ValueError:
            raise microscope.UnsupportedFeatureError(
                "no support for trigger type %s" % ttype)

        if trg_source.name != self._handle.get_trigger_source():
            # Changing trigger source requires stopping acquisition.
            with _disabled_camera(self):
                self._handle.set_trigger_source(trg_source.name)
Example #6
0
    def set_trigger(self, ttype: microscope.TriggerType,
                    tmode: microscope.TriggerMode) -> None:
        if tmode is not microscope.TriggerMode.BULB:
            raise microscope.UnsupportedFeatureError(
                "only TriggerMode.BULB mode is supported")

        # From the manual it seems that cw and ttl parameters are
        # mutually exclusive but also still need to be set separately.
        if ttype is microscope.TriggerType.HIGH:
            self._conn.set_cw(False)
            self._conn.set_use_ttl(True)
        elif ttype is microscope.TriggerType.SOFTWARE:
            self._conn.set_use_ttl(False)
            self._conn.set_cw(True)
        else:
            raise microscope.UnsupportedFeatureError(
                "only trigger type HIGH and SOFTWARE are supported")
Example #7
0
 def set_trigger(self, ttype: microscope.TriggerType,
                 tmode: microscope.TriggerMode) -> None:
     for available_mode in self._trigger_mode.get_available_values():
         trigger = SDK3_STRING_TO_TRIGGER[available_mode.lower()]
         if trigger == (ttype, tmode):
             self._trigger_mode.set_string(available_mode)
             break
     else:
         raise microscope.UnsupportedFeatureError(
             "no SDK3 mode for %s and %s" % (ttype, tmode))
Example #8
0
    def set_trigger(self, ttype, tmode):
        if tmode not in self._supported_TriggerModes:
            raise microscope.UnsupportedFeatureError(
                "unsupported trigger of mode '%s' for Alpao Mirrors" %
                tmode.name)
        elif (ttype == microscope.TriggerType.SOFTWARE
              and tmode != microscope.TriggerMode.ONCE):
            raise microscope.UnsupportedFeatureError(
                "trigger mode '%s' only supports trigger type ONCE" %
                tmode.name)
        self._trigger_mode = tmode

        try:
            value = self._TriggerType_to_asdkTriggerIn[ttype]
        except KeyError:
            raise microscope.UnsupportedFeatureError(
                "unsupported trigger of type '%s' for Alpao Mirrors" %
                ttype.name)
        status = asdk.Set(self._dm, b"TriggerIn", value)
        self._raise_if_error(status)
        self._trigger_type = ttype
Example #9
0
    def queue_patterns(self, patterns: numpy.ndarray) -> None:
        if self._trigger_type == microscope.TriggerType.SOFTWARE:
            super().queue_patterns(patterns)
            return

        self._validate_patterns(patterns)
        patterns = self._normalize_patterns(patterns)
        patterns = numpy.atleast_2d(patterns)
        n_patterns: int = patterns.shape[0]

        # The Alpao SDK seems to only support the trigger mode start.  It
        # still has option called nRepeats that we can't really figure
        # what is meant to do.  When set to 1, the mode is start.  What
        # we want it is to have trigger mode once which was not
        # supported.  We have received a modified version where if
        # nRepeats is set to same number of patterns, does trigger mode
        # once (not documented on Alpao SDK).
        if self._trigger_mode == microscope.TriggerMode.ONCE:
            n_repeats = n_patterns
        elif self._trigger_mode == microscope.TriggerMode.START:
            n_repeats = 1
        else:
            # We should not get here in the first place since
            # set_trigger filters unsupported modes.
            raise microscope.UnsupportedFeatureError(
                "trigger type '%s' and trigger mode '%s' is not supported" %
                (self._trigger_type.name, self._trigger_mode.name))

        data_pointer = patterns.ctypes.data_as(asdk.Scalar_p)

        # We don't know if the previous queue of pattern ran until the
        # end, so we need to clear it before sending (see issue #50)
        status = asdk.Stop(self._dm)
        self._raise_if_error(status)

        status = asdk.SendPattern(self._dm, data_pointer, n_patterns,
                                  n_repeats)
        self._raise_if_error(status)