Esempio n. 1
0
    def timestamp_mu(self):
        """Poll the RTIO input and returns an event timestamp (in machine
        units), according to the gating.

        If the gate is permanently closed, returns a negative value.
        """
        return rtio_input_timestamp(self.i_previous_timestamp, self.channel)
Esempio n. 2
0
    def timestamp_mu(self):
        """Poll the RTIO input and returns an event timestamp (in machine
        units), according to the gating.

        If the gate is permanently closed, returns a negative value.
        """
        return rtio_input_timestamp(self.i_previous_timestamp, self.channel)
Esempio n. 3
0
 def count(self):
     """Poll the RTIO input during all the previously programmed gate
     openings, and returns the number of registered events."""
     count = 0
     while rtio_input_timestamp(self.i_previous_timestamp, self.channel) >= 0:
         count += 1
     return count
Esempio n. 4
0
File: ttl.py Progetto: cjbe/artiq
    def timestamp_mu(self):
        """Poll the RTIO input and returns an event timestamp (in machine
        units), according to the gating.

        If the gate is permanently closed, returns a negative value.

        This function does not interact with the time cursor."""
        return rtio_input_timestamp(self.i_previous_timestamp, self.channel)
Esempio n. 5
0
    def timestamp_mu(self):
        """Poll the RTIO input and returns an event timestamp (in machine
        units), according to the gating.

        If the gate is permanently closed, returns a negative value.

        This function does not interact with the time cursor."""
        return rtio_input_timestamp(self.i_previous_timestamp, self.channel)
Esempio n. 6
0
 def count(self):
     """Poll the RTIO input during all the previously programmed gate
     openings, and returns the number of registered events."""
     count = 0
     while rtio_input_timestamp(self.i_previous_timestamp,
                                self.channel) >= 0:
         count += 1
     return count
Esempio n. 7
0
    def measure_frame_timestamp(self):
        """Measure the timestamp of an arbitrary frame and store it in `self.frame_tstamp`.

        To be used as reference for aligning updates to the FastLink frames.
        See `get_next_frame_mu()`.
        """
        rtio_output(self.channel_base << 8, 0)  # read any register
        self.frame_tstamp = rtio_input_timestamp(now_mu() + 4 * self.t_frame, self.channel_base)
        delay(100 * us)
Esempio n. 8
0
    def count(self, up_to_timestamp_mu):
        """Consume RTIO input events until the hardware timestamp counter has
        reached the specified timestamp and return the number of observed
        events.

        This function does not interact with the timeline cursor.

        See the ``gate_*()`` family of methods to select the input transitions
        that generate events, and :meth:`timestamp_mu` to obtain the timestamp
        of the first event rather than an accumulated count.

        :param up_to_timestamp_mu: The timestamp up to which execution is
            blocked, that is, up to which input events are guaranteed to be
            taken into account. (Events with later timestamps might still be
            registered if they are already available.)

        :return: The number of events before the timeout elapsed (0 if none
            observed).

        Examples:
            To count events on channel ``ttl_input``, up to the current timeline
            position::

                ttl_input.count(now_mu())

            If other events are scheduled between the end of the input gate
            period and when the number of events is counted, using ``now_mu()``
            as timeout consumes an unnecessary amount of timeline slack. In
            such cases, it can be beneficial to pass a more precise timestamp,
            for example::

                gate_end_mu = ttl_input.gate_rising(100 * us)

                # Schedule a long pulse sequence, represented here by a delay.
                delay(10 * ms)

                # Get number of rising edges. This will block until the end of
                # the gate window, but does not wait for the long pulse sequence
                # afterwards, thus (likely) completing with a large amount of
                # slack left.
                num_rising_edges = ttl_input.count(gate_end_mu)

            The ``gate_*()`` family of methods return the cursor at the end
            of the window, allowing this to be expressed in a compact fashion::

                ttl_input.count(ttl_input.gate_rising(100 * us))
        """
        count = 0
        while rtio_input_timestamp(up_to_timestamp_mu + self.gate_latency_mu,
                                   self.channel) >= 0:
            count += 1
        return count
Esempio n. 9
0
File: ttl.py Progetto: m-labs/artiq
    def count(self, up_to_timestamp_mu):
        """Consume RTIO input events until the hardware timestamp counter has
        reached the specified timestamp and return the number of observed
        events.

        This function does not interact with the timeline cursor.

        See the ``gate_*()`` family of methods to select the input transitions
        that generate events, and :meth:`timestamp_mu` to obtain the timestamp
        of the first event rather than an accumulated count.

        :param up_to_timestamp_mu: The timestamp up to which execution is
            blocked, that is, up to which input events are guaranteed to be
            taken into account. (Events with later timestamps might still be
            registered if they are already available.)

        :return: The number of events before the timeout elapsed (0 if none
            observed).

        Examples:
            To count events on channel ``ttl_input``, up to the current timeline
            position::

                ttl_input.count(now_mu())

            If other events are scheduled between the end of the input gate
            period and when the number of events is counted, using ``now_mu()``
            as timeout consumes an unnecessary amount of timeline slack. In
            such cases, it can be beneficial to pass a more precise timestamp,
            for example::

                gate_end_mu = ttl_input.gate_rising(100 * us)

                # Schedule a long pulse sequence, represented here by a delay.
                delay(10 * ms)

                # Get number of rising edges. This will block until the end of
                # the gate window, but does not wait for the long pulse sequence
                # afterwards, thus (likely) completing with a large amount of
                # slack left.
                num_rising_edges = ttl_input.count(gate_end_mu)

            The ``gate_*()`` family of methods return the cursor at the end
            of the window, allowing this to be expressed in a compact fashion::

                ttl_input.count(ttl_input.gate_rising(100 * us))
        """
        count = 0
        while rtio_input_timestamp(up_to_timestamp_mu + self.gate_latency_mu, self.channel) >= 0:
            count += 1
        return count
Esempio n. 10
0
    def watch_done(self):
        """Stop watching the input at the position of the time cursor.

        Returns ``True`` if the input has not changed state while it
        was being watched.

        The time cursor is not modified by this function. This function
        always makes the slack negative.
        """
        rtio_output(now_mu(), self.channel, 2, 0)
        success = True
        try:
            while rtio_input_timestamp(now_mu(), self.channel) != -1:
                success = False
        except RTIOOverflow:
            success = False
        return success
Esempio n. 11
0
File: ttl.py Progetto: m-labs/artiq
    def watch_done(self):
        """Stop watching the input at the position of the time cursor.

        Returns ``True`` if the input has not changed state while it
        was being watched.

        The time cursor is not modified by this function. This function
        always makes the slack negative.
        """
        rtio_output(self.target_sens, 0)
        success = True
        try:
            while rtio_input_timestamp(now_mu() + self.gate_latency_mu, self.channel) != -1:
                success = False
        except RTIOOverflow:
            success = False
        return success
Esempio n. 12
0
File: ttl.py Progetto: m-labs/artiq
    def timestamp_mu(self, up_to_timestamp_mu):
        """Return the timestamp of the next RTIO input event, or -1 if the
        hardware timestamp counter reaches the given value before an event is
        received.

        This function does not interact with the timeline cursor.

        See the ``gate_*()`` family of methods to select the input transitions
        that generate events, and :meth:`count` for usage examples.

        :param up_to_timestamp_mu: The timestamp up to which execution is
            blocked, that is, up to which input events are guaranteed to be
            taken into account. (Events with later timestamps might still be
            registered if they are already available.)

        :return: The timestamp (in machine units) of the first event received;
            -1 on timeout.
        """
        return rtio_input_timestamp(up_to_timestamp_mu + self.gate_latency_mu, self.channel)
Esempio n. 13
0
    def timestamp_mu(self, up_to_timestamp_mu):
        """Return the timestamp of the next RTIO input event, or -1 if the
        hardware timestamp counter reaches the given value before an event is
        received.

        This function does not interact with the timeline cursor.

        See the ``gate_*()`` family of methods to select the input transitions
        that generate events, and :meth:`count` for usage examples.

        :param up_to_timestamp_mu: The timestamp up to which execution is
            blocked, that is, up to which input events are guaranteed to be
            taken into account. (Events with later timestamps might still be
            registered if they are already available.)

        :return: The timestamp (in machine units) of the first event received;
            -1 on timeout.
        """
        return rtio_input_timestamp(up_to_timestamp_mu + self.gate_latency_mu,
                                    self.channel)